ippsMLKEM_KeyGen#

Generates an encapsulation key and a corresponding decapsulation key.

Syntax#

IppStatus ippsMLKEM_KeyGen(Ipp8u* pEncKey, Ipp8u* pDecKey, IppsMLKEMState* pMLKEMCtx,
                           Ipp8u* pScratchBuffer, IppBitSupplier rndFunc, void* pRndParam);

Include Files#

ippcp.h

Parameters#

pEncKey

Pointer to the produced encapsulation key of 384*k + 32 bytes.

pDecKey

Pointer to the produced decapsulation key of 786*k + 96 bytes.

pMLKEMCtx

Pointer to the ML-KEM context.

pScratchBuffer

Pointer to the working buffer of size queried ippsMLKEM_KeyGenBufferGetSize.

rndFunc

Optional function pointer to generate random numbers, can be NULL.

pRndParam

Optional parameters for rndFunc, can be NULL.

Description#

The function generates an encapsulation key and a corresponding decapsulation key. The size of the output parameters depends on the selected scheme type and can be obtained using ippsMLKEM_GetInfo function. The working buffer should be allocated with the size not less than provided by ippsMLKEM_KeyGenBufferGetSize function.

This function uses internally the random number generator (RNG) provided by the user through the rndFunc parameter, please see User’s Implementation of a RNG for more information regarding creation the customer’s defined RNG object. If rndFunc is NULL, the internal default random number generator based on RDRAND hardware instruction is used.

Note

Important

The API family is supported in experimental mode. To use the functions, users need to define the IPPCP_PREVIEW_ML_KEM macro before including the ippcp.h header file. See Preview Features for more details.

Return Values#

ippStsNoErr

Indicates no error. Any other value indicates an error or warning.

ippStsNullPtrErr

Any of the input pointers is NULL.

ippStsContextMatchErr

pMLKEMCtx was not initialized.

ippStsMemAllocErr

An internal functional error. If this output status appears, update to the latest version of the library or contact Intel.

ippStsNotSupportedModeErr

Unsupported RDRAND instruction.

ippStsErr

Random bit sequence can’t be generated.

An error that may be returned by rndFunc.

Problems with the user-defined random number generator.