]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
Move handy test functions to testutil
authorNikola Pajkovsky <nikolap@openssl.org>
Thu, 18 Sep 2025 08:42:42 +0000 (10:42 +0200)
committerNeil Horman <nhorman@openssl.org>
Thu, 16 Oct 2025 13:10:54 +0000 (09:10 -0400)
Signed-off-by: Nikola Pajkovsky <nikolap@openssl.org>
Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/28599)

test/crltest.c
test/testutil.h
test/testutil/load.c

index 07ccddd47793a29ce38e018846caed2b901864b8..cb35c15d9c8d3dc310ca054b91f4a18e6e0155b1 100644 (file)
@@ -275,60 +275,6 @@ static X509 *test_leaf = NULL;
 static X509 *test_root2 = NULL;
 static X509 *test_leaf2 = NULL;
 
-/*
- * Glue an array of strings together.  Return a BIO and put the string
- * into |*out| so we can free it.
- */
-static BIO *glue2bio(const char **pem, char **out)
-{
-    size_t s = 0;
-
-    *out = glue_strings(pem, &s);
-    return BIO_new_mem_buf(*out, (int)s);
-}
-
-/*
- * Create a CRL from an array of strings.
- */
-static X509_CRL *CRL_from_strings(const char **pem)
-{
-    X509_CRL *crl;
-    char *p;
-    BIO *b = glue2bio(pem, &p);
-
-    if (b == NULL) {
-        OPENSSL_free(p);
-        return NULL;
-    }
-
-    crl = PEM_read_bio_X509_CRL(b, NULL, NULL, NULL);
-
-    OPENSSL_free(p);
-    BIO_free(b);
-    return crl;
-}
-
-/*
- * Create an X509 from an array of strings.
- */
-static X509 *X509_from_strings(const char **pem)
-{
-    X509 *x;
-    char *p;
-    BIO *b = glue2bio(pem, &p);
-
-    if (b == NULL) {
-        OPENSSL_free(p);
-        return NULL;
-    }
-
-    x = PEM_read_bio_X509(b, NULL, NULL, NULL);
-
-    OPENSSL_free(p);
-    BIO_free(b);
-    return x;
-}
-
 /*
  * Verify |leaf| certificate (chained up to |root|).  |crls| if
  * not NULL, is a list of CRLs to include in the verification. It is
index a262d937195530387a39a741c9b9c1b508cd2965..01535b85f8e7b2f86d1f9057e38a5b27222ed01d 100644 (file)
@@ -652,6 +652,19 @@ X509 *load_cert_der(const unsigned char *bytes, int len);
 STACK_OF(X509) *load_certs_pem(const char *file);
 X509_REQ *load_csr_der(const char *file, OSSL_LIB_CTX *libctx);
 time_t test_asn1_string_to_time_t(const char *asn1_string);
-
 int compare_with_reference_file(BIO *membio, const char *reffile);
+/*
+ * Create an X509 from an array of strings.
+ */
+X509 *X509_from_strings(const char **pem);
+/*
+ * Create a CRL from an array of strings.
+ */
+X509_CRL *CRL_from_strings(const char **pem);
+/*
+ * Glue an array of strings together.  Return a BIO and put the string
+ * into |*out| so we can free it.
+ */
+BIO *glue2bio(const char **pem, char **out);
+
 #endif                          /* OSSL_TESTUTIL_H */
index 982e0a39a9b22fbcbcef7d772de4b8f1e44cb88b..e630c54abd8b559e0e139626fd89d133d532e23c 100644 (file)
@@ -103,3 +103,57 @@ X509_REQ *load_csr_der(const char *file, OSSL_LIB_CTX *libctx)
     BIO_free(bio);
     return csr;
 }
+
+/*
+ * Glue an array of strings together.  Return a BIO and put the string
+ * into |*out| so we can free it.
+ */
+BIO *glue2bio(const char **pem, char **out)
+{
+    size_t s = 0;
+
+    *out = glue_strings(pem, &s);
+    return BIO_new_mem_buf(*out, (int)s);
+}
+
+/*
+ * Create a CRL from an array of strings.
+ */
+X509_CRL *CRL_from_strings(const char **pem)
+{
+    X509_CRL *crl;
+    char *p;
+    BIO *b = glue2bio(pem, &p);
+
+    if (b == NULL) {
+        OPENSSL_free(p);
+        return NULL;
+    }
+
+    crl = PEM_read_bio_X509_CRL(b, NULL, NULL, NULL);
+
+    OPENSSL_free(p);
+    BIO_free(b);
+    return crl;
+}
+
+/*
+ * Create an X509 from an array of strings.
+ */
+X509 *X509_from_strings(const char **pem)
+{
+    X509 *x;
+    char *p;
+    BIO *b = glue2bio(pem, &p);
+
+    if (b == NULL) {
+        OPENSSL_free(p);
+        return NULL;
+    }
+
+    x = PEM_read_bio_X509(b, NULL, NULL, NULL);
+
+    OPENSSL_free(p);
+    BIO_free(b);
+    return x;
+}