From 2eda2404144735f3a57ad645e0c87770411a399b Mon Sep 17 00:00:00 2001 From: job Date: Wed, 2 Nov 2022 12:56:38 +0000 Subject: [PATCH] Add regress for Signed TAL (.tak) files --- regress/usr.sbin/rpki-client/Makefile.inc | 8 +- .../usr.sbin/rpki-client/openssl11/Makefile | 3 +- .../tak/05F53BCE4DAA11EDB9AC0C5B9E174E93.tak | Bin 0 -> 2576 bytes .../tak/42AE70A64DA711EDB37796549E174E93.tak | Bin 0 -> 2122 bytes .../tak/B7C2334E4DA911EDAF862D5A9E174E93.tak | Bin 0 -> 2463 bytes regress/usr.sbin/rpki-client/test-tak.c | 97 ++++++++++++++++++ 6 files changed, 106 insertions(+), 2 deletions(-) create mode 100644 regress/usr.sbin/rpki-client/tak/05F53BCE4DAA11EDB9AC0C5B9E174E93.tak create mode 100644 regress/usr.sbin/rpki-client/tak/42AE70A64DA711EDB37796549E174E93.tak create mode 100644 regress/usr.sbin/rpki-client/tak/B7C2334E4DA911EDAF862D5A9E174E93.tak create mode 100644 regress/usr.sbin/rpki-client/test-tak.c diff --git a/regress/usr.sbin/rpki-client/Makefile.inc b/regress/usr.sbin/rpki-client/Makefile.inc index e35dcf67db5..9a690df0c30 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.25 2022/08/30 22:48:16 job Exp $ +# $OpenBSD: Makefile.inc,v 1.26 2022/11/02 12:56:38 job Exp $ .PATH: ${.CURDIR}/../../../../usr.sbin/rpki-client @@ -11,6 +11,7 @@ PROGS += test-rsc PROGS += test-tal PROGS += test-rrdp PROGS += test-aspa +PROGS += test-tak .for p in ${PROGS} REGRESS_TARGETS += run-regress-$p @@ -65,6 +66,11 @@ SRCS_test-aspa+= test-aspa.c aspa.c cms.c x509.c ip.c as.c io.c log.c \ run-regress-test-aspa: test-aspa ./test-aspa -v ${.CURDIR}/../aspa/*.asa +SRCS_test-tak+= test-tak.c tak.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-tak: test-tak + ./test-tak -v ${.CURDIR}/../tak/*.tak + 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/openssl11/Makefile b/regress/usr.sbin/rpki-client/openssl11/Makefile index 0df73646a24..4080e51512a 100644 --- a/regress/usr.sbin/rpki-client/openssl11/Makefile +++ b/regress/usr.sbin/rpki-client/openssl11/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.12 2022/10/14 17:17:13 tb Exp $ +# $OpenBSD: Makefile,v 1.13 2022/11/02 12:56:38 job Exp $ LDADD += -Wl,-rpath,/usr/local/lib/eopenssl11 -L/usr/local/lib/eopenssl11 CFLAGS += -I${.CURDIR}/ -I/usr/local/include/eopenssl11/ @@ -26,6 +26,7 @@ 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 +SRCS_test-tak = 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/tak/05F53BCE4DAA11EDB9AC0C5B9E174E93.tak b/regress/usr.sbin/rpki-client/tak/05F53BCE4DAA11EDB9AC0C5B9E174E93.tak new file mode 100644 index 0000000000000000000000000000000000000000..71a01eda1c5c08e98a9a11392b60cbae28d7736b GIT binary patch literal 2576 zcmcImc~nzp7SBsw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|ER7E zpFX3uZj8`vRu<;hy8*mh{6DM-u=BK|v)z|;#qIZW#ab4b z0Q5cthg6p?s{&vJTFJcCAD5LCTZD-~8>ql&lu~itf0wp=B1B5ADuoC_W$b)Wll+)> zm3z4VUfnGdr0pt};;$OJ{CvB?75{B-Rl1Y146lKM{5!fg{f`8F5$8De{JVTqxIp}F z=AfGEe#^cvF!pvx5iq2Kq-v~%ENJP`)Kg=Gm6Li#88Hh#-8z~4)HN+4&c`y!;%R}< zWiC;*oEG4inm8}{9)Ei>%Ae>jbgH^cXxBOSs=K)N`k{V&n|Z6nB2q=?xh822rwTZ~ zge;TOUq}aOPP!@Bm7DhUnk00BW9t)*EnetP1V8*q-gIsDN|ltYuejSiv5eUGjjm>C zqfMS!_0J;#qg}U2U36ECJTGEE`~_3hvi$~CbtxTb6AN*wl!}n_PIW2*om6(2-Smn>6oEN04qL<-98L{}e7IiZBA9oC>sz`dW5oj}ERXIgyoa zXqOk^bG_8K$>Xh4L}Jh6{k&XG*iGV;XI1TKIE!t2-mkc}0J)#CWt!O&YTjdDizY^SIcqH=S7ucwc^al>TsYOwtR??Pd zH_l#MTe!2u^g_pDPiK9eW6`d%ExWC(jh|Say2R_S{#(>dS)*v5kX)@2P;tnsom7_F o3EBw49}HvTPn|QW;2n6Wy1;vAQNvp?b>8w|AvRMF1hV7)3A<{>MF0Q* literal 0 HcmV?d00001 diff --git a/regress/usr.sbin/rpki-client/tak/42AE70A64DA711EDB37796549E174E93.tak b/regress/usr.sbin/rpki-client/tak/42AE70A64DA711EDB37796549E174E93.tak new file mode 100644 index 0000000000000000000000000000000000000000..cc4e89f094a18505ae815998457a93c838868e4a GIT binary patch literal 2122 zcmcIl3s6&68qU4B3Bizn7y`N^yksa?$jOTkX-OKP!MQBNF7KZ5VC?*6az$E zV?FUKF2n+!gREfp^w$Ri9VrW#* zZbSv`FeY-0-!^~(>&Rh>^i3(^4{3Y zViS$&#aqeauy`y!k3**m_$!$l4%d^-;tJ>-mVnEoDdcjchghO8{@f7|J`@Q-7!+Cs znWK#J3t$xlp;~Y>eaXqAr*jwD?e4ndolq$}MMB*}6> zwI%=n=*D;MiMA#%IrBnbLni~$+@3`QPbN$3CE+HxOX7jof28FaFKW-Gi<^6gaAk2t zw~?#$Z=AZTp9-Elh`duvO$^?Gsrp#izQtQ~c4D2~g|cG*RJ+iF{^b=Jc|{|bs1}@G zaoXlyMsU)v=_GyVE%w;LiBEwl$TyOGvr+vgLPb7f0LdOn`^-X?yTQG{=JSYIwk zu&^w?K8~1=R=s_M2M^9Qc+0G99GiwGrQO43$pvq|s9vahTv?%gMj2>5H0mkeaK>3y zb4-eI5ACV@O3E0Hb7F^TJQjUAh40hy!#|~d?~pZ23A?qG=lWWEr61#(t3w_5#4qh} zZ}|_9Pnqub2t1o8NE^gr}}Sr*P&ck8ocDyVFCDGsHuzkO4Usw+stmFeVU$h=B-v{yqk<`u`#UHnX?2pS?X1n1KcF zk0Zih`|kGvgh#f4EF&<#)duit`Tr0T7K10?fIkM!Ln)F1tM`XPxY=T{0MWq4#&h^E zZA5Gau>=+Xi@+$OlFf~?OXdlju~m%%2cg8ia)%XG$!jZugKJY{6Zq$Fh-BoAEt|tz#$0-BRBu>xs59A9~s2vKLC!mhG&0=INb2 zkf}SOeg~aad{*$3McCed+;`WLnG+kP*&E|O3je|klb>JmmmMRr(6%}(7cYsl zf|ExR3|`B{v}d8~Y9iKzpA*ZxdVb;m5`?J%6Do}oosJ=H~SfqAl Ti>}=sx_bMam#DOAXsq&|bodm{ literal 0 HcmV?d00001 diff --git a/regress/usr.sbin/rpki-client/tak/B7C2334E4DA911EDAF862D5A9E174E93.tak b/regress/usr.sbin/rpki-client/tak/B7C2334E4DA911EDAF862D5A9E174E93.tak new file mode 100644 index 0000000000000000000000000000000000000000..c1b87b862a4737562ca58e918125a18df245f38b GIT binary patch literal 2463 zcmeHJYgAKL7S6r71Y!u!@USBxfCIh=Cl8*5LIeaQG9X4Cf*2skOTvVZ0&0OP22q=0 zsU1XtP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jid@#z^+k@Ojq|r1=TN(*7xj0 z$PTTiu79#~t|+!9uD@pMo(>xGrR{seSNp2ws)qOk zWr^G015T1c?veXT;o`Pnr)DF1%Y+wa04a%ayAe(=5Z2G!yxMDD_u=*~X7hQzcP}&b z<<|*1IhBnL>5uPE{MgIl>V77={m@mGR!K3BF*_5o#B956{k~{fee_tjRGExAm|vbZD%|oU*0j?w{Yav5eSd(M JnfIsN{{ZEJu>Jr5 literal 0 HcmV?d00001 diff --git a/regress/usr.sbin/rpki-client/test-tak.c b/regress/usr.sbin/rpki-client/test-tak.c new file mode 100644 index 00000000000..ee475129f6d --- /dev/null +++ b/regress/usr.sbin/rpki-client/test-tak.c @@ -0,0 +1,97 @@ +/* $Id: test-tak.c,v 1.1 2022/11/02 12:56:38 job Exp $ */ +/* + * Copyright (c) 2022 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 +main(int argc, char *argv[]) +{ + int c, i, ppem = 0, verb = 0; + X509 *xp = NULL; + struct tak *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 = tak_parse(&xp, argv[i], buf, len)) == NULL) { + free(buf); + break; + } + if (verb) + tak_print(xp, p); + if (ppem) { + if (!PEM_write_X509(stdout, xp)) + errx(1, "PEM_write_X509: unable to write cert"); + } + free(buf); + tak_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; +} -- 2.20.1