#include "common.h"
#if defined(MBEDTLS_OID_C)
#include "mbedtls/oid.h"
#include "mbedtls/rsa.h"
#include "mbedtls/error.h"
#include "mbedtls/pk.h"
#include <stdio.h>
#include <string.h>
#include "mbedtls/platform.h"
#define ADD_LEN(s) …
#if !defined(MBEDTLS_X509_REMOVE_INFO)
#define OID_DESCRIPTOR(s, name, description) …
#define NULL_OID_DESCRIPTOR …
#else
#define OID_DESCRIPTOR …
#define NULL_OID_DESCRIPTOR …
#endif
#define FN_OID_TYPED_FROM_ASN1(TYPE_T, NAME, LIST) …
#if !defined(MBEDTLS_X509_REMOVE_INFO)
#define FN_OID_GET_DESCRIPTOR_ATTR1(FN_NAME, TYPE_T, TYPE_NAME, ATTR1_TYPE, ATTR1) …
#endif
#define FN_OID_GET_ATTR1(FN_NAME, TYPE_T, TYPE_NAME, ATTR1_TYPE, ATTR1) …
#define FN_OID_GET_ATTR2(FN_NAME, TYPE_T, TYPE_NAME, ATTR1_TYPE, ATTR1, \
ATTR2_TYPE, ATTR2) …
#define FN_OID_GET_OID_BY_ATTR1(FN_NAME, TYPE_T, LIST, ATTR1_TYPE, ATTR1) …
#define FN_OID_GET_OID_BY_ATTR2(FN_NAME, TYPE_T, LIST, ATTR1_TYPE, ATTR1, \
ATTR2_TYPE, ATTR2) …
oid_x520_attr_t;
static const oid_x520_attr_t oid_x520_attr_type[] = …;
FN_OID_TYPED_FROM_ASN1(oid_x520_attr_t, x520_attr, oid_x520_attr_type)
FN_OID_GET_ATTR1(…) …
oid_x509_ext_t;
static const oid_x509_ext_t oid_x509_ext[] = …;
FN_OID_TYPED_FROM_ASN1(oid_x509_ext_t, x509_ext, oid_x509_ext)
FN_OID_GET_ATTR1(…) …
#if !defined(MBEDTLS_X509_REMOVE_INFO)
static const mbedtls_oid_descriptor_t oid_ext_key_usage[] = …;
FN_OID_TYPED_FROM_ASN1(mbedtls_oid_descriptor_t, ext_key_usage, oid_ext_key_usage)
FN_OID_GET_ATTR1(…) …
static const mbedtls_oid_descriptor_t oid_certificate_policies[] = …;
FN_OID_TYPED_FROM_ASN1(mbedtls_oid_descriptor_t, certificate_policies, oid_certificate_policies)
FN_OID_GET_ATTR1(…) …
#endif
oid_sig_alg_t;
static const oid_sig_alg_t oid_sig_alg[] = …;
FN_OID_TYPED_FROM_ASN1(oid_sig_alg_t, sig_alg, oid_sig_alg)
#if !defined(MBEDTLS_X509_REMOVE_INFO)
FN_OID_GET_DESCRIPTOR_ATTR1(…) …
#endif
FN_OID_GET_ATTR2(…) …
FN_OID_GET_OID_BY_ATTR2(mbedtls_oid_get_oid_by_sig_alg,
oid_sig_alg_t,
oid_sig_alg,
mbedtls_pk_type_t,
pk_alg,
mbedtls_md_type_t,
md_alg)
oid_pk_alg_t;
static const oid_pk_alg_t oid_pk_alg[] = …;
FN_OID_TYPED_FROM_ASN1(oid_pk_alg_t, pk_alg, oid_pk_alg)
FN_OID_GET_ATTR1(…) …
FN_OID_GET_OID_BY_ATTR1(mbedtls_oid_get_oid_by_pk_alg,
oid_pk_alg_t,
oid_pk_alg,
mbedtls_pk_type_t,
pk_alg)
#if defined(MBEDTLS_PK_HAVE_ECC_KEYS)
oid_ecp_grp_t;
static const oid_ecp_grp_t oid_ecp_grp[] = …;
FN_OID_TYPED_FROM_ASN1(oid_ecp_grp_t, grp_id, oid_ecp_grp)
FN_OID_GET_ATTR1(…) …
FN_OID_GET_OID_BY_ATTR1(mbedtls_oid_get_oid_by_ec_grp,
oid_ecp_grp_t,
oid_ecp_grp,
mbedtls_ecp_group_id,
grp_id)
oid_ecp_grp_algid_t;
static const oid_ecp_grp_algid_t oid_ecp_grp_algid[] = …;
FN_OID_TYPED_FROM_ASN1(oid_ecp_grp_algid_t, grp_id_algid, oid_ecp_grp_algid)
FN_OID_GET_ATTR1(…) …
FN_OID_GET_OID_BY_ATTR1(mbedtls_oid_get_oid_by_ec_grp_algid,
oid_ecp_grp_algid_t,
oid_ecp_grp_algid,
mbedtls_ecp_group_id,
grp_id)
#endif
#if defined(MBEDTLS_CIPHER_C)
oid_cipher_alg_t;
static const oid_cipher_alg_t oid_cipher_alg[] = …;
FN_OID_TYPED_FROM_ASN1(oid_cipher_alg_t, cipher_alg, oid_cipher_alg)
FN_OID_GET_ATTR1(…) …
#endif
oid_md_alg_t;
static const oid_md_alg_t oid_md_alg[] = …;
FN_OID_TYPED_FROM_ASN1(oid_md_alg_t, md_alg, oid_md_alg)
FN_OID_GET_ATTR1(…) …
FN_OID_GET_OID_BY_ATTR1(mbedtls_oid_get_oid_by_md,
oid_md_alg_t,
oid_md_alg,
mbedtls_md_type_t,
md_alg)
oid_md_hmac_t;
static const oid_md_hmac_t oid_md_hmac[] = …;
FN_OID_TYPED_FROM_ASN1(oid_md_hmac_t, md_hmac, oid_md_hmac)
FN_OID_GET_ATTR1(…) …
#if defined(MBEDTLS_PKCS12_C) && defined(MBEDTLS_CIPHER_C)
oid_pkcs12_pbe_alg_t;
static const oid_pkcs12_pbe_alg_t oid_pkcs12_pbe_alg[] = …;
FN_OID_TYPED_FROM_ASN1(oid_pkcs12_pbe_alg_t, pkcs12_pbe_alg, oid_pkcs12_pbe_alg)
FN_OID_GET_ATTR2(…) …
#endif
int mbedtls_oid_get_numeric_string(char *buf, size_t size,
const mbedtls_asn1_buf *oid)
{ … }
static int oid_parse_number(unsigned int *num, const char **p, const char *bound)
{ … }
static size_t oid_subidentifier_num_bytes(unsigned int value)
{ … }
static int oid_subidentifier_encode_into(unsigned char **p,
unsigned char *bound,
unsigned int value)
{ … }
int mbedtls_oid_from_numeric_string(mbedtls_asn1_buf *oid,
const char *oid_str, size_t size)
{ … }
#endif