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

Cryptographic Interface header file for declaring PKCS1 functions. More...

Go to the source code of this file.

Functions

MOC_EXTERN MSTATUS CRYPTO_INTERFACE_PKCS1_MGF1 (MOC_RSA(hwAccelDescr hwAccelCtx) const ubyte *mgfSeed, ubyte4 mgfSeedLen, ubyte4 maskLen, BulkHashAlgo *H, ubyte **ppRetMask)
 Generate an MGF1 mask based on a given hash function, as defined in RFC 3447. More...
 
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_PKCS1_rsaOaepDecrypt (MOC_RSA(hwAccelDescr hwAccelCtx) const RSAKey *pRSAKey, ubyte hashAlgo, ubyte mgfAlgo, ubyte mgfHashAlgo, const ubyte *pCipherText, ubyte4 cLen, const ubyte *pLabel, ubyte4 lLen, ubyte **ppPlainText, ubyte4 *pPlainTextLen)
 Perform RSA-OAEP decryption. More...
 
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_PKCS1_rsaOaepEncrypt (MOC_RSA(hwAccelDescr hwAccelCtx) randomContext *pRandomContext, const RSAKey *pRSAKey, ubyte hashAlgo, ubyte mgfAlgo, ubyte mgfHashAlgo, const ubyte *pMessage, ubyte4 mLen, const ubyte *pLabel, ubyte4 lLen, ubyte **ppCipherText, ubyte4 *pCipherTextLen)
 Perform RSA-OAEP encryption. More...
 
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_PKCS1_rsaPssPad (MOC_RSA(hwAccelDescr hwAccelCtx) RSAKey *pKey, RNGFun rngFun, void *rngFunArg, ubyte *M, ubyte4 mLen, ubyte4 sLen, ubyte hashAlgo, ubyte mgfAlgo, ubyte mgfHashAlgo, ubyte **ppRetEM, ubyte4 *pRetEMLen)
 Used to generated RSA-PSS padded data. More...
 
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_PKCS1_rsaPssSign (MOC_RSA(hwAccelDescr hwAccelCtx) randomContext *pRandomContext, const RSAKey *pRSAKey, ubyte hashAlgo, ubyte mgfAlgo, ubyte mgfHashAlgo, const ubyte *pMessage, ubyte4 mLen, ubyte4 saltLen, ubyte **ppSignature, ubyte4 *pSignatureLen)
 Use the provided RSA Key to sign some data using the PSS scheme. More...
 
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_PKCS1_rsaPssSignExt (MOC_RSA(hwAccelDescr hwAccelCtx) randomContext *pRandomContext, const RSAKey *pRSAKey, ubyte hashAlgo, ubyte mgfAlgo, ubyte mgfHashAlgo, const ubyte *pMessage, ubyte4 mLen, ubyte4 saltLen, ubyte **ppSignature, ubyte4 *pSignatureLen, void *pExtCtx)
 Use the provided RSA Key to sign some data using the PSS scheme. More...
 
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_PKCS1_rsaPssVerify (MOC_RSA(hwAccelDescr hwAccelCtx) const RSAKey *pRSAKey, ubyte hashAlgo, ubyte mgfAlgo, ubyte mgfHashAlgo, const ubyte *pMessage, ubyte4 mLen, const ubyte *pSignature, ubyte4 signatureLen, sbyte4 saltLen, ubyte4 *pVerify)
 Use the provided RSA Key to verify a PSS signature. More...
 
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_PKCS1_rsaPssVerifyExt (MOC_RSA(hwAccelDescr hwAccelCtx) const RSAKey *pRSAKey, ubyte hashAlgo, ubyte mgfAlgo, ubyte mgfHashAlgo, const ubyte *pMessage, ubyte4 mLen, const ubyte *pSignature, ubyte4 signatureLen, sbyte4 saltLen, ubyte4 *pVerify, void *pExtCtx)
 Use the provided RSA Key to verify a PSS signature. More...
 
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_PKCS1_rsassaPssVerify (MOC_RSA(hwAccelDescr hwAccelCtx) const RSAKey *pRSAKey, ubyte H_rsaAlgoId, mgfFunc MGF, const ubyte *const pMessage, ubyte4 mesgLen, const ubyte *pSignature, ubyte4 signatureLen, sbyte4 saltLen, intBoolean *pRetIsSignatureValid)
 Use the provided RSA Key to verify a PSS signature. More...
 

Detailed Description

Add details here.

crypto_interface_pkcs1.h

Function Documentation

◆ CRYPTO_INTERFACE_PKCS1_MGF1()

MOC_EXTERN MSTATUS CRYPTO_INTERFACE_PKCS1_MGF1 ( MOC_RSA(hwAccelDescr hwAccelCtx) const ubyte *  mgfSeed,
ubyte4  mgfSeedLen,
ubyte4  maskLen,
BulkHashAlgo *  H,
ubyte **  ppRetMask 
)

This function generates an MGF1 mask mask of a given length, based a given hash function, as defined in RFC 3447.

pkcs1.h

Parameters
hwAccelCtxHardware acceleration context.
mgfSeedSeed generated from a pRandomContext.
mgfSeedLenNumber of bytes in the MGF seed, mgfSeed.
maskLenNumber of bytes in the returned mask, ppRetMask.
HHash function.
ppRetMaskOn return, pointer to address of generated mask.
Returns
OK (0) if successful; otherwise a negative number error code definition from merrors.h. To retrieve a string containing an English text error identifier corresponding to the function's returned error status, use the DISPLAY_ERROR macro.

crypto_interface_pkcs1.c

◆ CRYPTO_INTERFACE_PKCS1_rsaOaepDecrypt()

MOC_EXTERN MSTATUS CRYPTO_INTERFACE_PKCS1_rsaOaepDecrypt ( MOC_RSA(hwAccelDescr hwAccelCtx) const RSAKey *  pRSAKey,
ubyte  hashAlgo,
ubyte  mgfAlgo,
ubyte  mgfHashAlgo,
const ubyte *  pCipherText,
ubyte4  cLen,
const ubyte *  pLabel,
ubyte4  lLen,
ubyte **  ppPlainText,
ubyte4 *  pPlainTextLen 
)
Parameters
pRSAKeyThe RSA private key to use for this operation.
hashAlgoThe hash algorithm to use for this operation, must be one of the ht_sha* values in crypto.h
mgfAlgoThe Mask Generation Function (MGF) to use, this function currently only supports MOC_PKCS1_ALG_MGF1.
mgfHashAlgoThe hash algorithm to use for the MGF. Typically the MGF uses the same hashAlgo.
pCipherTextThe ciphertext to be decrypted
cLenLength in bytes of the ciphertext to be decrypted.
pLabelOptional label to use in the decoding.
lLenLength in bytes of the label.
ppPlainTextPointer to the pointer which will be allocated by this function and which will recieve the resulting plaintext.
pPlainTextLenPointer to the location that will recieve the byte length of the resulting plaintext.
Returns
OK (0) if successful; otherwise a negative number error code definition from merrors.h.

◆ CRYPTO_INTERFACE_PKCS1_rsaOaepEncrypt()

MOC_EXTERN MSTATUS CRYPTO_INTERFACE_PKCS1_rsaOaepEncrypt ( MOC_RSA(hwAccelDescr hwAccelCtx) randomContext *  pRandomContext,
const RSAKey *  pRSAKey,
ubyte  hashAlgo,
ubyte  mgfAlgo,
ubyte  mgfHashAlgo,
const ubyte *  pMessage,
ubyte4  mLen,
const ubyte *  pLabel,
ubyte4  lLen,
ubyte **  ppCipherText,
ubyte4 *  pCipherTextLen 
)
Parameters
pRandomContextThe random context to use for this operation.
pRSAKeyThe RSA public key to use for this operation.
hashAlgoThe hash algorithm to use for this operation, must be one of the ht_sha* values in crypto.h
mgfAlgoThe Mask Generation Function (MGF) to use, this function currently only supports MOC_PKCS1_ALG_MGF1.
mgfHashAlgoThe hash algorithm to use for the MGF. Typically the MGF uses the same hashAlgo.
pMessageThe plaintext message to be encrypted, the length must be less than or equal to (k - 2hlen - 2) where k is the length in octets of the RSA modulus N.
mLenLength in bytes of the input message to be encrypted.
pLabelOptional label to use in the encoding.
lLenLength in bytes of the label.
ppCipherTextPointer to the pointer which will be allocated by this function and which will recieve the resulting ciphertext.
pCipherTextLenPointer to the location that will recieve the byte length of the resulting ciphertext.
Returns
OK (0) if successful; otherwise a negative number error code definition from merrors.h.

◆ CRYPTO_INTERFACE_PKCS1_rsaPssPad()

MOC_EXTERN MSTATUS CRYPTO_INTERFACE_PKCS1_rsaPssPad ( MOC_RSA(hwAccelDescr hwAccelCtx) RSAKey *  pKey,
RNGFun  rngFun,
void *  rngFunArg,
ubyte *  M,
ubyte4  mLen,
ubyte4  sLen,
ubyte  hashAlgo,
ubyte  mgfAlgo,
ubyte  mgfHashAlgo,
ubyte **  ppRetEM,
ubyte4 *  pRetEMLen 
)

This API does NOT perform the RSA sign operation on the padded data.

Parameters
pKeyThe RSA key to use for this operation.
hashAlgoThe hash algorithm to use for this operation, must be one of the ht_sha* values in crypto.h
rngFunThe RNG function pointer used to generated random bytes.
rngFunArgThe RNG function pointer argument.
MThe plaintext message to be padded.
mLenLength in bytes of the input message to be padded.
sLenLength in bytes of the salt.
hashAlgoRSA-PSS hash algorithm to use.
mgfAlgoThe Mask Generation Function (MGF) to use, this function currently only supports MOC_PKCS1_ALG_MGF1.
mgfHashAlgoMGF1 hash algorithm. Must be the same as the message hash algorithm.
ppRetEMPointer to the pointer which will be allocated by this function and which will recieve the resulting RSA-PSS encoded message.
pRetEMLenPointer to the location that will recieve the byte length of the resulting RSA-PSS encoded message.
Returns
OK (0) if successful; otherwise a negative number error code definition from merrors.h.

◆ CRYPTO_INTERFACE_PKCS1_rsaPssSign()

MOC_EXTERN MSTATUS CRYPTO_INTERFACE_PKCS1_rsaPssSign ( MOC_RSA(hwAccelDescr hwAccelCtx) randomContext *  pRandomContext,
const RSAKey *  pRSAKey,
ubyte  hashAlgo,
ubyte  mgfAlgo,
ubyte  mgfHashAlgo,
const ubyte *  pMessage,
ubyte4  mLen,
ubyte4  saltLen,
ubyte **  ppSignature,
ubyte4 *  pSignatureLen 
)
Parameters
pRandomContextThe random context to use for this operation.
pRSAKeyThe RSA private key to use for this operation.
hashAlgoThe hash algorithm to use for this operation, must be one of the ht_sha* values in crypto.h
mgfAlgoThe Mask Generation Function (MGF) to use, this function currently only supports MOC_PKCS1_ALG_MGF1.
mgfHashAlgoThe hash algorithm to use for the MGF. Typically the MGF uses the same hashAlgo.
pMessageThe plaintext message to be signed, note this is not the digest of the data to be signed.
mLenLength in bytes of the input message to be signed.
saltLenLength in bytes of the salt.
ppSignaturePointer to the pointer which will be allocated by this function and which will recieve the resulting signature.
pSignatureLenPointer to the location that will recieve the byte length of the resulting signature.
Returns
OK (0) if successful; otherwise a negative number error code definition from merrors.h.

◆ CRYPTO_INTERFACE_PKCS1_rsaPssSignExt()

MOC_EXTERN MSTATUS CRYPTO_INTERFACE_PKCS1_rsaPssSignExt ( MOC_RSA(hwAccelDescr hwAccelCtx) randomContext *  pRandomContext,
const RSAKey *  pRSAKey,
ubyte  hashAlgo,
ubyte  mgfAlgo,
ubyte  mgfHashAlgo,
const ubyte *  pMessage,
ubyte4  mLen,
ubyte4  saltLen,
ubyte **  ppSignature,
ubyte4 *  pSignatureLen,
void *  pExtCtx 
)
Parameters
pRandomContextThe random context to use for this operation.
pRSAKeyThe RSA private key to use for this operation.
hashAlgoThe hash algorithm to use for this operation, must be one of the ht_sha* values in crypto.h
mgfAlgoThe Mask Generation Function (MGF) to use, this function currently only supports MOC_PKCS1_ALG_MGF1.
mgfHashAlgoThe hash algorithm to use for the MGF. Typically the MGF uses the same hashAlgo.
pMessageThe plaintext message to be signed, note this is not the digest of the data to be signed.
mLenLength in bytes of the input message to be signed.
saltLenLength in bytes of the salt.
ppSignaturePointer to the pointer which will be allocated by this function and which will recieve the resulting signature.
pSignatureLenPointer to the location that will recieve the byte length of the resulting signature.
pExtCtxExtended Context for future use.
Returns
OK (0) if successful; otherwise a negative number error code definition from merrors.h.

◆ CRYPTO_INTERFACE_PKCS1_rsaPssVerify()

MOC_EXTERN MSTATUS CRYPTO_INTERFACE_PKCS1_rsaPssVerify ( MOC_RSA(hwAccelDescr hwAccelCtx) const RSAKey *  pRSAKey,
ubyte  hashAlgo,
ubyte  mgfAlgo,
ubyte  mgfHashAlgo,
const ubyte *  pMessage,
ubyte4  mLen,
const ubyte *  pSignature,
ubyte4  signatureLen,
sbyte4  saltLen,
ubyte4 *  pVerify 
)
Parameters
pRSAKeyThe RSA public key to use for this operation.
hashAlgoThe hash algorithm to use for this operation, must be one of the ht_sha* values in crypto.h
mgfAlgoThe Mask Generation Function (MGF) to use, this function currently only supports MOC_PKCS1_ALG_MGF1.
mgfHashAlgoThe hash algorithm to use for the MGF. Typically the MGF uses the same hashAlgo.
pMessageThe plaintext message to be verified, note this is not the digest of the data to be verified.
mLenLength in bytes of the input message to be signed.
pSignaturePointer to the signature to be verified.
signatureLenLength in bytes of the signature value.
saltLenLength in bytes of the salt. Pass in -1 if the salt length should be calculated rather than verified.
pVerifyPointer to the value which will recieve the verification result, zero if it verified successfully, nonzero otherwise.
Returns
OK (0) if successful; otherwise a negative number error code definition from merrors.h.

◆ CRYPTO_INTERFACE_PKCS1_rsaPssVerifyExt()

MOC_EXTERN MSTATUS CRYPTO_INTERFACE_PKCS1_rsaPssVerifyExt ( MOC_RSA(hwAccelDescr hwAccelCtx) const RSAKey *  pRSAKey,
ubyte  hashAlgo,
ubyte  mgfAlgo,
ubyte  mgfHashAlgo,
const ubyte *  pMessage,
ubyte4  mLen,
const ubyte *  pSignature,
ubyte4  signatureLen,
sbyte4  saltLen,
ubyte4 *  pVerify,
void *  pExtCtx 
)
Parameters
pRSAKeyThe RSA public key to use for this operation.
hashAlgoThe hash algorithm to use for this operation, must be one of the ht_sha* values in crypto.h
mgfAlgoThe Mask Generation Function (MGF) to use, this function currently only supports MOC_PKCS1_ALG_MGF1.
mgfHashAlgoThe hash algorithm to use for the MGF. Typically the MGF uses the same hashAlgo.
pMessageThe plaintext message to be verified, note this is not the digest of the data to be verified.
mLenLength in bytes of the input message to be signed.
pSignaturePointer to the signature to be verified.
signatureLenLength in bytes of the signature value.
saltLenLength in bytes of the salt. Pass in -1 if the salt length should be calculated rather than verified.
pVerifyPointer to the value which will recieve the verification result, zero if it verified successfully, nonzero otherwise.
pExtCtxExtended Context for future use.
Returns
OK (0) if successful; otherwise a negative number error code definition from merrors.h.

◆ CRYPTO_INTERFACE_PKCS1_rsassaPssVerify()

MOC_EXTERN MSTATUS CRYPTO_INTERFACE_PKCS1_rsassaPssVerify ( MOC_RSA(hwAccelDescr hwAccelCtx) const RSAKey *  pRSAKey,
ubyte  H_rsaAlgoId,
mgfFunc  MGF,
const ubyte *const  pMessage,
ubyte4  mesgLen,
const ubyte *  pSignature,
ubyte4  signatureLen,
sbyte4  saltLen,
intBoolean *  pRetIsSignatureValid 
)
Parameters
hwAccelCtxHardware acceleration context.
pRSAKeyThe RSA public key to use for this operation.
H_rsaAlgoIdThe hash algorithm to use for this operation, must be one of the ht_sha* values in crypto.h
MGFThe Mask Generation Function (MGF) to use in function pointer form.
pMessageThe plaintext message to be verified, note this is not the digest of the data to be verified.
mesgLenLength in bytes of the input message to be signed.
pSignaturePointer to the signature to be verified.
signatureLenLength in bytes of the signature value.
saltLenLength in bytes of the salt. Pass in -1 if the salt length should be calculated rather than verified.
pRetIsSignatureValidContents will be set to TRUE for a valid signature and FALSE otherwise.
Returns
OK (0) if successful; otherwise a negative number error code definition from merrors.h.