1.23 CRYPT_ECC_DHE_SharedSecretMake Function
C
int CRYPT_ECC_DHE_SharedSecretMake(
CRYPT_ECC_CTX* priv,
CRYPT_ECC_CTX* pub,
unsigned char* out,
unsigned int outSz,
unsigned int* usedSz
);Description
This function takes two ECC contexts (one public, one private) and creates a shared secret between the two. The secret conforms to EC-DH from ANSI X9.63.
Preconditions
Both contexts must have been initialized with a call to CRYPT_ECC_Initialize. Both contexts have had their respective keys imported or created.
Parameters
| Parameters | Description |
|---|---|
| priv | Pointer to the private ECC context (with the private key) |
| pub | Pointer to the public ECC context (with the public key) |
| out | Destination of the shared secret |
| outSz | The maximum size of the shared secret |
| usedSz | Resulting size of the shared secret |
Returns
- BAD_FUNC_ARG - An invalid pointer was passed to the function
- MEMORY_E - Could not create the memory buffer for the shared secret
- 0 - An invalid pointer was not passed to the function
Remarks
None.
Example
CRYPT_ECC_CTX userA; CRYPT_ECC_CTX userB; int ret; byte sharedA[100]; unsigned int aSz = (unsigned int)sizeof(sharedA); unsigned int usedA = 0; ret = CRYPT_ECC_Initialize(&userA); ret = CRYPT_ECC_Initialize(&userB); ... // Make or import the appropriate keys ... ret = CRYPT_ECC_DHE_SharedSecretMake(&userA, &userB, sharedA, aSz, &usedA);
