From 1c6d12a18927be32f24e3dd8c0cb0d33de676d66 Mon Sep 17 00:00:00 2001 From: tb <> Date: Wed, 3 Jan 2024 09:13:32 +0000 Subject: Improve order in ancient CMS helpers First came EVP_CIPHER_param_to_asn1() which wraps EVP_CIPHER_set_asn1_iv() which was implemented last. Then came EVP_CIPHER_asn1_to_param() wrapping EVP_CIPHER_get_asn1_iv(). Move each param function below the iv function it wraps. --- src/lib/libcrypto/evp/evp_cipher.c | 50 +++++++++++++++++++------------------- 1 file changed, 25 insertions(+), 25 deletions(-) (limited to 'src/lib/libcrypto') diff --git a/src/lib/libcrypto/evp/evp_cipher.c b/src/lib/libcrypto/evp/evp_cipher.c index 51e83b7573..c3e2cd45f3 100644 --- a/src/lib/libcrypto/evp/evp_cipher.c +++ b/src/lib/libcrypto/evp/evp_cipher.c @@ -1,4 +1,4 @@ -/* $OpenBSD: evp_cipher.c,v 1.13 2024/01/02 21:27:39 tb Exp $ */ +/* $OpenBSD: evp_cipher.c,v 1.14 2024/01/03 09:13:32 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -898,30 +898,6 @@ EVP_CIPHER_CTX_flags(const EVP_CIPHER_CTX *ctx) * Used by CMS and its predecessors. Only GOST and RC2 have a custom method. */ -int -EVP_CIPHER_param_to_asn1(EVP_CIPHER_CTX *ctx, ASN1_TYPE *type) -{ - if (ctx->cipher->set_asn1_parameters != NULL) - return ctx->cipher->set_asn1_parameters(ctx, type); - - if ((ctx->cipher->flags & EVP_CIPH_FLAG_DEFAULT_ASN1) != 0) - return EVP_CIPHER_set_asn1_iv(ctx, type); - - return -1; -} - -int -EVP_CIPHER_asn1_to_param(EVP_CIPHER_CTX *ctx, ASN1_TYPE *type) -{ - if (ctx->cipher->get_asn1_parameters != NULL) - return ctx->cipher->get_asn1_parameters(ctx, type); - - if ((ctx->cipher->flags & EVP_CIPH_FLAG_DEFAULT_ASN1) != 0) - return EVP_CIPHER_get_asn1_iv(ctx, type); - - return -1; -} - int EVP_CIPHER_get_asn1_iv(EVP_CIPHER_CTX *ctx, ASN1_TYPE *type) { @@ -943,6 +919,18 @@ EVP_CIPHER_get_asn1_iv(EVP_CIPHER_CTX *ctx, ASN1_TYPE *type) return (i); } +int +EVP_CIPHER_asn1_to_param(EVP_CIPHER_CTX *ctx, ASN1_TYPE *type) +{ + if (ctx->cipher->get_asn1_parameters != NULL) + return ctx->cipher->get_asn1_parameters(ctx, type); + + if ((ctx->cipher->flags & EVP_CIPH_FLAG_DEFAULT_ASN1) != 0) + return EVP_CIPHER_get_asn1_iv(ctx, type); + + return -1; +} + int EVP_CIPHER_set_asn1_iv(EVP_CIPHER_CTX *ctx, ASN1_TYPE *type) { @@ -960,6 +948,18 @@ EVP_CIPHER_set_asn1_iv(EVP_CIPHER_CTX *ctx, ASN1_TYPE *type) return (i); } +int +EVP_CIPHER_param_to_asn1(EVP_CIPHER_CTX *ctx, ASN1_TYPE *type) +{ + if (ctx->cipher->set_asn1_parameters != NULL) + return ctx->cipher->set_asn1_parameters(ctx, type); + + if ((ctx->cipher->flags & EVP_CIPH_FLAG_DEFAULT_ASN1) != 0) + return EVP_CIPHER_set_asn1_iv(ctx, type); + + return -1; +} + /* Convert the various cipher NIDs and dummies to a proper OID NID */ int EVP_CIPHER_type(const EVP_CIPHER *cipher) -- cgit v1.2.3-55-g6feb