From: tb Date: Fri, 24 Aug 2018 19:55:58 +0000 (+0000) Subject: Turn a number of #defines into proper functions with prototypes matching X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=ccd620fbc099e7a9a40c2431a39e45a101cea495;p=openbsd Turn a number of #defines into proper functions with prototypes matching those that OpenSSL has had for ages. ok jsing --- diff --git a/lib/libcrypto/Symbols.list b/lib/libcrypto/Symbols.list index 01b21bddc68..dc11ea497fc 100644 --- a/lib/libcrypto/Symbols.list +++ b/lib/libcrypto/Symbols.list @@ -2672,14 +2672,19 @@ X509_CRL_get0_extensions X509_CRL_get0_lastUpdate X509_CRL_get0_nextUpdate X509_CRL_get0_signature +X509_CRL_get_REVOKED X509_CRL_get_ext X509_CRL_get_ext_by_NID X509_CRL_get_ext_by_OBJ X509_CRL_get_ext_by_critical X509_CRL_get_ext_count X509_CRL_get_ext_d2i +X509_CRL_get_issuer +X509_CRL_get_lastUpdate X509_CRL_get_meth_data +X509_CRL_get_nextUpdate X509_CRL_get_signature_nid +X509_CRL_get_version X509_CRL_it X509_CRL_match X509_CRL_new @@ -2819,6 +2824,8 @@ X509_REQ_get_extension_nids X509_REQ_get_extensions X509_REQ_get_pubkey X509_REQ_get_signature_nid +X509_REQ_get_subject_name +X509_REQ_get_version X509_REQ_it X509_REQ_new X509_REQ_print @@ -3011,7 +3018,9 @@ X509_get_pubkey X509_get_pubkey_parameters X509_get_serialNumber X509_get_signature_nid +X509_get_signature_type X509_get_subject_name +X509_get_version X509_getm_notAfter X509_getm_notBefore X509_gmtime_adj diff --git a/lib/libcrypto/asn1/x_crl.c b/lib/libcrypto/asn1/x_crl.c index 890623c47c9..0837ec15be3 100644 --- a/lib/libcrypto/asn1/x_crl.c +++ b/lib/libcrypto/asn1/x_crl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: x_crl.c,v 1.32 2018/04/23 13:10:19 tb Exp $ */ +/* $OpenBSD: x_crl.c,v 1.33 2018/08/24 19:55:58 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -706,18 +706,48 @@ X509_CRL_get0_extensions(const X509_CRL *crl) return crl->crl->extensions; } +long +X509_CRL_get_version(const X509_CRL *crl) +{ + return ASN1_INTEGER_get(crl->crl->version); +} + const ASN1_TIME * X509_CRL_get0_lastUpdate(const X509_CRL *crl) { return crl->crl->lastUpdate; } +ASN1_TIME * +X509_CRL_get_lastUpdate(X509_CRL *crl) +{ + return crl->crl->lastUpdate; +} + const ASN1_TIME * X509_CRL_get0_nextUpdate(const X509_CRL *crl) { return crl->crl->nextUpdate; } +ASN1_TIME * +X509_CRL_get_nextUpdate(X509_CRL *crl) +{ + return crl->crl->nextUpdate; +} + +X509_NAME * +X509_CRL_get_issuer(const X509_CRL *crl) +{ + return crl->crl->issuer; +} + +STACK_OF(X509_REVOKED) * +X509_CRL_get_REVOKED(X509_CRL *crl) +{ + return crl->crl->revoked; +} + void X509_CRL_get0_signature(const X509_CRL *crl, const ASN1_BIT_STRING **psig, const X509_ALGOR **palg) diff --git a/lib/libcrypto/x509/x509.h b/lib/libcrypto/x509/x509.h index ed6225997aa..e6b205b7fce 100644 --- a/lib/libcrypto/x509/x509.h +++ b/lib/libcrypto/x509/x509.h @@ -1,4 +1,4 @@ -/* $OpenBSD: x509.h,v 1.69 2018/05/30 15:59:33 tb Exp $ */ +/* $OpenBSD: x509.h,v 1.70 2018/08/24 19:55:58 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -589,29 +589,21 @@ extern "C" { #define X509_EXT_PACK_UNKNOWN 1 #define X509_EXT_PACK_STRING 2 -#define X509_get_version(x) ASN1_INTEGER_get((x)->cert_info->version) -/* #define X509_get_serialNumber(x) ((x)->cert_info->serialNumber) */ -#define X509_get_notBefore(x) ((x)->cert_info->validity->notBefore) -#define X509_get_notAfter(x) ((x)->cert_info->validity->notAfter) #define X509_extract_key(x) X509_get_pubkey(x) /*****/ -#define X509_REQ_get_version(x) ASN1_INTEGER_get((x)->req_info->version) -#define X509_REQ_get_subject_name(x) ((x)->req_info->subject) #define X509_REQ_extract_key(a) X509_REQ_get_pubkey(a) #define X509_name_cmp(a,b) X509_NAME_cmp((a),(b)) -#define X509_get_signature_type(x) EVP_PKEY_type(OBJ_obj2nid((x)->sig_alg->algorithm)) - -#define X509_CRL_get_version(x) ASN1_INTEGER_get((x)->crl->version) -#define X509_CRL_get_lastUpdate(x) ((x)->crl->lastUpdate) -#define X509_CRL_get_nextUpdate(x) ((x)->crl->nextUpdate) -#define X509_CRL_get_issuer(x) ((x)->crl->issuer) -#define X509_CRL_get_REVOKED(x) ((x)->crl->revoked) int X509_CRL_up_ref(X509_CRL *x); int X509_CRL_get_signature_nid(const X509_CRL *crl); const STACK_OF(X509_EXTENSION) *X509_CRL_get0_extensions(const X509_CRL *crl); +long X509_CRL_get_version(const X509_CRL *crl); const ASN1_TIME *X509_CRL_get0_lastUpdate(const X509_CRL *crl); const ASN1_TIME *X509_CRL_get0_nextUpdate(const X509_CRL *crl); +ASN1_TIME *X509_CRL_get_lastUpdate(X509_CRL *crl); +ASN1_TIME *X509_CRL_get_nextUpdate(X509_CRL *crl); +X509_NAME *X509_CRL_get_issuer(const X509_CRL *crl); +STACK_OF(X509_REVOKED) *X509_CRL_get_REVOKED(X509_CRL *crl); void X509_CRL_get0_signature(const X509_CRL *crl, const ASN1_BIT_STRING **psig, const X509_ALGOR **palg); @@ -984,6 +976,7 @@ int ASN1_item_sign_ctx(const ASN1_ITEM *it, const STACK_OF(X509_EXTENSION) *X509_get0_extensions(const X509 *x); const X509_ALGOR *X509_get0_tbs_sigalg(const X509 *x); int X509_set_version(X509 *x, long version); +long X509_get_version(const X509 *x); int X509_set_serialNumber(X509 *x, ASN1_INTEGER *serial); ASN1_INTEGER * X509_get_serialNumber(X509 *x); int X509_set_issuer_name(X509 *x, X509_NAME *name); @@ -1003,9 +996,15 @@ EVP_PKEY * X509_get_pubkey(X509 *x); EVP_PKEY * X509_get0_pubkey(const X509 *x); ASN1_BIT_STRING *X509_get0_pubkey_bitstr(const X509 *x); int X509_certificate_type(const X509 *x, const EVP_PKEY *pubkey); +int X509_get_signature_type(const X509 *x); + +#define X509_get_notBefore X509_getm_notBefore +#define X509_get_notAfter X509_getm_notAfter int X509_REQ_set_version(X509_REQ *x,long version); -int X509_REQ_set_subject_name(X509_REQ *req,X509_NAME *name); +long X509_REQ_get_version(const X509_REQ *x); +int X509_REQ_set_subject_name(X509_REQ *req, X509_NAME *name); +X509_NAME *X509_REQ_get_subject_name(const X509_REQ *x); int X509_REQ_set_pubkey(X509_REQ *x, EVP_PKEY *pkey); EVP_PKEY * X509_REQ_get_pubkey(X509_REQ *req); int X509_REQ_extension_nid(int nid); diff --git a/lib/libcrypto/x509/x509_set.c b/lib/libcrypto/x509/x509_set.c index becdaf6ce5b..1a4b583ab72 100644 --- a/lib/libcrypto/x509/x509_set.c +++ b/lib/libcrypto/x509/x509_set.c @@ -1,4 +1,4 @@ -/* $OpenBSD: x509_set.c,v 1.16 2018/02/22 17:09:28 jsing Exp $ */ +/* $OpenBSD: x509_set.c,v 1.17 2018/08/24 19:55:58 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -87,6 +87,12 @@ X509_set_version(X509 *x, long version) return (ASN1_INTEGER_set(x->cert_info->version, version)); } +long +X509_get_version(const X509 *x) +{ + return ASN1_INTEGER_get(x->cert_info->version); +} + int X509_set_serialNumber(X509 *x, ASN1_INTEGER *serial) { @@ -204,3 +210,9 @@ X509_set_pubkey(X509 *x, EVP_PKEY *pkey) return (0); return (X509_PUBKEY_set(&(x->cert_info->key), pkey)); } + +int +X509_get_signature_type(const X509 *x) +{ + return EVP_PKEY_type(OBJ_obj2nid(x->sig_alg->algorithm)); +} diff --git a/lib/libcrypto/x509/x509rset.c b/lib/libcrypto/x509/x509rset.c index cfac977636f..de02a400389 100644 --- a/lib/libcrypto/x509/x509rset.c +++ b/lib/libcrypto/x509/x509rset.c @@ -1,4 +1,4 @@ -/* $OpenBSD: x509rset.c,v 1.6 2014/07/11 08:44:49 jsing Exp $ */ +/* $OpenBSD: x509rset.c,v 1.7 2018/08/24 19:55:58 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -71,6 +71,12 @@ X509_REQ_set_version(X509_REQ *x, long version) return (ASN1_INTEGER_set(x->req_info->version, version)); } +long +X509_REQ_get_version(const X509_REQ *x) +{ + return ASN1_INTEGER_get(x->req_info->version); +} + int X509_REQ_set_subject_name(X509_REQ *x, X509_NAME *name) { @@ -79,6 +85,12 @@ X509_REQ_set_subject_name(X509_REQ *x, X509_NAME *name) return (X509_NAME_set(&x->req_info->subject, name)); } +X509_NAME * +X509_REQ_get_subject_name(const X509_REQ *x) +{ + return x->req_info->subject; +} + int X509_REQ_set_pubkey(X509_REQ *x, EVP_PKEY *pkey) {