Provide X509_NAME_get0_der().
authorjsing <jsing@openbsd.org>
Tue, 20 Feb 2018 17:09:20 +0000 (17:09 +0000)
committerjsing <jsing@openbsd.org>
Tue, 20 Feb 2018 17:09:20 +0000 (17:09 +0000)
From OpenSSL.

lib/libcrypto/Symbols.list
lib/libcrypto/asn1/x_name.c
lib/libcrypto/x509/x509.h

index f446e08..0221762 100644 (file)
@@ -2695,6 +2695,7 @@ X509_NAME_digest
 X509_NAME_dup
 X509_NAME_entry_count
 X509_NAME_free
+X509_NAME_get0_der
 X509_NAME_get_entry
 X509_NAME_get_index_by_NID
 X509_NAME_get_index_by_OBJ
index 30fef39..4bf1842 100644 (file)
@@ -1,4 +1,4 @@
-/* $OpenBSD: x_name.c,v 1.33 2017/01/29 17:49:22 beck Exp $ */
+/* $OpenBSD: x_name.c,v 1.34 2018/02/20 17:09:20 jsing Exp $ */
 /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
  * All rights reserved.
  *
@@ -640,3 +640,16 @@ X509_NAME_set(X509_NAME **xn, X509_NAME *name)
        }
        return (*xn != NULL);
 }
+
+int
+X509_NAME_get0_der(X509_NAME *nm, const unsigned char **pder, size_t *pderlen)
+{
+       /* Make sure encoding is valid. */
+       if (i2d_X509_NAME(nm, NULL) <= 0)
+               return 0;
+       if (pder != NULL)
+               *pder = (unsigned char *)nm->bytes->data;
+       if (pderlen != NULL)
+               *pderlen = nm->bytes->length;
+       return 1;
+}
index 26e71ee..6f0f5f4 100644 (file)
@@ -1,4 +1,4 @@
-/* $OpenBSD: x509.h,v 1.31 2018/02/20 17:06:19 jsing Exp $ */
+/* $OpenBSD: x509.h,v 1.32 2018/02/20 17:09:20 jsing Exp $ */
 /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
  * All rights reserved.
  *
@@ -758,6 +758,7 @@ void X509_ALGOR_set_md(X509_ALGOR *alg, const EVP_MD *md);
 int X509_ALGOR_cmp(const X509_ALGOR *a, const X509_ALGOR *b);
 
 X509_NAME *X509_NAME_dup(X509_NAME *xn);
+int X509_NAME_get0_der(X509_NAME *nm, const unsigned char **pder, size_t *pderlen);
 X509_NAME_ENTRY *X509_NAME_ENTRY_dup(X509_NAME_ENTRY *ne);
 
 int            X509_cmp_time(const ASN1_TIME *s, time_t *t);