Annotation of embedaddon/strongswan/src/libcharon/plugins/vici/vici_cert_info.c, revision 1.1

1.1     ! misho       1: /*
        !             2:  * Copyright (C) 2015 Andreas Steffen
        !             3:  * HSR Hochschule fuer Technik Rapperswil
        !             4:  *
        !             5:  * This program is free software; you can redistribute it and/or modify it
        !             6:  * under the terms of the GNU General Public License as published by the
        !             7:  * Free Software Foundation; either version 2 of the License, or (at your
        !             8:  * option) any later version.  See <http://www.fsf.org/copyleft/gpl.txt>.
        !             9:  *
        !            10:  * This program is distributed in the hope that it will be useful, but
        !            11:  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
        !            12:  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
        !            13:  * for more details.
        !            14:  */
        !            15: 
        !            16: #include "vici_cert_info.h"
        !            17: 
        !            18: /**
        !            19:  * Legacy vici certificate types and directories created by swanctl
        !            20:  */
        !            21: typedef struct {
        !            22: 
        !            23:        /** Certificate type string used in legacy vici messages */
        !            24:        char *type_str;
        !            25:        /** Base certificate type */
        !            26:        certificate_type_t type;
        !            27:        /** X.509 flag */
        !            28:        x509_flag_t flag;
        !            29: } cert_type_t;
        !            30: 
        !            31: static cert_type_t cert_types[] = {
        !            32:        { "x509",     CERT_X509,           X509_NONE        },
        !            33:        { "x509ca",   CERT_X509,           X509_CA          },
        !            34:        { "x509ocsp", CERT_X509,           X509_OCSP_SIGNER },
        !            35:        { "x509aa",   CERT_X509,           X509_AA          },
        !            36:        { "x509ac",   CERT_X509_AC,        X509_NONE        },
        !            37:        { "x509crl",  CERT_X509_CRL,       X509_NONE        },
        !            38:        { "pubkey",   CERT_TRUSTED_PUBKEY, X509_NONE        },
        !            39: };
        !            40: 
        !            41: bool vici_cert_info_from_str(char *type_str, certificate_type_t *type,
        !            42:                                                         x509_flag_t *flag)
        !            43: {
        !            44:        int i;
        !            45: 
        !            46:        for (i = 0; i < countof(cert_types); i++)
        !            47:        {
        !            48:                if (strcaseeq(type_str, cert_types[i].type_str))
        !            49:                {
        !            50:                        *type = cert_types[i].type;
        !            51:                        *flag = cert_types[i].flag;
        !            52:                        return TRUE;
        !            53:                }
        !            54:        }
        !            55:        return FALSE;
        !            56: }
        !            57: 

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>