TrustCore SDK NanoCert API reference  version 7.0
pkcs1.h File Reference

Header file for SoT Platform PKCS #1 convenience API. More...

Go to the source code of this file.

Macros

#define MOC_PKCS1_ALG_MGF1   1
 
#define PKCS1_MGF1   PKCS1_MGF1_FUNC
 

Typedefs

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

Functions

MOC_EXTERN MSTATUS PKCS1_MGF1_FUNC (MOC_RSA(hwAccelDescr hwAccelCtx) const ubyte *mgfSeed, ubyte4 mgfSeedLen, ubyte4 maskLen, BulkHashAlgo *H, ubyte **ppRetMask)
 
MOC_EXTERN MSTATUS PKCS1_rsaesOaepDecrypt (MOC_RSA(hwAccelDescr hwAccelCtx) const RSAKey *pRSAKey, ubyte H_rsaAlgoId, mgfFunc MGF, const ubyte *C, ubyte4 cLen, const ubyte *L, ubyte4 lLen, ubyte **ppRetDecrypt, ubyte4 *pRetDecryptLength)
 
MOC_EXTERN MSTATUS PKCS1_rsaesOaepEncrypt (MOC_RSA(hwAccelDescr hwAccelCtx) randomContext *pRandomContext, const RSAKey *pRSAKey, ubyte H_rsaAlgoId, mgfFunc MGF, const ubyte *M, ubyte4 mLen, const ubyte *L, ubyte4 lLen, ubyte **ppRetEncrypt, ubyte4 *pRetEncryptLen)
 
MOC_EXTERN MSTATUS PKCS1_rsaOaepDecrypt (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 PKCS1_rsaOaepEncrypt (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 PKCS1_rsaPssSign (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 PKCS1_rsaPssSignExt (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 PKCS1_rsaPssVerify (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 PKCS1_rsaPssVerifyExt (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 PKCS1_rsassaFreePssSign (MOC_RSA(hwAccelDescr hwAccelCtx) ubyte **ppSignature)
 
MOC_EXTERN MSTATUS PKCS1_rsassaPssSign (MOC_RSA(hwAccelDescr hwAccelCtx) randomContext *pRandomContext, const RSAKey *pRSAKey, ubyte H_rsaAlgoId, mgfFunc MGF, const ubyte *pMessage, ubyte4 mesgLen, ubyte4 saltLen, ubyte **ppRetSignature, ubyte4 *pRetSignatureLen)
 
MOC_EXTERN MSTATUS 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)
 

Detailed Description

Header file for SoT Platform PKCS #1, version 2.1, convenience API, as defined by RFC 3447.

For documentation for this file's definitions, enumerations, and functions, see pkcs1.c.

Function Documentation

◆ PKCS1_rsaOaepDecrypt()

MOC_EXTERN MSTATUS PKCS1_rsaOaepDecrypt ( 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.

◆ PKCS1_rsaOaepEncrypt()

MOC_EXTERN MSTATUS PKCS1_rsaOaepEncrypt ( 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.

◆ PKCS1_rsaPssSign()

MOC_EXTERN MSTATUS PKCS1_rsaPssSign ( 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.

◆ PKCS1_rsaPssSignExt()

MOC_EXTERN MSTATUS PKCS1_rsaPssSignExt ( 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.

◆ PKCS1_rsaPssVerify()

MOC_EXTERN MSTATUS PKCS1_rsaPssVerify ( 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. Use -1 to retrieve saltLen from signature.
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.

◆ PKCS1_rsaPssVerifyExt()

MOC_EXTERN MSTATUS PKCS1_rsaPssVerifyExt ( 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.
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.