summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authortb <>2024-01-03 09:13:32 +0000
committertb <>2024-01-03 09:13:32 +0000
commit1c6d12a18927be32f24e3dd8c0cb0d33de676d66 (patch)
tree96e5f25074cd7d567b05bd451169e4c00305d1c3 /src
parentbc850408943f23b6a549255d26c13acb37706695 (diff)
downloadopenbsd-1c6d12a18927be32f24e3dd8c0cb0d33de676d66.tar.gz
openbsd-1c6d12a18927be32f24e3dd8c0cb0d33de676d66.tar.bz2
openbsd-1c6d12a18927be32f24e3dd8c0cb0d33de676d66.zip
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.
Diffstat (limited to 'src')
-rw-r--r--src/lib/libcrypto/evp/evp_cipher.c50
1 files changed, 25 insertions, 25 deletions
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 @@
1/* $OpenBSD: evp_cipher.c,v 1.13 2024/01/02 21:27:39 tb Exp $ */ 1/* $OpenBSD: evp_cipher.c,v 1.14 2024/01/03 09:13:32 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -899,30 +899,6 @@ EVP_CIPHER_CTX_flags(const EVP_CIPHER_CTX *ctx)
899 */ 899 */
900 900
901int 901int
902EVP_CIPHER_param_to_asn1(EVP_CIPHER_CTX *ctx, ASN1_TYPE *type)
903{
904 if (ctx->cipher->set_asn1_parameters != NULL)
905 return ctx->cipher->set_asn1_parameters(ctx, type);
906
907 if ((ctx->cipher->flags & EVP_CIPH_FLAG_DEFAULT_ASN1) != 0)
908 return EVP_CIPHER_set_asn1_iv(ctx, type);
909
910 return -1;
911}
912
913int
914EVP_CIPHER_asn1_to_param(EVP_CIPHER_CTX *ctx, ASN1_TYPE *type)
915{
916 if (ctx->cipher->get_asn1_parameters != NULL)
917 return ctx->cipher->get_asn1_parameters(ctx, type);
918
919 if ((ctx->cipher->flags & EVP_CIPH_FLAG_DEFAULT_ASN1) != 0)
920 return EVP_CIPHER_get_asn1_iv(ctx, type);
921
922 return -1;
923}
924
925int
926EVP_CIPHER_get_asn1_iv(EVP_CIPHER_CTX *ctx, ASN1_TYPE *type) 902EVP_CIPHER_get_asn1_iv(EVP_CIPHER_CTX *ctx, ASN1_TYPE *type)
927{ 903{
928 int i = 0; 904 int i = 0;
@@ -944,6 +920,18 @@ EVP_CIPHER_get_asn1_iv(EVP_CIPHER_CTX *ctx, ASN1_TYPE *type)
944} 920}
945 921
946int 922int
923EVP_CIPHER_asn1_to_param(EVP_CIPHER_CTX *ctx, ASN1_TYPE *type)
924{
925 if (ctx->cipher->get_asn1_parameters != NULL)
926 return ctx->cipher->get_asn1_parameters(ctx, type);
927
928 if ((ctx->cipher->flags & EVP_CIPH_FLAG_DEFAULT_ASN1) != 0)
929 return EVP_CIPHER_get_asn1_iv(ctx, type);
930
931 return -1;
932}
933
934int
947EVP_CIPHER_set_asn1_iv(EVP_CIPHER_CTX *ctx, ASN1_TYPE *type) 935EVP_CIPHER_set_asn1_iv(EVP_CIPHER_CTX *ctx, ASN1_TYPE *type)
948{ 936{
949 int i = 0; 937 int i = 0;
@@ -960,6 +948,18 @@ EVP_CIPHER_set_asn1_iv(EVP_CIPHER_CTX *ctx, ASN1_TYPE *type)
960 return (i); 948 return (i);
961} 949}
962 950
951int
952EVP_CIPHER_param_to_asn1(EVP_CIPHER_CTX *ctx, ASN1_TYPE *type)
953{
954 if (ctx->cipher->set_asn1_parameters != NULL)
955 return ctx->cipher->set_asn1_parameters(ctx, type);
956
957 if ((ctx->cipher->flags & EVP_CIPH_FLAG_DEFAULT_ASN1) != 0)
958 return EVP_CIPHER_set_asn1_iv(ctx, type);
959
960 return -1;
961}
962
963/* Convert the various cipher NIDs and dummies to a proper OID NID */ 963/* Convert the various cipher NIDs and dummies to a proper OID NID */
964int 964int
965EVP_CIPHER_type(const EVP_CIPHER *cipher) 965EVP_CIPHER_type(const EVP_CIPHER *cipher)