My Project
|
Functions | |
int | wc_AesSetKey (Aes *aes, const byte *key, word32 len, const byte *iv, int dir) |
This function initializes an AES structure by setting the key and then setting the initialization vector. More... | |
int | wc_AesSetIV (Aes *aes, const byte *iv) |
This function sets the initialization vector for a particular AES object. The AES object should be initialized before calling this function. More... | |
int | wc_AesCbcEncrypt (Aes *aes, byte *out, const byte *in, word32 sz) |
Encrypts a plaintext message from the input buffer in, and places the resulting cipher text in the output buffer out using cipher block chaining with AES. This function requires that the AES object has been initialized by calling AesSetKey before a message is able to be encrypted. This function assumes that the input message is AES block length aligned, and expects the input length to be a multiple of the block length, which will optionally be checked and enforced if WOLFSSL_AES_CBC_LENGTH_CHECKS is defined in the build configuration. In order to assure block-multiple input, PKCS#7 style padding should be added beforehand. This differs from the OpenSSL AES-CBC methods which add the padding for you. To make the wolfSSL and corresponding OpenSSL functions interoperate, one should specify the -nopad option in the OpenSSL command line function so that it behaves like the wolfSSL AesCbcEncrypt method and does not add extra padding during encryption. More... | |
int | wc_AesCbcDecrypt (Aes *aes, byte *out, const byte *in, word32 sz) |
Decrypts a cipher from the input buffer in, and places the resulting plain text in the output buffer out using cipher block chaining with AES. This function requires that the AES structure has been initialized by calling AesSetKey before a message is able to be decrypted. This function assumes that the original message was AES block length aligned, and expects the input length to be a multiple of the block length, which will optionally be checked and enforced if WOLFSSL_AES_CBC_LENGTH_CHECKS is defined in the build configuration. This differs from the OpenSSL AES-CBC methods, which add PKCS#7 padding automatically, and so do not require block-multiple input. To make the wolfSSL function and equivalent OpenSSL functions interoperate, one should specify the -nopad option in the OpenSSL command line function so that it behaves like the wolfSSL AesCbcEncrypt method and does not create errors during decryption. More... | |
int | wc_AesCtrEncrypt (Aes *aes, byte *out, const byte *in, word32 sz) |
Encrypts/Decrypts a message from the input buffer in, and places the resulting cipher text in the output buffer out using CTR mode with AES. This function is only enabled if WOLFSSL_AES_COUNTER is enabled at compile time. The AES structure should be initialized through AesSetKey before calling this function. Note that this function is used for both decryption and encryption. NOTE: Regarding using same API for encryption and decryption. User should differentiate between Aes structures for encrypt/decrypt. More... | |
int | wc_AesEncryptDirect (Aes *aes, byte *out, const byte *in) |
This function is a one-block encrypt of the input block, in, into the output block, out. It uses the key of the provided AES structure, which should be initialized with wc_AesSetKey before calling this function. wc_AesSetKey should have been called with the iv set to NULL. This is only enabled if the configure option WOLFSSL_AES_DIRECT is enabled. Warning: In nearly all use cases ECB mode is considered to be less secure. Please avoid using ECB API’s directly whenever possible. More... | |
int | wc_AesDecryptDirect (Aes *aes, byte *out, const byte *in) |
This function is a one-block decrypt of the input block, in, into the output block, out. It uses the key of the provided AES structure, which should be initialized with wc_AesSetKey before calling this function. wc_AesSetKey should have been called with the iv set to NULL. This is only enabled if the configure option WOLFSSL_AES_DIRECT is enabled. Warning: In nearly all use cases ECB mode is considered to be less secure. Please avoid using ECB API’s directly whenever possible. More... | |
int | wc_AesSetKeyDirect (Aes *aes, const byte *key, word32 len, const byte *iv, int dir) |
This function is used to set the AES keys for CTR mode with AES. It initializes an AES object with the given key, iv (initialization vector), and encryption dir (direction). It is only enabled if the configure option WOLFSSL_AES_DIRECT is enabled. Currently wc_AesSetKeyDirect uses wc_AesSetKey internally. Warning: In nearly all use cases ECB mode is considered to be less secure. Please avoid using ECB API’s directly whenever possible. More... | |
int | wc_AesGcmSetKey (Aes *aes, const byte *key, word32 len) |
This function is used to set the key for AES GCM (Galois/Counter Mode). It initializes an AES object with the given key. It is only enabled if the configure option HAVE_AESGCM is enabled at compile time. More... | |
int | wc_AesGcmEncrypt (Aes *aes, byte *out, const byte *in, word32 sz, const byte *iv, word32 ivSz, byte *authTag, word32 authTagSz, const byte *authIn, word32 authInSz) |
This function encrypts the input message, held in the buffer in, and stores the resulting cipher text in the output buffer out. It requires a new iv (initialization vector) for each call to encrypt. It also encodes the input authentication vector, authIn, into the authentication tag, authTag. More... | |
int | wc_AesGcmDecrypt (Aes *aes, byte *out, const byte *in, word32 sz, const byte *iv, word32 ivSz, const byte *authTag, word32 authTagSz, const byte *authIn, word32 authInSz) |
This function decrypts the input cipher text, held in the buffer in, and stores the resulting message text in the output buffer out. It also checks the input authentication vector, authIn, against the supplied authentication tag, authTag. More... | |
int | wc_GmacSetKey (Gmac *gmac, const byte *key, word32 len) |
This function initializes and sets the key for a GMAC object to be used for Galois Message Authentication. More... | |
int | wc_GmacUpdate (Gmac *gmac, const byte *iv, word32 ivSz, const byte *authIn, word32 authInSz, byte *authTag, word32 authTagSz) |
This function generates the Gmac hash of the authIn input and stores the result in the authTag buffer. After running wc_GmacUpdate, one should compare the generated authTag to a known authentication tag to verify the authenticity of a message. More... | |
int | wc_AesCcmSetKey (Aes *aes, const byte *key, word32 keySz) |
This function sets the key for an AES object using CCM (Counter with CBC-MAC). It takes a pointer to an AES structure and initializes it with supplied key. More... | |
int | wc_AesCcmEncrypt (Aes *aes, byte *out, const byte *in, word32 inSz, const byte *nonce, word32 nonceSz, byte *authTag, word32 authTagSz, const byte *authIn, word32 authInSz) |
This function encrypts the input message, in, into the output buffer, out, using CCM (Counter with CBC-MAC). It subsequently calculates and stores the authorization tag, authTag, from the authIn input. More... | |
int | wc_AesCcmDecrypt (Aes *aes, byte *out, const byte *in, word32 inSz, const byte *nonce, word32 nonceSz, const byte *authTag, word32 authTagSz, const byte *authIn, word32 authInSz) |
This function decrypts the input cipher text, in, into the output buffer, out, using CCM (Counter with CBC-MAC). It subsequently calculates the authorization tag, authTag, from the authIn input. If the authorization tag is invalid, it sets the output buffer to zero and returns the error: AES_CCM_AUTH_E. More... | |
int | wc_AesXtsInit (XtsAes *aes, void *heap, int devId) |
This is to initialize an AES-XTS context. It is up to user to call wc_AesXtsFree on aes key when done. More... | |
int | wc_AesXtsSetKeyNoInit (XtsAes *aes, const byte *key, word32 len, int dir) |
This is to help with setting keys to correct encrypt or decrypt type, after first calling wc_AesXtsInit(). It is up to user to call wc_AesXtsFree on aes key when done. More... | |
int | wc_AesXtsSetKey (XtsAes *aes, const byte *key, word32 len, int dir, void *heap, int devId) |
This is to help with setting keys to correct encrypt or decrypt type. It is up to user to call wc_AesXtsFree on aes key when done. More... | |
int | wc_AesXtsEncryptSector (XtsAes *aes, byte *out, const byte *in, word32 sz, word64 sector) |
Same process as wc_AesXtsEncrypt but uses a word64 type as the tweak value instead of a byte array. This just converts the word64 to a byte array and calls wc_AesXtsEncrypt. More... | |
int | wc_AesXtsDecryptSector (XtsAes *aes, byte *out, const byte *in, word32 sz, word64 sector) |
Same process as wc_AesXtsDecrypt but uses a word64 type as the tweak value instead of a byte array. This just converts the word64 to a byte array. More... | |
int | wc_AesXtsEncrypt (XtsAes *aes, byte *out, const byte *in, word32 sz, const byte *i, word32 iSz) |
AES with XTS mode. (XTS) XEX encryption with Tweak and cipher text Stealing. More... | |
int | wc_AesXtsDecrypt (XtsAes *aes, byte *out, const byte *in, word32 sz, const byte *i, word32 iSz) |
Same process as encryption but Aes key is AES_DECRYPTION type. More... | |
int | wc_AesXtsFree (XtsAes *aes) |
This is to free up any resources used by the XtsAes structure. More... | |
int | wc_AesInit (Aes *aes, void *heap, int devId) |
Initialize Aes structure. Sets heap hint to be used and ID for use with async hardware. It is up to the user to call wc_AesFree on the Aes structure when done. More... | |
int | wc_AesFree (Aes *aes) |
free resources associated with the Aes structure when applicable. Internally may sometimes be a no-op but still recommended to call in all cases as a general best-practice (IE if application code is ported for use on new environments where the call is applicable). More... | |
int | wc_AesCfbEncrypt (Aes *aes, byte *out, const byte *in, word32 sz) |
AES with CFB mode. More... | |
int | wc_AesCfbDecrypt (Aes *aes, byte *out, const byte *in, word32 sz) |
AES with CFB mode. More... | |
int | wc_AesSivEncrypt (const byte *key, word32 keySz, const byte *assoc, word32 assocSz, const byte *nonce, word32 nonceSz, const byte *in, word32 inSz, byte *siv, byte *out) |
This function performs SIV (synthetic initialization vector) encryption as described in RFC 5297. More... | |
int | wc_AesSivDecrypt (const byte *key, word32 keySz, const byte *assoc, word32 assocSz, const byte *nonce, word32 nonceSz, const byte *in, word32 inSz, byte *siv, byte *out) |
This function performs SIV (synthetic initialization vector) decryption as described in RFC 5297. More... | |
WOLFSSL_API int | wc_AesEaxEncryptAuth (const byte *key, word32 keySz, byte *out, const byte *in, word32 inSz, const byte *nonce, word32 nonceSz, byte *authTag, word32 authTagSz, const byte *authIn, word32 authInSz) |
This function performs AES EAX encryption and authentication as described in "EAX: A Conventional Authenticated-Encryption Mode" (https://eprint.iacr.org/2003/069). It is a "one-shot" API that performs all encryption and authentication operations in one function call. More... | |
WOLFSSL_API int | wc_AesEaxDecryptAuth (const byte *key, word32 keySz, byte *out, const byte *in, word32 inSz, const byte *nonce, word32 nonceSz, const byte *authTag, word32 authTagSz, const byte *authIn, word32 authInSz) |
This function performs AES EAX decryption and authentication as described in "EAX: A Conventional Authenticated-Encryption Mode" (https://eprint.iacr.org/2003/069). It is a "one-shot" API that performs all decryption and authentication operations in one function call. More... | |
WOLFSSL_API int | wc_AesEaxInit (AesEax *eax, const byte *key, word32 keySz, const byte *nonce, word32 nonceSz, const byte *authIn, word32 authInSz) |
This function initializes an AesEax object for use in authenticated encryption or decryption. This function must be called on an AesEax object before using it with any of the AES EAX incremental API functions. It does not need to be called if using the one-shot EAX API functions. All AesEax instances initialized with this function need to be freed with a call to wc_AesEaxFree() when done using the instance. More... | |
WOLFSSL_API int | wc_AesEaxEncryptUpdate (AesEax *eax, byte *out, const byte *in, word32 inSz, const byte *authIn, word32 authInSz) |
This function uses AES EAX to encrypt input data, and optionally, add more input data to the authentication stream. eax must have been previously initialized with a call to wc_AesEaxInit. More... | |
WOLFSSL_API int | wc_AesEaxDecryptUpdate (AesEax *eax, byte *out, const byte *in, word32 inSz, const byte *authIn, word32 authInSz) |
This function uses AES EAX to decrypt input data, and optionally, add more input data to the authentication stream. eax must have been previously initialized with a call to wc_AesEaxInit. More... | |
WOLFSSL_API int | wc_AesEaxAuthDataUpdate (AesEax *eax, const byte *authIn, word32 authInSz) |
This function adds input data to the authentication stream. eax must have been previously initialized with a call to wc_AesEaxInit. More... | |
WOLFSSL_API int | wc_AesEaxEncryptFinal (AesEax *eax, byte *authTag, word32 authTagSz) |
This function finalizes the encrypt AEAD operation, producing an auth tag over the current authentication stream. eax must have been previously initialized with a call to wc_AesEaxInit. When done using the AesEax context structure, make sure to free it using wc_AesEaxFree. More... | |
WOLFSSL_API int | wc_AesEaxDecryptFinal (AesEax *eax, const byte *authIn, word32 authInSz) |
This function finalizes the decrypt AEAD operation, finalizing the auth tag computation and checking it for validity against the user supplied tag. eax must have been previously initialized with a call to wc_AesEaxInit. When done using the AesEax context structure, make sure to free it using wc_AesEaxFree. More... | |
WOLFSSL_API int | wc_AesEaxFree (AesEax *eax) |
This frees up any resources, specifically keys, used by the Aes instance inside the AesEax wrapper struct. It should be called on the AesEax struct after it has been initialized with wc_AesEaxInit, and all desired EAX operations are complete. More... | |
int | wc_AesCbcDecryptWithKey (byte *out, const byte *in, word32 inSz, const byte *key, word32 keySz, const byte *iv) |
Decrypts a cipher from the input buffer in, and places the resulting plain text in the output buffer out using cipher block chaining with AES. This function does not require an AES structure to be initialized. Instead, it takes in a key and an iv (initialization vector) and uses these to initialize an AES object and then decrypt the cipher text. More... | |
int wc_AesCbcDecrypt | ( | Aes * | aes, |
byte * | out, | ||
const byte * | in, | ||
word32 | sz | ||
) |
Decrypts a cipher from the input buffer in, and places the resulting plain text in the output buffer out using cipher block chaining with AES. This function requires that the AES structure has been initialized by calling AesSetKey before a message is able to be decrypted. This function assumes that the original message was AES block length aligned, and expects the input length to be a multiple of the block length, which will optionally be checked and enforced if WOLFSSL_AES_CBC_LENGTH_CHECKS is defined in the build configuration. This differs from the OpenSSL AES-CBC methods, which add PKCS#7 padding automatically, and so do not require block-multiple input. To make the wolfSSL function and equivalent OpenSSL functions interoperate, one should specify the -nopad option in the OpenSSL command line function so that it behaves like the wolfSSL AesCbcEncrypt method and does not create errors during decryption.
aes | pointer to the AES object used to decrypt data. |
out | pointer to the output buffer in which to store the plain text of the decrypted message. size must be a multiple of AES_BLOCK_LENGTH, padded if necessary |
in | pointer to the input buffer containing cipher text to be decrypted. size must be a multiple of AES_BLOCK_LENGTH, padded if necessary |
sz | size of input message. |
Example
int wc_AesCbcDecryptWithKey | ( | byte * | out, |
const byte * | in, | ||
word32 | inSz, | ||
const byte * | key, | ||
word32 | keySz, | ||
const byte * | iv | ||
) |
Decrypts a cipher from the input buffer in, and places the resulting plain text in the output buffer out using cipher block chaining with AES. This function does not require an AES structure to be initialized. Instead, it takes in a key and an iv (initialization vector) and uses these to initialize an AES object and then decrypt the cipher text.
out | pointer to the output buffer in which to store the plain text of the decrypted message |
in | pointer to the input buffer containing cipher text to be decrypted |
inSz | size of input message |
key | 16, 24, or 32 byte secret key for decryption |
keySz | size of key used for decryption |
Example
int wc_AesCbcEncrypt | ( | Aes * | aes, |
byte * | out, | ||
const byte * | in, | ||
word32 | sz | ||
) |
Encrypts a plaintext message from the input buffer in, and places the resulting cipher text in the output buffer out using cipher block chaining with AES. This function requires that the AES object has been initialized by calling AesSetKey before a message is able to be encrypted. This function assumes that the input message is AES block length aligned, and expects the input length to be a multiple of the block length, which will optionally be checked and enforced if WOLFSSL_AES_CBC_LENGTH_CHECKS is defined in the build configuration. In order to assure block-multiple input, PKCS#7 style padding should be added beforehand. This differs from the OpenSSL AES-CBC methods which add the padding for you. To make the wolfSSL and corresponding OpenSSL functions interoperate, one should specify the -nopad option in the OpenSSL command line function so that it behaves like the wolfSSL AesCbcEncrypt method and does not add extra padding during encryption.
aes | pointer to the AES object used to encrypt data |
out | pointer to the output buffer in which to store the ciphertext of the encrypted message |
in | pointer to the input buffer containing message to be encrypted |
sz | size of input message |
Example
int wc_AesCcmDecrypt | ( | Aes * | aes, |
byte * | out, | ||
const byte * | in, | ||
word32 | inSz, | ||
const byte * | nonce, | ||
word32 | nonceSz, | ||
const byte * | authTag, | ||
word32 | authTagSz, | ||
const byte * | authIn, | ||
word32 | authInSz | ||
) |
This function decrypts the input cipher text, in, into the output buffer, out, using CCM (Counter with CBC-MAC). It subsequently calculates the authorization tag, authTag, from the authIn input. If the authorization tag is invalid, it sets the output buffer to zero and returns the error: AES_CCM_AUTH_E.
aes | pointer to the AES object used to encrypt data |
out | pointer to the output buffer in which to store the cipher text |
in | pointer to the input buffer holding the message to encrypt |
sz | length of the input cipher text to decrypt |
nonce | pointer to the buffer containing the nonce (number only used once) |
nonceSz | length of the nonce |
authTag | pointer to the buffer in which to store the authentication tag |
authTagSz | length of the desired authentication tag |
authIn | pointer to the buffer containing the input authentication vector |
authInSz | length of the input authentication vector |
Example
int wc_AesCcmEncrypt | ( | Aes * | aes, |
byte * | out, | ||
const byte * | in, | ||
word32 | inSz, | ||
const byte * | nonce, | ||
word32 | nonceSz, | ||
byte * | authTag, | ||
word32 | authTagSz, | ||
const byte * | authIn, | ||
word32 | authInSz | ||
) |
This function encrypts the input message, in, into the output buffer, out, using CCM (Counter with CBC-MAC). It subsequently calculates and stores the authorization tag, authTag, from the authIn input.
aes | pointer to the AES object used to encrypt data |
out | pointer to the output buffer in which to store the cipher text |
in | pointer to the input buffer holding the message to encrypt |
sz | length of the input message to encrypt |
nonce | pointer to the buffer containing the nonce (number only used once) |
nonceSz | length of the nonce |
authTag | pointer to the buffer in which to store the authentication tag |
authTagSz | length of the desired authentication tag |
authIn | pointer to the buffer containing the input authentication vector |
authInSz | length of the input authentication vector |
Example
int wc_AesCcmSetKey | ( | Aes * | aes, |
const byte * | key, | ||
word32 | keySz | ||
) |
This function sets the key for an AES object using CCM (Counter with CBC-MAC). It takes a pointer to an AES structure and initializes it with supplied key.
aes | aes structure in which to store the supplied key |
key | 16, 24, or 32 byte secret key for encryption and decryption |
keySz | size of the supplied key |
Example
int wc_AesCfbDecrypt | ( | Aes * | aes, |
byte * | out, | ||
const byte * | in, | ||
word32 | sz | ||
) |
AES with CFB mode.
aes | AES keys to use for block encrypt/decrypt |
out | output buffer to hold decrypted text must be at least as large as inputbuffer) |
in | input buffer to decrypt |
sz | size of input buffer |
Example
int wc_AesCfbEncrypt | ( | Aes * | aes, |
byte * | out, | ||
const byte * | in, | ||
word32 | sz | ||
) |
AES with CFB mode.
aes | AES keys to use for block encrypt/decrypt |
out | output buffer to hold cipher text must be at least as large as inputbuffer) |
in | input plain text buffer to encrypt |
sz | size of input buffer |
Example
int wc_AesCtrEncrypt | ( | Aes * | aes, |
byte * | out, | ||
const byte * | in, | ||
word32 | sz | ||
) |
Encrypts/Decrypts a message from the input buffer in, and places the resulting cipher text in the output buffer out using CTR mode with AES. This function is only enabled if WOLFSSL_AES_COUNTER is enabled at compile time. The AES structure should be initialized through AesSetKey before calling this function. Note that this function is used for both decryption and encryption. NOTE: Regarding using same API for encryption and decryption. User should differentiate between Aes structures for encrypt/decrypt.
aes | pointer to the AES object used to decrypt data |
out | pointer to the output buffer in which to store the cipher text of the encrypted message size must be a multiple of AES_BLOCK_LENGTH, padded if necessary |
in | pointer to the input buffer containing plain text to be encrypted size must be a multiple of AES_BLOCK_LENGTH, padded if necessary |
sz | size of the input plain text |
Example
int wc_AesDecryptDirect | ( | Aes * | aes, |
byte * | out, | ||
const byte * | in | ||
) |
This function is a one-block decrypt of the input block, in, into the output block, out. It uses the key of the provided AES structure, which should be initialized with wc_AesSetKey before calling this function. wc_AesSetKey should have been called with the iv set to NULL. This is only enabled if the configure option WOLFSSL_AES_DIRECT is enabled. Warning: In nearly all use cases ECB mode is considered to be less secure. Please avoid using ECB API’s directly whenever possible.
aes | pointer to the AES object used to encrypt data |
out | pointer to the output buffer in which to store the plain text of the decrypted cipher text |
in | pointer to the input buffer containing cipher text to be decrypted |
Example
WOLFSSL_API int wc_AesEaxAuthDataUpdate | ( | AesEax * | eax, |
const byte * | authIn, | ||
word32 | authInSz | ||
) |
This function adds input data to the authentication stream. eax
must have been previously initialized with a call to wc_AesEaxInit.
eax | AES EAX structure holding the context of the AEAD operation |
authIn | input data to add to the authentication stream |
authInSz | size in bytes of the input authentication data |
Example
WOLFSSL_API int wc_AesEaxDecryptAuth | ( | const byte * | key, |
word32 | keySz, | ||
byte * | out, | ||
const byte * | in, | ||
word32 | inSz, | ||
const byte * | nonce, | ||
word32 | nonceSz, | ||
const byte * | authTag, | ||
word32 | authTagSz, | ||
const byte * | authIn, | ||
word32 | authInSz | ||
) |
This function performs AES EAX decryption and authentication as described in "EAX: A Conventional Authenticated-Encryption Mode" (https://eprint.iacr.org/2003/069). It is a "one-shot" API that performs all decryption and authentication operations in one function call.
authTag
key | byte buffer containing the key to use | |
keySz | length of the key buffer in bytes | |
[out] | out | buffer to hold the plaintext. Should be the same length as the input ciphertext buffer |
in | ciphertext buffer to decrypt | |
inSz | length of ciphertext buffer | |
nonce | the cryptographic nonce to use for EAX operations | |
nonceSz | length of nonce buffer in bytes | |
authTag | buffer that holds the authentication tag to check the authenticity of the data against | |
authTagSz | Length of the input authentication tag | |
authIn | pointer to the buffer containing input data to authenticate | |
authInSz | length of the input authentication data |
Example
WOLFSSL_API int wc_AesEaxDecryptFinal | ( | AesEax * | eax, |
const byte * | authIn, | ||
word32 | authInSz | ||
) |
This function finalizes the decrypt AEAD operation, finalizing the auth tag computation and checking it for validity against the user supplied tag. eax
must have been previously initialized with a call to wc_AesEaxInit. When done using the AesEax
context structure, make sure to free it using wc_AesEaxFree.
authIn
eax | AES EAX structure holding the context of the AEAD operation |
authIn | input auth tag to check computed auth tag against |
authInSz | size in bytes of authIn |
Example
WOLFSSL_API int wc_AesEaxDecryptUpdate | ( | AesEax * | eax, |
byte * | out, | ||
const byte * | in, | ||
word32 | inSz, | ||
const byte * | authIn, | ||
word32 | authInSz | ||
) |
This function uses AES EAX to decrypt input data, and optionally, add more input data to the authentication stream. eax
must have been previously initialized with a call to wc_AesEaxInit.
eax | AES EAX structure holding the context of the AEAD operation | |
[out] | out | output buffer holding the decrypted plaintext |
in | input buffer holding the ciphertext | |
inSz | size in bytes of the input data buffer | |
authIn | (optional) input data to add to the authentication stream This argument should be NULL if not used | |
authInSz | size in bytes of the input authentication data |
Example
WOLFSSL_API int wc_AesEaxEncryptAuth | ( | const byte * | key, |
word32 | keySz, | ||
byte * | out, | ||
const byte * | in, | ||
word32 | inSz, | ||
const byte * | nonce, | ||
word32 | nonceSz, | ||
byte * | authTag, | ||
word32 | authTagSz, | ||
const byte * | authIn, | ||
word32 | authInSz | ||
) |
This function performs AES EAX encryption and authentication as described in "EAX: A Conventional Authenticated-Encryption Mode" (https://eprint.iacr.org/2003/069). It is a "one-shot" API that performs all encryption and authentication operations in one function call.
key | buffer containing the key to use | |
keySz | length of the key buffer in bytes | |
[out] | out | buffer to hold the ciphertext. Should be the same length as the plaintext buffer |
in | plaintext buffer to encrypt | |
inSz | length of plaintext buffer | |
nonce | the cryptographic nonce to use for EAX operations | |
nonceSz | length of nonce buffer in bytes | |
[out] | authTag | pointer to the buffer in which to store the authentication tag |
authTagSz | length of the desired authentication tag | |
authIn | pointer to the buffer containing input data to authenticate | |
authInSz | length of the input authentication data |
Example
WOLFSSL_API int wc_AesEaxEncryptFinal | ( | AesEax * | eax, |
byte * | authTag, | ||
word32 | authTagSz | ||
) |
This function finalizes the encrypt AEAD operation, producing an auth tag over the current authentication stream. eax
must have been previously initialized with a call to wc_AesEaxInit. When done using the AesEax
context structure, make sure to free it using wc_AesEaxFree.
eax | AES EAX structure holding the context of the AEAD operation |
authTag[out] | buffer that will hold the computed auth tag |
authTagSz | size in bytes of authTag |
Example
WOLFSSL_API int wc_AesEaxEncryptUpdate | ( | AesEax * | eax, |
byte * | out, | ||
const byte * | in, | ||
word32 | inSz, | ||
const byte * | authIn, | ||
word32 | authInSz | ||
) |
This function uses AES EAX to encrypt input data, and optionally, add more input data to the authentication stream. eax
must have been previously initialized with a call to wc_AesEaxInit.
eax | AES EAX structure holding the context of the AEAD operation | |
[out] | out | output buffer holding the ciphertext |
in | input buffer holding the plaintext to encrypt | |
inSz | size in bytes of the input data buffer | |
authIn | (optional) input data to add to the authentication stream This argument should be NULL if not used | |
authInSz | size in bytes of the input authentication data |
Example
WOLFSSL_API int wc_AesEaxFree | ( | AesEax * | eax | ) |
This frees up any resources, specifically keys, used by the Aes instance inside the AesEax wrapper struct. It should be called on the AesEax struct after it has been initialized with wc_AesEaxInit, and all desired EAX operations are complete.
eaxAES | EAX instance to free |
Example
WOLFSSL_API int wc_AesEaxInit | ( | AesEax * | eax, |
const byte * | key, | ||
word32 | keySz, | ||
const byte * | nonce, | ||
word32 | nonceSz, | ||
const byte * | authIn, | ||
word32 | authInSz | ||
) |
This function initializes an AesEax object for use in authenticated encryption or decryption. This function must be called on an AesEax object before using it with any of the AES EAX incremental API functions. It does not need to be called if using the one-shot EAX API functions. All AesEax instances initialized with this function need to be freed with a call to wc_AesEaxFree() when done using the instance.
eax | AES EAX structure holding the context of the AEAD operation |
key | 16, 24, or 32 byte secret key for encryption and decryption |
keySz | length of the supplied key in bytes |
nonce | the cryptographic nonce to use for EAX operations |
nonceSz | length of nonce buffer in bytes |
authIn | (optional) input data to add to the authentication stream This argument should be NULL if not used |
authInSz | size in bytes of the input authentication data |
Example
int wc_AesEncryptDirect | ( | Aes * | aes, |
byte * | out, | ||
const byte * | in | ||
) |
This function is a one-block encrypt of the input block, in, into the output block, out. It uses the key of the provided AES structure, which should be initialized with wc_AesSetKey before calling this function. wc_AesSetKey should have been called with the iv set to NULL. This is only enabled if the configure option WOLFSSL_AES_DIRECT is enabled. Warning: In nearly all use cases ECB mode is considered to be less secure. Please avoid using ECB API’s directly whenever possible.
aes | pointer to the AES object used to encrypt data |
out | pointer to the output buffer in which to store the cipher text of the encrypted message |
in | pointer to the input buffer containing plain text to be encrypted |
Example
int wc_AesFree | ( | Aes * | aes | ) |
free resources associated with the Aes structure when applicable. Internally may sometimes be a no-op but still recommended to call in all cases as a general best-practice (IE if application code is ported for use on new environments where the call is applicable).
aes | aes structure in to free |
Example
int wc_AesGcmDecrypt | ( | Aes * | aes, |
byte * | out, | ||
const byte * | in, | ||
word32 | sz, | ||
const byte * | iv, | ||
word32 | ivSz, | ||
const byte * | authTag, | ||
word32 | authTagSz, | ||
const byte * | authIn, | ||
word32 | authInSz | ||
) |
This function decrypts the input cipher text, held in the buffer in, and stores the resulting message text in the output buffer out. It also checks the input authentication vector, authIn, against the supplied authentication tag, authTag.
aes | pointer to the AES object used to encrypt data |
out | pointer to the output buffer in which to store the message text size must match in's size (sz) |
in | pointer to the input buffer holding the cipher text to decrypt size must be a multiple of AES_BLOCK_LENGTH, padded if necessary |
sz | length of the cipher text to decrypt |
iv | pointer to the buffer containing the initialization vector |
ivSz | length of the initialization vector |
authTag | pointer to the buffer containing the authentication tag |
authTagSz | length of the desired authentication tag |
authIn | pointer to the buffer containing the input authentication vector |
authInSz | length of the input authentication vector |
Example
int wc_AesGcmEncrypt | ( | Aes * | aes, |
byte * | out, | ||
const byte * | in, | ||
word32 | sz, | ||
const byte * | iv, | ||
word32 | ivSz, | ||
byte * | authTag, | ||
word32 | authTagSz, | ||
const byte * | authIn, | ||
word32 | authInSz | ||
) |
This function encrypts the input message, held in the buffer in, and stores the resulting cipher text in the output buffer out. It requires a new iv (initialization vector) for each call to encrypt. It also encodes the input authentication vector, authIn, into the authentication tag, authTag.
aes | - pointer to the AES object used to encrypt data |
out | pointer to the output buffer in which to store the cipher text size must match in's size (sz) |
in | pointer to the input buffer holding the message to encrypt size must be a multiple of AES_BLOCK_LENGTH, padded if necessary |
sz | length of the input message to encrypt |
iv | pointer to the buffer containing the initialization vector |
ivSz | length of the initialization vector |
authTag | pointer to the buffer in which to store the authentication tag |
authTagSz | length of the desired authentication tag |
authIn | pointer to the buffer containing the input authentication vector |
authInSz | length of the input authentication vector |
Example
int wc_AesGcmSetKey | ( | Aes * | aes, |
const byte * | key, | ||
word32 | len | ||
) |
This function is used to set the key for AES GCM (Galois/Counter Mode). It initializes an AES object with the given key. It is only enabled if the configure option HAVE_AESGCM is enabled at compile time.
aes | pointer to the AES object used to encrypt data |
key | 16, 24, or 32 byte secret key for encryption and decryption |
len | length of the key passed in |
Example
int wc_AesInit | ( | Aes * | aes, |
void * | heap, | ||
int | devId | ||
) |
Initialize Aes structure. Sets heap hint to be used and ID for use with async hardware. It is up to the user to call wc_AesFree on the Aes structure when done.
aes | aes structure in to initialize |
heap | heap hint to use for malloc / free if needed |
devId | ID to use with crypto callbacks or async hardware. Set to INVALID_DEVID (-2) if not used |
Example
int wc_AesSetIV | ( | Aes * | aes, |
const byte * | iv | ||
) |
This function sets the initialization vector for a particular AES object. The AES object should be initialized before calling this function.
aes | pointer to the AES structure on which to set the initialization vector |
iv | initialization vector used to initialize the AES structure. If the value is NULL, the default action initializes the iv to 0. |
Example
int wc_AesSetKey | ( | Aes * | aes, |
const byte * | key, | ||
word32 | len, | ||
const byte * | iv, | ||
int | dir | ||
) |
This function initializes an AES structure by setting the key and then setting the initialization vector.
aes | pointer to the AES structure to modify |
key | 16, 24, or 32 byte secret key for encryption and decryption |
len | length of the key passed in |
iv | pointer to the initialization vector used to initialize the key |
dir | Cipher direction. Set AES_ENCRYPTION to encrypt, or AES_DECRYPTION to decrypt. Direction for some modes (CFB and CTR) is always AES_ENCRYPTION. |
Example
int wc_AesSetKeyDirect | ( | Aes * | aes, |
const byte * | key, | ||
word32 | len, | ||
const byte * | iv, | ||
int | dir | ||
) |
This function is used to set the AES keys for CTR mode with AES. It initializes an AES object with the given key, iv (initialization vector), and encryption dir (direction). It is only enabled if the configure option WOLFSSL_AES_DIRECT is enabled. Currently wc_AesSetKeyDirect uses wc_AesSetKey internally. Warning: In nearly all use cases ECB mode is considered to be less secure. Please avoid using ECB API’s directly whenever possible.
aes | pointer to the AES object used to encrypt data |
key | 16, 24, or 32 byte secret key for encryption and decryption |
len | length of the key passed in |
iv | initialization vector used to initialize the key |
dir | Cipher direction. Set AES_ENCRYPTION to encrypt, or AES_DECRYPTION to decrypt. (See enum in wolfssl/wolfcrypt/aes.h) (NOTE: If using wc_AesSetKeyDirect with Aes Counter mode (Stream cipher) only use AES_ENCRYPTION for both encrypting and decrypting) |
Example
int wc_AesSivDecrypt | ( | const byte * | key, |
word32 | keySz, | ||
const byte * | assoc, | ||
word32 | assocSz, | ||
const byte * | nonce, | ||
word32 | nonceSz, | ||
const byte * | in, | ||
word32 | inSz, | ||
byte * | siv, | ||
byte * | out | ||
) |
This function performs SIV (synthetic initialization vector) decryption as described in RFC 5297.
key | Byte buffer containing the key to use. |
keySz | Length of the key buffer in bytes. |
assoc | Additional, authenticated associated data (AD). |
assocSz | Length of AD buffer in bytes. |
nonce | A number used once. Used by the underlying algorithm in the same manner as the AD. |
nonceSz | Length of nonce buffer in bytes. |
in | Ciphertext buffer to decrypt. |
inSz | Length of ciphertext buffer. |
siv | The SIV that accompanies the ciphertext (see RFC 5297 2.4). |
out | Buffer to hold the decrypted plaintext. Should be the same length as the ciphertext buffer. |
Example
int wc_AesSivEncrypt | ( | const byte * | key, |
word32 | keySz, | ||
const byte * | assoc, | ||
word32 | assocSz, | ||
const byte * | nonce, | ||
word32 | nonceSz, | ||
const byte * | in, | ||
word32 | inSz, | ||
byte * | siv, | ||
byte * | out | ||
) |
This function performs SIV (synthetic initialization vector) encryption as described in RFC 5297.
key | Byte buffer containing the key to use. |
keySz | Length of the key buffer in bytes. |
assoc | Additional, authenticated associated data (AD). |
assocSz | Length of AD buffer in bytes. |
nonce | A number used once. Used by the algorithm in the same manner as the AD. |
nonceSz | Length of nonce buffer in bytes. |
in | Plaintext buffer to encrypt. |
inSz | Length of plaintext buffer. |
siv | The SIV output by S2V (see RFC 5297 2.4). |
out | Buffer to hold the ciphertext. Should be the same length as the plaintext buffer. |
Example
int wc_AesXtsDecrypt | ( | XtsAes * | aes, |
byte * | out, | ||
const byte * | in, | ||
word32 | sz, | ||
const byte * | i, | ||
word32 | iSz | ||
) |
Same process as encryption but Aes key is AES_DECRYPTION type.
aes | AES keys to use for block encrypt/decrypt |
out | output buffer to hold plain text |
in | input cipher text buffer to decrypt |
sz | size of both out and in buffers |
i | value to use for tweak |
iSz | size of i buffer, should always be AES_BLOCK_SIZE but having this input adds a sanity check on how the user calls the function. |
Example
int wc_AesXtsDecryptSector | ( | XtsAes * | aes, |
byte * | out, | ||
const byte * | in, | ||
word32 | sz, | ||
word64 | sector | ||
) |
Same process as wc_AesXtsDecrypt but uses a word64 type as the tweak value instead of a byte array. This just converts the word64 to a byte array.
aes | AES keys to use for block encrypt/decrypt |
out | output buffer to hold plain text |
in | input cipher text buffer to decrypt |
sz | size of both out and in buffers |
sector | value to use for tweak |
Example
int wc_AesXtsEncrypt | ( | XtsAes * | aes, |
byte * | out, | ||
const byte * | in, | ||
word32 | sz, | ||
const byte * | i, | ||
word32 | iSz | ||
) |
AES with XTS mode. (XTS) XEX encryption with Tweak and cipher text Stealing.
aes | AES keys to use for block encrypt/decrypt |
out | output buffer to hold cipher text |
in | input plain text buffer to encrypt |
sz | size of both out and in buffers |
i | value to use for tweak |
iSz | size of i buffer, should always be AES_BLOCK_SIZE but having this input adds a sanity check on how the user calls the function. |
Example
int wc_AesXtsEncryptSector | ( | XtsAes * | aes, |
byte * | out, | ||
const byte * | in, | ||
word32 | sz, | ||
word64 | sector | ||
) |
Same process as wc_AesXtsEncrypt but uses a word64 type as the tweak value instead of a byte array. This just converts the word64 to a byte array and calls wc_AesXtsEncrypt.
aes | AES keys to use for block encrypt/decrypt |
out | output buffer to hold cipher text |
in | input plain text buffer to encrypt |
sz | size of both out and in buffers |
sector | value to use for tweak |
Example
int wc_AesXtsFree | ( | XtsAes * | aes | ) |
This is to free up any resources used by the XtsAes structure.
aes | AES keys to free |
Example
int wc_AesXtsInit | ( | XtsAes * | aes, |
void * | heap, | ||
int | devId | ||
) |
This is to initialize an AES-XTS context. It is up to user to call wc_AesXtsFree on aes key when done.
aes | AES keys for encrypt/decrypt process |
heap | heap hint to use for memory. Can be NULL |
devId | ID to use with crypto callbacks or async hardware. Set to INVALID_DEVID (-2) if not used |
Example
int wc_AesXtsSetKey | ( | XtsAes * | aes, |
const byte * | key, | ||
word32 | len, | ||
int | dir, | ||
void * | heap, | ||
int | devId | ||
) |
This is to help with setting keys to correct encrypt or decrypt type. It is up to user to call wc_AesXtsFree on aes key when done.
aes | AES keys for encrypt/decrypt process |
key | buffer holding aes key | tweak key |
len | length of key buffer in bytes. Should be twice that of key size. i.e. 32 for a 16 byte key. |
dir | direction, either AES_ENCRYPTION or AES_DECRYPTION |
heap | heap hint to use for memory. Can be NULL |
devId | ID to use with crypto callbacks or async hardware. Set to INVALID_DEVID (-2) if not used |
Example
int wc_AesXtsSetKeyNoInit | ( | XtsAes * | aes, |
const byte * | key, | ||
word32 | len, | ||
int | dir | ||
) |
This is to help with setting keys to correct encrypt or decrypt type, after first calling wc_AesXtsInit(). It is up to user to call wc_AesXtsFree on aes key when done.
aes | AES keys for encrypt/decrypt process |
key | buffer holding aes key | tweak key |
len | length of key buffer in bytes. Should be twice that of key size. i.e. 32 for a 16 byte key. |
dir | direction, either AES_ENCRYPTION or AES_DECRYPTION |
Example
int wc_GmacSetKey | ( | Gmac * | gmac, |
const byte * | key, | ||
word32 | len | ||
) |
This function initializes and sets the key for a GMAC object to be used for Galois Message Authentication.
gmac | pointer to the gmac object used for authentication |
key | 16, 24, or 32 byte secret key for authentication |
len | length of the key |
Example
int wc_GmacUpdate | ( | Gmac * | gmac, |
const byte * | iv, | ||
word32 | ivSz, | ||
const byte * | authIn, | ||
word32 | authInSz, | ||
byte * | authTag, | ||
word32 | authTagSz | ||
) |
This function generates the Gmac hash of the authIn input and stores the result in the authTag buffer. After running wc_GmacUpdate, one should compare the generated authTag to a known authentication tag to verify the authenticity of a message.
gmac | pointer to the gmac object used for authentication |
iv | initialization vector used for the hash |
ivSz | size of the initialization vector used |
authIn | pointer to the buffer containing the authentication vector to verify |
authInSz | size of the authentication vector |
authTag | pointer to the output buffer in which to store the Gmac hash |
authTagSz | the size of the output buffer used to store the Gmac hash |
Example