From: claudio Date: Sun, 24 Oct 2021 17:54:28 +0000 (+0000) Subject: Use the print.c file which is now shipped in rpki-client to print X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=690212d9ad7c7c7bde5ff962b2930919f7ad9391;p=openbsd Use the print.c file which is now shipped in rpki-client to print the cert, gbr, mft, roa and tal file contents. No real functional change. OK tb@ --- diff --git a/regress/usr.sbin/rpki-client/Makefile.inc b/regress/usr.sbin/rpki-client/Makefile.inc index cb5ef1b9a4f..3645310f4df 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.14 2021/10/11 17:32:27 job Exp $ +# $OpenBSD: Makefile.inc,v 1.15 2021/10/24 17:54:28 claudio Exp $ .PATH: ${.CURDIR}/../../../../usr.sbin/rpki-client @@ -17,7 +17,7 @@ CFLAGS+= -I${.CURDIR}/.. -I${.CURDIR}/../../../../usr.sbin/rpki-client LDADD+= -lcrypto -lutil DPADD+= ${LIBCRYPTO} ${LIBUTIL} -SRCS_test-ip= test-ip.c ip.c io.c +SRCS_test-ip= test-ip.c ip.c io.c encoding.c print.c run-regress-test-ip: test-ip ./test-ip @@ -26,24 +26,27 @@ TALARGS += ta/apnic-rpki-root-iana-origin.cer tal/apnic.tal TALARGS += ta/ripe-ncc-ta.cer tal/ripe.tal SRCS_test-cert+= test-cert.c cert.c cms.c x509.c ip.c as.c io.c \ - log.c tal.c validate.c encoding.c + log.c tal.c validate.c encoding.c print.c run-regress-test-cert: test-cert ./test-cert -v ${.CURDIR}/../cer/*.cer ./test-cert -vt ${TALARGS:S,,${.CURDIR}/../&,} -SRCS_test-mft+= test-mft.c mft.c cms.c x509.c io.c log.c validate.c \ - encoding.c dummy.c +SRCS_test-mft+= test-mft.c mft.c cms.c x509.c ip.c io.c log.c validate.c \ + encoding.c print.c dummy.c run-regress-test-mft: test-mft ./test-mft -v ${.CURDIR}/../mft/*.mft -SRCS_test-roa+= test-roa.c roa.c cms.c x509.c ip.c as.c io.c log.c encoding.c +SRCS_test-roa+= test-roa.c roa.c cms.c x509.c ip.c as.c io.c log.c \ + encoding.c print.c run-regress-test-roa: test-roa ./test-roa -v ${.CURDIR}/../roa/*.roa -SRCS_test-gbr+= test-gbr.c gbr.c cms.c x509.c io.c log.c encoding.c +SRCS_test-gbr+= test-gbr.c gbr.c cms.c x509.c ip.c io.c log.c \ + encoding.c print.c run-regress-test-gbr: test-gbr ./test-gbr -v ${.CURDIR}/../gbr/*.gbr -SRCS_test-tal+= test-tal.c tal.c io.c log.c validate.c encoding.c dummy.c +SRCS_test-tal+= test-tal.c tal.c ip.c io.c log.c validate.c \ + encoding.c print.c dummy.c run-regress-test-tal: test-tal ./test-tal -v ${.CURDIR}/../tal/*.tal diff --git a/regress/usr.sbin/rpki-client/dummy.c b/regress/usr.sbin/rpki-client/dummy.c index 1d5f98ea7ac..5caf1ebd944 100644 --- a/regress/usr.sbin/rpki-client/dummy.c +++ b/regress/usr.sbin/rpki-client/dummy.c @@ -17,18 +17,3 @@ as_check_covered(uint32_t min, uint32_t max, { return -1; } - -int -ip_addr_check_covered(enum afi afi, - const unsigned char *min, const unsigned char *max, - const struct cert_ip *ips, size_t ipsz) -{ - return -1; -} - -void -ip_addr_print(const struct ip_addr *addr, - enum afi afi, char *buf, size_t bufsz) -{ -} - diff --git a/regress/usr.sbin/rpki-client/test-cert.c b/regress/usr.sbin/rpki-client/test-cert.c index 9c80df6d587..1a56eedd4e3 100644 --- a/regress/usr.sbin/rpki-client/test-cert.c +++ b/regress/usr.sbin/rpki-client/test-cert.c @@ -1,4 +1,4 @@ -/* $Id: test-cert.c,v 1.13 2021/10/13 06:56:07 claudio Exp $ */ +/* $Id: test-cert.c,v 1.14 2021/10/24 17:54:28 claudio Exp $ */ /* * Copyright (c) 2019 Kristaps Dzonsons * @@ -32,75 +32,8 @@ #include "extern.h" -#include "test-common.c" - int verbose; -static void -cert_print(const struct cert *p) -{ - size_t i; - char buf1[64], buf2[64]; - int sockt; - char tbuf[21]; - - assert(p != NULL); - - printf("Subject key identifier: %s\n", pretty_key_id(p->ski)); - if (p->aki != NULL) - printf("Authority key identifier: %s\n", pretty_key_id(p->aki)); - if (p->aia != NULL) - printf("Authority info access: %s\n", p->aia); - if (p->mft != NULL) - printf("Manifest: %s\n", p->mft); - if (p->repo != NULL) - printf("caRepository: %s\n", p->repo); - if (p->notify != NULL) - printf("Notify URL: %s\n", p->notify); - if (p->pubkey != NULL) - printf("BGPsec P-256 ECDSA public key: %s\n", p->pubkey); - strftime(tbuf, sizeof(tbuf), "%FT%TZ", gmtime(&p->expires)); - printf("Valid until: %s\n", tbuf); - - printf("Subordinate Resources:\n"); - - for (i = 0; i < p->asz; i++) - switch (p->as[i].type) { - case CERT_AS_ID: - printf("%5zu: AS: %" - PRIu32 "\n", i + 1, p->as[i].id); - break; - case CERT_AS_INHERIT: - printf("%5zu: AS: inherit\n", i + 1); - break; - case CERT_AS_RANGE: - printf("%5zu: AS: %" - PRIu32 "--%" PRIu32 "\n", i + 1, - p->as[i].range.min, p->as[i].range.max); - break; - } - - for (i = 0; i < p->ipsz; i++) - switch (p->ips[i].type) { - case CERT_IP_INHERIT: - printf("%5zu: IP: inherit\n", i + 1); - break; - case CERT_IP_ADDR: - ip_addr_print(&p->ips[i].ip, - p->ips[i].afi, buf1, sizeof(buf1)); - printf("%5zu: IP: %s\n", i + 1, buf1); - break; - case CERT_IP_RANGE: - sockt = (p->ips[i].afi == AFI_IPV4) ? - AF_INET : AF_INET6; - inet_ntop(sockt, p->ips[i].min, buf1, sizeof(buf1)); - inet_ntop(sockt, p->ips[i].max, buf2, sizeof(buf2)); - printf("%5zu: IP: %s--%s\n", i + 1, buf1, buf2); - break; - } - -} - int main(int argc, char *argv[]) { diff --git a/regress/usr.sbin/rpki-client/test-common.c b/regress/usr.sbin/rpki-client/test-common.c deleted file mode 100644 index 8e08fc2efe4..00000000000 --- a/regress/usr.sbin/rpki-client/test-common.c +++ /dev/null @@ -1,33 +0,0 @@ -/* $OpenBSD: test-common.c,v 1.1 2021/03/29 15:47:34 claudio Exp $ */ -/* - * Copyright (c) 2021 Claudio Jeker - * - * 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. - */ - -const char * -pretty_key_id(char *hex) -{ - static char buf[128]; /* bigger than SHA_DIGEST_LENGTH * 3 */ - size_t i; - - for (i = 0; i < sizeof(buf) && *hex != '\0'; i++) { - if (i % 3 == 2 && *hex != '\0') - buf[i] = ':'; - else - buf[i] = *hex++; - } - if (i == sizeof(buf)) - memcpy(buf + sizeof(buf) - 4, "...", 4); - return buf; -} diff --git a/regress/usr.sbin/rpki-client/test-gbr.c b/regress/usr.sbin/rpki-client/test-gbr.c index a97e6ad8a7d..cca4977384b 100644 --- a/regress/usr.sbin/rpki-client/test-gbr.c +++ b/regress/usr.sbin/rpki-client/test-gbr.c @@ -1,4 +1,4 @@ -/* $Id: test-gbr.c,v 1.3 2021/03/29 15:47:34 claudio Exp $ */ +/* $Id: test-gbr.c,v 1.4 2021/10/24 17:54:28 claudio Exp $ */ /* * Copyright (c) 2019 Kristaps Dzonsons * @@ -30,24 +30,8 @@ #include "extern.h" -#include "test-common.c" - int verbose; -static void -gbr_print(const struct gbr *p) -{ - char buf[128]; - size_t i; - - assert(p != NULL); - - printf("Subject key identifier: %s\n", pretty_key_id(p->ski)); - printf("Authority key identifier: %s\n", pretty_key_id(p->aki)); - printf("Authority info access: %s\n", p->aia); - printf("vcard:\n%s", p->vcard); -} - int main(int argc, char *argv[]) { diff --git a/regress/usr.sbin/rpki-client/test-mft.c b/regress/usr.sbin/rpki-client/test-mft.c index 295f73ff509..7d0343907f8 100644 --- a/regress/usr.sbin/rpki-client/test-mft.c +++ b/regress/usr.sbin/rpki-client/test-mft.c @@ -1,4 +1,4 @@ -/* $Id: test-mft.c,v 1.15 2021/10/09 18:43:49 deraadt Exp $ */ +/* $Id: test-mft.c,v 1.16 2021/10/24 17:54:28 claudio Exp $ */ /* * Copyright (c) 2019 Kristaps Dzonsons * @@ -33,31 +33,8 @@ #include "extern.h" -#include "test-common.c" - int verbose; -static void -mft_print(const struct mft *p) -{ - size_t i; - char hash[256]; - - assert(p != NULL); - - printf("Subject key identifier: %s\n", pretty_key_id(p->ski)); - printf("Authority key identifier: %s\n", pretty_key_id(p->aki)); - printf("Authority info access: %s\n", p->aia); - printf("Manifest Number: %s\n", p->seqnum); - for (i = 0; i < p->filesz; i++) { - b64_ntop(p->files[i].hash, sizeof(p->files[i].hash), - hash, sizeof(hash)); - printf("%5zu: %s\n", i + 1, p->files[i].file); - printf("\thash %s\n", hash); - } -} - - int main(int argc, char *argv[]) { diff --git a/regress/usr.sbin/rpki-client/test-roa.c b/regress/usr.sbin/rpki-client/test-roa.c index e079e6426e1..4824e028d80 100644 --- a/regress/usr.sbin/rpki-client/test-roa.c +++ b/regress/usr.sbin/rpki-client/test-roa.c @@ -1,4 +1,4 @@ -/* $Id: test-roa.c,v 1.12 2021/10/07 10:34:39 claudio Exp $ */ +/* $Id: test-roa.c,v 1.13 2021/10/24 17:54:28 claudio Exp $ */ /* * Copyright (c) 2019 Kristaps Dzonsons * @@ -30,34 +30,8 @@ #include "extern.h" -#include "test-common.c" - int verbose; -static void -roa_print(const struct roa *p) -{ - char buf[128]; - size_t i; - char tbuf[21]; - - assert(p != NULL); - - printf("Subject key identifier: %s\n", pretty_key_id(p->ski)); - printf("Authority key identifier: %s\n", pretty_key_id(p->aki)); - printf("Authority info access: %s\n", p->aia); - strftime(tbuf, sizeof(tbuf), "%FT%TZ", gmtime(&p->expires)); - printf("ROA valid until: %s\n", tbuf); - - printf("asID: %" PRIu32 "\n", p->asid); - for (i = 0; i < p->ipsz; i++) { - ip_addr_print(&p->ips[i].addr, - p->ips[i].afi, buf, sizeof(buf)); - printf("%5zu: %s (max: %zu)\n", i + 1, - buf, p->ips[i].maxlength); - } -} - int main(int argc, char *argv[]) { diff --git a/regress/usr.sbin/rpki-client/test-tal.c b/regress/usr.sbin/rpki-client/test-tal.c index 2fa7255baab..dedd329f08a 100644 --- a/regress/usr.sbin/rpki-client/test-tal.c +++ b/regress/usr.sbin/rpki-client/test-tal.c @@ -1,4 +1,4 @@ -/* $Id: test-tal.c,v 1.6 2020/11/09 16:13:02 tb Exp $ */ +/* $Id: test-tal.c,v 1.7 2021/10/24 17:54:28 claudio Exp $ */ /* * Copyright (c) 2019 Kristaps Dzonsons * @@ -31,17 +31,6 @@ int verbose; -static void -tal_print(const struct tal *p) -{ - size_t i; - - assert(p != NULL); - - for (i = 0; i < p->urisz; i++) - printf("%5zu: URI: %s\n", i + 1, p->uri[i]); -} - int main(int argc, char *argv[]) {