Add ASPA regress bits
authorjob <job@openbsd.org>
Tue, 30 Aug 2022 22:48:16 +0000 (22:48 +0000)
committerjob <job@openbsd.org>
Tue, 30 Aug 2022 22:48:16 +0000 (22:48 +0000)
regress/usr.sbin/rpki-client/Makefile.inc
regress/usr.sbin/rpki-client/aspa/2338bd30cba1ff30fe3cf930824f39b45569d458de356729cb0121400ee3616a.asa [new file with mode: 0644]
regress/usr.sbin/rpki-client/aspa/5c67c85c9fbdf4daea0034480c2c3da10ef241738cb4f5a16e6cf60ec812713d.asa [new file with mode: 0644]
regress/usr.sbin/rpki-client/aspa/63bbc4571294a06f5e7533166179bafcb0252e0484708e6d45924e1e479c8636.asa [new file with mode: 0644]
regress/usr.sbin/rpki-client/aspa/c27f17d94c8a2f9e4c6d07e69f58c33c48c28c77ff602040e02bb19f6ffd3dfd.asa [new file with mode: 0644]
regress/usr.sbin/rpki-client/openssl11/Makefile
regress/usr.sbin/rpki-client/test-aspa.c [new file with mode: 0644]

index b69fb7d..e35dcf6 100644 (file)
@@ -1,4 +1,4 @@
-# $OpenBSD: Makefile.inc,v 1.24 2022/05/09 17:20:25 job Exp $
+# $OpenBSD: Makefile.inc,v 1.25 2022/08/30 22:48:16 job Exp $
 
 .PATH:         ${.CURDIR}/../../../../usr.sbin/rpki-client
 
@@ -10,6 +10,7 @@ PROGS += test-roa
 PROGS += test-rsc
 PROGS += test-tal
 PROGS += test-rrdp
+PROGS += test-aspa
 
 .for p in ${PROGS}
 REGRESS_TARGETS += run-regress-$p
@@ -59,6 +60,11 @@ SRCS_test-tal+=      test-tal.c tal.c ip.c io.c log.c validate.c \
 run-regress-test-tal: test-tal
        ./test-tal -v ${.CURDIR}/../tal/*.tal
 
+SRCS_test-aspa+=       test-aspa.c aspa.c cms.c x509.c ip.c as.c io.c log.c \
+               encoding.c print.c validate.c cert.c mft.c
+run-regress-test-aspa: test-aspa
+       ./test-aspa -v ${.CURDIR}/../aspa/*.asa
+
 SRCS_test-rrdp+=       test-rrdp.c rrdp_delta.c rrdp_notification.c \
                        rrdp_snapshot.c rrdp_util.c \
                        log.c encoding.c ip.c validate.c dummy.c x509.c
diff --git a/regress/usr.sbin/rpki-client/aspa/2338bd30cba1ff30fe3cf930824f39b45569d458de356729cb0121400ee3616a.asa b/regress/usr.sbin/rpki-client/aspa/2338bd30cba1ff30fe3cf930824f39b45569d458de356729cb0121400ee3616a.asa
new file mode 100644 (file)
index 0000000..f5754d6
Binary files /dev/null and b/regress/usr.sbin/rpki-client/aspa/2338bd30cba1ff30fe3cf930824f39b45569d458de356729cb0121400ee3616a.asa differ
diff --git a/regress/usr.sbin/rpki-client/aspa/5c67c85c9fbdf4daea0034480c2c3da10ef241738cb4f5a16e6cf60ec812713d.asa b/regress/usr.sbin/rpki-client/aspa/5c67c85c9fbdf4daea0034480c2c3da10ef241738cb4f5a16e6cf60ec812713d.asa
new file mode 100644 (file)
index 0000000..f08316f
Binary files /dev/null and b/regress/usr.sbin/rpki-client/aspa/5c67c85c9fbdf4daea0034480c2c3da10ef241738cb4f5a16e6cf60ec812713d.asa differ
diff --git a/regress/usr.sbin/rpki-client/aspa/63bbc4571294a06f5e7533166179bafcb0252e0484708e6d45924e1e479c8636.asa b/regress/usr.sbin/rpki-client/aspa/63bbc4571294a06f5e7533166179bafcb0252e0484708e6d45924e1e479c8636.asa
new file mode 100644 (file)
index 0000000..9617936
Binary files /dev/null and b/regress/usr.sbin/rpki-client/aspa/63bbc4571294a06f5e7533166179bafcb0252e0484708e6d45924e1e479c8636.asa differ
diff --git a/regress/usr.sbin/rpki-client/aspa/c27f17d94c8a2f9e4c6d07e69f58c33c48c28c77ff602040e02bb19f6ffd3dfd.asa b/regress/usr.sbin/rpki-client/aspa/c27f17d94c8a2f9e4c6d07e69f58c33c48c28c77ff602040e02bb19f6ffd3dfd.asa
new file mode 100644 (file)
index 0000000..cbd61d5
Binary files /dev/null and b/regress/usr.sbin/rpki-client/aspa/c27f17d94c8a2f9e4c6d07e69f58c33c48c28c77ff602040e02bb19f6ffd3dfd.asa differ
index 12c6926..f9a0eae 100644 (file)
@@ -29,6 +29,7 @@ SRCS_test-tal =               a_time_tm_gen.c o_time.c bs_ber.c bs_cbb.c bs_cbs.c
 SRCS_test-bgpsec =     a_time_tm_gen.c o_time.c bs_ber.c bs_cbb.c bs_cbs.c
 SRCS_test-rrdp =       a_time_tm_gen.c o_time.c bs_ber.c bs_cbb.c bs_cbs.c
 SRCS_test-rsc =                a_time_tm_gen.c o_time.c bs_ber.c bs_cbb.c bs_cbs.c
+SRCS_test-aspa =       a_time_tm_gen.c o_time.c bs_ber.c bs_cbb.c bs_cbs.c
 CFLAGS +=      -I${.CURDIR}/../../../../lib/libcrypto/
 CFLAGS +=      -I${.CURDIR}/../../../../lib/libcrypto/bytestring
 
diff --git a/regress/usr.sbin/rpki-client/test-aspa.c b/regress/usr.sbin/rpki-client/test-aspa.c
new file mode 100644 (file)
index 0000000..fa95eaa
--- /dev/null
@@ -0,0 +1,97 @@
+/*     $Id: test-aspa.c,v 1.1 2022/08/30 22:48:16 job Exp $ */
+/*
+ * Copyright (c) 2022 Job Snijders <job@fastly.com>
+ * Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <assert.h>
+#include <err.h>
+#include <inttypes.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include <openssl/err.h>
+#include <openssl/evp.h>
+#include <openssl/pem.h>
+#include <openssl/x509v3.h>
+
+#include "extern.h"
+
+int outformats;
+int verbose;
+
+int
+main(int argc, char *argv[])
+{
+       int              c, i, ppem = 0, verb = 0;
+       X509            *xp = NULL;
+       struct aspa     *p;
+       unsigned char   *buf;
+       size_t           len;
+
+       ERR_load_crypto_strings();
+       OpenSSL_add_all_ciphers();
+       OpenSSL_add_all_digests();
+       x509_init_oid();
+
+       while ((c = getopt(argc, argv, "pv")) != -1)
+               switch (c) {
+               case 'p':
+                       if (ppem)
+                               break;
+                       ppem = 1;
+                       break;
+               case 'v':
+                       verb++;
+                       break;
+               default:
+                       errx(1, "bad argument %c", c);
+               }
+
+       argv += optind;
+       argc -= optind;
+
+       if (argc == 0)
+               errx(1, "argument missing");
+
+       for (i = 0; i < argc; i++) {
+               buf = load_file(argv[i], &len);
+               if ((p = aspa_parse(&xp, argv[i], buf, len)) == NULL) {
+                       free(buf);
+                       break;
+               }
+               if (verb)
+                       aspa_print(xp, p);
+               if (ppem) {
+                       if (!PEM_write_X509(stdout, xp))
+                               errx(1, "PEM_write_X509: unable to write cert");
+               }
+               free(buf);
+               aspa_free(p);
+               X509_free(xp);
+       }
+
+       EVP_cleanup();
+       CRYPTO_cleanup_all_ex_data();
+       ERR_free_strings();
+
+       if (i < argc)
+               errx(1, "test failed for %s", argv[i]);
+
+       printf("OK\n");
+       return 0;
+}