49#if !defined(MBEDTLS_CONFIG_FILE)
52#include MBEDTLS_CONFIG_FILE
55#if defined(MBEDTLS_OID_C)
63#if defined(MBEDTLS_PLATFORM_C)
66#define mbedtls_snprintf snprintf
69#if defined(MBEDTLS_X509_USE_C) || defined(MBEDTLS_X509_CREATE_C)
76#define ADD_LEN(s) s, MBEDTLS_OID_SIZE(s)
82#define FN_OID_TYPED_FROM_ASN1( TYPE_T, NAME, LIST ) \
83 static const TYPE_T * oid_ ## NAME ## _from_asn1( \
84 const mbedtls_asn1_buf *oid ) \
86 const TYPE_T *p = (LIST); \
87 const mbedtls_oid_descriptor_t *cur = \
88 (const mbedtls_oid_descriptor_t *) p; \
89 if( p == NULL || oid == NULL ) return( NULL ); \
90 while( cur->asn1 != NULL ) { \
91 if( cur->asn1_len == oid->len && \
92 memcmp( cur->asn1, oid->p, oid->len ) == 0 ) { \
96 cur = (const mbedtls_oid_descriptor_t *) p; \
105#define FN_OID_GET_DESCRIPTOR_ATTR1(FN_NAME, TYPE_T, TYPE_NAME, ATTR1_TYPE, ATTR1) \
106int FN_NAME( const mbedtls_asn1_buf *oid, ATTR1_TYPE * ATTR1 ) \
108 const TYPE_T *data = oid_ ## TYPE_NAME ## _from_asn1( oid ); \
109 if( data == NULL ) return( MBEDTLS_ERR_OID_NOT_FOUND ); \
110 *ATTR1 = data->descriptor.ATTR1; \
118#define FN_OID_GET_ATTR1(FN_NAME, TYPE_T, TYPE_NAME, ATTR1_TYPE, ATTR1) \
119int FN_NAME( const mbedtls_asn1_buf *oid, ATTR1_TYPE * ATTR1 ) \
121 const TYPE_T *data = oid_ ## TYPE_NAME ## _from_asn1( oid ); \
122 if( data == NULL ) return( MBEDTLS_ERR_OID_NOT_FOUND ); \
123 *ATTR1 = data->ATTR1; \
131#define FN_OID_GET_ATTR2(FN_NAME, TYPE_T, TYPE_NAME, ATTR1_TYPE, ATTR1, \
133int FN_NAME( const mbedtls_asn1_buf *oid, ATTR1_TYPE * ATTR1, \
134 ATTR2_TYPE * ATTR2 ) \
136 const TYPE_T *data = oid_ ## TYPE_NAME ## _from_asn1( oid ); \
137 if( data == NULL ) return( MBEDTLS_ERR_OID_NOT_FOUND ); \
138 *(ATTR1) = data->ATTR1; \
139 *(ATTR2) = data->ATTR2; \
147#define FN_OID_GET_OID_BY_ATTR1(FN_NAME, TYPE_T, LIST, ATTR1_TYPE, ATTR1) \
148int FN_NAME( ATTR1_TYPE ATTR1, const char **oid, size_t *olen ) \
150 const TYPE_T *cur = (LIST); \
151 while( cur->descriptor.asn1 != NULL ) { \
152 if( cur->ATTR1 == (ATTR1) ) { \
153 *oid = cur->descriptor.asn1; \
154 *olen = cur->descriptor.asn1_len; \
159 return( MBEDTLS_ERR_OID_NOT_FOUND ); \
166#define FN_OID_GET_OID_BY_ATTR2(FN_NAME, TYPE_T, LIST, ATTR1_TYPE, ATTR1, \
168int FN_NAME( ATTR1_TYPE ATTR1, ATTR2_TYPE ATTR2, const char **oid , \
171 const TYPE_T *cur = (LIST); \
172 while( cur->descriptor.asn1 != NULL ) { \
173 if( cur->ATTR1 == (ATTR1) && cur->ATTR2 == (ATTR2) ) { \
174 *oid = cur->descriptor.asn1; \
175 *olen = cur->descriptor.asn1_len; \
180 return( MBEDTLS_ERR_OID_NOT_FOUND ); \
183#if defined(MBEDTLS_X509_USE_C) || defined(MBEDTLS_X509_CREATE_C)
192static const oid_x520_attr_t oid_x520_attr_type[] =
248 "generationQualifier",
276FN_OID_TYPED_FROM_ASN1(oid_x520_attr_t, x520_attr, oid_x520_attr_type)
287static const oid_x509_ext_t oid_x509_ext[] =
315FN_OID_TYPED_FROM_ASN1(oid_x509_ext_t, x509_ext, oid_x509_ext)
333#if defined(MBEDTLS_MD_C)
343static const oid_sig_alg_t oid_sig_alg[] =
345#if defined(MBEDTLS_RSA_C)
346#if defined(MBEDTLS_MD2_C)
352#if defined(MBEDTLS_MD4_C)
358#if defined(MBEDTLS_MD5_C)
364#if defined(MBEDTLS_SHA1_C)
370#if defined(MBEDTLS_SHA256_C)
380#if defined(MBEDTLS_SHA512_C)
390#if defined(MBEDTLS_SHA1_C)
397#if defined(MBEDTLS_ECDSA_C)
398#if defined(MBEDTLS_SHA1_C)
404#if defined(MBEDTLS_SHA256_C)
414#if defined(MBEDTLS_SHA512_C)
425#if defined(MBEDTLS_RSA_C)
437FN_OID_TYPED_FROM_ASN1(oid_sig_alg_t, sig_alg, oid_sig_alg)
451static const oid_pk_alg_t oid_pk_alg[] =
471FN_OID_TYPED_FROM_ASN1(oid_pk_alg_t, pk_alg, oid_pk_alg)
475#if defined(MBEDTLS_ECP_C)
484static const oid_ecp_grp_t oid_ecp_grp[] =
486#if defined(MBEDTLS_ECP_DP_SECP192R1_ENABLED)
492#if defined(MBEDTLS_ECP_DP_SECP224R1_ENABLED)
498#if defined(MBEDTLS_ECP_DP_SECP256R1_ENABLED)
504#if defined(MBEDTLS_ECP_DP_SECP384R1_ENABLED)
510#if defined(MBEDTLS_ECP_DP_SECP521R1_ENABLED)
516#if defined(MBEDTLS_ECP_DP_SECP192K1_ENABLED)
522#if defined(MBEDTLS_ECP_DP_SECP224K1_ENABLED)
528#if defined(MBEDTLS_ECP_DP_SECP256K1_ENABLED)
534#if defined(MBEDTLS_ECP_DP_BP256R1_ENABLED)
540#if defined(MBEDTLS_ECP_DP_BP384R1_ENABLED)
546#if defined(MBEDTLS_ECP_DP_BP512R1_ENABLED)
558FN_OID_TYPED_FROM_ASN1(oid_ecp_grp_t, grp_id, oid_ecp_grp)
563#if defined(MBEDTLS_CIPHER_C)
572static const oid_cipher_alg_t oid_cipher_alg[] =
588FN_OID_TYPED_FROM_ASN1(oid_cipher_alg_t, cipher_alg, oid_cipher_alg)
592#if defined(MBEDTLS_MD_C)
601static const oid_md_alg_t oid_md_alg[] =
603#if defined(MBEDTLS_MD2_C)
609#if defined(MBEDTLS_MD4_C)
615#if defined(MBEDTLS_MD5_C)
621#if defined(MBEDTLS_SHA1_C)
627#if defined(MBEDTLS_SHA256_C)
637#if defined(MBEDTLS_SHA512_C)
653FN_OID_TYPED_FROM_ASN1(oid_md_alg_t, md_alg, oid_md_alg)
665static const oid_md_hmac_t oid_md_hmac[] =
667#if defined(MBEDTLS_SHA1_C)
673#if defined(MBEDTLS_SHA256_C)
683#if defined(MBEDTLS_SHA512_C)
699FN_OID_TYPED_FROM_ASN1(oid_md_hmac_t,
md_hmac, oid_md_hmac)
703#if defined(MBEDTLS_PKCS12_C)
711} oid_pkcs12_pbe_alg_t;
713static const oid_pkcs12_pbe_alg_t oid_pkcs12_pbe_alg[] =
729FN_OID_TYPED_FROM_ASN1(oid_pkcs12_pbe_alg_t, pkcs12_pbe_alg, oid_pkcs12_pbe_alg)
733#define OID_SAFE_SNPRINTF \
735 if( ret < 0 || (size_t) ret >= n ) \
736 return( MBEDTLS_ERR_OID_BUF_TOO_SMALL ); \
762 for(
i = 1;
i < oid->
len;
i++ )
771 if( !( oid->
p[
i] & 0x80 ) )
780 return( (
int) (
size -
n ) );
mbedtls_cipher_type_t
Supported {cipher type, cipher mode} pairs.
@ MBEDTLS_CIPHER_DES_EDE3_CBC
@ MBEDTLS_CIPHER_DES_EDE_CBC
GLenum GLuint GLenum GLsizei const GLchar * buf
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
#define MBEDTLS_X509_EXT_EXTENDED_KEY_USAGE
#define MBEDTLS_X509_EXT_BASIC_CONSTRAINTS
#define MBEDTLS_X509_EXT_KEY_USAGE
#define MBEDTLS_X509_EXT_SUBJECT_ALT_NAME
#define MBEDTLS_X509_EXT_NS_CERT_TYPE
mbedtls_md_type_t
Supported message digests.
Object Identifier (OID) database.
#define MBEDTLS_OID_DIGEST_ALG_SHA384
#define MBEDTLS_OID_CODE_SIGNING
int mbedtls_oid_get_attr_short_name(const mbedtls_asn1_buf *oid, const char **short_name)
Translate an X.509 attribute type OID into the short name (e.g. the OID for an X520 Common Name into ...
#define MBEDTLS_OID_SUBJECT_ALT_NAME
#define MBEDTLS_OID_PKCS1_RSA
#define MBEDTLS_OID_PKCS12_PBE_SHA1_DES2_EDE_CBC
#define MBEDTLS_OID_AT_GENERATION_QUALIFIER
#define MBEDTLS_OID_DIGEST_ALG_SHA256
#define MBEDTLS_OID_DIGEST_ALG_SHA1
#define MBEDTLS_OID_EC_GRP_SECP521R1
#define MBEDTLS_OID_EC_GRP_SECP224R1
int mbedtls_oid_get_cipher_alg(const mbedtls_asn1_buf *oid, mbedtls_cipher_type_t *cipher_alg)
Translate encryption algorithm OID into cipher_type.
#define MBEDTLS_OID_EXTENDED_KEY_USAGE
#define MBEDTLS_OID_AT_POSTAL_ADDRESS
#define MBEDTLS_ERR_OID_BUF_TOO_SMALL
#define MBEDTLS_OID_AT_SERIAL_NUMBER
#define MBEDTLS_OID_AT_DN_QUALIFIER
#define MBEDTLS_OID_AT_UNIQUE_IDENTIFIER
#define MBEDTLS_OID_PKCS1_SHA384
#define MBEDTLS_OID_EC_ALG_ECDH
#define MBEDTLS_OID_EC_GRP_SECP256K1
#define MBEDTLS_OID_EC_ALG_UNRESTRICTED
#define MBEDTLS_OID_PKCS1_MD4
int mbedtls_oid_get_pk_alg(const mbedtls_asn1_buf *oid, mbedtls_pk_type_t *pk_alg)
Translate PublicKeyAlgorithm OID into pk_type.
#define MBEDTLS_OID_AT_INITIALS
#define MBEDTLS_OID_CLIENT_AUTH
#define MBEDTLS_OID_DIGEST_ALG_MD5
#define MBEDTLS_OID_DIGEST_ALG_SHA512
#define MBEDTLS_OID_ECDSA_SHA384
#define MBEDTLS_OID_EC_GRP_SECP384R1
#define MBEDTLS_OID_AT_LOCALITY
#define MBEDTLS_OID_DIGEST_ALG_MD2
#define MBEDTLS_OID_BASIC_CONSTRAINTS
int mbedtls_oid_get_extended_key_usage(const mbedtls_asn1_buf *oid, const char **desc)
Translate Extended Key Usage OID into description.
#define MBEDTLS_OID_RSA_SHA_OBS
#define MBEDTLS_OID_AT_POSTAL_CODE
#define MBEDTLS_OID_EC_GRP_SECP192K1
#define MBEDTLS_OID_KEY_USAGE
int mbedtls_oid_get_oid_by_md(mbedtls_md_type_t md_alg, const char **oid, size_t *olen)
Translate md_type into hash algorithm OID.
#define MBEDTLS_OID_PKCS1_MD2
#define MBEDTLS_OID_AT_SUR_NAME
#define MBEDTLS_OID_EC_GRP_BP384R1
#define MBEDTLS_OID_EC_GRP_SECP224K1
#define MBEDTLS_OID_AT_STATE
#define MBEDTLS_OID_DES_EDE3_CBC
#define MBEDTLS_OID_HMAC_SHA1
int mbedtls_oid_get_ec_grp(const mbedtls_asn1_buf *oid, mbedtls_ecp_group_id *grp_id)
Translate NamedCurve OID into an EC group identifier.
#define MBEDTLS_OID_PKCS9_EMAIL
#define MBEDTLS_OID_NS_CERT_TYPE
#define MBEDTLS_OID_PKCS1_MD5
int mbedtls_oid_get_oid_by_sig_alg(mbedtls_pk_type_t pk_alg, mbedtls_md_type_t md_alg, const char **oid, size_t *olen)
Translate md_type and pk_type into SignatureAlgorithm OID.
int mbedtls_oid_get_x509_ext_type(const mbedtls_asn1_buf *oid, int *ext_type)
Translate an X.509 extension OID into local values.
#define MBEDTLS_OID_EMAIL_PROTECTION
#define MBEDTLS_OID_DIGEST_ALG_SHA224
#define MBEDTLS_OID_DIGEST_ALG_MD4
#define MBEDTLS_OID_AT_TITLE
#define MBEDTLS_OID_AT_COUNTRY
#define MBEDTLS_OID_PKCS1_SHA256
#define MBEDTLS_OID_TIME_STAMPING
#define MBEDTLS_OID_HMAC_SHA512
#define MBEDTLS_OID_ECDSA_SHA512
int mbedtls_oid_get_oid_by_ec_grp(mbedtls_ecp_group_id grp_id, const char **oid, size_t *olen)
Translate EC group identifier into NamedCurve OID.
#define MBEDTLS_OID_HMAC_SHA256
#define MBEDTLS_OID_HMAC_SHA224
#define MBEDTLS_OID_AT_PSEUDONYM
#define MBEDTLS_OID_OCSP_SIGNING
#define MBEDTLS_OID_RSASSA_PSS
#define MBEDTLS_OID_SERVER_AUTH
int mbedtls_oid_get_md_hmac(const mbedtls_asn1_buf *oid, mbedtls_md_type_t *md_hmac)
Translate hmac algorithm OID into md_type.
#define MBEDTLS_OID_HMAC_SHA384
#define MBEDTLS_OID_DES_CBC
#define MBEDTLS_OID_EC_GRP_BP512R1
int mbedtls_oid_get_sig_alg(const mbedtls_asn1_buf *oid, mbedtls_md_type_t *md_alg, mbedtls_pk_type_t *pk_alg)
Translate SignatureAlgorithm OID into md_type and pk_type.
#define MBEDTLS_OID_EC_GRP_SECP256R1
#define MBEDTLS_OID_EC_GRP_SECP192R1
#define MBEDTLS_OID_DOMAIN_COMPONENT
int mbedtls_oid_get_md_alg(const mbedtls_asn1_buf *oid, mbedtls_md_type_t *md_alg)
Translate hash algorithm OID into md_type.
#define MBEDTLS_OID_AT_GIVEN_NAME
#define MBEDTLS_OID_AT_ORGANIZATION
#define MBEDTLS_OID_ECDSA_SHA1
#define MBEDTLS_OID_ECDSA_SHA256
int mbedtls_oid_get_sig_alg_desc(const mbedtls_asn1_buf *oid, const char **desc)
Translate SignatureAlgorithm OID into description.
#define MBEDTLS_OID_PKCS1_SHA1
#define MBEDTLS_OID_ECDSA_SHA224
#define MBEDTLS_OID_AT_CN
#define MBEDTLS_OID_PKCS1_SHA512
int mbedtls_oid_get_oid_by_pk_alg(mbedtls_pk_type_t pk_alg, const char **oid, size_t *olen)
Translate pk_type into PublicKeyAlgorithm OID.
#define MBEDTLS_OID_PKCS1_SHA224
#define MBEDTLS_OID_AT_ORG_UNIT
int mbedtls_oid_get_pkcs12_pbe_alg(const mbedtls_asn1_buf *oid, mbedtls_md_type_t *md_alg, mbedtls_cipher_type_t *cipher_alg)
Translate PKCS#12 PBE algorithm OID into md_type and cipher_type.
#define MBEDTLS_OID_PKCS12_PBE_SHA1_DES3_EDE_CBC
#define MBEDTLS_OID_EC_GRP_BP256R1
int mbedtls_oid_get_numeric_string(char *buf, size_t size, const mbedtls_asn1_buf *oid)
Translate an ASN.1 OID into its numeric representation (e.g. "\x2A\x86\x48\x86\xF7\x0D" into "1....
mbedtls_pk_type_t
Public key types.
This file provides an API for the RSA public-key cryptosystem.
Configuration options (set of defines)
@ MBEDTLS_ECP_DP_SECP192K1
@ MBEDTLS_ECP_DP_SECP384R1
@ MBEDTLS_ECP_DP_SECP256K1
@ MBEDTLS_ECP_DP_SECP224R1
@ MBEDTLS_ECP_DP_SECP521R1
@ MBEDTLS_ECP_DP_SECP224K1
@ MBEDTLS_ECP_DP_SECP192R1
@ MBEDTLS_ECP_DP_SECP256R1
Base OID descriptor structure.
X.509 generic defines and structures.