Paul Bakker | c70b982 | 2013-04-07 22:00:46 +0200 | [diff] [blame] | 1 | /** |
| 2 | * \file oid.h |
| 3 | * |
| 4 | * \brief Object Identifier (OID) database |
| 5 | * |
| 6 | * Copyright (C) 2006-2013, Brainspark B.V. |
| 7 | * |
| 8 | * This file is part of PolarSSL (http://www.polarssl.org) |
| 9 | * Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org> |
| 10 | * |
| 11 | * All rights reserved. |
| 12 | * |
| 13 | * This program is free software; you can redistribute it and/or modify |
| 14 | * it under the terms of the GNU General Public License as published by |
| 15 | * the Free Software Foundation; either version 2 of the License, or |
| 16 | * (at your option) any later version. |
| 17 | * |
| 18 | * This program is distributed in the hope that it will be useful, |
| 19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 21 | * GNU General Public License for more details. |
| 22 | * |
| 23 | * You should have received a copy of the GNU General Public License along |
| 24 | * with this program; if not, write to the Free Software Foundation, Inc., |
| 25 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 26 | */ |
| 27 | #ifndef POLARSSL_OID_H |
| 28 | #define POLARSSL_OID_H |
| 29 | |
| 30 | #include <string.h> |
| 31 | #include "asn1.h" |
Paul Bakker | 9b5e885 | 2013-06-28 16:12:50 +0200 | [diff] [blame] | 32 | #include "cipher.h" |
Paul Bakker | c70b982 | 2013-04-07 22:00:46 +0200 | [diff] [blame] | 33 | #include "md.h" |
Paul Bakker | ed27a04 | 2013-04-18 22:46:23 +0200 | [diff] [blame] | 34 | #include "pk.h" |
Paul Bakker | c70b982 | 2013-04-07 22:00:46 +0200 | [diff] [blame] | 35 | #include "x509.h" |
| 36 | |
| 37 | #define POLARSSL_ERR_OID_NOT_FOUND -0x002E /**< OID is not found. */ |
| 38 | |
| 39 | /* |
| 40 | * Top level OID tuples |
| 41 | */ |
| 42 | #define OID_ISO_MEMBER_BODIES "\x2a" /* {iso(1) member-body(2)} */ |
| 43 | #define OID_ISO_IDENTIFIED_ORG "\x2b" /* {iso(1) identified-organization(3)} */ |
| 44 | #define OID_ISO_CCITT_DS "\x55" /* {joint-iso-ccitt(2) ds(5)} */ |
| 45 | #define OID_ISO_ITU_COUNTRY "\x60" /* {joint-iso-itu-t(2) country(16)} */ |
| 46 | |
| 47 | /* |
| 48 | * ISO Member bodies OID parts |
| 49 | */ |
| 50 | #define OID_COUNTRY_US "\x86\x48" /* {us(840)} */ |
| 51 | #define OID_ORG_RSA_DATA_SECURITY "\x86\xf7\x0d" /* {rsadsi(113549)} */ |
| 52 | #define OID_RSA_COMPANY OID_ISO_MEMBER_BODIES OID_COUNTRY_US \ |
| 53 | OID_ORG_RSA_DATA_SECURITY /* {iso(1) member-body(2) us(840) rsadsi(113549)} */ |
| 54 | |
| 55 | /* |
| 56 | * ISO Identified organization OID parts |
| 57 | */ |
| 58 | #define OID_ORG_DOD "\x06" /* {dod(6)} */ |
Paul Bakker | 9b5e885 | 2013-06-28 16:12:50 +0200 | [diff] [blame] | 59 | #define OID_ORG_OIW "\x0e" |
| 60 | #define OID_OIW_SECSIG OID_ORG_OIW "\x03" |
| 61 | #define OID_OIW_SECSIG_ALG OID_OIW_SECSIG "\x02" |
| 62 | #define OID_OIW_SECSIG_SHA1 OID_OIW_SECSIG_ALG "\x1a" |
Paul Bakker | c70b982 | 2013-04-07 22:00:46 +0200 | [diff] [blame] | 63 | |
| 64 | /* |
| 65 | * ISO ITU OID parts |
| 66 | */ |
| 67 | #define OID_ORGANIZATION "\x01" /* {organization(1)} */ |
| 68 | #define OID_ISO_ITU_US_ORG OID_ISO_ITU_COUNTRY OID_COUNTRY_US OID_ORGANIZATION /* {joint-iso-itu-t(2) country(16) us(840) organization(1)} */ |
| 69 | |
| 70 | #define OID_ORG_GOV "\x65" /* {gov(101)} */ |
| 71 | #define OID_GOV OID_ISO_ITU_US_ORG OID_ORG_GOV /* {joint-iso-itu-t(2) country(16) us(840) organization(1) gov(101)} */ |
| 72 | |
| 73 | #define OID_ORG_NETSCAPE "\x86\xF8\x42" /* {netscape(113730)} */ |
| 74 | #define OID_NETSCAPE OID_ISO_ITU_US_ORG OID_ORG_NETSCAPE /* Netscape OID {joint-iso-itu-t(2) country(16) us(840) organization(1) netscape(113730)} */ |
| 75 | |
| 76 | /* ISO arc for standard certificate and CRL extensions */ |
| 77 | #define OID_ID_CE OID_ISO_CCITT_DS "\x1D" /**< id-ce OBJECT IDENTIFIER ::= {joint-iso-ccitt(2) ds(5) 29} */ |
| 78 | |
| 79 | /** |
| 80 | * Private Internet Extensions |
| 81 | * { iso(1) identified-organization(3) dod(6) internet(1) |
| 82 | * security(5) mechanisms(5) pkix(7) } |
| 83 | */ |
| 84 | #define OID_PKIX OID_ISO_IDENTIFIED_ORG OID_ORG_DOD "\x01\x05\x05\x07" |
| 85 | |
| 86 | /* |
| 87 | * Arc for standard naming attributes |
| 88 | */ |
| 89 | #define OID_AT OID_ISO_CCITT_DS "\x04" /**< id-at OBJECT IDENTIFIER ::= {joint-iso-ccitt(2) ds(5) 4} */ |
| 90 | #define OID_AT_CN OID_AT "\x03" /**< id-at-commonName AttributeType:= {id-at 3} */ |
| 91 | #define OID_AT_COUNTRY OID_AT "\x06" /**< id-at-countryName AttributeType:= {id-at 6} */ |
| 92 | #define OID_AT_LOCALITY OID_AT "\x07" /**< id-at-locality AttributeType:= {id-at 7} */ |
| 93 | #define OID_AT_STATE OID_AT "\x08" /**< id-at-state AttributeType:= {id-at 8} */ |
| 94 | #define OID_AT_ORGANIZATION OID_AT "\x0A" /**< id-at-organizationName AttributeType:= {id-at 10} */ |
| 95 | #define OID_AT_ORG_UNIT OID_AT "\x0B" /**< id-at-organizationalUnitName AttributeType:= {id-at 11} */ |
| 96 | |
| 97 | /* |
| 98 | * OIDs for standard certificate extensions |
| 99 | */ |
| 100 | #define OID_AUTHORITY_KEY_IDENTIFIER OID_ID_CE "\x23" /**< id-ce-authorityKeyIdentifier OBJECT IDENTIFIER ::= { id-ce 35 } */ |
| 101 | #define OID_SUBJECT_KEY_IDENTIFIER OID_ID_CE "\x0E" /**< id-ce-subjectKeyIdentifier OBJECT IDENTIFIER ::= { id-ce 14 } */ |
| 102 | #define OID_KEY_USAGE OID_ID_CE "\x0F" /**< id-ce-keyUsage OBJECT IDENTIFIER ::= { id-ce 15 } */ |
| 103 | #define OID_CERTIFICATE_POLICIES OID_ID_CE "\x20" /**< id-ce-certificatePolicies OBJECT IDENTIFIER ::= { id-ce 32 } */ |
| 104 | #define OID_POLICY_MAPPINGS OID_ID_CE "\x21" /**< id-ce-policyMappings OBJECT IDENTIFIER ::= { id-ce 33 } */ |
| 105 | #define OID_SUBJECT_ALT_NAME OID_ID_CE "\x11" /**< id-ce-subjectAltName OBJECT IDENTIFIER ::= { id-ce 17 } */ |
| 106 | #define OID_ISSUER_ALT_NAME OID_ID_CE "\x12" /**< id-ce-issuerAltName OBJECT IDENTIFIER ::= { id-ce 18 } */ |
| 107 | #define OID_SUBJECT_DIRECTORY_ATTRS OID_ID_CE "\x09" /**< id-ce-subjectDirectoryAttributes OBJECT IDENTIFIER ::= { id-ce 9 } */ |
| 108 | #define OID_BASIC_CONSTRAINTS OID_ID_CE "\x13" /**< id-ce-basicConstraints OBJECT IDENTIFIER ::= { id-ce 19 } */ |
| 109 | #define OID_NAME_CONSTRAINTS OID_ID_CE "\x1E" /**< id-ce-nameConstraints OBJECT IDENTIFIER ::= { id-ce 30 } */ |
| 110 | #define OID_POLICY_CONSTRAINTS OID_ID_CE "\x24" /**< id-ce-policyConstraints OBJECT IDENTIFIER ::= { id-ce 36 } */ |
| 111 | #define OID_EXTENDED_KEY_USAGE OID_ID_CE "\x25" /**< id-ce-extKeyUsage OBJECT IDENTIFIER ::= { id-ce 37 } */ |
| 112 | #define OID_CRL_DISTRIBUTION_POINTS OID_ID_CE "\x1F" /**< id-ce-cRLDistributionPoints OBJECT IDENTIFIER ::= { id-ce 31 } */ |
| 113 | #define OID_INIHIBIT_ANYPOLICY OID_ID_CE "\x36" /**< id-ce-inhibitAnyPolicy OBJECT IDENTIFIER ::= { id-ce 54 } */ |
| 114 | #define OID_FRESHEST_CRL OID_ID_CE "\x2E" /**< id-ce-freshestCRL OBJECT IDENTIFIER ::= { id-ce 46 } */ |
| 115 | |
| 116 | /* |
| 117 | * Netscape certificate extensions |
| 118 | */ |
| 119 | #define OID_NS_CERT OID_NETSCAPE "\x01" |
| 120 | #define OID_NS_CERT_TYPE OID_NS_CERT "\x01" |
| 121 | #define OID_NS_BASE_URL OID_NS_CERT "\x02" |
| 122 | #define OID_NS_REVOCATION_URL OID_NS_CERT "\x03" |
| 123 | #define OID_NS_CA_REVOCATION_URL OID_NS_CERT "\x04" |
| 124 | #define OID_NS_RENEWAL_URL OID_NS_CERT "\x07" |
| 125 | #define OID_NS_CA_POLICY_URL OID_NS_CERT "\x08" |
| 126 | #define OID_NS_SSL_SERVER_NAME OID_NS_CERT "\x0C" |
| 127 | #define OID_NS_COMMENT OID_NS_CERT "\x0D" |
| 128 | #define OID_NS_DATA_TYPE OID_NETSCAPE "\x02" |
| 129 | #define OID_NS_CERT_SEQUENCE OID_NS_DATA_TYPE "\x05" |
| 130 | |
| 131 | /* |
| 132 | * OIDs for CRL extensions |
| 133 | */ |
| 134 | #define OID_PRIVATE_KEY_USAGE_PERIOD OID_ID_CE "\x10" |
| 135 | #define OID_CRL_NUMBER OID_ID_CE "\x14" /**< id-ce-cRLNumber OBJECT IDENTIFIER ::= { id-ce 20 } */ |
| 136 | |
| 137 | /* |
| 138 | * X.509 v3 Extended key usage OIDs |
| 139 | */ |
| 140 | #define OID_ANY_EXTENDED_KEY_USAGE OID_EXTENDED_KEY_USAGE "\x00" /**< anyExtendedKeyUsage OBJECT IDENTIFIER ::= { id-ce-extKeyUsage 0 } */ |
| 141 | |
| 142 | #define OID_KP OID_PKIX "\x03" /**< id-kp OBJECT IDENTIFIER ::= { id-pkix 3 } */ |
| 143 | #define OID_SERVER_AUTH OID_KP "\x01" /**< id-kp-serverAuth OBJECT IDENTIFIER ::= { id-kp 1 } */ |
| 144 | #define OID_CLIENT_AUTH OID_KP "\x02" /**< id-kp-clientAuth OBJECT IDENTIFIER ::= { id-kp 2 } */ |
| 145 | #define OID_CODE_SIGNING OID_KP "\x03" /**< id-kp-codeSigning OBJECT IDENTIFIER ::= { id-kp 3 } */ |
| 146 | #define OID_EMAIL_PROTECTION OID_KP "\x04" /**< id-kp-emailProtection OBJECT IDENTIFIER ::= { id-kp 4 } */ |
| 147 | #define OID_TIME_STAMPING OID_KP "\x08" /**< id-kp-timeStamping OBJECT IDENTIFIER ::= { id-kp 8 } */ |
| 148 | #define OID_OCSP_SIGNING OID_KP "\x09" /**< id-kp-OCSPSigning OBJECT IDENTIFIER ::= { id-kp 9 } */ |
| 149 | |
Paul Bakker | 9b5e885 | 2013-06-28 16:12:50 +0200 | [diff] [blame] | 150 | /* |
| 151 | * PKCS definition OIDs |
| 152 | */ |
| 153 | |
Paul Bakker | c70b982 | 2013-04-07 22:00:46 +0200 | [diff] [blame] | 154 | #define OID_PKCS OID_RSA_COMPANY "\x01" /**< pkcs OBJECT IDENTIFIER ::= { iso(1) member-body(2) us(840) rsadsi(113549) 1 } */ |
| 155 | #define OID_PKCS1 OID_PKCS "\x01" /**< pkcs-1 OBJECT IDENTIFIER ::= { iso(1) member-body(2) us(840) rsadsi(113549) pkcs(1) 1 } */ |
Paul Bakker | 9b5e885 | 2013-06-28 16:12:50 +0200 | [diff] [blame] | 156 | #define OID_PKCS5 OID_PKCS "\x05" /**< pkcs-5 OBJECT IDENTIFIER ::= { iso(1) member-body(2) us(840) rsadsi(113549) pkcs(1) 5 } */ |
Paul Bakker | c70b982 | 2013-04-07 22:00:46 +0200 | [diff] [blame] | 157 | #define OID_PKCS9 OID_PKCS "\x09" /**< pkcs-9 OBJECT IDENTIFIER ::= { iso(1) member-body(2) us(840) rsadsi(113549) pkcs(1) 9 } */ |
Paul Bakker | 7749a22 | 2013-06-28 17:28:20 +0200 | [diff] [blame^] | 158 | #define OID_PKCS12 OID_PKCS "\x0c" /**< pkcs-12 OBJECT IDENTIFIER ::= { iso(1) member-body(2) us(840) rsadsi(113549) pkcs(1) 12 } */ |
Paul Bakker | c70b982 | 2013-04-07 22:00:46 +0200 | [diff] [blame] | 159 | |
Paul Bakker | 9b5e885 | 2013-06-28 16:12:50 +0200 | [diff] [blame] | 160 | /* |
| 161 | * PKCS#1 OIDs |
| 162 | */ |
Paul Bakker | c70b982 | 2013-04-07 22:00:46 +0200 | [diff] [blame] | 163 | #define OID_PKCS1_RSA OID_PKCS1 "\x01" /**< rsaEncryption OBJECT IDENTIFIER ::= { pkcs-1 1 } */ |
| 164 | #define OID_PKCS1_MD2 OID_PKCS1 "\x02" /**< md2WithRSAEncryption ::= { pkcs-1 2 } */ |
| 165 | #define OID_PKCS1_MD4 OID_PKCS1 "\x03" /**< md4WithRSAEncryption ::= { pkcs-1 3 } */ |
| 166 | #define OID_PKCS1_MD5 OID_PKCS1 "\x04" /**< md5WithRSAEncryption ::= { pkcs-1 4 } */ |
| 167 | #define OID_PKCS1_SHA1 OID_PKCS1 "\x05" /**< sha1WithRSAEncryption ::= { pkcs-1 5 } */ |
| 168 | #define OID_PKCS1_SHA224 OID_PKCS1 "\x0e" /**< sha224WithRSAEncryption ::= { pkcs-1 14 } */ |
| 169 | #define OID_PKCS1_SHA256 OID_PKCS1 "\x0b" /**< sha256WithRSAEncryption ::= { pkcs-1 11 } */ |
| 170 | #define OID_PKCS1_SHA384 OID_PKCS1 "\x0c" /**< sha384WithRSAEncryption ::= { pkcs-1 12 } */ |
| 171 | #define OID_PKCS1_SHA512 OID_PKCS1 "\x0d" /**< sha512WithRSAEncryption ::= { pkcs-1 13 } */ |
| 172 | |
| 173 | #define OID_RSA_SHA_OBS "\x2B\x0E\x03\x02\x1D" |
| 174 | |
| 175 | #define OID_PKCS9_EMAIL OID_PKCS9 "\x01" /**< emailAddress AttributeType ::= { pkcs-9 1 } */ |
| 176 | |
Paul Bakker | 9b5e885 | 2013-06-28 16:12:50 +0200 | [diff] [blame] | 177 | /* |
| 178 | * Digest algorithms |
| 179 | */ |
Paul Bakker | c70b982 | 2013-04-07 22:00:46 +0200 | [diff] [blame] | 180 | #define OID_DIGEST_ALG_MD2 OID_RSA_COMPANY "\x02\x02" /**< id-md2 OBJECT IDENTIFIER ::= { iso(1) member-body(2) us(840) rsadsi(113549) digestAlgorithm(2) 2 } */ |
| 181 | #define OID_DIGEST_ALG_MD4 OID_RSA_COMPANY "\x02\x04" /**< id-md4 OBJECT IDENTIFIER ::= { iso(1) member-body(2) us(840) rsadsi(113549) digestAlgorithm(2) 4 } */ |
| 182 | #define OID_DIGEST_ALG_MD5 OID_RSA_COMPANY "\x02\x05" /**< id-md5 OBJECT IDENTIFIER ::= { iso(1) member-body(2) us(840) rsadsi(113549) digestAlgorithm(2) 5 } */ |
| 183 | #define OID_DIGEST_ALG_SHA1 OID_ISO_IDENTIFIED_ORG OID_OIW_SECSIG_SHA1 /**< id-sha1 OBJECT IDENTIFIER ::= { iso(1) identified-organization(3) oiw(14) secsig(3) algorithms(2) 26 } */ |
| 184 | #define OID_DIGEST_ALG_SHA224 OID_GOV "\x03\x04\x02\x04" /**< id-sha224 OBJECT IDENTIFIER ::= { joint-iso-itu-t(2) country(16) us(840) organization(1) gov(101) csor(3) nistalgorithm(4) hashalgs(2) 4 } */ |
| 185 | #define OID_DIGEST_ALG_SHA256 OID_GOV "\x03\x04\x02\x01" /**< id-sha256 OBJECT IDENTIFIER ::= { joint-iso-itu-t(2) country(16) us(840) organization(1) gov(101) csor(3) nistalgorithm(4) hashalgs(2) 1 } */ |
| 186 | |
| 187 | #define OID_DIGEST_ALG_SHA384 OID_GOV "\x03\x04\x02\x02" /**< id-sha384 OBJECT IDENTIFIER ::= { joint-iso-itu-t(2) country(16) us(840) organization(1) gov(101) csor(3) nistalgorithm(4) hashalgs(2) 2 } */ |
| 188 | |
| 189 | #define OID_DIGEST_ALG_SHA512 OID_GOV "\x03\x04\x02\x03" /**< id-sha512 OBJECT IDENTIFIER ::= { joint-iso-itu-t(2) country(16) us(840) organization(1) gov(101) csor(3) nistalgorithm(4) hashalgs(2) 3 } */ |
| 190 | |
Paul Bakker | 9b5e885 | 2013-06-28 16:12:50 +0200 | [diff] [blame] | 191 | #define OID_HMAC_SHA1 OID_RSA_COMPANY "\x02\x07" /**< id-hmacWithSHA1 OBJECT IDENTIFIER ::= { iso(1) member-body(2) us(840) rsadsi(113549) digestAlgorithm(2) 7 } */ |
| 192 | |
| 193 | /* |
| 194 | * Encryption algorithms |
| 195 | */ |
| 196 | #define OID_DES_CBC OID_ISO_IDENTIFIED_ORG OID_OIW_SECSIG_ALG "\x07" /**< desCBC OBJECT IDENTIFIER ::= { iso(1) identified-organization(3) oiw(14) secsig(3) algorithms(2) 7 } */ |
| 197 | #define OID_DES_EDE3_CBC OID_RSA_COMPANY "\x03\x07" /**< des-ede3-cbc OBJECT IDENTIFIER ::= { iso(1) member-body(2) -- us(840) rsadsi(113549) encryptionAlgorithm(3) 7 } */ |
| 198 | |
| 199 | /* |
| 200 | * PKCS#5 OIDs |
| 201 | */ |
| 202 | #define OID_PKCS5_PBKDF2 OID_PKCS5 "\x0c" /**< id-PBKDF2 OBJECT IDENTIFIER ::= {pkcs-5 12} */ |
| 203 | #define OID_PKCS5_PBES2 OID_PKCS5 "\x0d" /**< id-PBES2 OBJECT IDENTIFIER ::= {pkcs-5 13} */ |
| 204 | #define OID_PKCS5_PBMAC1 OID_PKCS5 "\x0e" /**< id-PBMAC1 OBJECT IDENTIFIER ::= {pkcs-5 14} */ |
| 205 | |
| 206 | /* |
| 207 | * PKCS#5 PBES1 algorithms |
| 208 | */ |
| 209 | #define OID_PKCS5_PBE_MD2_DES_CBC OID_PKCS5 "\x01" /**< pbeWithMD2AndDES-CBC OBJECT IDENTIFIER ::= {pkcs-5 1} */ |
| 210 | #define OID_PKCS5_PBE_MD2_RC2_CBC OID_PKCS5 "\x04" /**< pbeWithMD2AndRC2-CBC OBJECT IDENTIFIER ::= {pkcs-5 4} */ |
| 211 | #define OID_PKCS5_PBE_MD5_DES_CBC OID_PKCS5 "\x03" /**< pbeWithMD5AndDES-CBC OBJECT IDENTIFIER ::= {pkcs-5 3} */ |
| 212 | #define OID_PKCS5_PBE_MD5_RC2_CBC OID_PKCS5 "\x06" /**< pbeWithMD5AndRC2-CBC OBJECT IDENTIFIER ::= {pkcs-5 6} */ |
| 213 | #define OID_PKCS5_PBE_SHA1_DES_CBC OID_PKCS5 "\x0a" /**< pbeWithSHA1AndDES-CBC OBJECT IDENTIFIER ::= {pkcs-5 10} */ |
| 214 | #define OID_PKCS5_PBE_SHA1_RC2_CBC OID_PKCS5 "\x0b" /**< pbeWithSHA1AndRC2-CBC OBJECT IDENTIFIER ::= {pkcs-5 11} */ |
| 215 | |
Paul Bakker | 7749a22 | 2013-06-28 17:28:20 +0200 | [diff] [blame^] | 216 | /* |
| 217 | * PKCS#12 PBE OIDs |
| 218 | */ |
| 219 | #define OID_PKCS12_PBE OID_PKCS12 "\x01" /**< pkcs-12PbeIds OBJECT IDENTIFIER ::= {pkcs-12 1} */ |
| 220 | |
| 221 | #define OID_PKCS12_PBE_SHA1_RC4_128 OID_PKCS12_PBE "\x01" /**< pbeWithSHAAnd128BitRC4 OBJECT IDENTIFIER ::= {pkcs-12PbeIds 1} */ |
| 222 | #define OID_PKCS12_PBE_SHA1_RC4_40 OID_PKCS12_PBE "\x02" /**< pbeWithSHAAnd40BitRC4 OBJECT IDENTIFIER ::= {pkcs-12PbeIds 2} */ |
| 223 | #define OID_PKCS12_PBE_SHA1_DES3_EDE_CBC OID_PKCS12_PBE "\x03" /**< pbeWithSHAAnd3-KeyTripleDES-CBC OBJECT IDENTIFIER ::= {pkcs-12PbeIds 3} */ |
| 224 | #define OID_PKCS12_PBE_SHA1_DES2_EDE_CBC OID_PKCS12_PBE "\x04" /**< pbeWithSHAAnd2-KeyTripleDES-CBC OBJECT IDENTIFIER ::= {pkcs-12PbeIds 4} */ |
| 225 | #define OID_PKCS12_PBE_SHA1_RC2_128_CBC OID_PKCS12_PBE "\x05" /**< pbeWithSHAAnd128BitRC2-CBC OBJECT IDENTIFIER ::= {pkcs-12PbeIds 5} */ |
| 226 | #define OID_PKCS12_PBE_SHA1_RC2_40_CBC OID_PKCS12_PBE "\x06" /**< pbeWithSHAAnd40BitRC2-CBC OBJECT IDENTIFIER ::= {pkcs-12PbeIds 6} */ |
| 227 | |
Paul Bakker | c70b982 | 2013-04-07 22:00:46 +0200 | [diff] [blame] | 228 | #ifdef __cplusplus |
| 229 | extern "C" { |
| 230 | #endif |
| 231 | |
| 232 | /** |
| 233 | * \brief Base OID descriptor structure |
| 234 | */ |
| 235 | typedef struct { |
| 236 | const char *asn1; /*!< OID ASN.1 representation */ |
| 237 | const char *name; /*!< official name (e.g. from RFC) */ |
| 238 | const char *description; /*!< human friendly description */ |
| 239 | } oid_descriptor_t; |
| 240 | |
| 241 | /** |
| 242 | * \brief Translate an ASN.1 OID into its numeric representation |
| 243 | * (e.g. "\x2A\x86\x48\x86\xF7\x0D" into "1.2.840.113549") |
| 244 | * |
| 245 | * \param buf buffer to put representation in |
| 246 | * \param size size of the buffer |
| 247 | * \param oid OID to translate |
| 248 | * |
| 249 | * \return POLARSSL_ERR_DEBUG_BUF_TOO_SMALL or actual length used |
| 250 | */ |
| 251 | int oid_get_numeric_string( char *buf, size_t size, const asn1_buf *oid ); |
| 252 | |
Paul Bakker | ed27a04 | 2013-04-18 22:46:23 +0200 | [diff] [blame] | 253 | #if defined(POLARSSL_X509_PARSE_C) |
Paul Bakker | c70b982 | 2013-04-07 22:00:46 +0200 | [diff] [blame] | 254 | /** |
| 255 | * \brief Translate an X.509 extension OID into local values |
| 256 | * |
| 257 | * \param oid OID to use |
| 258 | * \param ext_type place to store the extension type |
| 259 | * |
| 260 | * \return 0 if successful, or POLARSSL_ERR_OID_NOT_FOUND |
| 261 | */ |
| 262 | int oid_get_x509_ext_type( const asn1_buf *oid, int *ext_type ); |
Paul Bakker | ed27a04 | 2013-04-18 22:46:23 +0200 | [diff] [blame] | 263 | #endif |
Paul Bakker | c70b982 | 2013-04-07 22:00:46 +0200 | [diff] [blame] | 264 | |
| 265 | /** |
| 266 | * \brief Translate an X.509 attribute type OID into the short name |
| 267 | * (e.g. the OID for an X520 Common Name into "CN") |
| 268 | * |
| 269 | * \param oid OID to use |
| 270 | * \param short_name place to store the string pointer |
| 271 | * |
| 272 | * \return 0 if successful, or POLARSSL_ERR_OID_NOT_FOUND |
| 273 | */ |
| 274 | int oid_get_attr_short_name( const asn1_buf *oid, const char **short_name ); |
| 275 | |
| 276 | /** |
| 277 | * \brief Translate PublicKeyAlgorithm OID into pk_type |
| 278 | * |
| 279 | * \param oid OID to use |
| 280 | * \param pk_alg place to store public key algorithm |
| 281 | * |
| 282 | * \return 0 if successful, or POLARSSL_ERR_OID_NOT_FOUND |
| 283 | */ |
| 284 | int oid_get_pk_alg( const asn1_buf *oid, pk_type_t *pk_alg ); |
| 285 | |
| 286 | /** |
| 287 | * \brief Translate SignatureAlgorithm OID into md_type and pk_type |
| 288 | * |
| 289 | * \param oid OID to use |
| 290 | * \param md_alg place to store message digest algorithm |
| 291 | * \param pk_alg place to store public key algorithm |
| 292 | * |
| 293 | * \return 0 if successful, or POLARSSL_ERR_OID_NOT_FOUND |
| 294 | */ |
| 295 | int oid_get_sig_alg( const asn1_buf *oid, |
| 296 | md_type_t *md_alg, pk_type_t *pk_alg ); |
| 297 | |
| 298 | /** |
| 299 | * \brief Translate SignatureAlgorithm OID into description |
| 300 | * |
| 301 | * \param oid OID to use |
| 302 | * \param desc place to store string pointer |
| 303 | * |
| 304 | * \return 0 if successful, or POLARSSL_ERR_OID_NOT_FOUND |
| 305 | */ |
| 306 | int oid_get_sig_alg_desc( const asn1_buf *oid, const char **desc ); |
| 307 | |
| 308 | /** |
| 309 | * \brief Translate md_type and pk_type into SignatureAlgorithm OID |
| 310 | * |
| 311 | * \param md_alg message digest algorithm |
| 312 | * \param pk_alg public key algorithm |
| 313 | * \param oid place to store ASN.1 OID string pointer |
| 314 | * |
| 315 | * \return 0 if successful, or POLARSSL_ERR_OID_NOT_FOUND |
| 316 | */ |
| 317 | int oid_get_oid_by_sig_alg( pk_type_t pk_alg, md_type_t md_alg, |
| 318 | const char **oid_str ); |
| 319 | |
| 320 | /** |
| 321 | * \brief Translate hash algorithm OID into md_type |
| 322 | * |
| 323 | * \param oid OID to use |
| 324 | * \param md_alg place to store message digest algorithm |
| 325 | * |
| 326 | * \return 0 if successful, or POLARSSL_ERR_OID_NOT_FOUND |
| 327 | */ |
| 328 | int oid_get_md_alg( const asn1_buf *oid, md_type_t *md_alg ); |
| 329 | |
| 330 | /** |
| 331 | * \brief Translate Extended Key Usage OID into description |
| 332 | * |
| 333 | * \param oid OID to use |
| 334 | * \param desc place to store string pointer |
| 335 | * |
| 336 | * \return 0 if successful, or POLARSSL_ERR_OID_NOT_FOUND |
| 337 | */ |
| 338 | int oid_get_extended_key_usage( const asn1_buf *oid, const char **desc ); |
| 339 | |
| 340 | /** |
| 341 | * \brief Translate md_type into hash algorithm OID |
| 342 | * |
| 343 | * \param md_alg message digest algorithm |
| 344 | * \param oid place to store ASN.1 OID string pointer |
| 345 | * |
| 346 | * \return 0 if successful, or POLARSSL_ERR_OID_NOT_FOUND |
| 347 | */ |
| 348 | int oid_get_oid_by_md( md_type_t md_alg, const char **oid_str ); |
| 349 | |
Paul Bakker | 9b5e885 | 2013-06-28 16:12:50 +0200 | [diff] [blame] | 350 | /** |
| 351 | * \brief Translate encryption algorithm OID into cipher_type |
| 352 | * |
| 353 | * \param oid OID to use |
| 354 | * \param cipher_alg place to store cipher algorithm |
| 355 | * |
| 356 | * \return 0 if successful, or POLARSSL_ERR_OID_NOT_FOUND |
| 357 | */ |
| 358 | int oid_get_cipher_alg( const asn1_buf *oid, cipher_type_t *cipher_alg ); |
| 359 | |
Paul Bakker | 7749a22 | 2013-06-28 17:28:20 +0200 | [diff] [blame^] | 360 | #if defined(POLARSSL_PKCS12_C) |
| 361 | /** |
| 362 | * \brief Translate PKCS#12 PBE algorithm OID into md_type and |
| 363 | * cipher_type |
| 364 | * |
| 365 | * \param oid OID to use |
| 366 | * \param md_alg place to store message digest algorithm |
| 367 | * \param cipher_alg place to store cipher algorithm |
| 368 | * |
| 369 | * \return 0 if successful, or POLARSSL_ERR_OID_NOT_FOUND |
| 370 | */ |
| 371 | int oid_get_pkcs12_pbe_alg( const asn1_buf *oid, md_type_t *md_alg, |
| 372 | cipher_type_t *cipher_alg ); |
| 373 | #endif /* POLARSSL_PKCS12_C */ |
| 374 | |
Paul Bakker | c70b982 | 2013-04-07 22:00:46 +0200 | [diff] [blame] | 375 | #ifdef __cplusplus |
| 376 | } |
| 377 | #endif |
| 378 | |
| 379 | #endif /* oid.h */ |