From 3e8d4b7d11b7f3c38b1f4a7e16e6df3072397025 Mon Sep 17 00:00:00 2001 From: tb Date: Sat, 8 Jun 2024 13:30:35 +0000 Subject: [PATCH] Helper to convert purpose into a printable string ok job --- usr.sbin/rpki-client/extern.h | 3 ++- usr.sbin/rpki-client/print.c | 21 ++++++++++++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/usr.sbin/rpki-client/extern.h b/usr.sbin/rpki-client/extern.h index 7b431a7d8d2..b811b485e3e 100644 --- a/usr.sbin/rpki-client/extern.h +++ b/usr.sbin/rpki-client/extern.h @@ -1,4 +1,4 @@ -/* $OpenBSD: extern.h,v 1.223 2024/06/08 13:29:54 tb Exp $ */ +/* $OpenBSD: extern.h,v 1.224 2024/06/08 13:30:35 tb Exp $ */ /* * Copyright (c) 2019 Kristaps Dzonsons * @@ -925,6 +925,7 @@ time_t x509_find_expires(time_t, struct auth *, struct crl_tree *); /* printers */ char *nid2str(int); +const char *purpose2str(enum cert_purpose); char *time2str(time_t); void x509_print(const X509 *); void tal_print(const struct tal *); diff --git a/usr.sbin/rpki-client/print.c b/usr.sbin/rpki-client/print.c index 3fbf3553769..6738cbc7a43 100644 --- a/usr.sbin/rpki-client/print.c +++ b/usr.sbin/rpki-client/print.c @@ -1,4 +1,4 @@ -/* $OpenBSD: print.c,v 1.54 2024/06/06 05:57:36 tb Exp $ */ +/* $OpenBSD: print.c,v 1.55 2024/06/08 13:30:35 tb Exp $ */ /* * Copyright (c) 2021 Claudio Jeker * Copyright (c) 2019 Kristaps Dzonsons @@ -65,6 +65,25 @@ nid2str(int nid) return buf; } +const char * +purpose2str(enum cert_purpose purpose) +{ + switch (purpose) { + case CERT_PURPOSE_INVALID: + return "invalid cert"; + case CERT_PURPOSE_TA: + return "TA cert"; + case CERT_PURPOSE_CA: + return "CA cert"; + case CERT_PURPOSE_EE: + return "EE cert"; + case CERT_PURPOSE_BGPSEC_ROUTER: + return "BGPsec Router cert"; + default: + return "unknown certificate purpose"; + } +} + char * time2str(time_t t) { -- 2.20.1