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> |
Paul Bakker | 47fce02 | 2013-06-28 17:34:34 +0200 | [diff] [blame] | 31 | #include "config.h" |
Paul Bakker | c70b982 | 2013-04-07 22:00:46 +0200 | [diff] [blame] | 32 | #include "asn1.h" |
Paul Bakker | ed27a04 | 2013-04-18 22:46:23 +0200 | [diff] [blame] | 33 | #include "pk.h" |
Paul Bakker | 47fce02 | 2013-06-28 17:34:34 +0200 | [diff] [blame] | 34 | #if defined(POLARSSL_CIPHER_C) |
| 35 | #include "cipher.h" |
| 36 | #endif |
| 37 | |
| 38 | #if defined(POLARSSL_MD_C) |
| 39 | #include "md.h" |
| 40 | #endif |
| 41 | |
| 42 | #if defined(POLARSSL_X509_PARSE_C) |
Paul Bakker | c70b982 | 2013-04-07 22:00:46 +0200 | [diff] [blame] | 43 | #include "x509.h" |
Paul Bakker | 47fce02 | 2013-06-28 17:34:34 +0200 | [diff] [blame] | 44 | #endif |
Paul Bakker | c70b982 | 2013-04-07 22:00:46 +0200 | [diff] [blame] | 45 | |
| 46 | #define POLARSSL_ERR_OID_NOT_FOUND -0x002E /**< OID is not found. */ |
| 47 | |
| 48 | /* |
| 49 | * Top level OID tuples |
| 50 | */ |
| 51 | #define OID_ISO_MEMBER_BODIES "\x2a" /* {iso(1) member-body(2)} */ |
| 52 | #define OID_ISO_IDENTIFIED_ORG "\x2b" /* {iso(1) identified-organization(3)} */ |
| 53 | #define OID_ISO_CCITT_DS "\x55" /* {joint-iso-ccitt(2) ds(5)} */ |
| 54 | #define OID_ISO_ITU_COUNTRY "\x60" /* {joint-iso-itu-t(2) country(16)} */ |
| 55 | |
| 56 | /* |
| 57 | * ISO Member bodies OID parts |
| 58 | */ |
| 59 | #define OID_COUNTRY_US "\x86\x48" /* {us(840)} */ |
| 60 | #define OID_ORG_RSA_DATA_SECURITY "\x86\xf7\x0d" /* {rsadsi(113549)} */ |
| 61 | #define OID_RSA_COMPANY OID_ISO_MEMBER_BODIES OID_COUNTRY_US \ |
| 62 | OID_ORG_RSA_DATA_SECURITY /* {iso(1) member-body(2) us(840) rsadsi(113549)} */ |
Manuel Pégourié-Gonnard | 5a9b82e | 2013-07-01 16:57:44 +0200 | [diff] [blame] | 63 | #define OID_ORG_ANSI_X9_62 "\xce\x3d" /* ansi-X9-62(10045) */ |
| 64 | #define OID_ANSI_X9_62 OID_ISO_MEMBER_BODIES OID_COUNTRY_US \ |
| 65 | OID_ORG_ANSI_X9_62 |
Paul Bakker | c70b982 | 2013-04-07 22:00:46 +0200 | [diff] [blame] | 66 | |
| 67 | /* |
| 68 | * ISO Identified organization OID parts |
| 69 | */ |
| 70 | #define OID_ORG_DOD "\x06" /* {dod(6)} */ |
Paul Bakker | 9b5e885 | 2013-06-28 16:12:50 +0200 | [diff] [blame] | 71 | #define OID_ORG_OIW "\x0e" |
| 72 | #define OID_OIW_SECSIG OID_ORG_OIW "\x03" |
| 73 | #define OID_OIW_SECSIG_ALG OID_OIW_SECSIG "\x02" |
| 74 | #define OID_OIW_SECSIG_SHA1 OID_OIW_SECSIG_ALG "\x1a" |
Manuel Pégourié-Gonnard | 5a9b82e | 2013-07-01 16:57:44 +0200 | [diff] [blame] | 75 | #define OID_ORG_CERTICOM "\x81\x04" /* certicom(132) */ |
| 76 | #define OID_CERTICOM OID_ISO_IDENTIFIED_ORG OID_ORG_CERTICOM |
Paul Bakker | c70b982 | 2013-04-07 22:00:46 +0200 | [diff] [blame] | 77 | |
| 78 | /* |
| 79 | * ISO ITU OID parts |
| 80 | */ |
| 81 | #define OID_ORGANIZATION "\x01" /* {organization(1)} */ |
| 82 | #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)} */ |
| 83 | |
| 84 | #define OID_ORG_GOV "\x65" /* {gov(101)} */ |
| 85 | #define OID_GOV OID_ISO_ITU_US_ORG OID_ORG_GOV /* {joint-iso-itu-t(2) country(16) us(840) organization(1) gov(101)} */ |
| 86 | |
| 87 | #define OID_ORG_NETSCAPE "\x86\xF8\x42" /* {netscape(113730)} */ |
| 88 | #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)} */ |
| 89 | |
| 90 | /* ISO arc for standard certificate and CRL extensions */ |
| 91 | #define OID_ID_CE OID_ISO_CCITT_DS "\x1D" /**< id-ce OBJECT IDENTIFIER ::= {joint-iso-ccitt(2) ds(5) 29} */ |
| 92 | |
| 93 | /** |
| 94 | * Private Internet Extensions |
| 95 | * { iso(1) identified-organization(3) dod(6) internet(1) |
| 96 | * security(5) mechanisms(5) pkix(7) } |
| 97 | */ |
| 98 | #define OID_PKIX OID_ISO_IDENTIFIED_ORG OID_ORG_DOD "\x01\x05\x05\x07" |
| 99 | |
| 100 | /* |
| 101 | * Arc for standard naming attributes |
| 102 | */ |
| 103 | #define OID_AT OID_ISO_CCITT_DS "\x04" /**< id-at OBJECT IDENTIFIER ::= {joint-iso-ccitt(2) ds(5) 4} */ |
| 104 | #define OID_AT_CN OID_AT "\x03" /**< id-at-commonName AttributeType:= {id-at 3} */ |
| 105 | #define OID_AT_COUNTRY OID_AT "\x06" /**< id-at-countryName AttributeType:= {id-at 6} */ |
| 106 | #define OID_AT_LOCALITY OID_AT "\x07" /**< id-at-locality AttributeType:= {id-at 7} */ |
| 107 | #define OID_AT_STATE OID_AT "\x08" /**< id-at-state AttributeType:= {id-at 8} */ |
| 108 | #define OID_AT_ORGANIZATION OID_AT "\x0A" /**< id-at-organizationName AttributeType:= {id-at 10} */ |
| 109 | #define OID_AT_ORG_UNIT OID_AT "\x0B" /**< id-at-organizationalUnitName AttributeType:= {id-at 11} */ |
| 110 | |
| 111 | /* |
| 112 | * OIDs for standard certificate extensions |
| 113 | */ |
| 114 | #define OID_AUTHORITY_KEY_IDENTIFIER OID_ID_CE "\x23" /**< id-ce-authorityKeyIdentifier OBJECT IDENTIFIER ::= { id-ce 35 } */ |
| 115 | #define OID_SUBJECT_KEY_IDENTIFIER OID_ID_CE "\x0E" /**< id-ce-subjectKeyIdentifier OBJECT IDENTIFIER ::= { id-ce 14 } */ |
| 116 | #define OID_KEY_USAGE OID_ID_CE "\x0F" /**< id-ce-keyUsage OBJECT IDENTIFIER ::= { id-ce 15 } */ |
| 117 | #define OID_CERTIFICATE_POLICIES OID_ID_CE "\x20" /**< id-ce-certificatePolicies OBJECT IDENTIFIER ::= { id-ce 32 } */ |
| 118 | #define OID_POLICY_MAPPINGS OID_ID_CE "\x21" /**< id-ce-policyMappings OBJECT IDENTIFIER ::= { id-ce 33 } */ |
| 119 | #define OID_SUBJECT_ALT_NAME OID_ID_CE "\x11" /**< id-ce-subjectAltName OBJECT IDENTIFIER ::= { id-ce 17 } */ |
| 120 | #define OID_ISSUER_ALT_NAME OID_ID_CE "\x12" /**< id-ce-issuerAltName OBJECT IDENTIFIER ::= { id-ce 18 } */ |
| 121 | #define OID_SUBJECT_DIRECTORY_ATTRS OID_ID_CE "\x09" /**< id-ce-subjectDirectoryAttributes OBJECT IDENTIFIER ::= { id-ce 9 } */ |
| 122 | #define OID_BASIC_CONSTRAINTS OID_ID_CE "\x13" /**< id-ce-basicConstraints OBJECT IDENTIFIER ::= { id-ce 19 } */ |
| 123 | #define OID_NAME_CONSTRAINTS OID_ID_CE "\x1E" /**< id-ce-nameConstraints OBJECT IDENTIFIER ::= { id-ce 30 } */ |
| 124 | #define OID_POLICY_CONSTRAINTS OID_ID_CE "\x24" /**< id-ce-policyConstraints OBJECT IDENTIFIER ::= { id-ce 36 } */ |
| 125 | #define OID_EXTENDED_KEY_USAGE OID_ID_CE "\x25" /**< id-ce-extKeyUsage OBJECT IDENTIFIER ::= { id-ce 37 } */ |
| 126 | #define OID_CRL_DISTRIBUTION_POINTS OID_ID_CE "\x1F" /**< id-ce-cRLDistributionPoints OBJECT IDENTIFIER ::= { id-ce 31 } */ |
| 127 | #define OID_INIHIBIT_ANYPOLICY OID_ID_CE "\x36" /**< id-ce-inhibitAnyPolicy OBJECT IDENTIFIER ::= { id-ce 54 } */ |
| 128 | #define OID_FRESHEST_CRL OID_ID_CE "\x2E" /**< id-ce-freshestCRL OBJECT IDENTIFIER ::= { id-ce 46 } */ |
| 129 | |
| 130 | /* |
| 131 | * Netscape certificate extensions |
| 132 | */ |
| 133 | #define OID_NS_CERT OID_NETSCAPE "\x01" |
| 134 | #define OID_NS_CERT_TYPE OID_NS_CERT "\x01" |
| 135 | #define OID_NS_BASE_URL OID_NS_CERT "\x02" |
| 136 | #define OID_NS_REVOCATION_URL OID_NS_CERT "\x03" |
| 137 | #define OID_NS_CA_REVOCATION_URL OID_NS_CERT "\x04" |
| 138 | #define OID_NS_RENEWAL_URL OID_NS_CERT "\x07" |
| 139 | #define OID_NS_CA_POLICY_URL OID_NS_CERT "\x08" |
| 140 | #define OID_NS_SSL_SERVER_NAME OID_NS_CERT "\x0C" |
| 141 | #define OID_NS_COMMENT OID_NS_CERT "\x0D" |
| 142 | #define OID_NS_DATA_TYPE OID_NETSCAPE "\x02" |
| 143 | #define OID_NS_CERT_SEQUENCE OID_NS_DATA_TYPE "\x05" |
| 144 | |
| 145 | /* |
| 146 | * OIDs for CRL extensions |
| 147 | */ |
| 148 | #define OID_PRIVATE_KEY_USAGE_PERIOD OID_ID_CE "\x10" |
| 149 | #define OID_CRL_NUMBER OID_ID_CE "\x14" /**< id-ce-cRLNumber OBJECT IDENTIFIER ::= { id-ce 20 } */ |
| 150 | |
| 151 | /* |
| 152 | * X.509 v3 Extended key usage OIDs |
| 153 | */ |
| 154 | #define OID_ANY_EXTENDED_KEY_USAGE OID_EXTENDED_KEY_USAGE "\x00" /**< anyExtendedKeyUsage OBJECT IDENTIFIER ::= { id-ce-extKeyUsage 0 } */ |
| 155 | |
| 156 | #define OID_KP OID_PKIX "\x03" /**< id-kp OBJECT IDENTIFIER ::= { id-pkix 3 } */ |
| 157 | #define OID_SERVER_AUTH OID_KP "\x01" /**< id-kp-serverAuth OBJECT IDENTIFIER ::= { id-kp 1 } */ |
| 158 | #define OID_CLIENT_AUTH OID_KP "\x02" /**< id-kp-clientAuth OBJECT IDENTIFIER ::= { id-kp 2 } */ |
| 159 | #define OID_CODE_SIGNING OID_KP "\x03" /**< id-kp-codeSigning OBJECT IDENTIFIER ::= { id-kp 3 } */ |
| 160 | #define OID_EMAIL_PROTECTION OID_KP "\x04" /**< id-kp-emailProtection OBJECT IDENTIFIER ::= { id-kp 4 } */ |
| 161 | #define OID_TIME_STAMPING OID_KP "\x08" /**< id-kp-timeStamping OBJECT IDENTIFIER ::= { id-kp 8 } */ |
| 162 | #define OID_OCSP_SIGNING OID_KP "\x09" /**< id-kp-OCSPSigning OBJECT IDENTIFIER ::= { id-kp 9 } */ |
| 163 | |
Paul Bakker | 9b5e885 | 2013-06-28 16:12:50 +0200 | [diff] [blame] | 164 | /* |
| 165 | * PKCS definition OIDs |
| 166 | */ |
| 167 | |
Paul Bakker | c70b982 | 2013-04-07 22:00:46 +0200 | [diff] [blame] | 168 | #define OID_PKCS OID_RSA_COMPANY "\x01" /**< pkcs OBJECT IDENTIFIER ::= { iso(1) member-body(2) us(840) rsadsi(113549) 1 } */ |
| 169 | #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] | 170 | #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] | 171 | #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] | 172 | #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] | 173 | |
Paul Bakker | 9b5e885 | 2013-06-28 16:12:50 +0200 | [diff] [blame] | 174 | /* |
| 175 | * PKCS#1 OIDs |
| 176 | */ |
Paul Bakker | c70b982 | 2013-04-07 22:00:46 +0200 | [diff] [blame] | 177 | #define OID_PKCS1_RSA OID_PKCS1 "\x01" /**< rsaEncryption OBJECT IDENTIFIER ::= { pkcs-1 1 } */ |
| 178 | #define OID_PKCS1_MD2 OID_PKCS1 "\x02" /**< md2WithRSAEncryption ::= { pkcs-1 2 } */ |
| 179 | #define OID_PKCS1_MD4 OID_PKCS1 "\x03" /**< md4WithRSAEncryption ::= { pkcs-1 3 } */ |
| 180 | #define OID_PKCS1_MD5 OID_PKCS1 "\x04" /**< md5WithRSAEncryption ::= { pkcs-1 4 } */ |
| 181 | #define OID_PKCS1_SHA1 OID_PKCS1 "\x05" /**< sha1WithRSAEncryption ::= { pkcs-1 5 } */ |
| 182 | #define OID_PKCS1_SHA224 OID_PKCS1 "\x0e" /**< sha224WithRSAEncryption ::= { pkcs-1 14 } */ |
| 183 | #define OID_PKCS1_SHA256 OID_PKCS1 "\x0b" /**< sha256WithRSAEncryption ::= { pkcs-1 11 } */ |
| 184 | #define OID_PKCS1_SHA384 OID_PKCS1 "\x0c" /**< sha384WithRSAEncryption ::= { pkcs-1 12 } */ |
| 185 | #define OID_PKCS1_SHA512 OID_PKCS1 "\x0d" /**< sha512WithRSAEncryption ::= { pkcs-1 13 } */ |
| 186 | |
| 187 | #define OID_RSA_SHA_OBS "\x2B\x0E\x03\x02\x1D" |
| 188 | |
| 189 | #define OID_PKCS9_EMAIL OID_PKCS9 "\x01" /**< emailAddress AttributeType ::= { pkcs-9 1 } */ |
| 190 | |
Paul Bakker | 9b5e885 | 2013-06-28 16:12:50 +0200 | [diff] [blame] | 191 | /* |
| 192 | * Digest algorithms |
| 193 | */ |
Paul Bakker | c70b982 | 2013-04-07 22:00:46 +0200 | [diff] [blame] | 194 | #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 } */ |
| 195 | #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 } */ |
| 196 | #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 } */ |
| 197 | #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 } */ |
| 198 | #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 } */ |
| 199 | #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 } */ |
| 200 | |
| 201 | #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 } */ |
| 202 | |
| 203 | #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 } */ |
| 204 | |
Paul Bakker | 9b5e885 | 2013-06-28 16:12:50 +0200 | [diff] [blame] | 205 | #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 } */ |
| 206 | |
| 207 | /* |
| 208 | * Encryption algorithms |
| 209 | */ |
| 210 | #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 } */ |
| 211 | #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 } */ |
| 212 | |
| 213 | /* |
| 214 | * PKCS#5 OIDs |
| 215 | */ |
| 216 | #define OID_PKCS5_PBKDF2 OID_PKCS5 "\x0c" /**< id-PBKDF2 OBJECT IDENTIFIER ::= {pkcs-5 12} */ |
| 217 | #define OID_PKCS5_PBES2 OID_PKCS5 "\x0d" /**< id-PBES2 OBJECT IDENTIFIER ::= {pkcs-5 13} */ |
| 218 | #define OID_PKCS5_PBMAC1 OID_PKCS5 "\x0e" /**< id-PBMAC1 OBJECT IDENTIFIER ::= {pkcs-5 14} */ |
| 219 | |
| 220 | /* |
| 221 | * PKCS#5 PBES1 algorithms |
| 222 | */ |
| 223 | #define OID_PKCS5_PBE_MD2_DES_CBC OID_PKCS5 "\x01" /**< pbeWithMD2AndDES-CBC OBJECT IDENTIFIER ::= {pkcs-5 1} */ |
| 224 | #define OID_PKCS5_PBE_MD2_RC2_CBC OID_PKCS5 "\x04" /**< pbeWithMD2AndRC2-CBC OBJECT IDENTIFIER ::= {pkcs-5 4} */ |
| 225 | #define OID_PKCS5_PBE_MD5_DES_CBC OID_PKCS5 "\x03" /**< pbeWithMD5AndDES-CBC OBJECT IDENTIFIER ::= {pkcs-5 3} */ |
| 226 | #define OID_PKCS5_PBE_MD5_RC2_CBC OID_PKCS5 "\x06" /**< pbeWithMD5AndRC2-CBC OBJECT IDENTIFIER ::= {pkcs-5 6} */ |
| 227 | #define OID_PKCS5_PBE_SHA1_DES_CBC OID_PKCS5 "\x0a" /**< pbeWithSHA1AndDES-CBC OBJECT IDENTIFIER ::= {pkcs-5 10} */ |
| 228 | #define OID_PKCS5_PBE_SHA1_RC2_CBC OID_PKCS5 "\x0b" /**< pbeWithSHA1AndRC2-CBC OBJECT IDENTIFIER ::= {pkcs-5 11} */ |
| 229 | |
Paul Bakker | 7749a22 | 2013-06-28 17:28:20 +0200 | [diff] [blame] | 230 | /* |
| 231 | * PKCS#12 PBE OIDs |
| 232 | */ |
| 233 | #define OID_PKCS12_PBE OID_PKCS12 "\x01" /**< pkcs-12PbeIds OBJECT IDENTIFIER ::= {pkcs-12 1} */ |
| 234 | |
| 235 | #define OID_PKCS12_PBE_SHA1_RC4_128 OID_PKCS12_PBE "\x01" /**< pbeWithSHAAnd128BitRC4 OBJECT IDENTIFIER ::= {pkcs-12PbeIds 1} */ |
| 236 | #define OID_PKCS12_PBE_SHA1_RC4_40 OID_PKCS12_PBE "\x02" /**< pbeWithSHAAnd40BitRC4 OBJECT IDENTIFIER ::= {pkcs-12PbeIds 2} */ |
| 237 | #define OID_PKCS12_PBE_SHA1_DES3_EDE_CBC OID_PKCS12_PBE "\x03" /**< pbeWithSHAAnd3-KeyTripleDES-CBC OBJECT IDENTIFIER ::= {pkcs-12PbeIds 3} */ |
| 238 | #define OID_PKCS12_PBE_SHA1_DES2_EDE_CBC OID_PKCS12_PBE "\x04" /**< pbeWithSHAAnd2-KeyTripleDES-CBC OBJECT IDENTIFIER ::= {pkcs-12PbeIds 4} */ |
| 239 | #define OID_PKCS12_PBE_SHA1_RC2_128_CBC OID_PKCS12_PBE "\x05" /**< pbeWithSHAAnd128BitRC2-CBC OBJECT IDENTIFIER ::= {pkcs-12PbeIds 5} */ |
| 240 | #define OID_PKCS12_PBE_SHA1_RC2_40_CBC OID_PKCS12_PBE "\x06" /**< pbeWithSHAAnd40BitRC2-CBC OBJECT IDENTIFIER ::= {pkcs-12PbeIds 6} */ |
| 241 | |
Manuel Pégourié-Gonnard | 5a9b82e | 2013-07-01 16:57:44 +0200 | [diff] [blame] | 242 | /* |
Manuel Pégourié-Gonnard | f0b30d0 | 2013-07-01 17:34:57 +0200 | [diff] [blame^] | 243 | * EC key algorithms from RFC 5480 |
Manuel Pégourié-Gonnard | 5a9b82e | 2013-07-01 16:57:44 +0200 | [diff] [blame] | 244 | */ |
| 245 | |
| 246 | /* id-ecPublicKey OBJECT IDENTIFIER ::= { |
| 247 | * iso(1) member-body(2) us(840) ansi-X9-62(10045) keyType(2) 1 } */ |
| 248 | #define OID_EC_ALG_UNRESTRICTED OID_ANSI_X9_62 "\x02\01" |
| 249 | |
| 250 | /* id-ecDH OBJECT IDENTIFIER ::= { |
| 251 | * iso(1) identified-organization(3) certicom(132) |
| 252 | * schemes(1) ecdh(12) } */ |
| 253 | #define OID_EC_ALG_ECDH OID_CERTICOM "\x01\x0c" |
| 254 | |
Manuel Pégourié-Gonnard | f0b30d0 | 2013-07-01 17:34:57 +0200 | [diff] [blame^] | 255 | /* |
| 256 | * ECParameters namedCurve identifiers, from RFC 5480 |
| 257 | */ |
| 258 | |
| 259 | /* secp192r1 OBJECT IDENTIFIER ::= { |
| 260 | * iso(1) member-body(2) us(840) ansi-X9-62(10045) curves(3) prime(1) 1 } */ |
| 261 | #define OID_EC_GRP_SECP192R1 OID_ANSI_X9_62 "\x03\x01\x01" |
| 262 | |
| 263 | /* secp224r1 OBJECT IDENTIFIER ::= { |
| 264 | * iso(1) identified-organization(3) certicom(132) curve(0) 33 } */ |
| 265 | #define OID_EC_GRP_SECP224R1 OID_CERTICOM "\x00\x21" |
| 266 | |
| 267 | /* secp256r1 OBJECT IDENTIFIER ::= { |
| 268 | * iso(1) member-body(2) us(840) ansi-X9-62(10045) curves(3) prime(1) 7 } */ |
| 269 | #define OID_EC_GRP_SECP256R1 OID_ANSI_X9_62 "\x03\x01\x07" |
| 270 | |
| 271 | /* secp384r1 OBJECT IDENTIFIER ::= { |
| 272 | * iso(1) identified-organization(3) certicom(132) curve(0) 34 } */ |
| 273 | #define OID_EC_GRP_SECP384R1 OID_CERTICOM "\x00\x22" |
| 274 | |
| 275 | /* secp521r1 OBJECT IDENTIFIER ::= { |
| 276 | * iso(1) identified-organization(3) certicom(132) curve(0) 35 } */ |
| 277 | #define OID_EC_GRP_SECP521R1 OID_CERTICOM "\x00\x23" |
| 278 | |
Paul Bakker | c70b982 | 2013-04-07 22:00:46 +0200 | [diff] [blame] | 279 | #ifdef __cplusplus |
| 280 | extern "C" { |
| 281 | #endif |
| 282 | |
| 283 | /** |
| 284 | * \brief Base OID descriptor structure |
| 285 | */ |
| 286 | typedef struct { |
| 287 | const char *asn1; /*!< OID ASN.1 representation */ |
| 288 | const char *name; /*!< official name (e.g. from RFC) */ |
| 289 | const char *description; /*!< human friendly description */ |
| 290 | } oid_descriptor_t; |
| 291 | |
| 292 | /** |
| 293 | * \brief Translate an ASN.1 OID into its numeric representation |
| 294 | * (e.g. "\x2A\x86\x48\x86\xF7\x0D" into "1.2.840.113549") |
| 295 | * |
| 296 | * \param buf buffer to put representation in |
| 297 | * \param size size of the buffer |
| 298 | * \param oid OID to translate |
| 299 | * |
| 300 | * \return POLARSSL_ERR_DEBUG_BUF_TOO_SMALL or actual length used |
| 301 | */ |
| 302 | int oid_get_numeric_string( char *buf, size_t size, const asn1_buf *oid ); |
| 303 | |
Paul Bakker | ed27a04 | 2013-04-18 22:46:23 +0200 | [diff] [blame] | 304 | #if defined(POLARSSL_X509_PARSE_C) |
Paul Bakker | c70b982 | 2013-04-07 22:00:46 +0200 | [diff] [blame] | 305 | /** |
| 306 | * \brief Translate an X.509 extension OID into local values |
| 307 | * |
| 308 | * \param oid OID to use |
| 309 | * \param ext_type place to store the extension type |
| 310 | * |
| 311 | * \return 0 if successful, or POLARSSL_ERR_OID_NOT_FOUND |
| 312 | */ |
| 313 | 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] | 314 | #endif |
Paul Bakker | c70b982 | 2013-04-07 22:00:46 +0200 | [diff] [blame] | 315 | |
| 316 | /** |
| 317 | * \brief Translate an X.509 attribute type OID into the short name |
| 318 | * (e.g. the OID for an X520 Common Name into "CN") |
| 319 | * |
| 320 | * \param oid OID to use |
| 321 | * \param short_name place to store the string pointer |
| 322 | * |
| 323 | * \return 0 if successful, or POLARSSL_ERR_OID_NOT_FOUND |
| 324 | */ |
| 325 | int oid_get_attr_short_name( const asn1_buf *oid, const char **short_name ); |
| 326 | |
| 327 | /** |
| 328 | * \brief Translate PublicKeyAlgorithm OID into pk_type |
| 329 | * |
| 330 | * \param oid OID to use |
| 331 | * \param pk_alg place to store public key algorithm |
| 332 | * |
| 333 | * \return 0 if successful, or POLARSSL_ERR_OID_NOT_FOUND |
| 334 | */ |
| 335 | int oid_get_pk_alg( const asn1_buf *oid, pk_type_t *pk_alg ); |
| 336 | |
Manuel Pégourié-Gonnard | f0b30d0 | 2013-07-01 17:34:57 +0200 | [diff] [blame^] | 337 | /** |
| 338 | * \brief Translate ECParameters OID into an EC group identifier |
| 339 | * |
| 340 | * \param oid OID to use |
| 341 | * \param grp_id place to store group id |
| 342 | * |
| 343 | * \return 0 if successful, or POLARSSL_ERR_OID_NOT_FOUND |
| 344 | */ |
| 345 | int oid_get_ec_grp( const asn1_buf *oid, ecp_group_id *grp_id ); |
| 346 | |
Paul Bakker | 47fce02 | 2013-06-28 17:34:34 +0200 | [diff] [blame] | 347 | #if defined(POLARSSL_MD_C) |
Paul Bakker | c70b982 | 2013-04-07 22:00:46 +0200 | [diff] [blame] | 348 | /** |
| 349 | * \brief Translate SignatureAlgorithm OID into md_type and pk_type |
| 350 | * |
| 351 | * \param oid OID to use |
| 352 | * \param md_alg place to store message digest algorithm |
| 353 | * \param pk_alg place to store public key algorithm |
| 354 | * |
| 355 | * \return 0 if successful, or POLARSSL_ERR_OID_NOT_FOUND |
| 356 | */ |
| 357 | int oid_get_sig_alg( const asn1_buf *oid, |
| 358 | md_type_t *md_alg, pk_type_t *pk_alg ); |
| 359 | |
| 360 | /** |
| 361 | * \brief Translate SignatureAlgorithm OID into description |
| 362 | * |
| 363 | * \param oid OID to use |
| 364 | * \param desc place to store string pointer |
| 365 | * |
| 366 | * \return 0 if successful, or POLARSSL_ERR_OID_NOT_FOUND |
| 367 | */ |
| 368 | int oid_get_sig_alg_desc( const asn1_buf *oid, const char **desc ); |
| 369 | |
| 370 | /** |
| 371 | * \brief Translate md_type and pk_type into SignatureAlgorithm OID |
| 372 | * |
| 373 | * \param md_alg message digest algorithm |
| 374 | * \param pk_alg public key algorithm |
| 375 | * \param oid place to store ASN.1 OID string pointer |
| 376 | * |
| 377 | * \return 0 if successful, or POLARSSL_ERR_OID_NOT_FOUND |
| 378 | */ |
| 379 | int oid_get_oid_by_sig_alg( pk_type_t pk_alg, md_type_t md_alg, |
| 380 | const char **oid_str ); |
| 381 | |
| 382 | /** |
| 383 | * \brief Translate hash algorithm OID into md_type |
| 384 | * |
| 385 | * \param oid OID to use |
| 386 | * \param md_alg place to store message digest algorithm |
| 387 | * |
| 388 | * \return 0 if successful, or POLARSSL_ERR_OID_NOT_FOUND |
| 389 | */ |
| 390 | int oid_get_md_alg( const asn1_buf *oid, md_type_t *md_alg ); |
Paul Bakker | 47fce02 | 2013-06-28 17:34:34 +0200 | [diff] [blame] | 391 | #endif /* POLARSSL_MD_C */ |
Paul Bakker | c70b982 | 2013-04-07 22:00:46 +0200 | [diff] [blame] | 392 | |
| 393 | /** |
| 394 | * \brief Translate Extended Key Usage OID into description |
| 395 | * |
| 396 | * \param oid OID to use |
| 397 | * \param desc place to store string pointer |
| 398 | * |
| 399 | * \return 0 if successful, or POLARSSL_ERR_OID_NOT_FOUND |
| 400 | */ |
| 401 | int oid_get_extended_key_usage( const asn1_buf *oid, const char **desc ); |
| 402 | |
| 403 | /** |
| 404 | * \brief Translate md_type into hash algorithm OID |
| 405 | * |
| 406 | * \param md_alg message digest algorithm |
| 407 | * \param oid place to store ASN.1 OID string pointer |
| 408 | * |
| 409 | * \return 0 if successful, or POLARSSL_ERR_OID_NOT_FOUND |
| 410 | */ |
| 411 | int oid_get_oid_by_md( md_type_t md_alg, const char **oid_str ); |
| 412 | |
Paul Bakker | 47fce02 | 2013-06-28 17:34:34 +0200 | [diff] [blame] | 413 | #if defined(POLARSSL_CIPHER_C) |
Paul Bakker | 9b5e885 | 2013-06-28 16:12:50 +0200 | [diff] [blame] | 414 | /** |
| 415 | * \brief Translate encryption algorithm OID into cipher_type |
| 416 | * |
| 417 | * \param oid OID to use |
| 418 | * \param cipher_alg place to store cipher algorithm |
| 419 | * |
| 420 | * \return 0 if successful, or POLARSSL_ERR_OID_NOT_FOUND |
| 421 | */ |
| 422 | int oid_get_cipher_alg( const asn1_buf *oid, cipher_type_t *cipher_alg ); |
Paul Bakker | 47fce02 | 2013-06-28 17:34:34 +0200 | [diff] [blame] | 423 | #endif /* POLARSSL_CIPHER_C */ |
Paul Bakker | 9b5e885 | 2013-06-28 16:12:50 +0200 | [diff] [blame] | 424 | |
Paul Bakker | 7749a22 | 2013-06-28 17:28:20 +0200 | [diff] [blame] | 425 | #if defined(POLARSSL_PKCS12_C) |
| 426 | /** |
| 427 | * \brief Translate PKCS#12 PBE algorithm OID into md_type and |
| 428 | * cipher_type |
| 429 | * |
| 430 | * \param oid OID to use |
| 431 | * \param md_alg place to store message digest algorithm |
| 432 | * \param cipher_alg place to store cipher algorithm |
| 433 | * |
| 434 | * \return 0 if successful, or POLARSSL_ERR_OID_NOT_FOUND |
| 435 | */ |
| 436 | int oid_get_pkcs12_pbe_alg( const asn1_buf *oid, md_type_t *md_alg, |
| 437 | cipher_type_t *cipher_alg ); |
| 438 | #endif /* POLARSSL_PKCS12_C */ |
| 439 | |
Paul Bakker | c70b982 | 2013-04-07 22:00:46 +0200 | [diff] [blame] | 440 | #ifdef __cplusplus |
| 441 | } |
| 442 | #endif |
| 443 | |
| 444 | #endif /* oid.h */ |