Loading crypto/evp/evp_enc.c +10 −2 Original line number Diff line number Diff line Loading @@ -241,7 +241,11 @@ int EVP_CipherInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, return 0; } return ctx->cipher->einit(ctx->provctx, key, iv); return ctx->cipher->einit(ctx->provctx, key, EVP_CIPHER_CTX_key_length(ctx), iv, EVP_CIPHER_CTX_iv_length(ctx)); } if (ctx->cipher->dinit == NULL) { Loading @@ -249,7 +253,11 @@ int EVP_CipherInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, return 0; } return ctx->cipher->dinit(ctx->provctx, key, iv); return ctx->cipher->dinit(ctx->provctx, key, EVP_CIPHER_CTX_key_length(ctx), iv, EVP_CIPHER_CTX_iv_length(ctx)); /* TODO(3.0): Remove legacy code below */ legacy: Loading include/openssl/core_numbers.h +6 −2 Original line number Diff line number Diff line Loading @@ -126,10 +126,14 @@ OSSL_CORE_MAKE_FUNC(size_t, OP_digest_block_size, (void)) OSSL_CORE_MAKE_FUNC(void *, OP_cipher_newctx, (void)) OSSL_CORE_MAKE_FUNC(int, OP_cipher_encrypt_init, (void *vctx, const unsigned char *key, const unsigned char *iv)) size_t keylen, const unsigned char *iv, size_t ivlen)) OSSL_CORE_MAKE_FUNC(int, OP_cipher_decrypt_init, (void *vctx, const unsigned char *key, const unsigned char *iv)) size_t keylen, const unsigned char *iv, size_t ivlen)) OSSL_CORE_MAKE_FUNC(int, OP_cipher_update, (void *, unsigned char *out, size_t *outl, const unsigned char *in, size_t inl)) Loading providers/common/ciphers/aes.c +24 −10 Original line number Diff line number Diff line Loading @@ -17,35 +17,49 @@ #include "internal/provider_algs.h" #include "ciphers_locl.h" static void PROV_AES_KEY_generic_init(PROV_AES_KEY *ctx, static int PROV_AES_KEY_generic_init(PROV_AES_KEY *ctx, const unsigned char *iv, size_t ivlen, int enc) { if (iv != NULL) if (iv != NULL && ctx->mode != EVP_CIPH_ECB_MODE) { if (ivlen != AES_BLOCK_SIZE) return 0; memcpy(ctx->iv, iv, AES_BLOCK_SIZE); } ctx->enc = enc; return 1; } static int aes_einit(void *vctx, const unsigned char *key, const unsigned char *iv) static int aes_einit(void *vctx, const unsigned char *key, size_t keylen, const unsigned char *iv, size_t ivlen) { PROV_AES_KEY *ctx = (PROV_AES_KEY *)vctx; PROV_AES_KEY_generic_init(ctx, iv, 1); if (key != NULL) if (!PROV_AES_KEY_generic_init(ctx, iv, ivlen, 1)) return 0; if (key != NULL) { if (keylen != ctx->keylen) return 0; return ctx->ciph->init(ctx, key, ctx->keylen); } return 1; } static int aes_dinit(void *vctx, const unsigned char *key, const unsigned char *iv) static int aes_dinit(void *vctx, const unsigned char *key, size_t keylen, const unsigned char *iv, size_t ivlen) { PROV_AES_KEY *ctx = (PROV_AES_KEY *)vctx; PROV_AES_KEY_generic_init(ctx, iv, 0); if (key != NULL) if (!PROV_AES_KEY_generic_init(ctx, iv, ivlen, 0)) return 0; if (key != NULL) { if (keylen != ctx->keylen) return 0; return ctx->ciph->init(ctx, key, ctx->keylen); } return 1; } Loading Loading
crypto/evp/evp_enc.c +10 −2 Original line number Diff line number Diff line Loading @@ -241,7 +241,11 @@ int EVP_CipherInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, return 0; } return ctx->cipher->einit(ctx->provctx, key, iv); return ctx->cipher->einit(ctx->provctx, key, EVP_CIPHER_CTX_key_length(ctx), iv, EVP_CIPHER_CTX_iv_length(ctx)); } if (ctx->cipher->dinit == NULL) { Loading @@ -249,7 +253,11 @@ int EVP_CipherInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, return 0; } return ctx->cipher->dinit(ctx->provctx, key, iv); return ctx->cipher->dinit(ctx->provctx, key, EVP_CIPHER_CTX_key_length(ctx), iv, EVP_CIPHER_CTX_iv_length(ctx)); /* TODO(3.0): Remove legacy code below */ legacy: Loading
include/openssl/core_numbers.h +6 −2 Original line number Diff line number Diff line Loading @@ -126,10 +126,14 @@ OSSL_CORE_MAKE_FUNC(size_t, OP_digest_block_size, (void)) OSSL_CORE_MAKE_FUNC(void *, OP_cipher_newctx, (void)) OSSL_CORE_MAKE_FUNC(int, OP_cipher_encrypt_init, (void *vctx, const unsigned char *key, const unsigned char *iv)) size_t keylen, const unsigned char *iv, size_t ivlen)) OSSL_CORE_MAKE_FUNC(int, OP_cipher_decrypt_init, (void *vctx, const unsigned char *key, const unsigned char *iv)) size_t keylen, const unsigned char *iv, size_t ivlen)) OSSL_CORE_MAKE_FUNC(int, OP_cipher_update, (void *, unsigned char *out, size_t *outl, const unsigned char *in, size_t inl)) Loading
providers/common/ciphers/aes.c +24 −10 Original line number Diff line number Diff line Loading @@ -17,35 +17,49 @@ #include "internal/provider_algs.h" #include "ciphers_locl.h" static void PROV_AES_KEY_generic_init(PROV_AES_KEY *ctx, static int PROV_AES_KEY_generic_init(PROV_AES_KEY *ctx, const unsigned char *iv, size_t ivlen, int enc) { if (iv != NULL) if (iv != NULL && ctx->mode != EVP_CIPH_ECB_MODE) { if (ivlen != AES_BLOCK_SIZE) return 0; memcpy(ctx->iv, iv, AES_BLOCK_SIZE); } ctx->enc = enc; return 1; } static int aes_einit(void *vctx, const unsigned char *key, const unsigned char *iv) static int aes_einit(void *vctx, const unsigned char *key, size_t keylen, const unsigned char *iv, size_t ivlen) { PROV_AES_KEY *ctx = (PROV_AES_KEY *)vctx; PROV_AES_KEY_generic_init(ctx, iv, 1); if (key != NULL) if (!PROV_AES_KEY_generic_init(ctx, iv, ivlen, 1)) return 0; if (key != NULL) { if (keylen != ctx->keylen) return 0; return ctx->ciph->init(ctx, key, ctx->keylen); } return 1; } static int aes_dinit(void *vctx, const unsigned char *key, const unsigned char *iv) static int aes_dinit(void *vctx, const unsigned char *key, size_t keylen, const unsigned char *iv, size_t ivlen) { PROV_AES_KEY *ctx = (PROV_AES_KEY *)vctx; PROV_AES_KEY_generic_init(ctx, iv, 0); if (key != NULL) if (!PROV_AES_KEY_generic_init(ctx, iv, ivlen, 0)) return 0; if (key != NULL) { if (keylen != ctx->keylen) return 0; return ctx->ciph->init(ctx, key, ctx->keylen); } return 1; } Loading