22#ifndef MBEDTLS_X509_CRT_H
23#define MBEDTLS_X509_CRT_H
25#if !defined(MBEDTLS_CONFIG_FILE)
28#include MBEDTLS_CONFIG_FILE
152#define MBEDTLS_X509_ID_FLAG( id ) ( 1 << ( (id) - 1 ) )
168#define MBEDTLS_X509_CRT_VERSION_1 0
169#define MBEDTLS_X509_CRT_VERSION_2 1
170#define MBEDTLS_X509_CRT_VERSION_3 2
172#define MBEDTLS_X509_RFC5280_MAX_SERIAL_LEN 32
173#define MBEDTLS_X509_RFC5280_UTC_TIME_LEN 15
175#if !defined( MBEDTLS_X509_MAX_FILE_PATH_LEN )
176#define MBEDTLS_X509_MAX_FILE_PATH_LEN 512
191 char not_before[MBEDTLS_X509_RFC5280_UTC_TIME_LEN + 1];
192 char not_after[MBEDTLS_X509_RFC5280_UTC_TIME_LEN + 1];
208#define MBEDTLS_X509_MAX_VERIFY_CHAIN_SIZE ( MBEDTLS_X509_MAX_INTERMEDIATE_CA + 2 )
218#if defined(MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK)
227#if defined(MBEDTLS_ECDSA_C) && defined(MBEDTLS_ECP_RESTARTABLE)
235 mbedtls_pk_restart_ctx pk;
240 int fallback_signature_is_good;
243 int parent_is_trusted;
248 x509_crt_rs_find_parent,
253} mbedtls_x509_crt_restart_ctx;
258typedef void mbedtls_x509_crt_restart_ctx;
262#if defined(MBEDTLS_X509_CRT_PARSE_C)
301 const unsigned char *buf,
334typedef int (*mbedtls_x509_crt_ext_cb_t)(
void *p_ctx,
338 const unsigned char *p,
339 const unsigned char *end );
382 const unsigned char *buf,
385 mbedtls_x509_crt_ext_cb_t cb,
416 const unsigned char *buf,
449int mbedtls_x509_crt_parse(
mbedtls_x509_crt *chain,
const unsigned char *buf,
size_t buflen );
451#if defined(MBEDTLS_FS_IO)
465int mbedtls_x509_crt_parse_file(
mbedtls_x509_crt *chain,
const char *path );
480int mbedtls_x509_crt_parse_path(
mbedtls_x509_crt *chain,
const char *path );
524int mbedtls_x509_crt_info(
char *buf,
size_t size,
const char *prefix,
539int mbedtls_x509_crt_verify_info(
char *buf,
size_t size,
const char *prefix,
611 const char *cn, uint32_t *flags,
653 const char *cn, uint32_t *flags,
687 const char *cn, uint32_t *flags,
690 mbedtls_x509_crt_restart_ctx *rs_ctx );
722typedef int (*mbedtls_x509_crt_ca_cb_t)(
void *p_ctx,
726#if defined(MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK)
750 mbedtls_x509_crt_ca_cb_t f_ca_cb,
753 const char *cn, uint32_t *flags,
759#if defined(MBEDTLS_X509_CHECK_KEY_USAGE)
782 unsigned int usage );
785#if defined(MBEDTLS_X509_CHECK_EXTENDED_KEY_USAGE)
800 const char *usage_oid,
804#if defined(MBEDTLS_X509_CRL_PARSE_C)
831#if defined(MBEDTLS_ECDSA_C) && defined(MBEDTLS_ECP_RESTARTABLE)
835void mbedtls_x509_crt_restart_init( mbedtls_x509_crt_restart_ctx *ctx );
840void mbedtls_x509_crt_restart_free( mbedtls_x509_crt_restart_ctx *ctx );
847#if defined(MBEDTLS_X509_CRT_WRITE_C)
890 const char *not_after );
905 const char *issuer_name );
920 const char *subject_name );
961 const char *oid,
size_t oid_len,
963 const unsigned char *val,
size_t val_len );
977 int is_ca,
int max_pathlen );
979#if defined(MBEDTLS_SHA1_C)
1013 unsigned int key_usage );
1025 unsigned char ns_cert_type );
1055 int (*f_rng)(
void *,
unsigned char *,
size_t),
1058#if defined(MBEDTLS_PEM_WRITE_C)
1076 int (*f_rng)(
void *,
unsigned char *,
size_t),
Multi-precision integer library.
Configuration options (set of defines)
mbedtls_md_type_t
Supported message digests.
#define MBEDTLS_X509_MAX_VERIFY_CHAIN_SIZE
Max size of verification chain: end-entity + intermediates + trusted root.
mbedtls_pk_type_t
Public key types.
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.
Certificate revocation list structure.
Security profile for certificate verification.
uint32_t rsa_min_bitlen
Minimum size for RSA keys
uint32_t allowed_pks
PK algs for signatures
uint32_t allowed_mds
MDs for signatures
uint32_t allowed_curves
Elliptic curves for ECDSA
Item in a verification chain: cert and flags for it.
Verification chain as built by mbedtls_crt_verify_chain()
Container for an X.509 certificate.
unsigned int key_usage
Optional key usage extension value: See the values in x509.h.
mbedtls_md_type_t sig_md
Internal representation of the MD algorithm of the signature algorithm, e.g.
mbedtls_x509_name issuer
The parsed issuer data (named information object).
mbedtls_x509_buf sig_oid
Signature algorithm, e.g.
mbedtls_x509_sequence subject_alt_names
Optional list of raw entries of Subject Alternative Names extension (currently only dNSName and Other...
mbedtls_x509_sequence ext_key_usage
Optional list of extended key usage OIDs.
mbedtls_x509_buf subject_raw
The raw subject data (DER).
mbedtls_pk_context pk
Container for the public key context.
mbedtls_pk_type_t sig_pk
Internal representation of the Public Key algorithm of the signature algorithm, e....
mbedtls_x509_name subject
The parsed subject data (named information object).
mbedtls_x509_buf issuer_id
Optional X.509 v2/v3 issuer unique identifier.
int ca_istrue
Optional Basic Constraint extension value: 1 if this certificate belongs to a CA, 0 otherwise.
mbedtls_x509_buf raw
The raw certificate data (DER).
mbedtls_x509_buf sig
Signature: hash of the tbs part signed with the private key.
mbedtls_x509_buf v3_ext
Optional X.509 v3 extensions.
mbedtls_x509_buf serial
Unique id for certificate issued by a specific CA.
mbedtls_x509_sequence certificate_policies
Optional list of certificate policies (Only anyPolicy is printed and enforced, however the rest of th...
mbedtls_x509_buf issuer_raw
The raw issuer data (DER).
int own_buffer
Indicates if raw is owned by the structure or not.
int version
The X.509 version.
int max_pathlen
Optional Basic Constraint extension value: The maximum path length to the root certificate.
mbedtls_x509_buf tbs
The raw certificate body (DER).
mbedtls_x509_time valid_from
Start time of certificate validity.
mbedtls_x509_time valid_to
End time of certificate validity.
struct mbedtls_x509_crt * next
Next certificate in the CA-chain.
int ext_types
Bit string containing detected and parsed extensions.
unsigned char ns_cert_type
Optional Netscape certificate type extension value: See the values in x509.h.
mbedtls_x509_buf subject_id
Optional X.509 v2/v3 subject unique identifier.
void * sig_opts
Signature options to be passed to mbedtls_pk_verify_ext(), e.g.
From RFC 5280 section 4.2.1.6: OtherName ::= SEQUENCE { type-id OBJECT IDENTIFIER,...
mbedtls_x509_buf type_id
The type_id is an OID as deifned in RFC 5280.
struct mbedtls_x509_san_other_name::@58::@59 hardware_module_name
From RFC 4108 section 5: HardwareModuleName ::= SEQUENCE { hwType OBJECT IDENTIFIER,...
mbedtls_x509_buf oid
The object identifier.
mbedtls_x509_buf val
The named value.
A structure for holding the parsed Subject Alternative Name, according to type.
union mbedtls_x509_subject_alternative_name::@60 san
A union of the supported SAN types.
int type
The SAN type, value of MBEDTLS_X509_SAN_XXX.
mbedtls_x509_san_other_name other_name
The otherName supported type.
mbedtls_x509_buf unstructured_name
The buffer for the un constructed types.
Container for date and time (precision in seconds).
Container for writing a certificate (CRT)
X.509 generic defines and structures.
X.509 certificate revocation list parsing.