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 | /* |
Paul Bakker | fde4270 | 2013-08-25 14:47:27 +0200 | [diff] [blame^] | 231 | * PKCS#8 OIDs |
| 232 | */ |
| 233 | #define OID_PKCS9_CSR_EXT_REQ OID_PKCS9 "\x0e" /**< extensionRequest OBJECT IDENTIFIER ::= {pkcs-9 14} */ |
| 234 | |
| 235 | /* |
Paul Bakker | 7749a22 | 2013-06-28 17:28:20 +0200 | [diff] [blame] | 236 | * PKCS#12 PBE OIDs |
| 237 | */ |
| 238 | #define OID_PKCS12_PBE OID_PKCS12 "\x01" /**< pkcs-12PbeIds OBJECT IDENTIFIER ::= {pkcs-12 1} */ |
| 239 | |
| 240 | #define OID_PKCS12_PBE_SHA1_RC4_128 OID_PKCS12_PBE "\x01" /**< pbeWithSHAAnd128BitRC4 OBJECT IDENTIFIER ::= {pkcs-12PbeIds 1} */ |
| 241 | #define OID_PKCS12_PBE_SHA1_RC4_40 OID_PKCS12_PBE "\x02" /**< pbeWithSHAAnd40BitRC4 OBJECT IDENTIFIER ::= {pkcs-12PbeIds 2} */ |
| 242 | #define OID_PKCS12_PBE_SHA1_DES3_EDE_CBC OID_PKCS12_PBE "\x03" /**< pbeWithSHAAnd3-KeyTripleDES-CBC OBJECT IDENTIFIER ::= {pkcs-12PbeIds 3} */ |
| 243 | #define OID_PKCS12_PBE_SHA1_DES2_EDE_CBC OID_PKCS12_PBE "\x04" /**< pbeWithSHAAnd2-KeyTripleDES-CBC OBJECT IDENTIFIER ::= {pkcs-12PbeIds 4} */ |
| 244 | #define OID_PKCS12_PBE_SHA1_RC2_128_CBC OID_PKCS12_PBE "\x05" /**< pbeWithSHAAnd128BitRC2-CBC OBJECT IDENTIFIER ::= {pkcs-12PbeIds 5} */ |
| 245 | #define OID_PKCS12_PBE_SHA1_RC2_40_CBC OID_PKCS12_PBE "\x06" /**< pbeWithSHAAnd40BitRC2-CBC OBJECT IDENTIFIER ::= {pkcs-12PbeIds 6} */ |
| 246 | |
Manuel Pégourié-Gonnard | 5a9b82e | 2013-07-01 16:57:44 +0200 | [diff] [blame] | 247 | /* |
Manuel Pégourié-Gonnard | f0b30d0 | 2013-07-01 17:34:57 +0200 | [diff] [blame] | 248 | * EC key algorithms from RFC 5480 |
Manuel Pégourié-Gonnard | 5a9b82e | 2013-07-01 16:57:44 +0200 | [diff] [blame] | 249 | */ |
| 250 | |
| 251 | /* id-ecPublicKey OBJECT IDENTIFIER ::= { |
| 252 | * iso(1) member-body(2) us(840) ansi-X9-62(10045) keyType(2) 1 } */ |
| 253 | #define OID_EC_ALG_UNRESTRICTED OID_ANSI_X9_62 "\x02\01" |
| 254 | |
| 255 | /* id-ecDH OBJECT IDENTIFIER ::= { |
| 256 | * iso(1) identified-organization(3) certicom(132) |
| 257 | * schemes(1) ecdh(12) } */ |
| 258 | #define OID_EC_ALG_ECDH OID_CERTICOM "\x01\x0c" |
| 259 | |
Manuel Pégourié-Gonnard | f0b30d0 | 2013-07-01 17:34:57 +0200 | [diff] [blame] | 260 | /* |
| 261 | * ECParameters namedCurve identifiers, from RFC 5480 |
| 262 | */ |
| 263 | |
| 264 | /* secp192r1 OBJECT IDENTIFIER ::= { |
| 265 | * iso(1) member-body(2) us(840) ansi-X9-62(10045) curves(3) prime(1) 1 } */ |
| 266 | #define OID_EC_GRP_SECP192R1 OID_ANSI_X9_62 "\x03\x01\x01" |
| 267 | |
| 268 | /* secp224r1 OBJECT IDENTIFIER ::= { |
| 269 | * iso(1) identified-organization(3) certicom(132) curve(0) 33 } */ |
| 270 | #define OID_EC_GRP_SECP224R1 OID_CERTICOM "\x00\x21" |
| 271 | |
| 272 | /* secp256r1 OBJECT IDENTIFIER ::= { |
| 273 | * iso(1) member-body(2) us(840) ansi-X9-62(10045) curves(3) prime(1) 7 } */ |
| 274 | #define OID_EC_GRP_SECP256R1 OID_ANSI_X9_62 "\x03\x01\x07" |
| 275 | |
| 276 | /* secp384r1 OBJECT IDENTIFIER ::= { |
| 277 | * iso(1) identified-organization(3) certicom(132) curve(0) 34 } */ |
| 278 | #define OID_EC_GRP_SECP384R1 OID_CERTICOM "\x00\x22" |
| 279 | |
| 280 | /* secp521r1 OBJECT IDENTIFIER ::= { |
| 281 | * iso(1) identified-organization(3) certicom(132) curve(0) 35 } */ |
| 282 | #define OID_EC_GRP_SECP521R1 OID_CERTICOM "\x00\x23" |
| 283 | |
Manuel Pégourié-Gonnard | 1e60cd0 | 2013-07-10 10:28:53 +0200 | [diff] [blame] | 284 | /* |
| 285 | * ECDSA signature identifers, from RFC 5480 |
| 286 | */ |
| 287 | #define OID_ANSI_X9_62_SIG OID_ANSI_X9_62 "\x04" /* signatures(4) */ |
| 288 | #define OID_ANSI_X9_62_SIG_SHA2 OID_ANSI_X9_62_SIG "\x03" /* ecdsa-with-SHA2(3) */ |
| 289 | |
| 290 | /* ecdsa-with-SHA1 OBJECT IDENTIFIER ::= { |
| 291 | * iso(1) member-body(2) us(840) ansi-X9-62(10045) signatures(4) 1 } */ |
| 292 | #define OID_ECDSA_SHA1 OID_ANSI_X9_62_SIG "\x01" |
| 293 | |
| 294 | /* ecdsa-with-SHA224 OBJECT IDENTIFIER ::= { |
| 295 | * iso(1) member-body(2) us(840) ansi-X9-62(10045) signatures(4) |
| 296 | * ecdsa-with-SHA2(3) 1 } */ |
| 297 | #define OID_ECDSA_SHA224 OID_ANSI_X9_62_SIG_SHA2 "\x01" |
| 298 | |
| 299 | /* ecdsa-with-SHA256 OBJECT IDENTIFIER ::= { |
| 300 | * iso(1) member-body(2) us(840) ansi-X9-62(10045) signatures(4) |
| 301 | * ecdsa-with-SHA2(3) 2 } */ |
| 302 | #define OID_ECDSA_SHA256 OID_ANSI_X9_62_SIG_SHA2 "\x02" |
| 303 | |
| 304 | /* ecdsa-with-SHA384 OBJECT IDENTIFIER ::= { |
| 305 | * iso(1) member-body(2) us(840) ansi-X9-62(10045) signatures(4) |
| 306 | * ecdsa-with-SHA2(3) 3 } */ |
| 307 | #define OID_ECDSA_SHA384 OID_ANSI_X9_62_SIG_SHA2 "\x03" |
| 308 | |
| 309 | /* ecdsa-with-SHA512 OBJECT IDENTIFIER ::= { |
| 310 | * iso(1) member-body(2) us(840) ansi-X9-62(10045) signatures(4) |
| 311 | * ecdsa-with-SHA2(3) 4 } */ |
| 312 | #define OID_ECDSA_SHA512 OID_ANSI_X9_62_SIG_SHA2 "\x04" |
| 313 | |
Paul Bakker | c70b982 | 2013-04-07 22:00:46 +0200 | [diff] [blame] | 314 | #ifdef __cplusplus |
| 315 | extern "C" { |
| 316 | #endif |
| 317 | |
| 318 | /** |
| 319 | * \brief Base OID descriptor structure |
| 320 | */ |
| 321 | typedef struct { |
| 322 | const char *asn1; /*!< OID ASN.1 representation */ |
Manuel Pégourié-Gonnard | 298aae4 | 2013-08-15 14:22:17 +0200 | [diff] [blame] | 323 | size_t asn1_len; /*!< length of asn1 */ |
Paul Bakker | c70b982 | 2013-04-07 22:00:46 +0200 | [diff] [blame] | 324 | const char *name; /*!< official name (e.g. from RFC) */ |
| 325 | const char *description; /*!< human friendly description */ |
| 326 | } oid_descriptor_t; |
| 327 | |
| 328 | /** |
| 329 | * \brief Translate an ASN.1 OID into its numeric representation |
| 330 | * (e.g. "\x2A\x86\x48\x86\xF7\x0D" into "1.2.840.113549") |
| 331 | * |
| 332 | * \param buf buffer to put representation in |
| 333 | * \param size size of the buffer |
| 334 | * \param oid OID to translate |
| 335 | * |
| 336 | * \return POLARSSL_ERR_DEBUG_BUF_TOO_SMALL or actual length used |
| 337 | */ |
| 338 | int oid_get_numeric_string( char *buf, size_t size, const asn1_buf *oid ); |
| 339 | |
Paul Bakker | ed27a04 | 2013-04-18 22:46:23 +0200 | [diff] [blame] | 340 | #if defined(POLARSSL_X509_PARSE_C) |
Paul Bakker | c70b982 | 2013-04-07 22:00:46 +0200 | [diff] [blame] | 341 | /** |
| 342 | * \brief Translate an X.509 extension OID into local values |
| 343 | * |
| 344 | * \param oid OID to use |
| 345 | * \param ext_type place to store the extension type |
| 346 | * |
| 347 | * \return 0 if successful, or POLARSSL_ERR_OID_NOT_FOUND |
| 348 | */ |
| 349 | 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] | 350 | #endif |
Paul Bakker | c70b982 | 2013-04-07 22:00:46 +0200 | [diff] [blame] | 351 | |
| 352 | /** |
| 353 | * \brief Translate an X.509 attribute type OID into the short name |
| 354 | * (e.g. the OID for an X520 Common Name into "CN") |
| 355 | * |
| 356 | * \param oid OID to use |
| 357 | * \param short_name place to store the string pointer |
| 358 | * |
| 359 | * \return 0 if successful, or POLARSSL_ERR_OID_NOT_FOUND |
| 360 | */ |
| 361 | int oid_get_attr_short_name( const asn1_buf *oid, const char **short_name ); |
| 362 | |
| 363 | /** |
| 364 | * \brief Translate PublicKeyAlgorithm OID into pk_type |
| 365 | * |
| 366 | * \param oid OID to use |
| 367 | * \param pk_alg place to store public key algorithm |
| 368 | * |
| 369 | * \return 0 if successful, or POLARSSL_ERR_OID_NOT_FOUND |
| 370 | */ |
| 371 | int oid_get_pk_alg( const asn1_buf *oid, pk_type_t *pk_alg ); |
| 372 | |
Manuel Pégourié-Gonnard | f0b30d0 | 2013-07-01 17:34:57 +0200 | [diff] [blame] | 373 | /** |
| 374 | * \brief Translate ECParameters OID into an EC group identifier |
| 375 | * |
| 376 | * \param oid OID to use |
| 377 | * \param grp_id place to store group id |
| 378 | * |
| 379 | * \return 0 if successful, or POLARSSL_ERR_OID_NOT_FOUND |
| 380 | */ |
| 381 | int oid_get_ec_grp( const asn1_buf *oid, ecp_group_id *grp_id ); |
| 382 | |
Paul Bakker | 47fce02 | 2013-06-28 17:34:34 +0200 | [diff] [blame] | 383 | #if defined(POLARSSL_MD_C) |
Paul Bakker | c70b982 | 2013-04-07 22:00:46 +0200 | [diff] [blame] | 384 | /** |
| 385 | * \brief Translate SignatureAlgorithm OID into md_type and pk_type |
| 386 | * |
| 387 | * \param oid OID to use |
| 388 | * \param md_alg place to store message digest algorithm |
| 389 | * \param pk_alg place to store public key algorithm |
| 390 | * |
| 391 | * \return 0 if successful, or POLARSSL_ERR_OID_NOT_FOUND |
| 392 | */ |
| 393 | int oid_get_sig_alg( const asn1_buf *oid, |
| 394 | md_type_t *md_alg, pk_type_t *pk_alg ); |
| 395 | |
| 396 | /** |
| 397 | * \brief Translate SignatureAlgorithm OID into description |
| 398 | * |
| 399 | * \param oid OID to use |
| 400 | * \param desc place to store string pointer |
| 401 | * |
| 402 | * \return 0 if successful, or POLARSSL_ERR_OID_NOT_FOUND |
| 403 | */ |
| 404 | int oid_get_sig_alg_desc( const asn1_buf *oid, const char **desc ); |
| 405 | |
| 406 | /** |
| 407 | * \brief Translate md_type and pk_type into SignatureAlgorithm OID |
| 408 | * |
| 409 | * \param md_alg message digest algorithm |
| 410 | * \param pk_alg public key algorithm |
| 411 | * \param oid place to store ASN.1 OID string pointer |
| 412 | * |
| 413 | * \return 0 if successful, or POLARSSL_ERR_OID_NOT_FOUND |
| 414 | */ |
| 415 | int oid_get_oid_by_sig_alg( pk_type_t pk_alg, md_type_t md_alg, |
| 416 | const char **oid_str ); |
| 417 | |
| 418 | /** |
| 419 | * \brief Translate hash algorithm OID into md_type |
| 420 | * |
| 421 | * \param oid OID to use |
| 422 | * \param md_alg place to store message digest algorithm |
| 423 | * |
| 424 | * \return 0 if successful, or POLARSSL_ERR_OID_NOT_FOUND |
| 425 | */ |
| 426 | 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] | 427 | #endif /* POLARSSL_MD_C */ |
Paul Bakker | c70b982 | 2013-04-07 22:00:46 +0200 | [diff] [blame] | 428 | |
| 429 | /** |
| 430 | * \brief Translate Extended Key Usage OID into description |
| 431 | * |
| 432 | * \param oid OID to use |
| 433 | * \param desc place to store string pointer |
| 434 | * |
| 435 | * \return 0 if successful, or POLARSSL_ERR_OID_NOT_FOUND |
| 436 | */ |
| 437 | int oid_get_extended_key_usage( const asn1_buf *oid, const char **desc ); |
| 438 | |
| 439 | /** |
| 440 | * \brief Translate md_type into hash algorithm OID |
| 441 | * |
| 442 | * \param md_alg message digest algorithm |
| 443 | * \param oid place to store ASN.1 OID string pointer |
| 444 | * |
| 445 | * \return 0 if successful, or POLARSSL_ERR_OID_NOT_FOUND |
| 446 | */ |
| 447 | int oid_get_oid_by_md( md_type_t md_alg, const char **oid_str ); |
| 448 | |
Paul Bakker | 47fce02 | 2013-06-28 17:34:34 +0200 | [diff] [blame] | 449 | #if defined(POLARSSL_CIPHER_C) |
Paul Bakker | 9b5e885 | 2013-06-28 16:12:50 +0200 | [diff] [blame] | 450 | /** |
| 451 | * \brief Translate encryption algorithm OID into cipher_type |
| 452 | * |
| 453 | * \param oid OID to use |
| 454 | * \param cipher_alg place to store cipher algorithm |
| 455 | * |
| 456 | * \return 0 if successful, or POLARSSL_ERR_OID_NOT_FOUND |
| 457 | */ |
| 458 | 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] | 459 | #endif /* POLARSSL_CIPHER_C */ |
Paul Bakker | 9b5e885 | 2013-06-28 16:12:50 +0200 | [diff] [blame] | 460 | |
Paul Bakker | 7749a22 | 2013-06-28 17:28:20 +0200 | [diff] [blame] | 461 | #if defined(POLARSSL_PKCS12_C) |
| 462 | /** |
| 463 | * \brief Translate PKCS#12 PBE algorithm OID into md_type and |
| 464 | * cipher_type |
| 465 | * |
| 466 | * \param oid OID to use |
| 467 | * \param md_alg place to store message digest algorithm |
| 468 | * \param cipher_alg place to store cipher algorithm |
| 469 | * |
| 470 | * \return 0 if successful, or POLARSSL_ERR_OID_NOT_FOUND |
| 471 | */ |
| 472 | int oid_get_pkcs12_pbe_alg( const asn1_buf *oid, md_type_t *md_alg, |
| 473 | cipher_type_t *cipher_alg ); |
| 474 | #endif /* POLARSSL_PKCS12_C */ |
| 475 | |
Paul Bakker | c70b982 | 2013-04-07 22:00:46 +0200 | [diff] [blame] | 476 | #ifdef __cplusplus |
| 477 | } |
| 478 | #endif |
| 479 | |
| 480 | #endif /* oid.h */ |