RetroArch
Classes | Macros | Functions | Variables
oid.c File Reference

Object Identifier (OID) database. More...

#include "mbedtls/config.h"
#include "mbedtls/oid.h"
#include "mbedtls/rsa.h"
#include <stdio.h>
#include <string.h>
#include "mbedtls/platform.h"
#include "mbedtls/x509.h"
Include dependency graph for oid.c:

Classes

struct  oid_x520_attr_t
 
struct  oid_x509_ext_t
 
struct  oid_sig_alg_t
 
struct  oid_pk_alg_t
 
struct  oid_ecp_grp_t
 
struct  oid_cipher_alg_t
 
struct  oid_md_alg_t
 
struct  oid_pkcs12_pbe_alg_t
 

Macros

#define ADD_LEN(s)   s, MBEDTLS_OID_SIZE(s)
 
#define FN_OID_TYPED_FROM_ASN1(TYPE_T, NAME, LIST)
 
#define FN_OID_GET_DESCRIPTOR_ATTR1(FN_NAME, TYPE_T, TYPE_NAME, ATTR1_TYPE, ATTR1)
 
#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)
 
#define OID_SAFE_SNPRINTF
 

Functions

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.2.840.113549") More...
 

Variables

static const oid_x520_attr_t oid_x520_attr_type []
 
static const oid_x509_ext_t oid_x509_ext []
 
static const mbedtls_oid_descriptor_t oid_ext_key_usage []
 
static const oid_sig_alg_t oid_sig_alg []
 
static const oid_pk_alg_t oid_pk_alg []
 
static const oid_ecp_grp_t oid_ecp_grp []
 
static const oid_cipher_alg_t oid_cipher_alg []
 
static const oid_md_alg_t oid_md_alg []
 
static const oid_pkcs12_pbe_alg_t oid_pkcs12_pbe_alg []
 

Detailed Description

Object Identifier (OID) database.

Copyright (C) 2006-2015, ARM Limited, All Rights Reserved SPDX-License-Identifier: Apache-2.0

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

This file is part of mbed TLS (https://tls.mbed.org)

Macro Definition Documentation

◆ ADD_LEN

#define ADD_LEN (   s)    s, MBEDTLS_OID_SIZE(s)

◆ FN_OID_GET_ATTR1

#define FN_OID_GET_ATTR1 (   FN_NAME,
  TYPE_T,
  TYPE_NAME,
  ATTR1_TYPE,
  ATTR1 
)
Value:
int FN_NAME( const mbedtls_asn1_buf *oid, ATTR1_TYPE * ATTR1 ) \
{ \
const TYPE_T *data = oid_ ## TYPE_NAME ## _from_asn1( oid ); \
if( data == NULL ) return( MBEDTLS_ERR_OID_NOT_FOUND ); \
*ATTR1 = data->ATTR1; \
return( 0 ); \
}
#define TYPE_NAME()
Definition: vector_list.c:42
Definition: ibxm.h:9
Definition: asn1.h:118
#define NULL
Pointer to 0.
Definition: gctypes.h:65
#define MBEDTLS_ERR_OID_NOT_FOUND
Definition: oid.h:49

◆ FN_OID_GET_ATTR2

#define FN_OID_GET_ATTR2 (   FN_NAME,
  TYPE_T,
  TYPE_NAME,
  ATTR1_TYPE,
  ATTR1,
  ATTR2_TYPE,
  ATTR2 
)
Value:
int FN_NAME( const mbedtls_asn1_buf *oid, ATTR1_TYPE * ATTR1, ATTR2_TYPE * ATTR2 ) \
{ \
const TYPE_T *data = oid_ ## TYPE_NAME ## _from_asn1( oid ); \
if( data == NULL ) return( MBEDTLS_ERR_OID_NOT_FOUND ); \
*ATTR1 = data->ATTR1; \
*ATTR2 = data->ATTR2; \
return( 0 ); \
}
#define TYPE_NAME()
Definition: vector_list.c:42
Definition: ibxm.h:9
Definition: asn1.h:118
#define NULL
Pointer to 0.
Definition: gctypes.h:65
#define MBEDTLS_ERR_OID_NOT_FOUND
Definition: oid.h:49

◆ FN_OID_GET_DESCRIPTOR_ATTR1

#define FN_OID_GET_DESCRIPTOR_ATTR1 (   FN_NAME,
  TYPE_T,
  TYPE_NAME,
  ATTR1_TYPE,
  ATTR1 
)
Value:
int FN_NAME( const mbedtls_asn1_buf *oid, ATTR1_TYPE * ATTR1 ) \
{ \
const TYPE_T *data = oid_ ## TYPE_NAME ## _from_asn1( oid ); \
if( data == NULL ) return( MBEDTLS_ERR_OID_NOT_FOUND ); \
*ATTR1 = data->descriptor.ATTR1; \
return( 0 ); \
}
#define TYPE_NAME()
Definition: vector_list.c:42
Definition: ibxm.h:9
Definition: asn1.h:118
#define NULL
Pointer to 0.
Definition: gctypes.h:65
#define MBEDTLS_ERR_OID_NOT_FOUND
Definition: oid.h:49

◆ FN_OID_GET_OID_BY_ATTR1

#define FN_OID_GET_OID_BY_ATTR1 (   FN_NAME,
  TYPE_T,
  LIST,
  ATTR1_TYPE,
  ATTR1 
)
Value:
int FN_NAME( ATTR1_TYPE ATTR1, const char **oid, size_t *olen ) \
{ \
const TYPE_T *cur = LIST; \
while( cur->descriptor.asn1 != NULL ) { \
if( cur->ATTR1 == ATTR1 ) { \
*oid = cur->descriptor.asn1; \
*olen = cur->descriptor.asn1_len; \
return( 0 ); \
} \
cur++; \
} \
}
static overlayled_t * cur
Definition: led_overlay.c:18
#define NULL
Pointer to 0.
Definition: gctypes.h:65
#define MBEDTLS_ERR_OID_NOT_FOUND
Definition: oid.h:49

◆ FN_OID_GET_OID_BY_ATTR2

#define FN_OID_GET_OID_BY_ATTR2 (   FN_NAME,
  TYPE_T,
  LIST,
  ATTR1_TYPE,
  ATTR1,
  ATTR2_TYPE,
  ATTR2 
)
Value:
int FN_NAME( ATTR1_TYPE ATTR1, ATTR2_TYPE ATTR2, const char **oid , \
size_t *olen ) \
{ \
const TYPE_T *cur = LIST; \
while( cur->descriptor.asn1 != NULL ) { \
if( cur->ATTR1 == ATTR1 && cur->ATTR2 == ATTR2 ) { \
*oid = cur->descriptor.asn1; \
*olen = cur->descriptor.asn1_len; \
return( 0 ); \
} \
cur++; \
} \
}
static overlayled_t * cur
Definition: led_overlay.c:18
#define NULL
Pointer to 0.
Definition: gctypes.h:65
#define MBEDTLS_ERR_OID_NOT_FOUND
Definition: oid.h:49

◆ FN_OID_TYPED_FROM_ASN1

#define FN_OID_TYPED_FROM_ASN1 (   TYPE_T,
  NAME,
  LIST 
)
Value:
static const TYPE_T * oid_ ## NAME ## _from_asn1( const mbedtls_asn1_buf *oid ) \
{ \
const TYPE_T *p = LIST; \
if( p == NULL || oid == NULL ) return( NULL ); \
while( cur->asn1 != NULL ) { \
if( cur->asn1_len == oid->len && \
memcmp( cur->asn1, oid->p, oid->len ) == 0 ) { \
return( p ); \
} \
p++; \
cur = (const mbedtls_oid_descriptor_t *) p; \
} \
return( NULL ); \
}
static overlayled_t * cur
Definition: led_overlay.c:18
int memcmp(const void *s1, const void *s2, unsigned int length)
Definition: compat_ctype.c:51
Definition: asn1.h:118
#define NULL
Pointer to 0.
Definition: gctypes.h:65
Definition: inflate.h:30
GLfloat GLfloat p
Definition: glext.h:9809
Base OID descriptor structure.
Definition: oid.h:382

◆ OID_SAFE_SNPRINTF

#define OID_SAFE_SNPRINTF
Value:
do { \
if( ret < 0 || (size_t) ret >= n ) \
\
n -= (size_t) ret; \
p += (size_t) ret; \
} while( 0 )
#define MBEDTLS_ERR_OID_BUF_TOO_SMALL
Definition: oid.h:50
GLdouble n
Definition: glext.h:8396

Function Documentation

◆ mbedtls_oid_get_numeric_string()

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.2.840.113549")

Parameters
bufbuffer to put representation in
sizesize of the buffer
oidOID to translate
Returns
Length of the string written (excluding final NULL) or MBEDTLS_ERR_OID_BUF_TOO_SMALL in case of error

Variable Documentation

◆ oid_cipher_alg

const oid_cipher_alg_t oid_cipher_alg[]
static
Initial value:
=
{
{
{ ADD_LEN( MBEDTLS_OID_DES_CBC ), "desCBC", "DES-CBC" },
},
{
{ ADD_LEN( MBEDTLS_OID_DES_EDE3_CBC ), "des-ede3-cbc", "DES-EDE3-CBC" },
},
{
{ NULL, 0, NULL, NULL },
},
}
#define MBEDTLS_OID_DES_EDE3_CBC
Definition: oid.h:234
Definition: cipher.h:111
#define NULL
Pointer to 0.
Definition: gctypes.h:65
Definition: cipher.h:115
Definition: cipher.h:78
#define MBEDTLS_OID_DES_CBC
Definition: oid.h:233
#define ADD_LEN(s)
Definition: oid.c:51

◆ oid_ecp_grp

const oid_ecp_grp_t oid_ecp_grp[]
static

◆ oid_ext_key_usage

const mbedtls_oid_descriptor_t oid_ext_key_usage[]
static
Initial value:
=
{
{ ADD_LEN( MBEDTLS_OID_SERVER_AUTH ), "id-kp-serverAuth", "TLS Web Server Authentication" },
{ ADD_LEN( MBEDTLS_OID_CLIENT_AUTH ), "id-kp-clientAuth", "TLS Web Client Authentication" },
{ ADD_LEN( MBEDTLS_OID_CODE_SIGNING ), "id-kp-codeSigning", "Code Signing" },
{ ADD_LEN( MBEDTLS_OID_EMAIL_PROTECTION ), "id-kp-emailProtection", "E-mail Protection" },
{ ADD_LEN( MBEDTLS_OID_TIME_STAMPING ), "id-kp-timeStamping", "Time Stamping" },
{ ADD_LEN( MBEDTLS_OID_OCSP_SIGNING ), "id-kp-OCSPSigning", "OCSP Signing" },
{ NULL, 0, NULL, NULL },
}
#define MBEDTLS_OID_TIME_STAMPING
Definition: oid.h:180
#define MBEDTLS_OID_CODE_SIGNING
Definition: oid.h:178
#define MBEDTLS_OID_EMAIL_PROTECTION
Definition: oid.h:179
#define MBEDTLS_OID_CLIENT_AUTH
Definition: oid.h:177
#define NULL
Pointer to 0.
Definition: gctypes.h:65
#define MBEDTLS_OID_SERVER_AUTH
Definition: oid.h:176
#define MBEDTLS_OID_OCSP_SIGNING
Definition: oid.h:181
#define ADD_LEN(s)
Definition: oid.c:51

◆ oid_md_alg

const oid_md_alg_t oid_md_alg[]
static

◆ oid_pk_alg

const oid_pk_alg_t oid_pk_alg[]
static
Initial value:
=
{
{
{ ADD_LEN( MBEDTLS_OID_PKCS1_RSA ), "rsaEncryption", "RSA" },
},
{
{ ADD_LEN( MBEDTLS_OID_EC_ALG_UNRESTRICTED ), "id-ecPublicKey", "Generic EC key" },
},
{
{ ADD_LEN( MBEDTLS_OID_EC_ALG_ECDH ), "id-ecDH", "EC key for ECDH" },
},
{
{ NULL, 0, NULL, NULL },
},
}
Definition: pk.h:74
Definition: pk.h:75
#define MBEDTLS_OID_PKCS1_RSA
Definition: oid.h:196
Definition: pk.h:72
#define NULL
Pointer to 0.
Definition: gctypes.h:65
#define MBEDTLS_OID_EC_ALG_ECDH
Definition: oid.h:281
Definition: pk.h:73
#define MBEDTLS_OID_EC_ALG_UNRESTRICTED
Definition: oid.h:276
#define ADD_LEN(s)
Definition: oid.c:51

◆ oid_pkcs12_pbe_alg

const oid_pkcs12_pbe_alg_t oid_pkcs12_pbe_alg[]
static
Initial value:
=
{
{
{ ADD_LEN( MBEDTLS_OID_PKCS12_PBE_SHA1_DES3_EDE_CBC ), "pbeWithSHAAnd3-KeyTripleDES-CBC", "PBE with SHA1 and 3-Key 3DES" },
},
{
{ ADD_LEN( MBEDTLS_OID_PKCS12_PBE_SHA1_DES2_EDE_CBC ), "pbeWithSHAAnd2-KeyTripleDES-CBC", "PBE with SHA1 and 2-Key 3DES" },
},
{
{ NULL, 0, NULL, NULL },
},
}
Definition: cipher.h:113
Definition: md.h:40
#define NULL
Pointer to 0.
Definition: gctypes.h:65
Definition: cipher.h:115
Definition: cipher.h:78
#define MBEDTLS_OID_PKCS12_PBE_SHA1_DES3_EDE_CBC
Definition: oid.h:265
#define MBEDTLS_OID_PKCS12_PBE_SHA1_DES2_EDE_CBC
Definition: oid.h:266
#define ADD_LEN(s)
Definition: oid.c:51
Definition: md.h:44

◆ oid_sig_alg

const oid_sig_alg_t oid_sig_alg[]
static

◆ oid_x509_ext

const oid_x509_ext_t oid_x509_ext[]
static
Initial value:
=
{
{
{ ADD_LEN( MBEDTLS_OID_BASIC_CONSTRAINTS ), "id-ce-basicConstraints", "Basic Constraints" },
},
{
{ ADD_LEN( MBEDTLS_OID_KEY_USAGE ), "id-ce-keyUsage", "Key Usage" },
},
{
{ ADD_LEN( MBEDTLS_OID_EXTENDED_KEY_USAGE ), "id-ce-extKeyUsage", "Extended Key Usage" },
},
{
{ ADD_LEN( MBEDTLS_OID_SUBJECT_ALT_NAME ), "id-ce-subjectAltName", "Subject Alt Name" },
},
{
{ ADD_LEN( MBEDTLS_OID_NS_CERT_TYPE ), "id-netscape-certtype", "Netscape Certificate Type" },
},
{
{ NULL, 0, NULL, NULL },
0,
},
}
#define MBEDTLS_OID_NS_CERT_TYPE
Definition: oid.h:153
#define NULL
Pointer to 0.
Definition: gctypes.h:65
#define MBEDTLS_X509_EXT_NS_CERT_TYPE
Definition: x509.h:160
#define MBEDTLS_X509_EXT_BASIC_CONSTRAINTS
Definition: x509.h:152
#define MBEDTLS_X509_EXT_EXTENDED_KEY_USAGE
Definition: x509.h:155
#define MBEDTLS_OID_KEY_USAGE
Definition: oid.h:135
#define MBEDTLS_X509_EXT_SUBJECT_ALT_NAME
Definition: x509.h:149
#define MBEDTLS_OID_BASIC_CONSTRAINTS
Definition: oid.h:141
#define MBEDTLS_OID_EXTENDED_KEY_USAGE
Definition: oid.h:144
#define MBEDTLS_X509_EXT_KEY_USAGE
Definition: x509.h:146
#define MBEDTLS_OID_SUBJECT_ALT_NAME
Definition: oid.h:138
#define ADD_LEN(s)
Definition: oid.c:51

◆ oid_x520_attr_type

const oid_x520_attr_t oid_x520_attr_type[]
static