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