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

Cryptographic Interface header file for declaring common Quantum Safe methods. More...

Go to the source code of this file.

Data Structures

struct  QS_CTX
 Context structure to hold the appropriate quantum safe asymmetric keys. More...
 

Functions

MOC_EXTERN MSTATUS CRYPTO_INTERFACE_QS_cloneCtx (QS_CTX **ppNewCtx, QS_CTX *pCtx)
 Clones a QS context. More...
 
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_QS_deleteCtx (QS_CTX **ppCtx)
 Deletes a QS context. More...
 
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_QS_equalKey (QS_CTX *pCtx1, QS_CTX *pCtx2, byteBoolean *pRes)
 Compares public key value of two QS contexts. More...
 
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_QS_generateKeyPair (QS_CTX *pCtx, RNGFun rngFun, void *pRngFunArg)
 Generates a new key pair within a QS context. More...
 
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_QS_getAlg (QS_CTX *pCtx, ubyte4 *pAlg)
 Gets tha algorithm identifier from the context. More...
 
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_QS_getPublicKey (QS_CTX *pCtx, ubyte *pPublicKey, ubyte4 pubLen)
 Gets the public key from a QS context. More...
 
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_QS_getPublicKeyAlloc (QS_CTX *pCtx, ubyte **ppPublicKey, ubyte4 *pPubLen)
 Gets the public key from a QS context and allocates a buffer for it. More...
 
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_QS_getPublicKeyLen (QS_CTX *pCtx, ubyte4 *pPubLen)
 Gets the length of a public key associated with a QS context in bytes. More...
 
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_QS_getPublicKeyLenFromAlgo (ubyte4 algo, ubyte4 *pPubLen)
 Gets the length of a public key associated with a QS algorithm in bytes. More...
 
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_QS_newCtx (QS_CTX **ppNewCtx, ubyte4 algo)
 Creates a new QS context. More...
 
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_QS_setPublicKey (QS_CTX *pCtx, ubyte *pPublicKey, ubyte4 pubLen)
 Sets the public key within a QS context. More...
 

Detailed Description

Function Documentation

◆ CRYPTO_INTERFACE_QS_cloneCtx()

MOC_EXTERN MSTATUS CRYPTO_INTERFACE_QS_cloneCtx ( QS_CTX **  ppNewCtx,
QS_CTX pCtx 
)

Clones a new QS context from an existing context. Be sure to call CRYPTO_INTERFACE_QS_deleteCtx to free memory when done with the new context.

Parameters
ppNewCtxPointer to the location that will contain the newly allocated clone of the original context.
pCtxPointer to the existing context to be cloned.
Returns
OK (0) if successful, otherwise a negative number error code from merrors.h.

◆ CRYPTO_INTERFACE_QS_deleteCtx()

MOC_EXTERN MSTATUS CRYPTO_INTERFACE_QS_deleteCtx ( QS_CTX **  ppCtx)

Deletes a QS context including freeing internal keys and memory allocated for the context itself.

Parameters
ppCtxPointer to the location of the context to be deleted.
Returns
OK (0) if successful, otherwise a negative number error code from merrors.h.

◆ CRYPTO_INTERFACE_QS_equalKey()

MOC_EXTERN MSTATUS CRYPTO_INTERFACE_QS_equalKey ( QS_CTX pCtx1,
QS_CTX pCtx2,
byteBoolean *  pRes 
)

Compares public key value of two QS contexts.

Parameters
pCtx1Pointer to the first QS context.
pCtx2Pointer to the second QS context.
pResReturns TRUE if public keys match, else FALSE.
pubLenThe length of the public key in bytes.
Returns
OK (0) if successful, otherwise a negative number error code from merrors.h.

◆ CRYPTO_INTERFACE_QS_generateKeyPair()

MOC_EXTERN MSTATUS CRYPTO_INTERFACE_QS_generateKeyPair ( QS_CTX pCtx,
RNGFun  rngFun,
void *  pRngFunArg 
)

Generates a new key pair within a QS context.

Parameters
pCtxPointer to the QS context that will hold the new keys.
rngFunFunction pointer to a random number generation function.
pRngFunArgInput data or context into the random number generation function pointer.
Returns
OK (0) if successful, otherwise a negative number error code from merrors.h.

◆ CRYPTO_INTERFACE_QS_getAlg()

MOC_EXTERN MSTATUS CRYPTO_INTERFACE_QS_getAlg ( QS_CTX pCtx,
ubyte4 *  pAlg 
)

Gets tha algorithm identifier from the context.

Parameters
pCtxPointer to a previously allocated context.
pAlgContents Will be set to the algorithm identifier macro value.
Returns
OK (0) if successful, otherwise a negative number error code from merrors.h.

◆ CRYPTO_INTERFACE_QS_getPublicKey()

MOC_EXTERN MSTATUS CRYPTO_INTERFACE_QS_getPublicKey ( QS_CTX pCtx,
ubyte *  pPublicKey,
ubyte4  pubLen 
)

Gets the public key from a QS context.

Parameters
pCtxPointer to the QS context that contains at least a public key.
pPublicKeyBuffer to hold the resulting public key.
pubLenThe length of the pPublicKey buffer in bytes.
Returns
OK (0) if successful, otherwise a negative number error code from merrors.h.

◆ CRYPTO_INTERFACE_QS_getPublicKeyAlloc()

MOC_EXTERN MSTATUS CRYPTO_INTERFACE_QS_getPublicKeyAlloc ( QS_CTX pCtx,
ubyte **  ppPublicKey,
ubyte4 *  pPubLen 
)

Gets the public key from a QS context. A buffer is allocated to hold the public key. Be sure to free this buffer when done with it.

Parameters
pCtxPointer to the QS context that contains at least a public key.
ppPublicKeyPointer to the location that will receive the newly allocated buffer.
pPubLenContents will be set to the length of the public key in bytes.
Returns
OK (0) if successful, otherwise a negative number error code from merrors.h.

◆ CRYPTO_INTERFACE_QS_getPublicKeyLen()

MOC_EXTERN MSTATUS CRYPTO_INTERFACE_QS_getPublicKeyLen ( QS_CTX pCtx,
ubyte4 *  pPubLen 
)

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

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

◆ CRYPTO_INTERFACE_QS_getPublicKeyLenFromAlgo()

MOC_EXTERN MSTATUS CRYPTO_INTERFACE_QS_getPublicKeyLenFromAlgo ( ubyte4  algo,
ubyte4 *  pPubLen 
)

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

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

◆ CRYPTO_INTERFACE_QS_newCtx()

MOC_EXTERN MSTATUS CRYPTO_INTERFACE_QS_newCtx ( QS_CTX **  ppNewCtx,
ubyte4  algo 
)

Creates a new QS context including allocation of the internal key shells. Be sure to call CRYPTO_INTERFACE_QS_deleteCtx to free memory when done with the context.

Parameters
ppNewCtxPointer to the location that will contain the newly allocated context.
algoOne of the algorithm flags to indicate which algorithm will be performed,.
Returns
OK (0) if successful, otherwise a negative number error code from merrors.h.

◆ CRYPTO_INTERFACE_QS_setPublicKey()

MOC_EXTERN MSTATUS CRYPTO_INTERFACE_QS_setPublicKey ( QS_CTX pCtx,
ubyte *  pPublicKey,
ubyte4  pubLen 
)

Sets the public key within a QS context.

Parameters
pCtxPointer to the QS context.
pPublicKeyBuffer holding the public key to be set.
pubLenThe length of the public key in bytes.
Returns
OK (0) if successful, otherwise a negative number error code from merrors.h.