TrustCore SDK Crypto Interface API reference  version 2.0
crypto_interface_qs_kem.h File Reference

Cryptographic Interface header file for declaring Key Encapsulation Mechanism methods. More...

Go to the source code of this file.

Functions

MOC_EXTERN MSTATUS CRYPTO_INTERFACE_QS_KEM_decapsulate (QS_CTX *pCtx, ubyte *pCipherText, ubyte4 cipherTextLen, ubyte *pSharedSecret, ubyte4 sharedSecretLen)
 Performs the key decapsulation algorithm. More...
 
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_QS_KEM_decapsulateAlloc (QS_CTX *pCtx, ubyte *pCipherText, ubyte4 cipherTextLen, ubyte **ppSharedSecret, ubyte4 *pSharedSecretLen)
 Performs the key decapsulation algorithm. More...
 
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_QS_KEM_encapsulate (QS_CTX *pCtx, RNGFun rngFun, void *pRngFunArg, ubyte *pCipherText, ubyte4 cipherTextLen, ubyte *pSharedSecret, ubyte4 sharedSecretLen)
 Performs the key encapsulation algorithm. More...
 
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_QS_KEM_encapsulateAlloc (QS_CTX *pCtx, RNGFun rngFun, void *pRngFunArg, ubyte **ppCipherText, ubyte4 *pCipherTextLen, ubyte **ppSharedSecret, ubyte4 *pSharedSecretLen)
 Performs the key encapsulation algorithm. More...
 
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_QS_KEM_getCipherTextLen (QS_CTX *pCtx, ubyte4 *pCipherLen)
 Gets the length of the ciphertext associated with a QS context in bytes. More...
 
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_QS_KEM_getCipherTextLenFromAlgo (ubyte4 algo, ubyte4 *pCipherLen)
 Gets the length of the ciphertext associated with a QS algorithm in bytes. More...
 
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_QS_KEM_getSharedSecretLen (QS_CTX *pCtx, ubyte4 *pSharedSecretLen)
 Gets the length of a shared secret associated with a QS context in bytes. More...
 

Detailed Description

Function Documentation

◆ CRYPTO_INTERFACE_QS_KEM_decapsulate()

MOC_EXTERN MSTATUS CRYPTO_INTERFACE_QS_KEM_decapsulate ( QS_CTX pCtx,
ubyte *  pCipherText,
ubyte4  cipherTextLen,
ubyte *  pSharedSecret,
ubyte4  sharedSecretLen 
)

Performs the key decapsulation algorithm.

Parameters
pCtxPointer to a previously allocated context.
pCipherTextBuffer holding the input ciphertext.
cipherTextLenThe length of the ciphertext in bytes.
pSharedSecretBuffer that will hold the resulting shared secret.
sharedSecretLenThe length of the pSharedSecret buffer in bytes.
Returns
OK (0) if successful, otherwise a negative number error code from merrors.h.

◆ CRYPTO_INTERFACE_QS_KEM_decapsulateAlloc()

MOC_EXTERN MSTATUS CRYPTO_INTERFACE_QS_KEM_decapsulateAlloc ( QS_CTX pCtx,
ubyte *  pCipherText,
ubyte4  cipherTextLen,
ubyte **  ppSharedSecret,
ubyte4 *  pSharedSecretLen 
)

Performs the key decapsulation algorithm. This method allocates a buffer for the shared secret. Be sure to free this buffer whwn done with it.

Parameters
pCtxPointer to a previously allocated context.
pCipherTextBuffer holding the input ciphertext.
cipherTextLenThe length of the ciphertext in bytes.
ppSharedSecretPointer to the location of the newly allocated buffer that will contain the output shared secret.
pSharedSecretLenContents will be set to the length of the shared secret in bytes.
Returns
OK (0) if successful, otherwise a negative number error code from merrors.h.

◆ CRYPTO_INTERFACE_QS_KEM_encapsulate()

MOC_EXTERN MSTATUS CRYPTO_INTERFACE_QS_KEM_encapsulate ( QS_CTX pCtx,
RNGFun  rngFun,
void *  pRngFunArg,
ubyte *  pCipherText,
ubyte4  cipherTextLen,
ubyte *  pSharedSecret,
ubyte4  sharedSecretLen 
)

Performs the key encapsulation algorithm.

Parameters
pCtxPointer to a previously allocated context.
rngFunFunction pointer to a random number generation function.
pRngFunArgInput data or context into the random number generation function pointer.
pCipherTextBuffer that will hold the resulting ciphertext.
cipherTextLenThe length of the pCipherText buffer in bytes.
pSharedSecretBuffer that will hold the resulting shared secret.
sharedSecretLenThe length of the pSharedSecret buffer in bytes.
Returns
OK (0) if successful, otherwise a negative number error code from merrors.h.

◆ CRYPTO_INTERFACE_QS_KEM_encapsulateAlloc()

MOC_EXTERN MSTATUS CRYPTO_INTERFACE_QS_KEM_encapsulateAlloc ( QS_CTX pCtx,
RNGFun  rngFun,
void *  pRngFunArg,
ubyte **  ppCipherText,
ubyte4 *  pCipherTextLen,
ubyte **  ppSharedSecret,
ubyte4 *  pSharedSecretLen 
)

Performs the key encapsulation algorithm. This method allocates two buffers, one for the ciphertext and one for the shared secret. Be sure to free these buffers when done with them.

Parameters
pCtxPointer to a previously allocated context.
rngFunFunction pointer to a random number generation function.
pRngFunArgInput data or context into the random number generation function pointer.
ppCipherTextPointer to the location of the newly allocated buffer that will contain the output ciphertext.
pCipherTextLenContents will be set to the length of the ciphertext in bytes.
ppSharedSecretPointer to the location of the newly allocated buffer that will contain the output shared secret.
pSharedSecretLenContents will be set to the length of the shared secret in bytes.
Returns
OK (0) if successful, otherwise a negative number error code from merrors.h.

◆ CRYPTO_INTERFACE_QS_KEM_getCipherTextLen()

MOC_EXTERN MSTATUS CRYPTO_INTERFACE_QS_KEM_getCipherTextLen ( QS_CTX pCtx,
ubyte4 *  pCipherLen 
)

Gets the length of the ciphertext associated with a QS context in bytes.

Parameters
pCtxPointer to the QS context.
pCipherLenContents will be set to the length of the ciphertext in bytes.
Returns
OK (0) if successful, otherwise a negative number error code from merrors.h.

◆ CRYPTO_INTERFACE_QS_KEM_getCipherTextLenFromAlgo()

MOC_EXTERN MSTATUS CRYPTO_INTERFACE_QS_KEM_getCipherTextLenFromAlgo ( ubyte4  algo,
ubyte4 *  pCipherLen 
)

Gets the length of the ciphertext associated with a QS algorithm in bytes.

Parameters
algoThe algorithm identifier.
pCipherLenContents will be set to the length of the ciphertext in bytes.
Returns
OK (0) if successful, otherwise a negative number error code from merrors.h.

◆ CRYPTO_INTERFACE_QS_KEM_getSharedSecretLen()

MOC_EXTERN MSTATUS CRYPTO_INTERFACE_QS_KEM_getSharedSecretLen ( QS_CTX pCtx,
ubyte4 *  pSharedSecretLen 
)

Gets the length of a shared secret associated with a QS context in bytes.

Parameters
pCtxPointer to the QS context.
pSharedSecretLenContents will be set to the length of the shared secret in bytes.
Returns
OK (0) if successful, otherwise a negative number error code from merrors.h.