Skip to content

Latest commit

 

History

History
53 lines (34 loc) · 1.2 KB

GUID-ED7E9986-0544-4B38-AF37-DB8E9630174F.md

File metadata and controls

53 lines (34 loc) · 1.2 KB

CRYPT_RSA_PublicKeyDecode Function

Parent topic:MPLAB® Harmony Crypto Library

C

int CRYPT_RSA_PublicKeyDecode(
    CRYPT_RSA_CTX* rsa, 
    const unsigned char* in, 
    unsigned int inSz
);

Description

This function builds a public key from a DER-formatted certificate. DER stands for Distinguished Encoding Rules.

Preconditions

The context must have been initialized with a call to CRYPT_RSA_Initialize.

Parameters

Parameters Description
rsa Pointer to context which saves state between calls.
in Pointer to buffer containing the certificate to process to extract the public key.
inSz Size of the input data in bytes.

Returns

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

  • 0 - An invalid pointer was not passed to the function.

Remarks

None.

Example

CRYPT_RSA_CTX mcRsa;
int           ret;
unsigned int  keySz = (unsigned int)sizeof(client_key_der_1024);

ret = CRYPT_RSA_Initialize(&mcRsa);
ret = CRYPT_RSA_PublicKeyDecode(&mcRsa, client_key_der_1024, keySz);
ret = CRYPT_RSA_PublicEncrypt(&mcRsa, out1, sizeof(out1), ourData, RSA_TEST_SIZE, &mcRng);