25#if !defined(MBEDTLS_CONFIG_FILE)
28#include MBEDTLS_CONFIG_FILE
34#if defined(MBEDTLS_RSA_C)
47#if !defined(MBEDTLS_X509_MAX_INTERMEDIATE_CA)
56#define MBEDTLS_X509_MAX_INTERMEDIATE_CA 8
63#define MBEDTLS_ERR_X509_FEATURE_UNAVAILABLE -0x2080
64#define MBEDTLS_ERR_X509_UNKNOWN_OID -0x2100
65#define MBEDTLS_ERR_X509_INVALID_FORMAT -0x2180
66#define MBEDTLS_ERR_X509_INVALID_VERSION -0x2200
67#define MBEDTLS_ERR_X509_INVALID_SERIAL -0x2280
68#define MBEDTLS_ERR_X509_INVALID_ALG -0x2300
69#define MBEDTLS_ERR_X509_INVALID_NAME -0x2380
70#define MBEDTLS_ERR_X509_INVALID_DATE -0x2400
71#define MBEDTLS_ERR_X509_INVALID_SIGNATURE -0x2480
72#define MBEDTLS_ERR_X509_INVALID_EXTENSIONS -0x2500
73#define MBEDTLS_ERR_X509_UNKNOWN_VERSION -0x2580
74#define MBEDTLS_ERR_X509_UNKNOWN_SIG_ALG -0x2600
75#define MBEDTLS_ERR_X509_SIG_MISMATCH -0x2680
76#define MBEDTLS_ERR_X509_CERT_VERIFY_FAILED -0x2700
77#define MBEDTLS_ERR_X509_CERT_UNKNOWN_FORMAT -0x2780
78#define MBEDTLS_ERR_X509_BAD_INPUT_DATA -0x2800
79#define MBEDTLS_ERR_X509_ALLOC_FAILED -0x2880
80#define MBEDTLS_ERR_X509_FILE_IO_ERROR -0x2900
81#define MBEDTLS_ERR_X509_BUFFER_TOO_SMALL -0x2980
82#define MBEDTLS_ERR_X509_FATAL_ERROR -0x3000
90#define MBEDTLS_X509_BADCERT_EXPIRED 0x01
91#define MBEDTLS_X509_BADCERT_REVOKED 0x02
92#define MBEDTLS_X509_BADCERT_CN_MISMATCH 0x04
93#define MBEDTLS_X509_BADCERT_NOT_TRUSTED 0x08
94#define MBEDTLS_X509_BADCRL_NOT_TRUSTED 0x10
95#define MBEDTLS_X509_BADCRL_EXPIRED 0x20
96#define MBEDTLS_X509_BADCERT_MISSING 0x40
97#define MBEDTLS_X509_BADCERT_SKIP_VERIFY 0x80
98#define MBEDTLS_X509_BADCERT_OTHER 0x0100
99#define MBEDTLS_X509_BADCERT_FUTURE 0x0200
100#define MBEDTLS_X509_BADCRL_FUTURE 0x0400
101#define MBEDTLS_X509_BADCERT_KEY_USAGE 0x0800
102#define MBEDTLS_X509_BADCERT_EXT_KEY_USAGE 0x1000
103#define MBEDTLS_X509_BADCERT_NS_CERT_TYPE 0x2000
104#define MBEDTLS_X509_BADCERT_BAD_MD 0x4000
105#define MBEDTLS_X509_BADCERT_BAD_PK 0x8000
106#define MBEDTLS_X509_BADCERT_BAD_KEY 0x010000
107#define MBEDTLS_X509_BADCRL_BAD_MD 0x020000
108#define MBEDTLS_X509_BADCRL_BAD_PK 0x040000
109#define MBEDTLS_X509_BADCRL_BAD_KEY 0x080000
125#define MBEDTLS_X509_SAN_OTHER_NAME 0
126#define MBEDTLS_X509_SAN_RFC822_NAME 1
127#define MBEDTLS_X509_SAN_DNS_NAME 2
128#define MBEDTLS_X509_SAN_X400_ADDRESS_NAME 3
129#define MBEDTLS_X509_SAN_DIRECTORY_NAME 4
130#define MBEDTLS_X509_SAN_EDI_PARTY_NAME 5
131#define MBEDTLS_X509_SAN_UNIFORM_RESOURCE_IDENTIFIER 6
132#define MBEDTLS_X509_SAN_IP_ADDRESS 7
133#define MBEDTLS_X509_SAN_REGISTERED_ID 8
139#define MBEDTLS_X509_KU_DIGITAL_SIGNATURE (0x80)
140#define MBEDTLS_X509_KU_NON_REPUDIATION (0x40)
141#define MBEDTLS_X509_KU_KEY_ENCIPHERMENT (0x20)
142#define MBEDTLS_X509_KU_DATA_ENCIPHERMENT (0x10)
143#define MBEDTLS_X509_KU_KEY_AGREEMENT (0x08)
144#define MBEDTLS_X509_KU_KEY_CERT_SIGN (0x04)
145#define MBEDTLS_X509_KU_CRL_SIGN (0x02)
146#define MBEDTLS_X509_KU_ENCIPHER_ONLY (0x01)
147#define MBEDTLS_X509_KU_DECIPHER_ONLY (0x8000)
154#define MBEDTLS_X509_NS_CERT_TYPE_SSL_CLIENT (0x80)
155#define MBEDTLS_X509_NS_CERT_TYPE_SSL_SERVER (0x40)
156#define MBEDTLS_X509_NS_CERT_TYPE_EMAIL (0x20)
157#define MBEDTLS_X509_NS_CERT_TYPE_OBJECT_SIGNING (0x10)
158#define MBEDTLS_X509_NS_CERT_TYPE_RESERVED (0x08)
159#define MBEDTLS_X509_NS_CERT_TYPE_SSL_CA (0x04)
160#define MBEDTLS_X509_NS_CERT_TYPE_EMAIL_CA (0x02)
161#define MBEDTLS_X509_NS_CERT_TYPE_OBJECT_SIGNING_CA (0x01)
172#define MBEDTLS_X509_EXT_AUTHORITY_KEY_IDENTIFIER MBEDTLS_OID_X509_EXT_AUTHORITY_KEY_IDENTIFIER
173#define MBEDTLS_X509_EXT_SUBJECT_KEY_IDENTIFIER MBEDTLS_OID_X509_EXT_SUBJECT_KEY_IDENTIFIER
174#define MBEDTLS_X509_EXT_KEY_USAGE MBEDTLS_OID_X509_EXT_KEY_USAGE
175#define MBEDTLS_X509_EXT_CERTIFICATE_POLICIES MBEDTLS_OID_X509_EXT_CERTIFICATE_POLICIES
176#define MBEDTLS_X509_EXT_POLICY_MAPPINGS MBEDTLS_OID_X509_EXT_POLICY_MAPPINGS
177#define MBEDTLS_X509_EXT_SUBJECT_ALT_NAME MBEDTLS_OID_X509_EXT_SUBJECT_ALT_NAME
178#define MBEDTLS_X509_EXT_ISSUER_ALT_NAME MBEDTLS_OID_X509_EXT_ISSUER_ALT_NAME
179#define MBEDTLS_X509_EXT_SUBJECT_DIRECTORY_ATTRS MBEDTLS_OID_X509_EXT_SUBJECT_DIRECTORY_ATTRS
180#define MBEDTLS_X509_EXT_BASIC_CONSTRAINTS MBEDTLS_OID_X509_EXT_BASIC_CONSTRAINTS
181#define MBEDTLS_X509_EXT_NAME_CONSTRAINTS MBEDTLS_OID_X509_EXT_NAME_CONSTRAINTS
182#define MBEDTLS_X509_EXT_POLICY_CONSTRAINTS MBEDTLS_OID_X509_EXT_POLICY_CONSTRAINTS
183#define MBEDTLS_X509_EXT_EXTENDED_KEY_USAGE MBEDTLS_OID_X509_EXT_EXTENDED_KEY_USAGE
184#define MBEDTLS_X509_EXT_CRL_DISTRIBUTION_POINTS MBEDTLS_OID_X509_EXT_CRL_DISTRIBUTION_POINTS
185#define MBEDTLS_X509_EXT_INIHIBIT_ANYPOLICY MBEDTLS_OID_X509_EXT_INIHIBIT_ANYPOLICY
186#define MBEDTLS_X509_EXT_FRESHEST_CRL MBEDTLS_OID_X509_EXT_FRESHEST_CRL
187#define MBEDTLS_X509_EXT_NS_CERT_TYPE MBEDTLS_OID_X509_EXT_NS_CERT_TYPE
193#define MBEDTLS_X509_FORMAT_DER 1
194#define MBEDTLS_X509_FORMAT_PEM 2
196#define MBEDTLS_X509_MAX_DN_NAME_SIZE 256
291#if defined(MBEDTLS_SELF_TEST)
298int mbedtls_x509_self_test(
int verbose );
306int mbedtls_x509_get_name(
unsigned char **p,
const unsigned char *end,
308int mbedtls_x509_get_alg_null(
unsigned char **p,
const unsigned char *end,
310int mbedtls_x509_get_alg(
unsigned char **p,
const unsigned char *end,
312#if defined(MBEDTLS_X509_RSASSA_PSS_SUPPORT)
317int mbedtls_x509_get_sig(
unsigned char **p,
const unsigned char *end,
mbedtls_x509_buf *sig );
321int mbedtls_x509_get_time(
unsigned char **p,
const unsigned char *end,
323int mbedtls_x509_get_serial(
unsigned char **p,
const unsigned char *end,
325int mbedtls_x509_get_ext(
unsigned char **p,
const unsigned char *end,
327int mbedtls_x509_sig_alg_gets(
char *buf,
size_t size,
const mbedtls_x509_buf *sig_oid,
329 const void *sig_opts );
330int mbedtls_x509_key_size_helper(
char *buf,
size_t buf_size,
const char *name );
333 int critical,
const unsigned char *val,
335int mbedtls_x509_write_extensions(
unsigned char **p,
unsigned char *start,
337int mbedtls_x509_write_names(
unsigned char **p,
unsigned char *start,
339int mbedtls_x509_write_sig(
unsigned char **p,
unsigned char *start,
340 const char *oid,
size_t oid_len,
341 unsigned char *sig,
size_t size );
343#define MBEDTLS_X509_SAFE_SNPRINTF \
345 if( ret < 0 || (size_t) ret >= n ) \
346 return( MBEDTLS_ERR_X509_BUFFER_TOO_SMALL ); \
Configuration options (set of defines)
mbedtls_md_type_t
Supported message digests.
int mbedtls_x509_time_is_past(const mbedtls_x509_time *to)
Check a given mbedtls_x509_time against the system time and tell if it's in the past.
int mbedtls_x509_time_is_future(const mbedtls_x509_time *from)
Check a given mbedtls_x509_time against the system time and tell if it's in the future.
mbedtls_asn1_named_data mbedtls_x509_name
Container for ASN1 named information objects.
mbedtls_asn1_buf mbedtls_x509_buf
Type-length-value structure that allows for ASN1 using DER.
int mbedtls_x509_dn_gets(char *buf, size_t size, const mbedtls_x509_name *dn)
Store the certificate DN in printable form into buf; no more than size characters will be written.
mbedtls_asn1_sequence mbedtls_x509_sequence
Container for a sequence of ASN.1 items.
mbedtls_asn1_bitstring mbedtls_x509_bitstring
Container for ASN1 bit strings.
int mbedtls_x509_serial_gets(char *buf, size_t size, const mbedtls_x509_buf *serial)
Store the certificate serial in printable form into buf; no more than size characters will be written...
Public Key abstraction layer.
mbedtls_pk_type_t
Public key types.
This file provides an API for the RSA public-key cryptosystem.
Container for ASN1 bit strings.
Type-length-value structure that allows for ASN1 using DER.
Container for a sequence or list of 'named' ASN.1 data items.
Container for a sequence of ASN.1 items.
Container for date and time (precision in seconds).