1.37 CRYPT_RSA_PrivateDecrypt Function

C

int CRYPT_RSA_PrivateDecrypt(
    CRYPT_RSA_CTX* rsa, 
    unsigned char* out, 
    unsigned int outSz, 
    const unsigned char* in, 
    unsigned int inSz
);

Description

This function decrypts a data block using a private key.

Preconditions

The context must be initialized using CRYPT_RSA_Initialize and the private key decoded using CRYPT_RSA_PrivateKeyDecode prior to calling this function.

Parameters

ParametersDescription
rsaPointer to context which saves state between calls.
outPointer to output buffer to store results.
outSzSize of output buffer.
inPointer to source buffer to be decrypted.
inSzSize of input buffer.

Returns

  • BAD_FUNC_ARG - An invalid pointer was passed to the function.

  • int - Size of the actual output.

Remarks

None.

Example

CRYPT_RSA_CTX mcRsa;
int           ret;
unsigned int  keySz = (unsigned int)sizeof(client_key_der_1024);
byte          out1[256];

ret = CRYPT_RSA_Initialize(&mcRsa);
ret = CRYPT_RSA_PrivateKeyDecode(&mcRsa, client_key_der_1024, keySz);
ret = CRYPT_RSA_PrivateDecrypt(&mcRsa, out2, sizeof(out2), out1, RSA_TEST_SIZE);