X-Git-Url: https://git.openssl.org/?a=blobdiff_plain;f=engines%2Fafalg%2Fe_afalg.c;h=3ccf9d517c3134bd6985966c772a8ee23ba08ac3;hb=580731aff3fc9855ea93ea734bd924febea027c3;hp=30a5e388c46d6b88ca61f3272113af8000a6d64c;hpb=6cba4a66619dfb2c5cb784fe5aa5677cafbf9a33;p=openssl.git diff --git a/engines/afalg/e_afalg.c b/engines/afalg/e_afalg.c index 30a5e388c4..3ccf9d517c 100644 --- a/engines/afalg/e_afalg.c +++ b/engines/afalg/e_afalg.c @@ -60,6 +60,7 @@ #include #include +#include #include #define K_MAJ 4 @@ -129,7 +130,7 @@ static int afalg_chk_platform(void); static const char *engine_afalg_id = "afalg"; static const char *engine_afalg_name = "AFLAG engine support"; -int afalg_cipher_nids[] = { +static int afalg_cipher_nids[] = { NID_aes_128_cbc }; @@ -445,14 +446,11 @@ static int afalg_start_cipher_sk(afalg_ctx *actx, const unsigned char *in, # ifdef ALG_ZERO_COPY int ret; # endif + char cbuf[CMSG_SPACE(ALG_IV_LEN(ALG_AES_IV_LEN)) + CMSG_SPACE(ALG_OP_LEN)]; - const ssize_t cbuf_sz = CMSG_SPACE(ALG_IV_LEN(ALG_AES_IV_LEN)) - + CMSG_SPACE(ALG_OP_LEN); - char cbuf[cbuf_sz]; - - memset(cbuf, 0, cbuf_sz); + memset(cbuf, 0, sizeof(cbuf)); msg.msg_control = cbuf; - msg.msg_controllen = cbuf_sz; + msg.msg_controllen = sizeof(cbuf); /* * cipher direction (i.e. encrypt or decrypt) and iv are sent to the @@ -542,7 +540,7 @@ static int afalg_cipher_init(EVP_CIPHER_CTX *ctx, const unsigned char *key, return 0; } - actx = EVP_CIPHER_CTX_cipher_data(ctx); + actx = EVP_CIPHER_CTX_get_cipher_data(ctx); if (actx == NULL) { ALG_WARN("%s: Cipher data NULL\n", __func__); return 0; @@ -605,7 +603,7 @@ static int afalg_do_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, return 0; } - actx = (afalg_ctx *) EVP_CIPHER_CTX_cipher_data(ctx); + actx = (afalg_ctx *) EVP_CIPHER_CTX_get_cipher_data(ctx); if (actx == NULL || actx->init_done != MAGIC_INIT_NUM) { ALG_WARN("%s afalg ctx passed\n", ctx == NULL ? "NULL" : "Uninitialised"); @@ -652,7 +650,7 @@ static int afalg_cipher_cleanup(EVP_CIPHER_CTX *ctx) return 0; } - actx = (afalg_ctx *) EVP_CIPHER_CTX_cipher_data(ctx); + actx = (afalg_ctx *) EVP_CIPHER_CTX_get_cipher_data(ctx); if (actx == NULL || actx->init_done != MAGIC_INIT_NUM) { ALG_WARN("%s afalg ctx passed\n", ctx == NULL ? "NULL" : "Uninitialised"); @@ -847,6 +845,8 @@ static int afalg_finish(ENGINE *e) static int afalg_destroy(ENGINE *e) { ERR_unload_AFALG_strings(); + EVP_CIPHER_meth_free(_hidden_aes_128_cbc); + _hidden_aes_128_cbc = NULL; return 1; }