Skip to content

Latest commit

 

History

History
59 lines (39 loc) · 1.43 KB

GUID-79361D69-413A-4AF2-B1BF-1823CFA77CE6.md

File metadata and controls

59 lines (39 loc) · 1.43 KB

CRYPT_ECC_PublicExport Function

Parent topic:MPLAB® Harmony Crypto Library

C

int CRYPT_ECC_PublicExport(
    CRYPT_ECC_CTX* ecc, 
    unsigned char* out, 
    unsigned int outSz, 
    unsigned int* usedSz
);

Description

This function takes an ECC public key and exports it in ANSI X9.63 format.

Preconditions

The context must be initialized previously with a call to CRYPT_ECC_Initialize. The key must also have been constructed with a call to CRYPT_ECC_DHE_KeyMake. A random number generator must have been initialized with a call to CRYPT_RNG_Initialize.

Parameters

Parameters Description
ecc Pointer to context which saves state between calls.
out Buffer in which to store the public key.
outSz The available size of the buffer, in bytes.
usedSz Return value indicating how many bytes were used.

Returns

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

  • BUFFER_E - The output buffer was too small to store the key.

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

Remarks

None.

Example

CRYPT_ECC_CTX userA; 
int           ret;
byte          sharedA[100];
unsigned int  aSz = (unsigned int)sizeof(sharedA);
unsigned int  usedA = 0;

ret = CRYPT_ECC_Initialize(&userA);
ret = CRYPT_ECC_DHE_KeyMake(&userA, &mcRng, 32);
ret = CRYPT_ECC_PublicExport(&userA, sharedA, aSz, &usedA);