diff options
Diffstat (limited to '')
-rw-r--r-- | src/lib/libcrypto/evp/evp_cipher.c | 46 |
1 files changed, 17 insertions, 29 deletions
diff --git a/src/lib/libcrypto/evp/evp_cipher.c b/src/lib/libcrypto/evp/evp_cipher.c index e9c266d1b9..04e0e1c0b0 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.23 2024/04/10 15:00:38 beck Exp $ */ | 1 | /* $OpenBSD: evp_cipher.c,v 1.28 2025/07/02 06:19:46 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 | * |
@@ -115,10 +115,10 @@ | |||
115 | #include <string.h> | 115 | #include <string.h> |
116 | 116 | ||
117 | #include <openssl/asn1.h> | 117 | #include <openssl/asn1.h> |
118 | #include <openssl/err.h> | ||
119 | #include <openssl/evp.h> | 118 | #include <openssl/evp.h> |
120 | 119 | ||
121 | #include "asn1_local.h" | 120 | #include "asn1_local.h" |
121 | #include "err_local.h" | ||
122 | #include "evp_local.h" | 122 | #include "evp_local.h" |
123 | 123 | ||
124 | int | 124 | int |
@@ -167,7 +167,7 @@ EVP_CipherInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, ENGINE *engine, | |||
167 | } | 167 | } |
168 | 168 | ||
169 | if ((ctx->cipher->flags & EVP_CIPH_CTRL_INIT) != 0) { | 169 | if ((ctx->cipher->flags & EVP_CIPH_CTRL_INIT) != 0) { |
170 | if (!EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_INIT, 0, NULL)) { | 170 | if (EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_INIT, 0, NULL) <= 0) { |
171 | EVPerror(EVP_R_INITIALIZATION_ERROR); | 171 | EVPerror(EVP_R_INITIALIZATION_ERROR); |
172 | return 0; | 172 | return 0; |
173 | } | 173 | } |
@@ -944,14 +944,20 @@ EVP_CIPHER_CTX_flags(const EVP_CIPHER_CTX *ctx) | |||
944 | LCRYPTO_ALIAS(EVP_CIPHER_CTX_flags); | 944 | LCRYPTO_ALIAS(EVP_CIPHER_CTX_flags); |
945 | 945 | ||
946 | /* | 946 | /* |
947 | * Used by CMS and its predecessors. Only GOST and RC2 have a custom method. | 947 | * Used by CMS and its predecessors. Only RC2 has a custom method. |
948 | */ | 948 | */ |
949 | 949 | ||
950 | int | 950 | int |
951 | EVP_CIPHER_get_asn1_iv(EVP_CIPHER_CTX *ctx, ASN1_TYPE *type) | 951 | EVP_CIPHER_asn1_to_param(EVP_CIPHER_CTX *ctx, ASN1_TYPE *type) |
952 | { | 952 | { |
953 | int iv_len; | 953 | int iv_len; |
954 | 954 | ||
955 | if (ctx->cipher->get_asn1_parameters != NULL) | ||
956 | return ctx->cipher->get_asn1_parameters(ctx, type); | ||
957 | |||
958 | if ((ctx->cipher->flags & EVP_CIPH_FLAG_DEFAULT_ASN1) == 0) | ||
959 | return -1; | ||
960 | |||
955 | if (type == NULL) | 961 | if (type == NULL) |
956 | return 0; | 962 | return 0; |
957 | 963 | ||
@@ -970,21 +976,15 @@ EVP_CIPHER_get_asn1_iv(EVP_CIPHER_CTX *ctx, ASN1_TYPE *type) | |||
970 | } | 976 | } |
971 | 977 | ||
972 | int | 978 | int |
973 | EVP_CIPHER_asn1_to_param(EVP_CIPHER_CTX *ctx, ASN1_TYPE *type) | 979 | EVP_CIPHER_param_to_asn1(EVP_CIPHER_CTX *ctx, ASN1_TYPE *type) |
974 | { | 980 | { |
975 | if (ctx->cipher->get_asn1_parameters != NULL) | 981 | int iv_len; |
976 | return ctx->cipher->get_asn1_parameters(ctx, type); | ||
977 | |||
978 | if ((ctx->cipher->flags & EVP_CIPH_FLAG_DEFAULT_ASN1) != 0) | ||
979 | return EVP_CIPHER_get_asn1_iv(ctx, type); | ||
980 | 982 | ||
981 | return -1; | 983 | if (ctx->cipher->set_asn1_parameters != NULL) |
982 | } | 984 | return ctx->cipher->set_asn1_parameters(ctx, type); |
983 | 985 | ||
984 | int | 986 | if ((ctx->cipher->flags & EVP_CIPH_FLAG_DEFAULT_ASN1) == 0) |
985 | EVP_CIPHER_set_asn1_iv(EVP_CIPHER_CTX *ctx, ASN1_TYPE *type) | 987 | return -1; |
986 | { | ||
987 | int iv_len; | ||
988 | 988 | ||
989 | if (type == NULL) | 989 | if (type == NULL) |
990 | return 0; | 990 | return 0; |
@@ -998,18 +998,6 @@ EVP_CIPHER_set_asn1_iv(EVP_CIPHER_CTX *ctx, ASN1_TYPE *type) | |||
998 | return ASN1_TYPE_set_octetstring(type, ctx->oiv, iv_len); | 998 | return ASN1_TYPE_set_octetstring(type, ctx->oiv, iv_len); |
999 | } | 999 | } |
1000 | 1000 | ||
1001 | int | ||
1002 | EVP_CIPHER_param_to_asn1(EVP_CIPHER_CTX *ctx, ASN1_TYPE *type) | ||
1003 | { | ||
1004 | if (ctx->cipher->set_asn1_parameters != NULL) | ||
1005 | return ctx->cipher->set_asn1_parameters(ctx, type); | ||
1006 | |||
1007 | if ((ctx->cipher->flags & EVP_CIPH_FLAG_DEFAULT_ASN1) != 0) | ||
1008 | return EVP_CIPHER_set_asn1_iv(ctx, type); | ||
1009 | |||
1010 | return -1; | ||
1011 | } | ||
1012 | |||
1013 | /* Convert the various cipher NIDs and dummies to a proper OID NID */ | 1001 | /* Convert the various cipher NIDs and dummies to a proper OID NID */ |
1014 | int | 1002 | int |
1015 | EVP_CIPHER_type(const EVP_CIPHER *cipher) | 1003 | EVP_CIPHER_type(const EVP_CIPHER *cipher) |