Provide X509_OBJECT_get0_X509() and X509_OBJECT_get0_X509_CRL().
authorjsing <jsing@openbsd.org>
Thu, 22 Feb 2018 17:17:09 +0000 (17:17 +0000)
committerjsing <jsing@openbsd.org>
Thu, 22 Feb 2018 17:17:09 +0000 (17:17 +0000)
lib/libcrypto/Symbols.list
lib/libcrypto/x509/x509_lu.c
lib/libcrypto/x509/x509_vfy.h

index 9396056..ac0f399 100644 (file)
@@ -2747,6 +2747,8 @@ X509_NAME_print_ex
 X509_NAME_print_ex_fp
 X509_NAME_set
 X509_OBJECT_free_contents
+X509_OBJECT_get0_X509
+X509_OBJECT_get0_X509_CRL
 X509_OBJECT_idx_by_subject
 X509_OBJECT_retrieve_by_subject
 X509_OBJECT_retrieve_match
index 175b8b6..3a28c06 100644 (file)
@@ -1,4 +1,4 @@
-/* $OpenBSD: x509_lu.c,v 1.24 2018/02/22 17:15:09 jsing Exp $ */
+/* $OpenBSD: x509_lu.c,v 1.25 2018/02/22 17:17:09 jsing Exp $ */
 /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
  * All rights reserved.
  *
@@ -533,6 +533,22 @@ X509_OBJECT_retrieve_by_subject(STACK_OF(X509_OBJECT) *h, int type,
        return sk_X509_OBJECT_value(h, idx);
 }
 
+X509 *
+X509_OBJECT_get0_X509(const X509_OBJECT *xo)
+{
+       if (xo != NULL && xo->type == X509_LU_X509)
+               return xo->data.x509;
+       return NULL;
+}
+
+X509_CRL *
+X509_OBJECT_get0_X509_CRL(X509_OBJECT *xo)
+{
+       if (xo != NULL && xo->type == X509_LU_CRL)
+               return xo->data.crl;
+       return NULL;
+}
+
 STACK_OF(X509) *
 X509_STORE_get1_certs(X509_STORE_CTX *ctx, X509_NAME *nm)
 {
@@ -656,7 +672,6 @@ X509_OBJECT_retrieve_match(STACK_OF(X509_OBJECT) *h, X509_OBJECT *x)
        return NULL;
 }
 
-
 /* Try to get issuer certificate from store. Due to limitations
  * of the API this can only retrieve a single certificate matching
  * a given subject name. However it will fill the cache with all
index 57c19ac..a62f89a 100644 (file)
@@ -1,4 +1,4 @@
-/* $OpenBSD: x509_vfy.h,v 1.22 2018/02/22 17:15:09 jsing Exp $ */
+/* $OpenBSD: x509_vfy.h,v 1.23 2018/02/22 17:17:09 jsing Exp $ */
 /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
  * All rights reserved.
  *
@@ -426,6 +426,8 @@ X509_OBJECT *X509_OBJECT_retrieve_by_subject(STACK_OF(X509_OBJECT) *h,int type,X
 X509_OBJECT *X509_OBJECT_retrieve_match(STACK_OF(X509_OBJECT) *h, X509_OBJECT *x);
 void X509_OBJECT_up_ref_count(X509_OBJECT *a);
 void X509_OBJECT_free_contents(X509_OBJECT *a);
+X509 *X509_OBJECT_get0_X509(const X509_OBJECT *xo);
+X509_CRL *X509_OBJECT_get0_X509_CRL(X509_OBJECT *xo);
 
 X509_STORE *X509_STORE_new(void);
 void X509_STORE_free(X509_STORE *v);