summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/x509/x509_vfy.c
diff options
context:
space:
mode:
authorbeck <>2021-09-03 08:58:53 +0000
committerbeck <>2021-09-03 08:58:53 +0000
commit994245ef52a1aae31fcfe4b4f477541af4815037 (patch)
tree9c46aa8dc9877d0ff22a6819eece4485287e26be /src/lib/libcrypto/x509/x509_vfy.c
parent85941777b4cebd473c07bdc6a1b63738e4b65fa3 (diff)
downloadopenbsd-994245ef52a1aae31fcfe4b4f477541af4815037.tar.gz
openbsd-994245ef52a1aae31fcfe4b4f477541af4815037.tar.bz2
openbsd-994245ef52a1aae31fcfe4b4f477541af4815037.zip
Call the callback on success in new verifier in a compatible way
when we succeed with a chain, and ensure we do not call the callback twice when the caller doesn't expect it. A refactor of the end of the legacy verify code in x509_vfy is probably overdue, but this should be done based on a piece that works. the important bit here is this allows the perl regression tests in tree to pass. Changes the previously committed regress tests to test the success case callbacks to be known to pass. ok bluhm@ tb@
Diffstat (limited to 'src/lib/libcrypto/x509/x509_vfy.c')
-rw-r--r--src/lib/libcrypto/x509/x509_vfy.c22
1 files changed, 17 insertions, 5 deletions
diff --git a/src/lib/libcrypto/x509/x509_vfy.c b/src/lib/libcrypto/x509/x509_vfy.c
index a161b330ae..2f69017e96 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.88 2021/08/28 15:22:42 beck Exp $ */ 1/* $OpenBSD: x509_vfy.c,v 1.89 2021/09/03 08:58:53 beck 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 *
@@ -1879,7 +1879,7 @@ x509_check_cert_time(X509_STORE_CTX *ctx, X509 *x, int depth)
1879} 1879}
1880 1880
1881static int 1881static int
1882internal_verify(X509_STORE_CTX *ctx) 1882x509_vfy_internal_verify(X509_STORE_CTX *ctx, int chain_verified)
1883{ 1883{
1884 int n = sk_X509_num(ctx->chain) - 1; 1884 int n = sk_X509_num(ctx->chain) - 1;
1885 X509 *xi = sk_X509_value(ctx->chain, n); 1885 X509 *xi = sk_X509_value(ctx->chain, n);
@@ -1915,8 +1915,8 @@ internal_verify(X509_STORE_CTX *ctx)
1915 * certificate and its depth (rather than the depth of 1915 * certificate and its depth (rather than the depth of
1916 * the subject). 1916 * the subject).
1917 */ 1917 */
1918 if (xs != xi || 1918 if (!chain_verified && ( xs != xi ||
1919 (ctx->param->flags & X509_V_FLAG_CHECK_SS_SIGNATURE)) { 1919 (ctx->param->flags & X509_V_FLAG_CHECK_SS_SIGNATURE))) {
1920 EVP_PKEY *pkey; 1920 EVP_PKEY *pkey;
1921 if ((pkey = X509_get_pubkey(xi)) == NULL) { 1921 if ((pkey = X509_get_pubkey(xi)) == NULL) {
1922 if (!verify_cb_cert(ctx, xi, xi != xs ? n+1 : n, 1922 if (!verify_cb_cert(ctx, xi, xi != xs ? n+1 : n,
@@ -1933,7 +1933,7 @@ internal_verify(X509_STORE_CTX *ctx)
1933 } 1933 }
1934check_cert: 1934check_cert:
1935 /* Calls verify callback as needed */ 1935 /* Calls verify callback as needed */
1936 if (!x509_check_cert_time(ctx, xs, n)) 1936 if (!chain_verified && !x509_check_cert_time(ctx, xs, n))
1937 return 0; 1937 return 0;
1938 1938
1939 /* 1939 /*
@@ -1954,6 +1954,18 @@ check_cert:
1954 return 1; 1954 return 1;
1955} 1955}
1956 1956
1957static int
1958internal_verify(X509_STORE_CTX *ctx)
1959{
1960 return x509_vfy_internal_verify(ctx, 0);
1961}
1962
1963int
1964x509_vfy_callback_indicate_success(X509_STORE_CTX *ctx)
1965{
1966 return x509_vfy_internal_verify(ctx, 1);
1967}
1968
1957int 1969int
1958X509_cmp_current_time(const ASN1_TIME *ctm) 1970X509_cmp_current_time(const ASN1_TIME *ctm)
1959{ 1971{