Prepare to provide X509_OBJECT_{new,free}()
authortb <tb@openbsd.org>
Sun, 24 Oct 2021 09:27:48 +0000 (09:27 +0000)
committertb <tb@openbsd.org>
Sun, 24 Oct 2021 09:27:48 +0000 (09:27 +0000)
ok beck inoguchi jsing

lib/libcrypto/x509/x509_lu.c
lib/libcrypto/x509/x509_vfy.h

index d567dea..cd1c807 100644 (file)
@@ -1,4 +1,4 @@
-/* $OpenBSD: x509_lu.c,v 1.33 2021/10/21 16:55:25 tb Exp $ */
+/* $OpenBSD: x509_lu.c,v 1.34 2021/10/24 09:27:48 tb Exp $ */
 /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
  * All rights reserved.
  *
@@ -232,9 +232,27 @@ err:
        return NULL;
 }
 
-static void
+X509_OBJECT *
+X509_OBJECT_new(void)
+{
+       X509_OBJECT *ret;
+
+       if ((ret = calloc(1, sizeof(*ret))) == NULL) {
+               X509error(ERR_R_MALLOC_FAILURE);
+               return NULL;
+       }
+
+       ret->type = 0;
+
+       return ret;
+}
+
+void
 X509_OBJECT_free(X509_OBJECT *a)
 {
+       if (a == NULL)
+               return;
+
        X509_OBJECT_free_contents(a);
        free(a);
 }
index ab41426..e80e7de 100644 (file)
@@ -1,4 +1,4 @@
-/* $OpenBSD: x509_vfy.h,v 1.34 2021/10/23 16:18:20 tb Exp $ */
+/* $OpenBSD: x509_vfy.h,v 1.35 2021/10/24 09:27:48 tb Exp $ */
 /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
  * All rights reserved.
  *
@@ -421,6 +421,10 @@ void X509_STORE_CTX_set_depth(X509_STORE_CTX *ctx, int depth);
                                | X509_V_FLAG_INHIBIT_ANY \
                                | X509_V_FLAG_INHIBIT_MAP)
 
+#if defined(LIBRESSL_NEW_API)
+X509_OBJECT *X509_OBJECT_new(void);
+void X509_OBJECT_free(X509_OBJECT *a);
+#endif
 int X509_OBJECT_idx_by_subject(STACK_OF(X509_OBJECT) *h, int type,
             X509_NAME *name);
 X509_OBJECT *X509_OBJECT_retrieve_by_subject(STACK_OF(X509_OBJECT) *h,int type,X509_NAME *name);