diff options
author | tb <> | 2023-05-28 05:25:24 +0000 |
---|---|---|
committer | tb <> | 2023-05-28 05:25:24 +0000 |
commit | a95e36808ea4031670010ec297a8701fa0500aaa (patch) | |
tree | ec517a3d5252ee6f882377da37f2eed9b56f843c /src/lib/libcrypto/x509/x509_vfy.c | |
parent | d4cbaebb201580abb6146f23b603e976b071aa6c (diff) | |
download | openbsd-a95e36808ea4031670010ec297a8701fa0500aaa.tar.gz openbsd-a95e36808ea4031670010ec297a8701fa0500aaa.tar.bz2 openbsd-a95e36808ea4031670010ec297a8701fa0500aaa.zip |
Merge X509_VERIFY_PARAM_ID into X509_VERIFY_PARAM
Back in the day when essentially every struct was open to all applications,
X509_VERIFY_PARAM_ID provided a modicum of opacity. This indirection is now
no longer needed with X509_VERIFY_PARAM being opaque itself, so stop using
X509_VERIFY_PARAM_ID and merge it into X509_VERIFY_PARAM. This is a first
small step towards cleaning up the X509_VERIFY_PARAM mess.
ok jsing
Diffstat (limited to 'src/lib/libcrypto/x509/x509_vfy.c')
-rw-r--r-- | src/lib/libcrypto/x509/x509_vfy.c | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/src/lib/libcrypto/x509/x509_vfy.c b/src/lib/libcrypto/x509/x509_vfy.c index 6bc06187e1..0c2144752d 100644 --- a/src/lib/libcrypto/x509/x509_vfy.c +++ b/src/lib/libcrypto/x509/x509_vfy.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: x509_vfy.c,v 1.123 2023/05/14 20:20:40 tb Exp $ */ | 1 | /* $OpenBSD: x509_vfy.c,v 1.124 2023/05/28 05:25:24 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 | * |
@@ -177,19 +177,19 @@ check_id_error(X509_STORE_CTX *ctx, int errcode) | |||
177 | } | 177 | } |
178 | 178 | ||
179 | static int | 179 | static int |
180 | check_hosts(X509 *x, X509_VERIFY_PARAM_ID *id) | 180 | check_hosts(X509 *x, X509_VERIFY_PARAM *vpm) |
181 | { | 181 | { |
182 | int i, n; | 182 | int i, n; |
183 | char *name; | 183 | char *name; |
184 | 184 | ||
185 | n = sk_OPENSSL_STRING_num(id->hosts); | 185 | n = sk_OPENSSL_STRING_num(vpm->hosts); |
186 | free(id->peername); | 186 | free(vpm->peername); |
187 | id->peername = NULL; | 187 | vpm->peername = NULL; |
188 | 188 | ||
189 | for (i = 0; i < n; ++i) { | 189 | for (i = 0; i < n; ++i) { |
190 | name = sk_OPENSSL_STRING_value(id->hosts, i); | 190 | name = sk_OPENSSL_STRING_value(vpm->hosts, i); |
191 | if (X509_check_host(x, name, strlen(name), id->hostflags, | 191 | if (X509_check_host(x, name, strlen(name), vpm->hostflags, |
192 | &id->peername) > 0) | 192 | &vpm->peername) > 0) |
193 | return 1; | 193 | return 1; |
194 | } | 194 | } |
195 | return n == 0; | 195 | return n == 0; |
@@ -199,19 +199,18 @@ static int | |||
199 | check_id(X509_STORE_CTX *ctx) | 199 | check_id(X509_STORE_CTX *ctx) |
200 | { | 200 | { |
201 | X509_VERIFY_PARAM *vpm = ctx->param; | 201 | X509_VERIFY_PARAM *vpm = ctx->param; |
202 | X509_VERIFY_PARAM_ID *id = vpm->id; | ||
203 | X509 *x = ctx->cert; | 202 | X509 *x = ctx->cert; |
204 | 203 | ||
205 | if (id->hosts && check_hosts(x, id) <= 0) { | 204 | if (vpm->hosts && check_hosts(x, vpm) <= 0) { |
206 | if (!check_id_error(ctx, X509_V_ERR_HOSTNAME_MISMATCH)) | 205 | if (!check_id_error(ctx, X509_V_ERR_HOSTNAME_MISMATCH)) |
207 | return 0; | 206 | return 0; |
208 | } | 207 | } |
209 | if (id->email != NULL && X509_check_email(x, id->email, id->emaillen, 0) | 208 | if (vpm->email != NULL && X509_check_email(x, vpm->email, vpm->emaillen, 0) |
210 | <= 0) { | 209 | <= 0) { |
211 | if (!check_id_error(ctx, X509_V_ERR_EMAIL_MISMATCH)) | 210 | if (!check_id_error(ctx, X509_V_ERR_EMAIL_MISMATCH)) |
212 | return 0; | 211 | return 0; |
213 | } | 212 | } |
214 | if (id->ip != NULL && X509_check_ip(x, id->ip, id->iplen, 0) <= 0) { | 213 | if (vpm->ip != NULL && X509_check_ip(x, vpm->ip, vpm->iplen, 0) <= 0) { |
215 | if (!check_id_error(ctx, X509_V_ERR_IP_ADDRESS_MISMATCH)) | 214 | if (!check_id_error(ctx, X509_V_ERR_IP_ADDRESS_MISMATCH)) |
216 | return 0; | 215 | return 0; |
217 | } | 216 | } |
@@ -609,7 +608,7 @@ X509_verify_cert(X509_STORE_CTX *ctx) | |||
609 | ctx->error = X509_V_ERR_INVALID_CALL; | 608 | ctx->error = X509_V_ERR_INVALID_CALL; |
610 | return -1; | 609 | return -1; |
611 | } | 610 | } |
612 | if (ctx->param->id->poisoned) { | 611 | if (ctx->param->poisoned) { |
613 | /* | 612 | /* |
614 | * This X509_STORE_CTX had failures setting | 613 | * This X509_STORE_CTX had failures setting |
615 | * up verify parameters. We can not use it. | 614 | * up verify parameters. We can not use it. |