diff options
Diffstat (limited to 'crypto/evp/evp_enc.c')
| -rw-r--r-- | crypto/evp/evp_enc.c | 255 |
1 files changed, 123 insertions, 132 deletions
diff --git a/crypto/evp/evp_enc.c b/crypto/evp/evp_enc.c index 4e6f83e3d0a9..2bb53561e48c 100644 --- a/crypto/evp/evp_enc.c +++ b/crypto/evp/evp_enc.c @@ -1,5 +1,5 @@ /* - * Copyright 1995-2023 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 1995-2026 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the Apache License 2.0 (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy @@ -17,7 +17,7 @@ #include <openssl/err.h> #include <openssl/rand.h> #ifndef FIPS_MODULE -# include <openssl/engine.h> +#include <openssl/engine.h> #endif #include <openssl/params.h> #include <openssl/core_names.h> @@ -48,7 +48,7 @@ int EVP_CIPHER_CTX_reset(EVP_CIPHER_CTX *ctx) return 1; /* Remove legacy code below when legacy support is removed. */ - legacy: +legacy: if (ctx->cipher != NULL) { if (ctx->cipher->cleanup && !ctx->cipher->cleanup(ctx)) @@ -80,10 +80,10 @@ void EVP_CIPHER_CTX_free(EVP_CIPHER_CTX *ctx) } static int evp_cipher_init_internal(EVP_CIPHER_CTX *ctx, - const EVP_CIPHER *cipher, - ENGINE *impl, const unsigned char *key, - const unsigned char *iv, int enc, - const OSSL_PARAM params[]) + const EVP_CIPHER *cipher, + ENGINE *impl, const unsigned char *key, + const unsigned char *iv, int enc, + const OSSL_PARAM params[]) { int n; #if !defined(OPENSSL_NO_ENGINE) && !defined(FIPS_MODULE) @@ -124,7 +124,7 @@ static int evp_cipher_init_internal(EVP_CIPHER_CTX *ctx, goto skip_to_init; if (cipher != NULL && impl == NULL) { - /* Ask if an ENGINE is reserved for this job */ + /* Ask if an ENGINE is reserved for this job */ tmpimpl = ENGINE_get_cipher_engine(cipher->nid); } #endif @@ -134,12 +134,12 @@ static int evp_cipher_init_internal(EVP_CIPHER_CTX *ctx, */ if (ctx->engine != NULL #if !defined(OPENSSL_NO_ENGINE) && !defined(FIPS_MODULE) - || tmpimpl != NULL + || tmpimpl != NULL #endif - || impl != NULL - || (cipher != NULL && cipher->origin == EVP_ORIG_METH) - || (cipher == NULL && ctx->cipher != NULL - && ctx->cipher->origin == EVP_ORIG_METH)) { + || impl != NULL + || (cipher != NULL && cipher->origin == EVP_ORIG_METH) + || (cipher == NULL && ctx->cipher != NULL + && ctx->cipher->origin == EVP_ORIG_METH)) { if (ctx->cipher == ctx->fetched_cipher) ctx->cipher = NULL; EVP_CIPHER_free(ctx->fetched_cipher); @@ -178,11 +178,10 @@ static int evp_cipher_init_internal(EVP_CIPHER_CTX *ctx, ERR_raise(ERR_LIB_EVP, EVP_R_INITIALIZATION_ERROR); return 0; #else - EVP_CIPHER *provciph = - EVP_CIPHER_fetch(NULL, - cipher->nid == NID_undef ? "NULL" - : OBJ_nid2sn(cipher->nid), - ""); + EVP_CIPHER *provciph = EVP_CIPHER_fetch(NULL, + cipher->nid == NID_undef ? "NULL" + : OBJ_nid2sn(cipher->nid), + ""); if (provciph == NULL) return 0; @@ -234,16 +233,16 @@ static int evp_cipher_init_internal(EVP_CIPHER_CTX *ctx, */ if (params != NULL) { OSSL_PARAM param_lens[3] = { OSSL_PARAM_END, OSSL_PARAM_END, - OSSL_PARAM_END }; + OSSL_PARAM_END }; OSSL_PARAM *q = param_lens; const OSSL_PARAM *p; - p = OSSL_PARAM_locate_const(params, OSSL_CIPHER_PARAM_KEYLEN); + p = OSSL_PARAM_locate_const(params, OSSL_CIPHER_PARAM_KEYLEN); if (p != NULL) memcpy(q++, p, sizeof(*q)); /* - * Note that OSSL_CIPHER_PARAM_AEAD_IVLEN is a synomym for + * Note that OSSL_CIPHER_PARAM_AEAD_IVLEN is a synonym for * OSSL_CIPHER_PARAM_IVLEN so both are covered here. */ p = OSSL_PARAM_locate_const(params, OSSL_CIPHER_PARAM_IVLEN); @@ -266,13 +265,13 @@ static int evp_cipher_init_internal(EVP_CIPHER_CTX *ctx, } return ctx->cipher->einit(ctx->algctx, - key, - key == NULL ? 0 - : EVP_CIPHER_CTX_get_key_length(ctx), - iv, - iv == NULL ? 0 - : EVP_CIPHER_CTX_get_iv_length(ctx), - params); + key, + key == NULL ? 0 + : EVP_CIPHER_CTX_get_key_length(ctx), + iv, + iv == NULL ? 0 + : EVP_CIPHER_CTX_get_iv_length(ctx), + params); } if (ctx->cipher->dinit == NULL) { @@ -281,16 +280,16 @@ static int evp_cipher_init_internal(EVP_CIPHER_CTX *ctx, } return ctx->cipher->dinit(ctx->algctx, - key, - key == NULL ? 0 - : EVP_CIPHER_CTX_get_key_length(ctx), - iv, - iv == NULL ? 0 - : EVP_CIPHER_CTX_get_iv_length(ctx), - params); + key, + key == NULL ? 0 + : EVP_CIPHER_CTX_get_key_length(ctx), + iv, + iv == NULL ? 0 + : EVP_CIPHER_CTX_get_iv_length(ctx), + params); /* Code below to be removed when legacy support is dropped. */ - legacy: +legacy: if (cipher != NULL) { /* @@ -362,15 +361,15 @@ static int evp_cipher_init_internal(EVP_CIPHER_CTX *ctx, } } #if !defined(OPENSSL_NO_ENGINE) && !defined(FIPS_MODULE) - skip_to_init: +skip_to_init: #endif if (ctx->cipher == NULL) return 0; /* we assume block size is a power of 2 in *cryptUpdate */ OPENSSL_assert(ctx->cipher->block_size == 1 - || ctx->cipher->block_size == 8 - || ctx->cipher->block_size == 16); + || ctx->cipher->block_size == 8 + || ctx->cipher->block_size == 16); if (!(ctx->flags & EVP_CIPHER_CTX_FLAG_WRAP_ALLOW) && EVP_CIPHER_CTX_get_mode(ctx) == EVP_CIPH_WRAP_MODE) { @@ -379,7 +378,8 @@ static int evp_cipher_init_internal(EVP_CIPHER_CTX *ctx, } if ((EVP_CIPHER_get_flags(EVP_CIPHER_CTX_get0_cipher(ctx)) - & EVP_CIPH_CUSTOM_IV) == 0) { + & EVP_CIPH_CUSTOM_IV) + == 0) { switch (EVP_CIPHER_CTX_get_mode(ctx)) { case EVP_CIPH_STREAM_CIPHER: @@ -432,14 +432,14 @@ static int evp_cipher_init_internal(EVP_CIPHER_CTX *ctx, } int EVP_CipherInit_ex2(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, - const unsigned char *key, const unsigned char *iv, - int enc, const OSSL_PARAM params[]) + const unsigned char *key, const unsigned char *iv, + int enc, const OSSL_PARAM params[]) { return evp_cipher_init_internal(ctx, cipher, NULL, key, iv, enc, params); } int EVP_CipherInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, - const unsigned char *key, const unsigned char *iv, int enc) + const unsigned char *key, const unsigned char *iv, int enc) { if (cipher != NULL) EVP_CIPHER_CTX_reset(ctx); @@ -447,14 +447,14 @@ int EVP_CipherInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, } int EVP_CipherInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, - ENGINE *impl, const unsigned char *key, - const unsigned char *iv, int enc) + ENGINE *impl, const unsigned char *key, + const unsigned char *iv, int enc) { return evp_cipher_init_internal(ctx, cipher, impl, key, iv, enc, NULL); } int EVP_CipherUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl, - const unsigned char *in, int inl) + const unsigned char *in, int inl) { if (ctx->encrypt) return EVP_EncryptUpdate(ctx, out, outl, in, inl); @@ -479,41 +479,41 @@ int EVP_CipherFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl) } int EVP_EncryptInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, - const unsigned char *key, const unsigned char *iv) + const unsigned char *key, const unsigned char *iv) { return EVP_CipherInit(ctx, cipher, key, iv, 1); } int EVP_EncryptInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, - ENGINE *impl, const unsigned char *key, - const unsigned char *iv) + ENGINE *impl, const unsigned char *key, + const unsigned char *iv) { return EVP_CipherInit_ex(ctx, cipher, impl, key, iv, 1); } int EVP_EncryptInit_ex2(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, - const unsigned char *key, const unsigned char *iv, - const OSSL_PARAM params[]) + const unsigned char *key, const unsigned char *iv, + const OSSL_PARAM params[]) { return EVP_CipherInit_ex2(ctx, cipher, key, iv, 1, params); } int EVP_DecryptInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, - const unsigned char *key, const unsigned char *iv) + const unsigned char *key, const unsigned char *iv) { return EVP_CipherInit(ctx, cipher, key, iv, 0); } int EVP_DecryptInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, - ENGINE *impl, const unsigned char *key, - const unsigned char *iv) + ENGINE *impl, const unsigned char *key, + const unsigned char *iv) { return EVP_CipherInit_ex(ctx, cipher, impl, key, iv, 0); } int EVP_DecryptInit_ex2(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, - const unsigned char *key, const unsigned char *iv, - const OSSL_PARAM params[]) + const unsigned char *key, const unsigned char *iv, + const OSSL_PARAM params[]) { return EVP_CipherInit_ex2(ctx, cipher, key, iv, 0, params); } @@ -525,9 +525,9 @@ int EVP_DecryptInit_ex2(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, * are not partially overlapping with standard pointer arithmetic. */ #ifdef PTRDIFF_T -# undef PTRDIFF_T +#undef PTRDIFF_T #endif -#if defined(OPENSSL_SYS_VMS) && __INITIAL_POINTER_SIZE==64 +#if defined(OPENSSL_SYS_VMS) && __INITIAL_POINTER_SIZE == 64 /* * Then we have VMS that distinguishes itself by adhering to * sizeof(size_t)==4 even in 64-bit builds, which means that @@ -536,28 +536,27 @@ int EVP_DecryptInit_ex2(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, * equality is implemented. To be on the safe side we adhere to * PTRDIFF_T even for comparison for equality. */ -# define PTRDIFF_T uint64_t +#define PTRDIFF_T uint64_t #else -# define PTRDIFF_T size_t +#define PTRDIFF_T size_t #endif int ossl_is_partially_overlapping(const void *ptr1, const void *ptr2, int len) { - PTRDIFF_T diff = (PTRDIFF_T)ptr1-(PTRDIFF_T)ptr2; + PTRDIFF_T diff = (PTRDIFF_T)ptr1 - (PTRDIFF_T)ptr2; /* * Check for partially overlapping buffers. [Binary logical * operations are used instead of boolean to minimize number * of conditional branches.] */ - int overlapped = (len > 0) & (diff != 0) & ((diff < (PTRDIFF_T)len) | - (diff > (0 - (PTRDIFF_T)len))); + int overlapped = (len > 0) & (diff != 0) & ((diff < (PTRDIFF_T)len) | (diff > (0 - (PTRDIFF_T)len))); return overlapped; } static int evp_EncryptDecryptUpdate(EVP_CIPHER_CTX *ctx, - unsigned char *out, int *outl, - const unsigned char *in, int inl) + unsigned char *out, int *outl, + const unsigned char *in, int inl) { int i, j, bl, cmpl = inl; @@ -645,9 +644,8 @@ static int evp_EncryptDecryptUpdate(EVP_CIPHER_CTX *ctx, return 1; } - int EVP_EncryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl, - const unsigned char *in, int inl) + const unsigned char *in, int inl) { int ret; size_t soutl, inl_ = (size_t)inl; @@ -676,14 +674,14 @@ int EVP_EncryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl, blocksize = ctx->cipher->block_size; - if (ctx->cipher->cupdate == NULL || blocksize < 1) { + if (ctx->cipher->cupdate == NULL || blocksize < 1) { ERR_raise(ERR_LIB_EVP, EVP_R_UPDATE_ERROR); return 0; } ret = ctx->cipher->cupdate(ctx->algctx, out, &soutl, - inl_ + (size_t)(blocksize == 1 ? 0 : blocksize), - in, inl_); + inl_ + (size_t)(blocksize == 1 ? 0 : blocksize), + in, inl_); if (ret) { if (soutl > INT_MAX) { @@ -696,7 +694,7 @@ int EVP_EncryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl, return ret; /* Code below to be removed when legacy support is dropped. */ - legacy: +legacy: return evp_EncryptDecryptUpdate(ctx, out, outl, in, inl); } @@ -743,7 +741,7 @@ int EVP_EncryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl) } ret = ctx->cipher->cfinal(ctx->algctx, out, &soutl, - blocksize == 1 ? 0 : blocksize); + blocksize == 1 ? 0 : blocksize); if (ret) { if (soutl > INT_MAX) { @@ -756,7 +754,7 @@ int EVP_EncryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl) return ret; /* Code below to be removed when legacy support is dropped. */ - legacy: +legacy: if (ctx->cipher->flags & EVP_CIPH_FLAG_CUSTOM_CIPHER) { ret = ctx->cipher->do_cipher(ctx, out, NULL, 0); @@ -795,7 +793,7 @@ int EVP_EncryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl) } int EVP_DecryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl, - const unsigned char *in, int inl) + const unsigned char *in, int inl) { int fix_len, cmpl = inl, ret; unsigned int b; @@ -829,8 +827,8 @@ int EVP_DecryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl, return 0; } ret = ctx->cipher->cupdate(ctx->algctx, out, &soutl, - inl_ + (size_t)(blocksize == 1 ? 0 : blocksize), - in, inl_); + inl_ + (size_t)(blocksize == 1 ? 0 : blocksize), + in, inl_); if (ret) { if (soutl > INT_MAX) { @@ -843,7 +841,7 @@ int EVP_DecryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl, return ret; /* Code below to be removed when legacy support is dropped. */ - legacy: +legacy: b = ctx->cipher->block_size; @@ -965,7 +963,7 @@ int EVP_DecryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl) } ret = ctx->cipher->cfinal(ctx->algctx, out, &soutl, - blocksize == 1 ? 0 : blocksize); + blocksize == 1 ? 0 : blocksize); if (ret) { if (soutl > INT_MAX) { @@ -978,7 +976,7 @@ int EVP_DecryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl) return ret; /* Code below to be removed when legacy support is dropped. */ - legacy: +legacy: *outl = 0; if (ctx->cipher->flags & EVP_CIPH_FLAG_CUSTOM_CIPHER) { @@ -1042,7 +1040,8 @@ int EVP_CIPHER_CTX_set_key_length(EVP_CIPHER_CTX *c, int keylen) /* Check the cipher actually understands this parameter */ if (OSSL_PARAM_locate_const(EVP_CIPHER_settable_ctx_params(c->cipher), - OSSL_CIPHER_PARAM_KEYLEN) == NULL) { + OSSL_CIPHER_PARAM_KEYLEN) + == NULL) { ERR_raise(ERR_LIB_EVP, EVP_R_INVALID_KEY_LENGTH); return 0; } @@ -1112,11 +1111,10 @@ int EVP_CIPHER_CTX_ctrl(EVP_CIPHER_CTX *ctx, int type, int arg, void *ptr) case EVP_CTRL_SET_KEY_LENGTH: params[0] = OSSL_PARAM_construct_size_t(OSSL_CIPHER_PARAM_KEYLEN, &sz); break; - case EVP_CTRL_RAND_KEY: /* Used by DES */ + case EVP_CTRL_RAND_KEY: /* Used by DES */ set_params = 0; - params[0] = - OSSL_PARAM_construct_octet_string(OSSL_CIPHER_PARAM_RANDOM_KEY, - ptr, sz); + params[0] = OSSL_PARAM_construct_octet_string(OSSL_CIPHER_PARAM_RANDOM_KEY, + ptr, sz); break; case EVP_CTRL_INIT: @@ -1146,20 +1144,20 @@ int EVP_CIPHER_CTX_ctrl(EVP_CIPHER_CTX *ctx, int type, int arg, void *ptr) break; case EVP_CTRL_AEAD_SET_IV_FIXED: params[0] = OSSL_PARAM_construct_octet_string( - OSSL_CIPHER_PARAM_AEAD_TLS1_IV_FIXED, ptr, sz); + OSSL_CIPHER_PARAM_AEAD_TLS1_IV_FIXED, ptr, sz); break; case EVP_CTRL_GCM_IV_GEN: set_params = 0; if (arg < 0) sz = 0; /* special case that uses the iv length */ params[0] = OSSL_PARAM_construct_octet_string( - OSSL_CIPHER_PARAM_AEAD_TLS1_GET_IV_GEN, ptr, sz); + OSSL_CIPHER_PARAM_AEAD_TLS1_GET_IV_GEN, ptr, sz); break; case EVP_CTRL_GCM_SET_IV_INV: if (arg < 0) return 0; params[0] = OSSL_PARAM_construct_octet_string( - OSSL_CIPHER_PARAM_AEAD_TLS1_SET_IV_INV, ptr, sz); + OSSL_CIPHER_PARAM_AEAD_TLS1_SET_IV_INV, ptr, sz); break; case EVP_CTRL_GET_RC5_ROUNDS: set_params = 0; /* Fall thru */ @@ -1179,18 +1177,16 @@ int EVP_CIPHER_CTX_ctrl(EVP_CIPHER_CTX *ctx, int type, int arg, void *ptr) set_params = 0; /* Fall thru */ case EVP_CTRL_AEAD_SET_TAG: params[0] = OSSL_PARAM_construct_octet_string(OSSL_CIPHER_PARAM_AEAD_TAG, - ptr, sz); + ptr, sz); break; case EVP_CTRL_AEAD_TLS1_AAD: /* This one does a set and a get - since it returns a size */ - params[0] = - OSSL_PARAM_construct_octet_string(OSSL_CIPHER_PARAM_AEAD_TLS1_AAD, - ptr, sz); + params[0] = OSSL_PARAM_construct_octet_string(OSSL_CIPHER_PARAM_AEAD_TLS1_AAD, + ptr, sz); ret = evp_do_ciph_ctx_setparams(ctx->cipher, ctx->algctx, params); if (ret <= 0) goto end; - params[0] = - OSSL_PARAM_construct_size_t(OSSL_CIPHER_PARAM_AEAD_TLS1_AAD_PAD, &sz); + params[0] = OSSL_PARAM_construct_size_t(OSSL_CIPHER_PARAM_AEAD_TLS1_AAD_PAD, &sz); ret = evp_do_ciph_ctx_getparams(ctx->cipher, ctx->algctx, params); if (ret <= 0) goto end; @@ -1205,37 +1201,36 @@ int EVP_CIPHER_CTX_ctrl(EVP_CIPHER_CTX *ctx, int type, int arg, void *ptr) #if !defined(OPENSSL_NO_MULTIBLOCK) case EVP_CTRL_TLS1_1_MULTIBLOCK_MAX_BUFSIZE: params[0] = OSSL_PARAM_construct_size_t( - OSSL_CIPHER_PARAM_TLS1_MULTIBLOCK_MAX_SEND_FRAGMENT, &sz); + OSSL_CIPHER_PARAM_TLS1_MULTIBLOCK_MAX_SEND_FRAGMENT, &sz); ret = evp_do_ciph_ctx_setparams(ctx->cipher, ctx->algctx, params); if (ret <= 0) return 0; params[0] = OSSL_PARAM_construct_size_t( - OSSL_CIPHER_PARAM_TLS1_MULTIBLOCK_MAX_BUFSIZE, &sz); + OSSL_CIPHER_PARAM_TLS1_MULTIBLOCK_MAX_BUFSIZE, &sz); params[1] = OSSL_PARAM_construct_end(); ret = evp_do_ciph_ctx_getparams(ctx->cipher, ctx->algctx, params); if (ret <= 0) return 0; return sz; case EVP_CTRL_TLS1_1_MULTIBLOCK_AAD: { - EVP_CTRL_TLS1_1_MULTIBLOCK_PARAM *p = - (EVP_CTRL_TLS1_1_MULTIBLOCK_PARAM *)ptr; + EVP_CTRL_TLS1_1_MULTIBLOCK_PARAM *p = (EVP_CTRL_TLS1_1_MULTIBLOCK_PARAM *)ptr; if (arg < (int)sizeof(EVP_CTRL_TLS1_1_MULTIBLOCK_PARAM)) return 0; params[0] = OSSL_PARAM_construct_octet_string( - OSSL_CIPHER_PARAM_TLS1_MULTIBLOCK_AAD, (void*)p->inp, p->len); + OSSL_CIPHER_PARAM_TLS1_MULTIBLOCK_AAD, (void *)p->inp, p->len); params[1] = OSSL_PARAM_construct_uint( - OSSL_CIPHER_PARAM_TLS1_MULTIBLOCK_INTERLEAVE, &p->interleave); + OSSL_CIPHER_PARAM_TLS1_MULTIBLOCK_INTERLEAVE, &p->interleave); ret = evp_do_ciph_ctx_setparams(ctx->cipher, ctx->algctx, params); if (ret <= 0) return ret; /* Retrieve the return values changed by the set */ params[0] = OSSL_PARAM_construct_size_t( - OSSL_CIPHER_PARAM_TLS1_MULTIBLOCK_AAD_PACKLEN, &sz); + OSSL_CIPHER_PARAM_TLS1_MULTIBLOCK_AAD_PACKLEN, &sz); params[1] = OSSL_PARAM_construct_uint( - OSSL_CIPHER_PARAM_TLS1_MULTIBLOCK_INTERLEAVE, &p->interleave); + OSSL_CIPHER_PARAM_TLS1_MULTIBLOCK_INTERLEAVE, &p->interleave); params[2] = OSSL_PARAM_construct_end(); ret = evp_do_ciph_ctx_getparams(ctx->cipher, ctx->algctx, params); if (ret <= 0) @@ -1243,22 +1238,21 @@ int EVP_CIPHER_CTX_ctrl(EVP_CIPHER_CTX *ctx, int type, int arg, void *ptr) return sz; } case EVP_CTRL_TLS1_1_MULTIBLOCK_ENCRYPT: { - EVP_CTRL_TLS1_1_MULTIBLOCK_PARAM *p = - (EVP_CTRL_TLS1_1_MULTIBLOCK_PARAM *)ptr; + EVP_CTRL_TLS1_1_MULTIBLOCK_PARAM *p = (EVP_CTRL_TLS1_1_MULTIBLOCK_PARAM *)ptr; params[0] = OSSL_PARAM_construct_octet_string( - OSSL_CIPHER_PARAM_TLS1_MULTIBLOCK_ENC, p->out, p->len); + OSSL_CIPHER_PARAM_TLS1_MULTIBLOCK_ENC, p->out, p->len); params[1] = OSSL_PARAM_construct_octet_string( - OSSL_CIPHER_PARAM_TLS1_MULTIBLOCK_ENC_IN, (void*)p->inp, - p->len); + OSSL_CIPHER_PARAM_TLS1_MULTIBLOCK_ENC_IN, (void *)p->inp, + p->len); params[2] = OSSL_PARAM_construct_uint( - OSSL_CIPHER_PARAM_TLS1_MULTIBLOCK_INTERLEAVE, &p->interleave); + OSSL_CIPHER_PARAM_TLS1_MULTIBLOCK_INTERLEAVE, &p->interleave); ret = evp_do_ciph_ctx_setparams(ctx->cipher, ctx->algctx, params); if (ret <= 0) return ret; params[0] = OSSL_PARAM_construct_size_t( - OSSL_CIPHER_PARAM_TLS1_MULTIBLOCK_ENC_LEN, &sz); + OSSL_CIPHER_PARAM_TLS1_MULTIBLOCK_ENC_LEN, &sz); params[1] = OSSL_PARAM_construct_end(); ret = evp_do_ciph_ctx_getparams(ctx->cipher, ctx->algctx, params); if (ret <= 0) @@ -1270,7 +1264,7 @@ int EVP_CIPHER_CTX_ctrl(EVP_CIPHER_CTX *ctx, int type, int arg, void *ptr) if (arg < 0) return -1; params[0] = OSSL_PARAM_construct_octet_string( - OSSL_CIPHER_PARAM_AEAD_MAC_KEY, ptr, sz); + OSSL_CIPHER_PARAM_AEAD_MAC_KEY, ptr, sz); break; } @@ -1289,7 +1283,7 @@ legacy: ret = ctx->cipher->ctrl(ctx, type, arg, ptr); - end: +end: if (ret == EVP_CTRL_RET_UNSUPPORTED) { ERR_raise(ERR_LIB_EVP, EVP_R_CTRL_OPERATION_NOT_IMPLEMENTED); return 0; @@ -1324,7 +1318,7 @@ const OSSL_PARAM *EVP_CIPHER_gettable_params(const EVP_CIPHER *cipher) { if (cipher != NULL && cipher->gettable_params != NULL) return cipher->gettable_params( - ossl_provider_ctx(EVP_CIPHER_get0_provider(cipher))); + ossl_provider_ctx(EVP_CIPHER_get0_provider(cipher))); return NULL; } @@ -1440,7 +1434,7 @@ int EVP_CIPHER_CTX_copy(EVP_CIPHER_CTX *out, const EVP_CIPHER_CTX *in) return 1; /* Code below to be removed when legacy support is dropped. */ - legacy: +legacy: #if !defined(OPENSSL_NO_ENGINE) && !defined(FIPS_MODULE) /* Make sure it's safe to copy a cipher context using an ENGINE */ @@ -1505,7 +1499,7 @@ static void set_legacy_nid(const char *name, void *vlegacy_nid) */ const void *legacy_method = OBJ_NAME_get(name, OBJ_NAME_TYPE_CIPHER_METH); - if (*legacy_nid == -1) /* We found a clash already */ + if (*legacy_nid == -1) /* We found a clash already */ return; if (legacy_method == NULL) return; @@ -1519,8 +1513,8 @@ static void set_legacy_nid(const char *name, void *vlegacy_nid) #endif static void *evp_cipher_from_algorithm(const int name_id, - const OSSL_ALGORITHM *algodef, - OSSL_PROVIDER *prov) + const OSSL_ALGORITHM *algodef, + OSSL_PROVIDER *prov) { const OSSL_DISPATCH *fns = algodef->implementation; EVP_CIPHER *cipher = NULL; @@ -1534,7 +1528,7 @@ static void *evp_cipher_from_algorithm(const int name_id, #ifndef FIPS_MODULE cipher->nid = NID_undef; if (!evp_names_do_all(prov, name_id, set_legacy_nid, &cipher->nid) - || cipher->nid == -1) { + || cipher->nid == -1) { ERR_raise(ERR_LIB_EVP, ERR_R_INTERNAL_ERROR); EVP_CIPHER_free(cipher); return NULL; @@ -1619,20 +1613,18 @@ static void *evp_cipher_from_algorithm(const int name_id, case OSSL_FUNC_CIPHER_GETTABLE_CTX_PARAMS: if (cipher->gettable_ctx_params != NULL) break; - cipher->gettable_ctx_params = - OSSL_FUNC_cipher_gettable_ctx_params(fns); + cipher->gettable_ctx_params = OSSL_FUNC_cipher_gettable_ctx_params(fns); break; case OSSL_FUNC_CIPHER_SETTABLE_CTX_PARAMS: if (cipher->settable_ctx_params != NULL) break; - cipher->settable_ctx_params = - OSSL_FUNC_cipher_settable_ctx_params(fns); + cipher->settable_ctx_params = OSSL_FUNC_cipher_settable_ctx_params(fns); break; } } if ((fnciphcnt != 0 && fnciphcnt != 3 && fnciphcnt != 4) - || (fnciphcnt == 0 && cipher->ccipher == NULL) - || fnctxcnt != 2) { + || (fnciphcnt == 0 && cipher->ccipher == NULL) + || fnctxcnt != 2) { /* * In order to be a consistent set of functions we must have at least * a complete set of "encrypt" functions, or a complete set of "decrypt" @@ -1667,12 +1659,11 @@ static void evp_cipher_free(void *cipher) } EVP_CIPHER *EVP_CIPHER_fetch(OSSL_LIB_CTX *ctx, const char *algorithm, - const char *properties) + const char *properties) { - EVP_CIPHER *cipher = - evp_generic_fetch(ctx, OSSL_OP_CIPHER, algorithm, properties, - evp_cipher_from_algorithm, evp_cipher_up_ref, - evp_cipher_free); + EVP_CIPHER *cipher = evp_generic_fetch(ctx, OSSL_OP_CIPHER, algorithm, properties, + evp_cipher_from_algorithm, evp_cipher_up_ref, + evp_cipher_free); return cipher; } @@ -1708,11 +1699,11 @@ void EVP_CIPHER_free(EVP_CIPHER *cipher) } void EVP_CIPHER_do_all_provided(OSSL_LIB_CTX *libctx, - void (*fn)(EVP_CIPHER *mac, void *arg), - void *arg) + void (*fn)(EVP_CIPHER *mac, void *arg), + void *arg) { evp_generic_do_all(libctx, OSSL_OP_CIPHER, - (void (*)(void *, void *))fn, arg, - evp_cipher_from_algorithm, evp_cipher_up_ref, - evp_cipher_free); + (void (*)(void *, void *))fn, arg, + evp_cipher_from_algorithm, evp_cipher_up_ref, + evp_cipher_free); } |
