summaryrefslogtreecommitdiff
path: root/lib/libcrypto/x509
diff options
context:
space:
mode:
authorJob Snijders <job@cvs.openbsd.org>2023-04-25 09:46:37 +0000
committerJob Snijders <job@cvs.openbsd.org>2023-04-25 09:46:37 +0000
commit1426b597507f56592386b2d933dbacd4351b10d1 (patch)
tree4a61805282cc52d7f87e958915fc726ee1e1ce90 /lib/libcrypto/x509
parentec1704ad3e8b72b1f0bf939534c27589b7f01b18 (diff)
Use X509_set_version() and X509_REQ_set_version() instead doing it by hand
A small side-effect in X509_to_X509_REQ() is that 'x->req_info->enc.modified' now earlier on is set to 1. OK tb@ jsing@
Diffstat (limited to 'lib/libcrypto/x509')
-rw-r--r--lib/libcrypto/x509/x509_r2x.c6
-rw-r--r--lib/libcrypto/x509/x509_req.c9
2 files changed, 4 insertions, 11 deletions
diff --git a/lib/libcrypto/x509/x509_r2x.c b/lib/libcrypto/x509/x509_r2x.c
index 99c423d8c99..39b392259b5 100644
--- a/lib/libcrypto/x509/x509_r2x.c
+++ b/lib/libcrypto/x509/x509_r2x.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: x509_r2x.c,v 1.16 2023/02/16 08:38:17 tb Exp $ */
+/* $OpenBSD: x509_r2x.c,v 1.17 2023/04/25 09:46:36 job Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
@@ -85,9 +85,7 @@ X509_REQ_to_X509(X509_REQ *r, int days, EVP_PKEY *pkey)
xi = ret->cert_info;
if (sk_X509_ATTRIBUTE_num(r->req_info->attributes) != 0) {
- if ((xi->version = ASN1_INTEGER_new()) == NULL)
- goto err;
- if (!ASN1_INTEGER_set(xi->version, 2))
+ if (!X509_set_version(ret, 2))
goto err;
}
diff --git a/lib/libcrypto/x509/x509_req.c b/lib/libcrypto/x509/x509_req.c
index 0fea7e68b43..7ed106241aa 100644
--- a/lib/libcrypto/x509/x509_req.c
+++ b/lib/libcrypto/x509/x509_req.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: x509_req.c,v 1.32 2023/02/16 08:38:17 tb Exp $ */
+/* $OpenBSD: x509_req.c,v 1.33 2023/04/25 09:46:36 job Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
@@ -77,7 +77,6 @@ X509_REQ *
X509_to_X509_REQ(X509 *x, EVP_PKEY *pkey, const EVP_MD *md)
{
X509_REQ *ret;
- X509_REQ_INFO *ri;
int i;
EVP_PKEY *pktmp;
@@ -87,11 +86,7 @@ X509_to_X509_REQ(X509 *x, EVP_PKEY *pkey, const EVP_MD *md)
goto err;
}
- ri = ret->req_info;
-
- if ((ri->version = ASN1_INTEGER_new()) == NULL)
- goto err;
- if (ASN1_INTEGER_set(ri->version, 0) == 0)
+ if (!X509_REQ_set_version(ret, 0))
goto err;
if (!X509_REQ_set_subject_name(ret, X509_get_subject_name(x)))