From a6584db8192416a52b97ef05537e403cf2416421 Mon Sep 17 00:00:00 2001 From: job Date: Thu, 22 Feb 2024 12:51:50 +0000 Subject: [PATCH] Add regress for Signed Prefix List objects --- regress/usr.sbin/rpki-client/Makefile.inc | 9 +- .../spl/9X0AhXWTJDl8lJhfOwvnac-42CA.spl | Bin 0 -> 1853 bytes regress/usr.sbin/rpki-client/test-spl.c | 104 ++++++++++++++++++ 3 files changed, 112 insertions(+), 1 deletion(-) create mode 100644 regress/usr.sbin/rpki-client/spl/9X0AhXWTJDl8lJhfOwvnac-42CA.spl create mode 100644 regress/usr.sbin/rpki-client/test-spl.c diff --git a/regress/usr.sbin/rpki-client/Makefile.inc b/regress/usr.sbin/rpki-client/Makefile.inc index d16f78cbc34..80326f25f1e 100644 --- a/regress/usr.sbin/rpki-client/Makefile.inc +++ b/regress/usr.sbin/rpki-client/Makefile.inc @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile.inc,v 1.36 2024/01/08 08:26:38 tb Exp $ +# $OpenBSD: Makefile.inc,v 1.37 2024/02/22 12:51:50 job Exp $ .PATH: ${.CURDIR}/../../../../usr.sbin/rpki-client @@ -13,6 +13,7 @@ PROGS += test-tal PROGS += test-rrdp PROGS += test-aspa PROGS += test-tak +PROGS += test-spl .for p in ${PROGS} REGRESS_TARGETS += run-regress-$p @@ -89,6 +90,12 @@ SRCS_test-tak+= test-tak.c tak.c cms.c x509.c ip.c as.c io.c \ run-regress-test-tak: test-tak ./test-tak -v ${.CURDIR}/../tak/*.tak +SRCS_test-spl+= test-spl.c spl.c cms.c x509.c ip.c as.c io.c \ + encoding.c print.c validate.c cert.c crl.c mft.c json.c \ + constraints-dummy.c repo-dummy.c rfc3779.c +run-regress-test-spl: test-spl + ./test-spl -v ${.CURDIR}/../spl/*.spl + SRCS_test-rrdp+= test-rrdp.c rrdp_delta.c rrdp_notification.c cms.c \ rrdp_snapshot.c rrdp_util.c cert.c as.c mft.c io.c \ encoding.c ip.c validate.c crl.c x509.c \ diff --git a/regress/usr.sbin/rpki-client/spl/9X0AhXWTJDl8lJhfOwvnac-42CA.spl b/regress/usr.sbin/rpki-client/spl/9X0AhXWTJDl8lJhfOwvnac-42CA.spl new file mode 100644 index 0000000000000000000000000000000000000000..0fea07fc0f394f9d1470bffa10c921b9e9b19ed5 GIT binary patch literal 1853 zcmbVMX;4#F6n^);mpl^Sp&}X(6`>+XAvYl*1TC_J&7ws_1rafuvIi21P$`92&^l5o zrUJ@HQbiF(Kt<8wf}oV8LsNHXU22h{P^c9bEYJrPtDR1N^v{{^JLk^%?wot>2i1g- z&X}L$pYzNZ5U5s7%!g{i76ll`7#h+U>vH^o9K%rnvzq9Jug)0WcoJ5$_)dsaQI452MjbM@A8fT-aGg#fw&cRJ`nlVK`_*XHi(s8msDA zU_4TJRL{aO9MiK5#xs9K28QE$)+7w4=~-47PS>+MFr3h{GNCgiib6+>09F8JO`uBjE9QPz~Oa2Q&mz0~3VG zGf_1FNagd+A9r=^)(4xcvpinm@UvZ6@u%l9hKnmQXDqE=Xf4QXbv&14)Z#WbaSAE( zT4#6j%#A(Aud6hb7X(U<&~lviGAX}i4l0)KyG zRKKFk{8)&D`A1gL@hRam9?e?c(eEnhdpy@-L2z?3Dx7zLwqNk{)|IsKDe9@d47Xom z?o4w%&Dil#eLzs#ncbRHx_50pZF|R_5j)kBUH4=!mLUzpJ*J2K@_*Rz>`sH@0%22G zXVq1qZ+E&yrTgu+lJ>2QU1{E|s%)CAPP3?{NHFQi+S+U8h4nqx_?LSN6KJ0-}I z*-Ck$LKU5?P^Pg(KE9qS0z=qoNgI5*E*rVQFrKdpUb)&^DM=CWrAxTN4Ng+I63WJ| zHXDzC;V?|QO1mOw`9y1JRGdQYq*6!}$^?Zf`7Z%VjvX8jda;56O zRg`g1F>!Zbh)bauMow^O`2Pfjq0lobbXCY=QJibs;;8i>Y)nZIOC5P!Z%-#xV%$Hz z8nx>Hk-rqh8i~JJ)YN>mDygfrD6nRYWw2QxWXIgF>@(LK*yHEEG(*?zbtvswZqOH* zTOSR7e&9q{^6$UiD&uDC37fN%m&-&=hGx~UUdY{LyEkMlal>!D%)Mp^r~TBsukk(P zL>PT|-_?S%;*_v2AGH%(S?vxsJ+?E}#NLj0bgsUHooE&x6moP*@_>DTKeRpO8JCgz zAlUb|s+TOk>b>dE*JpoU)wb4LbB6R?yxBZ8jj+t08J&ABBB{n>&M@})zP7L;z1Co` zVadnGE^ZSsdm^514|fKR86Vl5t{>=52}tU#u&{RN8am?ARU&#YP<}V?-p+>mGe>vN zj=$>s4uNvipq$$71C;+}{`(%k>B-tyXz|*v7?fkb<$O~|o+*p~fD6@0eCQ4-6)R$UXPHG+6R=0M4)tk>nSre`Xh$xvnIj`#R z`A-Ji*`nOg#*R&-@nN!hZ{P=&`h^)zPt~L0Tes&mYAiP0$!t1so%i&nuH#_o6SmLX zqhZA->vV*h`9sgdgC)b~PX%~w>2Nmmm!3^vmezt)8?SfQ1RaZGVd`(biZ-?})9?EZkQg)EQ}?T@o`yOdm-I z&tJTQH)NdsJUoqzANbY%2z|P7OVP5n!I8Wpy5hr&W|N!!>NX?y7xkX4YyC1v`&|*= xEg~gvS95Bf=98u`e)e?wcJIcFezHBU%L!#1w7;U0hb}+AG%%%LHPIM4=TBo!mstP+ literal 0 HcmV?d00001 diff --git a/regress/usr.sbin/rpki-client/test-spl.c b/regress/usr.sbin/rpki-client/test-spl.c new file mode 100644 index 00000000000..bb6019d0504 --- /dev/null +++ b/regress/usr.sbin/rpki-client/test-spl.c @@ -0,0 +1,104 @@ +/* $Id: test-spl.c,v 1.1 2024/02/22 12:51:50 job Exp $ */ +/* + * Copyright (c) 2024 Job Snijders + * Copyright (c) 2019 Kristaps Dzonsons + * + * 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 +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include "extern.h" + +int outformats; +int verbose; +int filemode; + +int +main(int argc, char *argv[]) +{ + int c, i, ppem = 0, verb = 0; + X509 *xp = NULL; + struct spl *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 = spl_parse(&xp, argv[i], -1, buf, len)) == NULL) { + free(buf); + break; + } + if (verb) + spl_print(xp, p); + if (ppem) { + if (!PEM_write_X509(stdout, xp)) + errx(1, "PEM_write_X509: unable to write cert"); + } + free(buf); + spl_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; +} + +time_t +get_current_time(void) +{ + return time(NULL); +} -- 2.20.1