Skip to content

Latest commit

 

History

History
58 lines (39 loc) · 1.29 KB

GUID-73E14D6E-0286-45EC-8FD6-AF49F927216D.md

File metadata and controls

58 lines (39 loc) · 1.29 KB

CRYPT_RSA_PrivateDecrypt Function

Parent topic:MPLAB® Harmony Crypto Library

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

Parameters Description
rsa Pointer to context which saves state between calls.
out Pointer to output buffer to store results.
outSz Size of output buffer.
in Pointer to source buffer to be decrypted.
inSz Size 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);