diff options
-rw-r--r-- | regress/usr.sbin/rpki-client/Makefile.inc | 7 | ||||
-rw-r--r-- | regress/usr.sbin/rpki-client/gbr/LMrbiOIR4bDInnBEXLsY5MZ1q1U.gbr | bin | 0 -> 1923 bytes | |||
-rw-r--r-- | regress/usr.sbin/rpki-client/test-gbr.c | 107 |
3 files changed, 113 insertions, 1 deletions
diff --git a/regress/usr.sbin/rpki-client/Makefile.inc b/regress/usr.sbin/rpki-client/Makefile.inc index 4c11a7e63d7..2762bca2810 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.3 2020/11/09 16:05:10 tb Exp $ +# $OpenBSD: Makefile.inc,v 1.4 2020/12/09 11:30:44 claudio Exp $ .PATH: ${.CURDIR}/../../../../usr.sbin/rpki-client @@ -6,6 +6,7 @@ PROGS += test-ip PROGS += test-cert PROGS += test-mft PROGS += test-roa +PROGS += test-gbr PROGS += test-tal .for p in ${PROGS} @@ -48,6 +49,10 @@ SRCS_test-roa= test-roa.c roa.c cms.c x509.c ip.c as.c io.c log.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 +run-regress-test-gbr: test-gbr + ./test-gbr -v ${.CURDIR}/../gbr/*.gbr + SRCS_test-tal= test-tal.c tal.c rsync.c io.c log.c run-regress-test-tal: test-tal ./test-tal -v ${.CURDIR}/../tal/*.tal diff --git a/regress/usr.sbin/rpki-client/gbr/LMrbiOIR4bDInnBEXLsY5MZ1q1U.gbr b/regress/usr.sbin/rpki-client/gbr/LMrbiOIR4bDInnBEXLsY5MZ1q1U.gbr Binary files differnew file mode 100644 index 00000000000..0ecf27c5401 --- /dev/null +++ b/regress/usr.sbin/rpki-client/gbr/LMrbiOIR4bDInnBEXLsY5MZ1q1U.gbr diff --git a/regress/usr.sbin/rpki-client/test-gbr.c b/regress/usr.sbin/rpki-client/test-gbr.c new file mode 100644 index 00000000000..1835326bc05 --- /dev/null +++ b/regress/usr.sbin/rpki-client/test-gbr.c @@ -0,0 +1,107 @@ +/* $Id: test-gbr.c,v 1.1 2020/12/09 11:30:44 claudio Exp $ */ +/* + * 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 verbose; + +static void +gbr_print(const struct gbr *p) +{ + char buf[128]; + size_t i; + + assert(p != NULL); + + printf("Subject key identifier: %s\n", p->ski); + printf("Authority key identifier: %s\n", p->aki); + printf("vcard:\n%s", p->vcard); +} + +int +main(int argc, char *argv[]) +{ + int c, i, ppem = 0, verb = 0; + BIO *bio_out = NULL; + X509 *xp = NULL; + struct gbr *p; + + + ERR_load_crypto_strings(); + OpenSSL_add_all_ciphers(); + OpenSSL_add_all_digests(); + + while ((c = getopt(argc, argv, "pv")) != -1) + switch (c) { + case 'p': + if (ppem) + break; + ppem = 1; + if ((bio_out = BIO_new_fp(stdout, BIO_NOCLOSE)) == NULL) + errx(1, "BIO_new_fp"); + 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++) { + if ((p = gbr_parse(&xp, argv[i])) == NULL) + break; + if (verb) + gbr_print(p); + if (ppem) { + if (!PEM_write_bio_X509(bio_out, xp)) + errx(1, + "PEM_write_bio_X509: unable to write cert"); + } + gbr_free(p); + X509_free(xp); + } + + BIO_free(bio_out); + 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; +} |