Helper to convert purpose into a printable string
authortb <tb@openbsd.org>
Sat, 8 Jun 2024 13:30:35 +0000 (13:30 +0000)
committertb <tb@openbsd.org>
Sat, 8 Jun 2024 13:30:35 +0000 (13:30 +0000)
ok job

usr.sbin/rpki-client/extern.h
usr.sbin/rpki-client/print.c

index 7b431a7..b811b48 100644 (file)
@@ -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 <kristaps@bsd.lv>
  *
@@ -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 *);
index 3fbf355..6738cbc 100644 (file)
@@ -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 <claudio@openbsd.org>
  * Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
@@ -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)
 {