From: tb Date: Wed, 3 Jan 2024 09:13:32 +0000 (+0000) Subject: Improve order in ancient CMS helpers X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=0a1afe4ac5e459b8b31e2d67489edd4d96154e9c;p=openbsd 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. --- diff --git a/lib/libcrypto/evp/evp_cipher.c b/lib/libcrypto/evp/evp_cipher.c index 51e83b7573e..c3e2cd45f38 100644 --- a/lib/libcrypto/evp/evp_cipher.c +++ b/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)