wolfSSL_EVP_CipherInit_ex handle ENGINE argument and add a sanity check

This commit is contained in:
Jacob Barthelmeh 2016-12-10 12:57:03 -07:00
parent 1326fe1b0d
commit 4f317a9a1d
3 changed files with 18 additions and 1 deletions

View File

@ -11677,6 +11677,11 @@ int wolfSSL_EVP_MD_type(const WOLFSSL_EVP_MD *md)
const WOLFSSL_EVP_MD* type)
{
WOLFSSL_ENTER("EVP_DigestInit");
if (ctx == NULL || type == NULL) {
return BAD_FUNC_ARG;
}
if (XSTRNCMP(type, "SHA256", 6) == 0) {
ctx->macType = SHA256;
wolfSSL_SHA256_Init((SHA256_CTX*)&ctx->hash);

View File

@ -86,6 +86,17 @@ WOLFSSL_API int wolfSSL_EVP_EncryptFinal(WOLFSSL_EVP_CIPHER_CTX *ctx,
return 0;
}
WOLFSSL_API int wolfSSL_EVP_CipherInit_ex(WOLFSSL_EVP_CIPHER_CTX* ctx,
const WOLFSSL_EVP_CIPHER* type,
WOLFSSL_ENGINE *impl,
unsigned char* key, unsigned char* iv,
int enc)
{
(void)impl;
return wolfSSL_EVP_CipherInit(ctx, type, key, iv, enc);
}
WOLFSSL_API int wolfSSL_EVP_EncryptFinal_ex(WOLFSSL_EVP_CIPHER_CTX *ctx,
unsigned char *out, int *outl)
{

View File

@ -174,6 +174,7 @@ typedef struct WOLFSSL_EVP_CIPHER_CTX {
} WOLFSSL_EVP_CIPHER_CTX;
typedef int WOLFSSL_ENGINE ;
typedef WOLFSSL_ENGINE ENGINE;
WOLFSSL_API void wolfSSL_EVP_init(void);
WOLFSSL_API int wolfSSL_EVP_MD_size(const WOLFSSL_EVP_MD* md);
@ -360,7 +361,7 @@ typedef WOLFSSL_EVP_CIPHER_CTX EVP_CIPHER_CTX;
#define EVP_CIPHER_CTX_key_length wolfSSL_EVP_CIPHER_CTX_key_length
#define EVP_CIPHER_CTX_set_key_length wolfSSL_EVP_CIPHER_CTX_set_key_length
#define EVP_CipherInit wolfSSL_EVP_CipherInit
#define EVP_CipherInit_ex wolfSSL_EVP_CipherInit
#define EVP_CipherInit_ex wolfSSL_EVP_CipherInit_ex
#define EVP_EncryptInit wolfSSL_EVP_EncryptInit
#define EVP_EncryptInit_ex wolfSSL_EVP_EncryptInit_ex
#define EVP_DecryptInit wolfSSL_EVP_DecryptInit