evp.h
Functions
Name | |
---|---|
const WOLFSSL_EVP_CIPHER * | wolfSSL_EVP_des_ede3_ecb(void ) Getter functions for the respective WOLFSSL_EVP_CIPHER pointers. wolfSSL_EVP_init() must be called once in the program first to populate these cipher strings. WOLFSSL_DES_ECB macro must be defined for wolfSSL_EVP_des_ede3_ecb(). |
const WOLFSSL_EVP_CIPHER * | wolfSSL_EVP_des_cbc(void ) Getter functions for the respective WOLFSSL_EVP_CIPHER pointers. wolfSSL_EVP_init() must be called once in the program first to populate these cipher strings. WOLFSSL_DES_ECB macro must be defined for wolfSSL_EVP_des_ecb(). |
int | wolfSSL_EVP_DigestInit_ex(WOLFSSL_EVP_MD_CTX * ctx, const WOLFSSL_EVP_MD * type, WOLFSSL_ENGINE * impl) Function for initializing WOLFSSL_EVP_MD_CTX. This function is a wrapper for wolfSSL_EVP_DigestInit() because wolfSSL does not use WOLFSSL_ENGINE. |
int | wolfSSL_EVP_CipherInit_ex(WOLFSSL_EVP_CIPHER_CTX * ctx, const WOLFSSL_EVP_CIPHER * type, WOLFSSL_ENGINE * impl, const unsigned char * key, const unsigned char * iv, int enc) Function for initializing WOLFSSL_EVP_CIPHER_CTX. This function is a wrapper for wolfSSL_CipherInit() because wolfSSL does not use WOLFSSL_ENGINE. |
int | wolfSSL_EVP_EncryptInit_ex(WOLFSSL_EVP_CIPHER_CTX * ctx, const WOLFSSL_EVP_CIPHER * type, WOLFSSL_ENGINE * impl, const unsigned char * key, const unsigned char * iv) Function for initializing WOLFSSL_EVP_CIPHER_CTX. This function is a wrapper for wolfSSL_EVP_CipherInit() because wolfSSL does not use WOLFSSL_ENGINE. Sets encrypt flag to be encrypt. |
int | wolfSSL_EVP_DecryptInit_ex(WOLFSSL_EVP_CIPHER_CTX * ctx, const WOLFSSL_EVP_CIPHER * type, WOLFSSL_ENGINE * impl, const unsigned char * key, const unsigned char * iv) Function for initializing WOLFSSL_EVP_CIPHER_CTX. This function is a wrapper for wolfSSL_EVP_CipherInit() because wolfSSL does not use WOLFSSL_ENGINE. Sets encrypt flag to be decrypt. |
int | wolfSSL_EVP_CipherUpdate(WOLFSSL_EVP_CIPHER_CTX * ctx, unsigned char * out, int * outl, const unsigned char * in, int inl) Function for encrypting/decrypting data. In buffer is added to be encrypted or decrypted and out buffer holds the results. outl will be the length of encrypted/decrypted information. |
int | wolfSSL_EVP_CipherFinal(WOLFSSL_EVP_CIPHER_CTX * ctx, unsigned char * out, int * outl) This function performs the final cipher operations adding in padding. If WOLFSSL_EVP_CIPH_NO_PADDING flag is set in WOLFSSL_EVP_CIPHER_CTX structure then 1 is returned and no encryption/decryption is done. If padding flag is seti padding is added and encrypted when ctx is set to encrypt, padding values are checked when set to decrypt. |
int | wolfSSL_EVP_CIPHER_CTX_set_key_length(WOLFSSL_EVP_CIPHER_CTX * ctx, int keylen) Setter function for WOLFSSL_EVP_CIPHER_CTX structure key length. |
int | wolfSSL_EVP_CIPHER_CTX_block_size(const WOLFSSL_EVP_CIPHER_CTX * ctx) This is a getter function for the ctx block size. |
int | wolfSSL_EVP_CIPHER_block_size(const WOLFSSL_EVP_CIPHER * cipher) This is a getter function for the block size of cipher. |
void | wolfSSL_EVP_CIPHER_CTX_set_flags(WOLFSSL_EVP_CIPHER_CTX * ctx, int flags) Setter function for WOLFSSL_EVP_CIPHER_CTX structure. |
void | wolfSSL_EVP_CIPHER_CTX_clear_flags(WOLFSSL_EVP_CIPHER_CTX * ctx, int flags) Clearing function for WOLFSSL_EVP_CIPHER_CTX structure. |
int | wolfSSL_EVP_CIPHER_CTX_set_padding(WOLFSSL_EVP_CIPHER_CTX * c, int pad) Setter function for WOLFSSL_EVP_CIPHER_CTX structure to use padding. |
unsigned long | wolfSSL_EVP_CIPHER_CTX_flags(const WOLFSSL_EVP_CIPHER_CTX * ctx) Getter function for WOLFSSL_EVP_CIPHER_CTX structure. Deprecated v1.1.0. |
Functions Documentation
function wolfSSL_EVP_des_ede3_ecb
const WOLFSSL_EVP_CIPHER * wolfSSL_EVP_des_ede3_ecb(
void
)
Getter functions for the respective WOLFSSL_EVP_CIPHER pointers. wolfSSL_EVP_init() must be called once in the program first to populate these cipher strings. WOLFSSL_DES_ECB macro must be defined for wolfSSL_EVP_des_ede3_ecb().
Parameters:
- none No parameters.
See: wolfSSL_EVP_CIPHER_CTX_init
Return: pointer Returns a WOLFSSL_EVP_CIPHER pointer for DES EDE3 operations.
Example
printf("block size des ede3 cbc = %d\n",
wolfSSL_EVP_CIPHER_block_size(wolfSSL_EVP_des_ede3_cbc()));
printf("block size des ede3 ecb = %d\n",
wolfSSL_EVP_CIPHER_block_size(wolfSSL_EVP_des_ede3_ecb()));
function wolfSSL_EVP_des_cbc
const WOLFSSL_EVP_CIPHER * wolfSSL_EVP_des_cbc(
void
)
Getter functions for the respective WOLFSSL_EVP_CIPHER pointers. wolfSSL_EVP_init() must be called once in the program first to populate these cipher strings. WOLFSSL_DES_ECB macro must be defined for wolfSSL_EVP_des_ecb().
Parameters:
- none No parameters.
See: wolfSSL_EVP_CIPHER_CTX_init
Return: pointer Returns a WOLFSSL_EVP_CIPHER pointer for DES operations.
Example
WOLFSSL_EVP_CIPHER* cipher;
cipher = wolfSSL_EVP_des_cbc();
…
function wolfSSL_EVP_DigestInit_ex
int wolfSSL_EVP_DigestInit_ex(
WOLFSSL_EVP_MD_CTX * ctx,
const WOLFSSL_EVP_MD * type,
WOLFSSL_ENGINE * impl
)
Function for initializing WOLFSSL_EVP_MD_CTX. This function is a wrapper for wolfSSL_EVP_DigestInit() because wolfSSL does not use WOLFSSL_ENGINE.
Parameters:
- ctx structure to initialize.
- type type of hash to do, for example SHA.
- impl engine to use. N/A for wolfSSL, can be NULL.
See:
- wolfSSL_EVP_MD_CTX_new
- wolfCrypt_Init
- wolfSSL_EVP_MD_CTX_free
Return:
- SSL_SUCCESS If successfully set.
- SSL_FAILURE If not successful.
Example
WOLFSSL_EVP_MD_CTX* md = NULL;
wolfCrypt_Init();
md = wolfSSL_EVP_MD_CTX_new();
if (md == NULL) {
printf("error setting md\n");
return -1;
}
printf("cipher md init ret = %d\n", wolfSSL_EVP_DigestInit_ex(md,
wolfSSL_EVP_sha1(), e));
//free resources
function wolfSSL_EVP_CipherInit_ex
int wolfSSL_EVP_CipherInit_ex(
WOLFSSL_EVP_CIPHER_CTX * ctx,
const WOLFSSL_EVP_CIPHER * type,
WOLFSSL_ENGINE * impl,
const unsigned char * key,
const unsigned char * iv,
int enc
)
Function for initializing WOLFSSL_EVP_CIPHER_CTX. This function is a wrapper for wolfSSL_CipherInit() because wolfSSL does not use WOLFSSL_ENGINE.
Parameters:
- ctx structure to initialize.
- type type of encryption/decryption to do, for example AES.
- impl engine to use. N/A for wolfSSL, can be NULL.
- key key to set .
- iv iv if needed by algorithm.
- enc encryption (1) or decryption (0) flag.
See:
- wolfSSL_EVP_CIPHER_CTX_new
- wolfCrypt_Init
- wolfSSL_EVP_CIPHER_CTX_free
Return:
- SSL_SUCCESS If successfully set.
- SSL_FAILURE If not successful.
Example
WOLFSSL_EVP_CIPHER_CTX* ctx = NULL;
WOLFSSL_ENGINE* e = NULL;
unsigned char key[16];
unsigned char iv[12];
wolfCrypt_Init();
ctx = wolfSSL_EVP_CIPHER_CTX_new();
if (ctx == NULL) {
printf("issue creating ctx\n");
return -1;
}
printf("cipher init ex error ret = %d\n", wolfSSL_EVP_CipherInit_ex(NULL,
EVP_aes_128_ cbc(), e, key, iv, 1));
printf("cipher init ex success ret = %d\n", wolfSSL_EVP_CipherInit_ex(ctx,
EVP_aes_128_c bc(), e, key, iv, 1));
// free resources
function wolfSSL_EVP_EncryptInit_ex
int wolfSSL_EVP_EncryptInit_ex(
WOLFSSL_EVP_CIPHER_CTX * ctx,
const WOLFSSL_EVP_CIPHER * type,
WOLFSSL_ENGINE * impl,
const unsigned char * key,
const unsigned char * iv
)
Function for initializing WOLFSSL_EVP_CIPHER_CTX. This function is a wrapper for wolfSSL_EVP_CipherInit() because wolfSSL does not use WOLFSSL_ENGINE. Sets encrypt flag to be encrypt.
Parameters:
- ctx structure to initialize.
- type type of encryption to do, for example AES.
- impl engine to use. N/A for wolfSSL, can be NULL.
- key key to use.
- iv iv to use.
See:
- wolfSSL_EVP_CIPHER_CTX_new
- wolfCrypt_Init
- wolfSSL_EVP_CIPHER_CTX_free
Return:
- SSL_SUCCESS If successfully set.
- SSL_FAILURE If not successful.
Example
WOLFSSL_EVP_CIPHER_CTX* ctx = NULL;
wolfCrypt_Init();
ctx = wolfSSL_EVP_CIPHER_CTX_new();
if (ctx == NULL) {
printf("error setting ctx\n");
return -1;
}
printf("cipher ctx init ret = %d\n", wolfSSL_EVP_EncryptInit_ex(ctx,
wolfSSL_EVP_aes_128_cbc(), e, key, iv));
//free resources
function wolfSSL_EVP_DecryptInit_ex
int wolfSSL_EVP_DecryptInit_ex(
WOLFSSL_EVP_CIPHER_CTX * ctx,
const WOLFSSL_EVP_CIPHER * type,
WOLFSSL_ENGINE * impl,
const unsigned char * key,
const unsigned char * iv
)
Function for initializing WOLFSSL_EVP_CIPHER_CTX. This function is a wrapper for wolfSSL_EVP_CipherInit() because wolfSSL does not use WOLFSSL_ENGINE. Sets encrypt flag to be decrypt.
Parameters:
- ctx structure to initialize.
- type type of encryption/decryption to do, for example AES.
- impl engine to use. N/A for wolfSSL, can be NULL.
- key key to set .
- iv iv if needed by algorithm.
- enc encryption (1) or decryption (0) flag.
See:
- wolfSSL_EVP_CIPHER_CTX_new
- wolfCrypt_Init
- wolfSSL_EVP_CIPHER_CTX_free
Return:
- SSL_SUCCESS If successfully set.
- SSL_FAILURE If not successful.
Example
WOLFSSL_EVP_CIPHER_CTX* ctx = NULL;
WOLFSSL_ENGINE* e = NULL;
unsigned char key[16];
unsigned char iv[12];
wolfCrypt_Init();
ctx = wolfSSL_EVP_CIPHER_CTX_new();
if (ctx == NULL) {
printf("issue creating ctx\n");
return -1;
}
printf("cipher init ex error ret = %d\n", wolfSSL_EVP_DecryptInit_ex(NULL,
EVP_aes_128_ cbc(), e, key, iv, 1));
printf("cipher init ex success ret = %d\n", wolfSSL_EVP_DecryptInit_ex(ctx,
EVP_aes_128_c bc(), e, key, iv, 1));
// free resources
function wolfSSL_EVP_CipherUpdate
int wolfSSL_EVP_CipherUpdate(
WOLFSSL_EVP_CIPHER_CTX * ctx,
unsigned char * out,
int * outl,
const unsigned char * in,
int inl
)
Function for encrypting/decrypting data. In buffer is added to be encrypted or decrypted and out buffer holds the results. outl will be the length of encrypted/decrypted information.
Parameters:
- ctx structure to get cipher type from.
- out buffer to hold output.
- outl adjusted to be size of output.
- in buffer to perform operation on.
- inl length of input buffer.
See:
- wolfSSL_EVP_CIPHER_CTX_new
- wolfCrypt_Init
- wolfSSL_EVP_CIPHER_CTX_free
Return:
- SSL_SUCCESS If successful.
- SSL_FAILURE If not successful.
Example
WOLFSSL_EVP_CIPHER_CTX* ctx = NULL;
unsigned char out[100];
int outl;
unsigned char in[100];
int inl = 100;
ctx = wolfSSL_EVP_CIPHER_CTX_new();
// set up ctx
ret = wolfSSL_EVP_CipherUpdate(ctx, out, outl, in, inl);
// check ret value
// buffer out holds outl bytes of data
// free resources
function wolfSSL_EVP_CipherFinal
int wolfSSL_EVP_CipherFinal(
WOLFSSL_EVP_CIPHER_CTX * ctx,
unsigned char * out,
int * outl
)
This function performs the final cipher operations adding in padding. If WOLFSSL_EVP_CIPH_NO_PADDING flag is set in WOLFSSL_EVP_CIPHER_CTX structure then 1 is returned and no encryption/decryption is done. If padding flag is seti padding is added and encrypted when ctx is set to encrypt, padding values are checked when set to decrypt.
Parameters:
- ctx structure to decrypt/encrypt with.
- out buffer for final decrypt/encrypt.
- out1 size of out buffer when data has been added by function.
See: wolfSSL_EVP_CIPHER_CTX_new
Return:
- 1 Returned on success.
- 0 If encountering a failure.
Example
WOLFSSL_EVP_CIPHER_CTX* ctx;
int out1;
unsigned char out[64];
// create ctx
wolfSSL_EVP_CipherFinal(ctx, out, &out1);
function wolfSSL_EVP_CIPHER_CTX_set_key_length
int wolfSSL_EVP_CIPHER_CTX_set_key_length(
WOLFSSL_EVP_CIPHER_CTX * ctx,
int keylen
)
Setter function for WOLFSSL_EVP_CIPHER_CTX structure key length.
Parameters:
- ctx structure to set key length.
- keylen key length.
See: wolfSSL_EVP_CIPHER_flags
Return:
- SSL_SUCCESS If successfully set.
- SSL_FAILURE If failed to set key length.
Example
WOLFSSL_EVP_CIPHER_CTX* ctx;
int keylen;
// create ctx
wolfSSL_EVP_CIPHER_CTX_set_key_length(ctx, keylen);
function wolfSSL_EVP_CIPHER_CTX_block_size
int wolfSSL_EVP_CIPHER_CTX_block_size(
const WOLFSSL_EVP_CIPHER_CTX * ctx
)
This is a getter function for the ctx block size.
Parameters:
- ctx the cipher ctx to get block size of.
See: wolfSSL_EVP_CIPHER_block_size
Return: size Returns ctx->block_size.
Example
const WOLFSSL_CVP_CIPHER_CTX* ctx;
//set up ctx
printf(“block size = %d\n”, wolfSSL_EVP_CIPHER_CTX_block_size(ctx));
function wolfSSL_EVP_CIPHER_block_size
int wolfSSL_EVP_CIPHER_block_size(
const WOLFSSL_EVP_CIPHER * cipher
)
This is a getter function for the block size of cipher.
Parameters:
- cipher cipher to get block size of.
See: wolfSSL_EVP_aes_256_ctr
Return: size returns the block size.
Example
printf(“block size = %d\n”,
wolfSSL_EVP_CIPHER_block_size(wolfSSL_EVP_aes_256_ecb()));
function wolfSSL_EVP_CIPHER_CTX_set_flags
void wolfSSL_EVP_CIPHER_CTX_set_flags(
WOLFSSL_EVP_CIPHER_CTX * ctx,
int flags
)
Setter function for WOLFSSL_EVP_CIPHER_CTX structure.
Parameters:
- ctx structure to set flag.
- flag flag to set in structure.
See:
- wolfSSL_EVP_CIPHER_flags
- wolfSSL_EVP_CIPHER_CTX_flags
Return: none No returns.
Example
WOLFSSL_EVP_CIPHER_CTX* ctx;
int flag;
// create ctx
wolfSSL_EVP_CIPHER_CTX_set_flags(ctx, flag);
function wolfSSL_EVP_CIPHER_CTX_clear_flags
void wolfSSL_EVP_CIPHER_CTX_clear_flags(
WOLFSSL_EVP_CIPHER_CTX * ctx,
int flags
)
Clearing function for WOLFSSL_EVP_CIPHER_CTX structure.
Parameters:
- ctx structure to clear flag.
- flag flag value to clear in structure.
See:
- wolfSSL_EVP_CIPHER_flags
- wolfSSL_EVP_CIPHER_CTX_flags
Return: none No returns.
Example
WOLFSSL_EVP_CIPHER_CTX* ctx;
int flag;
// create ctx
wolfSSL_EVP_CIPHER_CTX_clear_flags(ctx, flag);
function wolfSSL_EVP_CIPHER_CTX_set_padding
int wolfSSL_EVP_CIPHER_CTX_set_padding(
WOLFSSL_EVP_CIPHER_CTX * c,
int pad
)
Setter function for WOLFSSL_EVP_CIPHER_CTX structure to use padding.
Parameters:
- ctx structure to set padding flag.
- padding 0 for not setting padding, 1 for setting padding.
See: wolfSSL_EVP_CIPHER_CTX_new
Return:
- SSL_SUCCESS If successfully set.
- BAD_FUNC_ARG If null argument passed in.
Example
WOLFSSL_EVP_CIPHER_CTX* ctx;
// create ctx
wolfSSL_EVP_CIPHER_CTX_set_padding(ctx, 1);
function wolfSSL_EVP_CIPHER_CTX_flags
unsigned long wolfSSL_EVP_CIPHER_CTX_flags(
const WOLFSSL_EVP_CIPHER_CTX * ctx
)
Getter function for WOLFSSL_EVP_CIPHER_CTX structure. Deprecated v1.1.0.
Parameters:
- ctx structure to get flag.
See:
- wolfSSL_EVP_CIPHER_CTX_new
- wolfSSL_EVP_CIPHER_flags
Return: unsigned long of flags/mode.
Example
WOLFSSL_EVP_CIPHER_CTX* ctx;
unsigned long flags;
ctx = wolfSSL_EVP_CIPHER_CTX_new()
flags = wolfSSL_EVP_CIPHER_CTX_flags(ctx);
Source code
const WOLFSSL_EVP_CIPHER* wolfSSL_EVP_des_ede3_ecb(void);
const WOLFSSL_EVP_CIPHER* wolfSSL_EVP_des_cbc(void);
int wolfSSL_EVP_DigestInit_ex(WOLFSSL_EVP_MD_CTX* ctx,
const WOLFSSL_EVP_MD* type,
WOLFSSL_ENGINE *impl);
int wolfSSL_EVP_CipherInit_ex(WOLFSSL_EVP_CIPHER_CTX* ctx,
const WOLFSSL_EVP_CIPHER* type,
WOLFSSL_ENGINE *impl,
const unsigned char* key,
const unsigned char* iv,
int enc);
int wolfSSL_EVP_EncryptInit_ex(WOLFSSL_EVP_CIPHER_CTX* ctx,
const WOLFSSL_EVP_CIPHER* type,
WOLFSSL_ENGINE *impl,
const unsigned char* key,
const unsigned char* iv);
int wolfSSL_EVP_DecryptInit_ex(WOLFSSL_EVP_CIPHER_CTX* ctx,
const WOLFSSL_EVP_CIPHER* type,
WOLFSSL_ENGINE *impl,
const unsigned char* key,
const unsigned char* iv);
int wolfSSL_EVP_CipherUpdate(WOLFSSL_EVP_CIPHER_CTX *ctx,
unsigned char *out, int *outl,
const unsigned char *in, int inl);
int wolfSSL_EVP_CipherFinal(WOLFSSL_EVP_CIPHER_CTX *ctx,
unsigned char *out, int *outl);
int wolfSSL_EVP_CIPHER_CTX_set_key_length(WOLFSSL_EVP_CIPHER_CTX* ctx,
int keylen);
int wolfSSL_EVP_CIPHER_CTX_block_size(const WOLFSSL_EVP_CIPHER_CTX *ctx);
int wolfSSL_EVP_CIPHER_block_size(const WOLFSSL_EVP_CIPHER *cipher);
void wolfSSL_EVP_CIPHER_CTX_set_flags(WOLFSSL_EVP_CIPHER_CTX *ctx, int flags);
void wolfSSL_EVP_CIPHER_CTX_clear_flags(WOLFSSL_EVP_CIPHER_CTX *ctx, int flags);
int wolfSSL_EVP_CIPHER_CTX_set_padding(WOLFSSL_EVP_CIPHER_CTX *c, int pad);
unsigned long wolfSSL_EVP_CIPHER_CTX_flags(const WOLFSSL_EVP_CIPHER_CTX *ctx);
Updated on 2024-11-22 at 01:12:39 +0000