My Project
Loading...
Searching...
No Matches
rsa.h File Reference

Go to the source code of this file.

Data Structures

struct  RsaNb
 
struct  RsaKey
 

Typedefs

typedef struct RsaNb RsaNb
 

Enumerations

enum  {
  RSA_PUBLIC = 0 , RSA_PRIVATE = 1 , RSA_TYPE_UNKNOWN = -1 , RSA_PUBLIC_ENCRYPT = 0 ,
  RSA_PUBLIC_DECRYPT = 1 , RSA_PRIVATE_ENCRYPT = 2 , RSA_PRIVATE_DECRYPT = 3 , RSA_BLOCK_TYPE_1 = 1 ,
  RSA_BLOCK_TYPE_2 = 2 , RSA_MIN_PAD_SZ = 11 , RSA_PSS_PAD_SZ = 8 , RSA_PSS_SALT_MAX_SZ = 62 ,
  RSA_PKCS1_PADDING_SIZE = 11 , RSA_PKCS1_OAEP_PADDING_SIZE = 42 , RSA_PSS_PAD_TERM = 0xBC , RSA_PSS_SALT_LEN_DEFAULT = -1 ,
  RSA_PSS_SALT_LEN_DISCOVER = -2 , RSA_MAX_ID_LEN = 32
}
 

Functions

WOLFSSL_API int wc_InitRsaKey (RsaKey *key, void *heap)
 This function initializes a provided RsaKey struct. It also takes in a heap identifier, for use with user defined memory overrides (see XMALLOC, XFREE, XREALLOC).
 
WOLFSSL_API int wc_InitRsaKey_ex (RsaKey *key, void *heap, int devId)
 
WOLFSSL_API int wc_FreeRsaKey (RsaKey *key)
 This function frees a provided RsaKey struct using mp_clear.
 
WOLFSSL_API int wc_InitRsaKey_Id (RsaKey *key, unsigned char *id, int len, void *heap, int devId)
 
WOLFSSL_API int wc_CheckRsaKey (RsaKey *key)
 
WOLFSSL_LOCAL int wc_InitRsaHw (RsaKey *key)
 
WOLFSSL_API int wc_RsaFunction (const byte *in, word32 inLen, byte *out, word32 *outLen, int type, RsaKey *key, WC_RNG *rng)
 
WOLFSSL_API int wc_RsaPublicEncrypt (const byte *in, word32 inLen, byte *out, word32 outLen, RsaKey *key, WC_RNG *rng)
 This function encrypts a message from in and stores the result in out. It requires an initialized public key and a random number generator. As a side effect, this function will return the bytes written to out in outLen.
 
WOLFSSL_API int wc_RsaPrivateDecryptInline (byte *in, word32 inLen, byte **out, RsaKey *key)
 This functions is utilized by the wc_RsaPrivateDecrypt function for decrypting.
 
WOLFSSL_API int wc_RsaPrivateDecrypt (const byte *in, word32 inLen, byte *out, word32 outLen, RsaKey *key)
 This functions provides private RSA decryption.
 
WOLFSSL_API int wc_RsaSSL_Sign (const byte *in, word32 inLen, byte *out, word32 outLen, RsaKey *key, WC_RNG *rng)
 Signs the provided array with the private key.
 
WOLFSSL_API int wc_RsaPSS_Sign (const byte *in, word32 inLen, byte *out, word32 outLen, enum wc_HashType hash, int mgf, RsaKey *key, WC_RNG *rng)
 
WOLFSSL_API int wc_RsaPSS_Sign_ex (const byte *in, word32 inLen, byte *out, word32 outLen, enum wc_HashType hash, int mgf, int saltLen, RsaKey *key, WC_RNG *rng)
 
WOLFSSL_API int wc_RsaSSL_VerifyInline (byte *in, word32 inLen, byte **out, RsaKey *key)
 Used to verify that the message was signed by RSA key. The output uses the same byte array as the input.
 
WOLFSSL_API int wc_RsaSSL_Verify (const byte *in, word32 inLen, byte *out, word32 outLen, RsaKey *key)
 Used to verify that the message was signed by key.
 
WOLFSSL_API int wc_RsaSSL_Verify_ex (const byte *in, word32 inLen, byte *out, word32 outLen, RsaKey *key, int pad_type)
 
WOLFSSL_API int wc_RsaPSS_VerifyInline (byte *in, word32 inLen, byte **out, enum wc_HashType hash, int mgf, RsaKey *key)
 
WOLFSSL_API int wc_RsaPSS_VerifyInline_ex (byte *in, word32 inLen, byte **out, enum wc_HashType hash, int mgf, int saltLen, RsaKey *key)
 
WOLFSSL_API int wc_RsaPSS_Verify (byte *in, word32 inLen, byte *out, word32 outLen, enum wc_HashType hash, int mgf, RsaKey *key)
 
WOLFSSL_API int wc_RsaPSS_Verify_ex (byte *in, word32 inLen, byte *out, word32 outLen, enum wc_HashType hash, int mgf, int saltLen, RsaKey *key)
 
WOLFSSL_API int wc_RsaPSS_CheckPadding (const byte *in, word32 inLen, byte *sig, word32 sigSz, enum wc_HashType hashType)
 
WOLFSSL_API int wc_RsaPSS_CheckPadding_ex (const byte *in, word32 inLen, byte *sig, word32 sigSz, enum wc_HashType hashType, int saltLen, int bits)
 
WOLFSSL_API int wc_RsaPSS_VerifyCheckInline (byte *in, word32 inLen, byte **out, const byte *digest, word32 digentLen, enum wc_HashType hash, int mgf, RsaKey *key)
 
WOLFSSL_API int wc_RsaPSS_VerifyCheck (byte *in, word32 inLen, byte *out, word32 outLen, const byte *digest, word32 digestLen, enum wc_HashType hash, int mgf, RsaKey *key)
 
WOLFSSL_API int wc_RsaEncryptSize (RsaKey *key)
 Returns the encryption size for the provided key structure.
 
WOLFSSL_API int wc_RsaPrivateKeyDecode (const byte *input, word32 *inOutIdx, RsaKey *, word32)
 This function parses a DER-formatted RSA private key, extracts the private key and stores it in the given RsaKey structure. It also sets the distance parsed in idx.
 
WOLFSSL_API int wc_RsaPublicKeyDecode (const byte *input, word32 *inOutIdx, RsaKey *, word32)
 This function parses a DER-formatted RSA public key, extracts the public key and stores it in the given RsaKey structure. It also sets the distance parsed in idx.
 
WOLFSSL_API int wc_RsaPublicKeyDecodeRaw (const byte *n, word32 nSz, const byte *e, word32 eSz, RsaKey *key)
 This function decodes the raw elements of an RSA public key, taking in the public modulus (n) and exponent (e). It stores these raw elements in the provided RsaKey structure, allowing one to use them in the encryption/decryption process.
 
WOLFSSL_API int wc_RsaKeyToDer (RsaKey *, byte *output, word32 inLen)
 This function converts an RsaKey key to DER format. The result is written to output and it returns the number of bytes written.
 
WOLFSSL_API int wc_RsaSetRNG (RsaKey *key, WC_RNG *rng)
 
WOLFSSL_API int wc_RsaSetNonBlock (RsaKey *key, RsaNb *nb)
 This function sets the non-blocking RSA context. When a RsaNb context is set it enables fast math based non-blocking exptmod, which splits the RSA function into many smaller operations. Enabled when WC_RSA_NONBLOCK is defined.
 
WOLFSSL_API int wc_RsaSetNonBlockTime (RsaKey *key, word32 maxBlockUs, word32 cpuMHz)
 This function configures the maximum amount of blocking time in microseconds. It uses a pre-computed table (see tfm.c exptModNbInst) along with the CPU speed in megahertz to determine if the next operation can be completed within the maximum blocking time provided. Enabled when WC_RSA_NONBLOCK_TIME is defined.
 
WOLFSSL_API int wc_RsaPublicEncrypt_ex (const byte *in, word32 inLen, byte *out, word32 outLen, RsaKey *key, WC_RNG *rng, int type, enum wc_HashType hash, int mgf, byte *label, word32 lableSz)
 This function performs RSA encrypt while allowing the choice of which padding to use.
 
WOLFSSL_API int wc_RsaPrivateDecrypt_ex (const byte *in, word32 inLen, byte *out, word32 outLen, RsaKey *key, int type, enum wc_HashType hash, int mgf, byte *label, word32 lableSz)
 This function uses RSA to decrypt a message and gives the option of what padding type.
 
WOLFSSL_API int wc_RsaPrivateDecryptInline_ex (byte *in, word32 inLen, byte **out, RsaKey *key, int type, enum wc_HashType hash, int mgf, byte *label, word32 lableSz)
 This function uses RSA to decrypt a message inline and gives the option of what padding type. The in buffer will contain the decrypted message after being called and the out byte pointer will point to the location in the “in” buffer where the plain text is.
 
WOLFSSL_API int wc_RsaDirect (byte *in, word32 inLen, byte *out, word32 *outSz, RsaKey *key, int type, WC_RNG *rng)
 
WOLFSSL_API int wc_RsaFlattenPublicKey (RsaKey *, byte *, word32 *, byte *, word32 *)
 Flattens the RsaKey structure into individual elements (e, n) used for the RSA algorithm.
 
WOLFSSL_API int wc_RsaExportKey (RsaKey *key, byte *e, word32 *eSz, byte *n, word32 *nSz, byte *d, word32 *dSz, byte *p, word32 *pSz, byte *q, word32 *qSz)
 
WOLFSSL_API int wc_RsaKeyToPublicDer (RsaKey *, byte *output, word32 inLen)
 Convert Rsa Public key to DER format. Writes to output, and returns count of bytes written.
 
WOLFSSL_API int wc_MakeRsaKey (RsaKey *key, int size, long e, WC_RNG *rng)
 This function generates a RSA private key of length size (in bits) and given exponent (e). It then stores this key in the provided RsaKey structure, so that it may be used for encryption/decryption. A secure number to use for e is 65537. size is required to be greater than RSA_MIN_SIZE and less than RSA_MAX_SIZE. For this function to be available, the option WOLFSSL_KEY_GEN must be enabled at compile time. This can be accomplished with –enable-keygen if using ./configure.
 
WOLFSSL_API int wc_CheckProbablePrime_ex (const byte *p, word32 pSz, const byte *q, word32 qSz, const byte *e, word32 eSz, int nlen, int *isPrime, WC_RNG *rng)
 
WOLFSSL_API int wc_CheckProbablePrime (const byte *p, word32 pSz, const byte *q, word32 qSz, const byte *e, word32 eSz, int nlen, int *isPrime)
 
WOLFSSL_LOCAL int wc_RsaPad_ex (const byte *input, word32 inputLen, byte *pkcsBlock, word32 pkcsBlockLen, byte padValue, WC_RNG *rng, int padType, enum wc_HashType hType, int mgf, byte *optLabel, word32 labelLen, int saltLen, int bits, void *heap)
 
WOLFSSL_LOCAL int wc_RsaUnPad_ex (byte *pkcsBlock, word32 pkcsBlockLen, byte **out, byte padValue, int padType, enum wc_HashType hType, int mgf, byte *optLabel, word32 labelLen, int saltLen, int bits, void *heap)
 

Variables

 C
 

Variable Documentation

◆ C

C
extern
Initial value:
{
#endif
enum {
RSA_MIN_SIZE = 512,
RSA_MAX_SIZE = 4096,
}