From 4df09fe563383692f2e4a9ccf083b32c92d7e5c5 Mon Sep 17 00:00:00 2001 From: Andreas Steffen Date: Fri, 11 Dec 2015 17:53:40 +0100 Subject: Modified vici_cert_info class for use with load_creds and vici_cred --- src/libcharon/plugins/vici/vici_cert_info.c | 54 ++++++++++++++++------------- src/libcharon/plugins/vici/vici_cert_info.h | 36 ++----------------- 2 files changed, 31 insertions(+), 59 deletions(-) (limited to 'src') diff --git a/src/libcharon/plugins/vici/vici_cert_info.c b/src/libcharon/plugins/vici/vici_cert_info.c index 9afaf05a1..61871e217 100644 --- a/src/libcharon/plugins/vici/vici_cert_info.c +++ b/src/libcharon/plugins/vici/vici_cert_info.c @@ -15,38 +15,42 @@ #include "vici_cert_info.h" -static vici_cert_info_t vici_cert_infos[] = { - { "any", "", CERT_ANY, - X509_NONE }, - { "x509", "X.509 End Entity Certificate", CERT_X509, - X509_NONE }, - { "x509ca", "X.509 CA Certificate", CERT_X509, - X509_CA }, - { "x509aa", "X.509 AA Certificate", CERT_X509, - X509_AA }, - { "x509ocsp", "X.509 OCSP Signer Certificate", CERT_X509, - X509_OCSP_SIGNER }, - { "x509ac", "X.509 Attribute Certificate", CERT_X509_AC, - X509_NONE }, - { "x509crl", "X.509 CRL", CERT_X509_CRL, - X509_NONE }, - { "ocsp", "OCSP Response", CERT_X509_OCSP_RESPONSE, - X509_NONE }, - { "pubkey", "Raw Public Key", CERT_TRUSTED_PUBKEY, - X509_NONE } +/** + * Legacy vici certificate types and directories created by swanctl + */ +typedef struct { + + /** Certificate type string used in legacy vici messages */ + char *type_str; + /** Base certificate type */ + certificate_type_t type; + /** X.509 flag */ + x509_flag_t flag; +} cert_type_t; + +static cert_type_t cert_types[] = { + { "x509", CERT_X509, X509_NONE }, + { "x509ca", CERT_X509, X509_CA }, + { "x509ocsp", CERT_X509, X509_OCSP_SIGNER }, + { "x509aa", CERT_X509, X509_AA }, + { "x509ac", CERT_X509_AC, X509_NONE }, + { "x509crl", CERT_X509_CRL, X509_NONE }, }; -/* See header. */ -vici_cert_info_t* vici_cert_info_retrieve(char *type_str) +bool vici_cert_info_from_str(char *type_str, certificate_type_t *type, + x509_flag_t *flag) { int i; - for (i = 0; i < countof(vici_cert_infos); i++) + for (i = 0; i < countof(cert_types); i++) { - if (strcaseeq(type_str, vici_cert_infos[i].type_str)) + if (strcaseeq(type_str, cert_types[i].type_str)) { - return &vici_cert_infos[i]; + *type = cert_types[i].type; + *flag = cert_types[i].flag; + return TRUE; } } - return NULL; + return FALSE; } + diff --git a/src/libcharon/plugins/vici/vici_cert_info.h b/src/libcharon/plugins/vici/vici_cert_info.h index 31d4b466f..e2a8c4d9f 100644 --- a/src/libcharon/plugins/vici/vici_cert_info.h +++ b/src/libcharon/plugins/vici/vici_cert_info.h @@ -26,39 +26,7 @@ typedef struct vici_cert_info_t vici_cert_info_t; #include #include -/** - * Information on vici certificate types - */ -struct vici_cert_info_t { - - /** - * Certificate type string used in vici messages - */ - char *type_str; - - /** - * Caption describing the certificate type - */ - char *caption; - - /** - * Base certificate type - */ - certificate_type_t type; - - /** - * X.509 flag - */ - x509_flag_t flag; - -}; - -/** - * Retrieve information on a given certificate type - * - * @param type_str Vici certificate type string - * @return Information record or NULL if not found - */ -vici_cert_info_t* vici_cert_info_retrieve(char *type_str); +bool vici_cert_info_from_str(char *type_str, certificate_type_t *type, + x509_flag_t *flag); #endif /** VICI_CERT_INFO_H_ @}*/ -- cgit v1.2.3