x509_crt.h
mbedtls/private_access.h
mbedtls/build_info.h
mbedtls/x509.h
mbedtls/x509_crl.h
mbedtls/bignum.h
pkcs7.h
ssl.h
mbedtls/asn1.h
mbedtls/bignum.h
mbedtls/build_info.h
mbedtls/ccm.h
mbedtls/chacha20.h
mbedtls/chachapoly.h
mbedtls/check_config.h
mbedtls/cipher.h
mbedtls/cmac.h
mbedtls/config_adjust_legacy_crypto.h
mbedtls/config_adjust_psa_from_legacy.h
mbedtls/config_adjust_psa_superset_legacy.h
mbedtls/config_adjust_ssl.h
mbedtls/config_adjust_x509.h
mbedtls/config_psa.h
mbedtls/ecdsa.h
mbedtls/ecjpake.h
mbedtls/ecp.h
mbedtls/gcm.h
mbedtls/mbedtls_config.h
mbedtls/md.h
mbedtls/md5.h
mbedtls/pk.h
mbedtls/platform_time.h
mbedtls/platform_util.h
mbedtls/poly1305.h
mbedtls/private_access.h
mbedtls/ripemd160.h
mbedtls/rsa.h
mbedtls/sha1.h
mbedtls/sha256.h
mbedtls/sha3.h
mbedtls/sha512.h
mbedtls/threading.h
mbedtls/x509.h
mbedtls/x509_crl.h
x509_crt.h
psa/build_info.h
psa/crypto.h
psa/crypto_adjust_auto_enabled.h
psa/crypto_adjust_config_dependencies.h
psa/crypto_adjust_config_key_pair_types.h
psa/crypto_adjust_config_synonyms.h
psa/crypto_builtin_composites.h
psa/crypto_builtin_key_derivation.h
psa/crypto_builtin_primitives.h
crypto_compat.h
psa/crypto_driver_common.h
psa/crypto_driver_contexts_composites.h
psa/crypto_driver_contexts_key_derivation.h
psa/crypto_driver_contexts_primitives.h
crypto_extra.h
psa/crypto_legacy.h
crypto_platform.h
crypto_sizes.h
crypto_struct.h
crypto_types.h
crypto_values.h
inttypes.h
limits.h
pthread.h
stddef.h
stdint.h
stdio.h
stdlib.h
time.h
debug.h
net_sockets.h
pkcs7.h
ssl.h
ssl_cache.h
ssl_cookie.h
ssl_ticket.h
x509_crt.h
mbedtls_x509_crt
mbedtls_x509_crt_profile
mbedtls_x509write_cert
mbedtls_x509_crt_verify_chain_item
mbedtls_x509_crt_verify_chain
Structures and functions for parsing and writing X.509 certificates
- MBEDTLS_X509_ID_FLAG
- MBEDTLS_X509_CRT_VERSION_1
- MBEDTLS_X509_CRT_VERSION_2
- MBEDTLS_X509_CRT_VERSION_3
- MBEDTLS_X509_RFC5280_MAX_SERIAL_LEN
- MBEDTLS_X509_RFC5280_UTC_TIME_LEN
- MBEDTLS_X509_MAX_FILE_PATH_LEN
- MBEDTLS_X509_CRT_ERROR_INFO_LIST
- MBEDTLS_X509_MAX_VERIFY_CHAIN_SIZE
- mbedtls_x509_crt
- mbedtls_x509_crt_profile
- mbedtls_x509write_cert
- mbedtls_x509_crt_restart_ctx
- mbedtls_x509_crt_ext_cb_t
- mbedtls_x509_crt_ca_cb_t
- mbedtls_x509_crt_profile_default
- mbedtls_x509_crt_profile_next
- mbedtls_x509_crt_profile_suiteb
- mbedtls_x509_crt_profile_none
- mbedtls_x509write_crt_set_subject_alternative_name
- mbedtls_x509_crt_parse_der
- mbedtls_x509_crt_parse_der_with_ext_cb
- mbedtls_x509_crt_parse_der_nocopy
- mbedtls_x509_crt_parse
- mbedtls_x509_crt_parse_file
- mbedtls_x509_crt_parse_path
- mbedtls_x509_crt_info
- mbedtls_x509_crt_verify_info
- mbedtls_x509_crt_verify
- mbedtls_x509_crt_verify_with_profile
- mbedtls_x509_crt_verify_restartable
- mbedtls_x509_crt_check_key_usage
- mbedtls_x509_crt_check_extended_key_usage
- mbedtls_x509_crt_is_revoked
- mbedtls_x509_crt_init
- mbedtls_x509_crt_free
- mbedtls_x509_crt_has_ext_type
- mbedtls_x509_crt_get_ca_istrue
- mbedtls_x509write_crt_init
- mbedtls_x509write_crt_set_version
- mbedtls_x509write_crt_set_serial
- mbedtls_x509write_crt_set_serial_raw
- mbedtls_x509write_crt_set_validity
- mbedtls_x509write_crt_set_issuer_name
- mbedtls_x509write_crt_set_subject_name
- mbedtls_x509write_crt_set_subject_key
- mbedtls_x509write_crt_set_issuer_key
- mbedtls_x509write_crt_set_md_alg
- mbedtls_x509write_crt_set_extension
- mbedtls_x509write_crt_set_basic_constraints
- mbedtls_x509write_crt_set_subject_key_identifier
- mbedtls_x509write_crt_set_authority_key_identifier
- mbedtls_x509write_crt_set_key_usage
- mbedtls_x509write_crt_set_ext_key_usage
- mbedtls_x509write_crt_set_ns_cert_type
- mbedtls_x509write_crt_free
- mbedtls_x509write_crt_der
- mbedtls_x509write_crt_pem

X.509 certificate parsing and writing.

    /*
    *CopyrightTheMbedTLSContributors
    *SPDX-License-Identifier:Apache-2.0ORGPL-2.0-or-later
    */
    #ifndefMBEDTLS_X509_CRT_H
    #defineMBEDTLS_X509_CRT_H
    #include"mbedtls/private_access.h"

    #include"mbedtls/build_info.h"

    #include"mbedtls/x509.h"
    #include"mbedtls/x509_crl.h"
    #include"mbedtls/bignum.h"

    #ifdef__cplusplus
    extern"C"{
    #endif

    typedefstructmbedtls_x509_crt{
    intMBEDTLS_PRIVATE(own_buffer);
    mbedtls_x509_bufraw;
    mbedtls_x509_buftbs;

    intversion;
    mbedtls_x509_bufserial;
    mbedtls_x509_bufsig_oid;

    mbedtls_x509_bufissuer_raw;
    mbedtls_x509_bufsubject_raw;

    mbedtls_x509_nameissuer;
    mbedtls_x509_namesubject;

    mbedtls_x509_timevalid_from;
    mbedtls_x509_timevalid_to;

    mbedtls_x509_bufpk_raw;
    mbedtls_pk_contextpk;

    mbedtls_x509_bufissuer_id;
    mbedtls_x509_bufsubject_id;
    mbedtls_x509_bufv3_ext;
    mbedtls_x509_sequencesubject_alt_names;
    mbedtls_x509_bufsubject_key_id;
    mbedtls_x509_authorityauthority_key_id;

    mbedtls_x509_sequencecertificate_policies;

    intMBEDTLS_PRIVATE(ext_types);
    intMBEDTLS_PRIVATE(ca_istrue);
    intMBEDTLS_PRIVATE(max_pathlen);

    unsignedintMBEDTLS_PRIVATE(key_usage);

    mbedtls_x509_sequenceext_key_usage;

    unsignedcharMBEDTLS_PRIVATE(ns_cert_type);

    mbedtls_x509_bufMBEDTLS_PRIVATE(sig);
    mbedtls_md_type_tMBEDTLS_PRIVATE(sig_md);
    mbedtls_pk_type_tMBEDTLS_PRIVATE(sig_pk);
    void*MBEDTLS_PRIVATE(sig_opts);

    structmbedtls_x509_crt*next;
    }
    mbedtls_x509_crt;

    #defineMBEDTLS_X509_ID_FLAG(id)(1<<((id)-1))

    typedefstructmbedtls_x509_crt_profile{
    uint32_tallowed_mds;
    uint32_tallowed_pks;
    uint32_tallowed_curves;
    uint32_trsa_min_bitlen;
    }
    mbedtls_x509_crt_profile;

    #defineMBEDTLS_X509_CRT_VERSION_10
    #defineMBEDTLS_X509_CRT_VERSION_21
    #defineMBEDTLS_X509_CRT_VERSION_32

    #defineMBEDTLS_X509_RFC5280_MAX_SERIAL_LEN20
    #defineMBEDTLS_X509_RFC5280_UTC_TIME_LEN15

    #if!defined(MBEDTLS_X509_MAX_FILE_PATH_LEN)
    #defineMBEDTLS_X509_MAX_FILE_PATH_LEN512
    #endif

    /*Thismacrounfoldstotheconcatenationofmacroinvocations
    *X509_CRT_ERROR_INFO(errorcode,
    *errorcodeasstring,
    *humanreadabledescription)
    *whereX509_CRT_ERROR_INFOisdefinedbytheuser.
    *Seex509_crt.cforanexampleofhowtousethis.*/
    #defineMBEDTLS_X509_CRT_ERROR_INFO_LIST\
    X509_CRT_ERROR_INFO(MBEDTLS_X509_BADCERT_EXPIRED,\
    "MBEDTLS_X509_BADCERT_EXPIRED",\
    "Thecertificatevalidityhasexpired")\
    X509_CRT_ERROR_INFO(MBEDTLS_X509_BADCERT_REVOKED,\
    "MBEDTLS_X509_BADCERT_REVOKED",\
    "Thecertificatehasbeenrevoked(isonaCRL)")\
    X509_CRT_ERROR_INFO(MBEDTLS_X509_BADCERT_CN_MISMATCH,\
    "MBEDTLS_X509_BADCERT_CN_MISMATCH",\
    "ThecertificateCommonName(CN)doesnotmatchwiththeexpectedCN")\
    X509_CRT_ERROR_INFO(MBEDTLS_X509_BADCERT_NOT_TRUSTED,\
    "MBEDTLS_X509_BADCERT_NOT_TRUSTED",\
    "ThecertificateisnotcorrectlysignedbythetrustedCA")\
    X509_CRT_ERROR_INFO(MBEDTLS_X509_BADCRL_NOT_TRUSTED,\
    "MBEDTLS_X509_BADCRL_NOT_TRUSTED",\
    "TheCRLisnotcorrectlysignedbythetrustedCA")\
    X509_CRT_ERROR_INFO(MBEDTLS_X509_BADCRL_EXPIRED,\
    "MBEDTLS_X509_BADCRL_EXPIRED",\
    "TheCRLisexpired")\
    X509_CRT_ERROR_INFO(MBEDTLS_X509_BADCERT_MISSING,\
    "MBEDTLS_X509_BADCERT_MISSING",\
    "Certificatewasmissing")\
    X509_CRT_ERROR_INFO(MBEDTLS_X509_BADCERT_SKIP_VERIFY,\
    "MBEDTLS_X509_BADCERT_SKIP_VERIFY",\
    "Certificateverificationwasskipped")\
    X509_CRT_ERROR_INFO(MBEDTLS_X509_BADCERT_OTHER,\
    "MBEDTLS_X509_BADCERT_OTHER",\
    "Otherreason(canbeusedbyverifycallback)")\
    X509_CRT_ERROR_INFO(MBEDTLS_X509_BADCERT_FUTURE,\
    "MBEDTLS_X509_BADCERT_FUTURE",\
    "Thecertificatevaliditystartsinthefuture")\
    X509_CRT_ERROR_INFO(MBEDTLS_X509_BADCRL_FUTURE,\
    "MBEDTLS_X509_BADCRL_FUTURE",\
    "TheCRLisfromthefuture")\
    X509_CRT_ERROR_INFO(MBEDTLS_X509_BADCERT_KEY_USAGE,\
    "MBEDTLS_X509_BADCERT_KEY_USAGE",\
    "UsagedoesnotmatchthekeyUsageextension")\
    X509_CRT_ERROR_INFO(MBEDTLS_X509_BADCERT_EXT_KEY_USAGE,\
    "MBEDTLS_X509_BADCERT_EXT_KEY_USAGE",\
    "UsagedoesnotmatchtheextendedKeyUsageextension")\
    X509_CRT_ERROR_INFO(MBEDTLS_X509_BADCERT_NS_CERT_TYPE,\
    "MBEDTLS_X509_BADCERT_NS_CERT_TYPE",\
    "UsagedoesnotmatchthensCertTypeextension")\
    X509_CRT_ERROR_INFO(MBEDTLS_X509_BADCERT_BAD_MD,\
    "MBEDTLS_X509_BADCERT_BAD_MD",\
    "Thecertificateissignedwithanunacceptablehash.")\
    X509_CRT_ERROR_INFO(MBEDTLS_X509_BADCERT_BAD_PK,\
    "MBEDTLS_X509_BADCERT_BAD_PK",\
    "ThecertificateissignedwithanunacceptablePKalg(egRSAvsECDSA).")\
    X509_CRT_ERROR_INFO(MBEDTLS_X509_BADCERT_BAD_KEY,\
    "MBEDTLS_X509_BADCERT_BAD_KEY",\
    "Thecertificateissignedwithanunacceptablekey(egbadcurve,RSAtooshort).")\
    X509_CRT_ERROR_INFO(MBEDTLS_X509_BADCRL_BAD_MD,\
    "MBEDTLS_X509_BADCRL_BAD_MD",\
    "TheCRLissignedwithanunacceptablehash.")\
    X509_CRT_ERROR_INFO(MBEDTLS_X509_BADCRL_BAD_PK,\
    "MBEDTLS_X509_BADCRL_BAD_PK",\
    "TheCRLissignedwithanunacceptablePKalg(egRSAvsECDSA).")\
    X509_CRT_ERROR_INFO(MBEDTLS_X509_BADCRL_BAD_KEY,\
    "MBEDTLS_X509_BADCRL_BAD_KEY",\
    "TheCRLissignedwithanunacceptablekey(egbadcurve,RSAtooshort).")

    typedefstructmbedtls_x509write_cert{
    intMBEDTLS_PRIVATE(version);
    unsignedcharMBEDTLS_PRIVATE(serial)[MBEDTLS_X509_RFC5280_MAX_SERIAL_LEN];
    size_tMBEDTLS_PRIVATE(serial_len);
    mbedtls_pk_context*MBEDTLS_PRIVATE(subject_key);
    mbedtls_pk_context*MBEDTLS_PRIVATE(issuer_key);
    mbedtls_asn1_named_data*MBEDTLS_PRIVATE(subject);
    mbedtls_asn1_named_data*MBEDTLS_PRIVATE(issuer);
    mbedtls_md_type_tMBEDTLS_PRIVATE(md_alg);
    charMBEDTLS_PRIVATE(not_before)[MBEDTLS_X509_RFC5280_UTC_TIME_LEN+1];
    charMBEDTLS_PRIVATE(not_after)[MBEDTLS_X509_RFC5280_UTC_TIME_LEN+1];
    mbedtls_asn1_named_data*MBEDTLS_PRIVATE(extensions);
    }
    mbedtls_x509write_cert;

    intmbedtls_x509write_crt_set_subject_alternative_name(mbedtls_x509write_cert*ctx,
    constmbedtls_x509_san_list*san_list);

    typedefstruct{
    mbedtls_x509_crt*MBEDTLS_PRIVATE(crt);
    uint32_tMBEDTLS_PRIVATE(flags);
    }mbedtls_x509_crt_verify_chain_item;

    #defineMBEDTLS_X509_MAX_VERIFY_CHAIN_SIZE(MBEDTLS_X509_MAX_INTERMEDIATE_CA+2)

    typedefstruct{
    mbedtls_x509_crt_verify_chain_itemMBEDTLS_PRIVATE(items)[MBEDTLS_X509_MAX_VERIFY_CHAIN_SIZE];
    unsignedMBEDTLS_PRIVATE(len);

    #ifdefined(MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK)
    /*Thisstoresthelistofpotentialtrustedsignersobtainedfrom
    *theCAcallbackusedfortheCRTverification,ifconfigured.
    *Wemusttrackitsomewherebecausethecallbackpassesits
    *ownershiptothecaller.*/
    mbedtls_x509_crt*MBEDTLS_PRIVATE(trust_ca_cb_result);
    #endif/*MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK*/
    }mbedtls_x509_crt_verify_chain;

    #ifdefined(MBEDTLS_ECDSA_C)&&defined(MBEDTLS_ECP_RESTARTABLE)

    typedefstruct{
    /*forcheck_signature()*/
    mbedtls_pk_restart_ctxMBEDTLS_PRIVATE(pk);

    /*forfind_parent_in()*/
    mbedtls_x509_crt*MBEDTLS_PRIVATE(parent);/*non-nulliffparent_ininprogress*/
    mbedtls_x509_crt*MBEDTLS_PRIVATE(fallback_parent);
    intMBEDTLS_PRIVATE(fallback_signature_is_good);

    /*forfind_parent()*/
    intMBEDTLS_PRIVATE(parent_is_trusted);/*-1iffind_parentisnotinprogress*/

    /*forverify_chain()*/
    enum{
    x509_crt_rs_none,
    x509_crt_rs_find_parent,
    }MBEDTLS_PRIVATE(in_progress);/*noneifnooperationisinprogress*/
    intMBEDTLS_PRIVATE(self_cnt);
    mbedtls_x509_crt_verify_chainMBEDTLS_PRIVATE(ver_chain);

    }mbedtls_x509_crt_restart_ctx;

    #else/*MBEDTLS_ECDSA_C&&MBEDTLS_ECP_RESTARTABLE*/

    /*Nowwecandeclarefunctionsthattakeapointertothat*/
    typedefvoidmbedtls_x509_crt_restart_ctx;

    #endif/*MBEDTLS_ECDSA_C&&MBEDTLS_ECP_RESTARTABLE*/

    #ifdefined(MBEDTLS_X509_CRT_PARSE_C)
    externconstmbedtls_x509_crt_profilembedtls_x509_crt_profile_default;

    externconstmbedtls_x509_crt_profilembedtls_x509_crt_profile_next;

    externconstmbedtls_x509_crt_profilembedtls_x509_crt_profile_suiteb;

    externconstmbedtls_x509_crt_profilembedtls_x509_crt_profile_none;

    intmbedtls_x509_crt_parse_der(mbedtls_x509_crt*chain,
    constunsignedchar*buf,
    size_tbuflen);

    typedefint(*mbedtls_x509_crt_ext_cb_t)(void*p_ctx,
    mbedtls_x509_crtconst*crt,
    mbedtls_x509_bufconst*oid,
    intcritical,
    constunsignedchar*p,
    constunsignedchar*end);

    intmbedtls_x509_crt_parse_der_with_ext_cb(mbedtls_x509_crt*chain,
    constunsignedchar*buf,
    size_tbuflen,
    intmake_copy,
    mbedtls_x509_crt_ext_cb_tcb,
    void*p_ctx);

    intmbedtls_x509_crt_parse_der_nocopy(mbedtls_x509_crt*chain,
    constunsignedchar*buf,
    size_tbuflen);

    intmbedtls_x509_crt_parse(mbedtls_x509_crt*chain,constunsignedchar*buf,size_tbuflen);

    #ifdefined(MBEDTLS_FS_IO)
    intmbedtls_x509_crt_parse_file(mbedtls_x509_crt*chain,constchar*path);

    intmbedtls_x509_crt_parse_path(mbedtls_x509_crt*chain,constchar*path);

    #endif/*MBEDTLS_FS_IO*/

    #if!defined(MBEDTLS_X509_REMOVE_INFO)
    intmbedtls_x509_crt_info(char*buf,size_tsize,constchar*prefix,
    constmbedtls_x509_crt*crt);

    intmbedtls_x509_crt_verify_info(char*buf,size_tsize,constchar*prefix,
    uint32_tflags);
    #endif/*!MBEDTLS_X509_REMOVE_INFO*/

    intmbedtls_x509_crt_verify(mbedtls_x509_crt*crt,
    mbedtls_x509_crt*trust_ca,
    mbedtls_x509_crl*ca_crl,
    constchar*cn,uint32_t*flags,
    int(*f_vrfy)(void*,mbedtls_x509_crt*,int,uint32_t*),
    void*p_vrfy);

    intmbedtls_x509_crt_verify_with_profile(mbedtls_x509_crt*crt,
    mbedtls_x509_crt*trust_ca,
    mbedtls_x509_crl*ca_crl,
    constmbedtls_x509_crt_profile*profile,
    constchar*cn,uint32_t*flags,
    int(*f_vrfy)(void*,mbedtls_x509_crt*,int,uint32_t*),
    void*p_vrfy);

    intmbedtls_x509_crt_verify_restartable(mbedtls_x509_crt*crt,
    mbedtls_x509_crt*trust_ca,
    mbedtls_x509_crl*ca_crl,
    constmbedtls_x509_crt_profile*profile,
    constchar*cn,uint32_t*flags,
    int(*f_vrfy)(void*,mbedtls_x509_crt*,int,uint32_t*),
    void*p_vrfy,
    mbedtls_x509_crt_restart_ctx*rs_ctx);

    typedefint(*mbedtls_x509_crt_ca_cb_t)(void*p_ctx,
    mbedtls_x509_crtconst*child,
    mbedtls_x509_crt**candidate_cas);

    #ifdefined(MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK)
    intmbedtls_x509_crt_verify_with_ca_cb(mbedtls_x509_crt*crt,
    mbedtls_x509_crt_ca_cb_tf_ca_cb,
    void*p_ca_cb,
    constmbedtls_x509_crt_profile*profile,
    constchar*cn,uint32_t*flags,
    int(*f_vrfy)(void*,mbedtls_x509_crt*,int,uint32_t*),
    void*p_vrfy);

    #endif/*MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK*/

    intmbedtls_x509_crt_check_key_usage(constmbedtls_x509_crt*crt,
    unsignedintusage);

    intmbedtls_x509_crt_check_extended_key_usage(constmbedtls_x509_crt*crt,
    constchar*usage_oid,
    size_tusage_len);

    #ifdefined(MBEDTLS_X509_CRL_PARSE_C)
    intmbedtls_x509_crt_is_revoked(constmbedtls_x509_crt*crt,constmbedtls_x509_crl*crl);
    #endif/*MBEDTLS_X509_CRL_PARSE_C*/

    voidmbedtls_x509_crt_init(mbedtls_x509_crt*crt);

    voidmbedtls_x509_crt_free(mbedtls_x509_crt*crt);

    #ifdefined(MBEDTLS_ECDSA_C)&&defined(MBEDTLS_ECP_RESTARTABLE)
    voidmbedtls_x509_crt_restart_init(mbedtls_x509_crt_restart_ctx*ctx);

    voidmbedtls_x509_crt_restart_free(mbedtls_x509_crt_restart_ctx*ctx);
    #endif/*MBEDTLS_ECDSA_C&&MBEDTLS_ECP_RESTARTABLE*/
    #endif/*MBEDTLS_X509_CRT_PARSE_C*/

    staticinlineintmbedtls_x509_crt_has_ext_type(constmbedtls_x509_crt*ctx,
    intext_type)
    {
    returnctx->MBEDTLS_PRIVATE(ext_types)&ext_type;
    }

    intmbedtls_x509_crt_get_ca_istrue(constmbedtls_x509_crt*crt);

    #ifdefined(MBEDTLS_X509_CRT_WRITE_C)
    voidmbedtls_x509write_crt_init(mbedtls_x509write_cert*ctx);

    voidmbedtls_x509write_crt_set_version(mbedtls_x509write_cert*ctx,intversion);

    #ifdefined(MBEDTLS_BIGNUM_C)&&!defined(MBEDTLS_DEPRECATED_REMOVED)
    intMBEDTLS_DEPRECATEDmbedtls_x509write_crt_set_serial(
    mbedtls_x509write_cert*ctx,constmbedtls_mpi*serial);
    #endif//MBEDTLS_BIGNUM_C&&!MBEDTLS_DEPRECATED_REMOVED

    intmbedtls_x509write_crt_set_serial_raw(mbedtls_x509write_cert*ctx,
    unsignedchar*serial,size_tserial_len);

    intmbedtls_x509write_crt_set_validity(mbedtls_x509write_cert*ctx,constchar*not_before,
    constchar*not_after);

    intmbedtls_x509write_crt_set_issuer_name(mbedtls_x509write_cert*ctx,
    constchar*issuer_name);

    intmbedtls_x509write_crt_set_subject_name(mbedtls_x509write_cert*ctx,
    constchar*subject_name);

    voidmbedtls_x509write_crt_set_subject_key(mbedtls_x509write_cert*ctx,mbedtls_pk_context*key);

    voidmbedtls_x509write_crt_set_issuer_key(mbedtls_x509write_cert*ctx,mbedtls_pk_context*key);

    voidmbedtls_x509write_crt_set_md_alg(mbedtls_x509write_cert*ctx,mbedtls_md_type_tmd_alg);

    intmbedtls_x509write_crt_set_extension(mbedtls_x509write_cert*ctx,
    constchar*oid,size_toid_len,
    intcritical,
    constunsignedchar*val,size_tval_len);

    intmbedtls_x509write_crt_set_basic_constraints(mbedtls_x509write_cert*ctx,
    intis_ca,intmax_pathlen);

    #ifdefined(MBEDTLS_MD_CAN_SHA1)
    intmbedtls_x509write_crt_set_subject_key_identifier(mbedtls_x509write_cert*ctx);

    intmbedtls_x509write_crt_set_authority_key_identifier(mbedtls_x509write_cert*ctx);
    #endif/*MBEDTLS_MD_CAN_SHA1*/

    intmbedtls_x509write_crt_set_key_usage(mbedtls_x509write_cert*ctx,
    unsignedintkey_usage);

    intmbedtls_x509write_crt_set_ext_key_usage(mbedtls_x509write_cert*ctx,
    constmbedtls_asn1_sequence*exts);

    intmbedtls_x509write_crt_set_ns_cert_type(mbedtls_x509write_cert*ctx,
    unsignedcharns_cert_type);

    voidmbedtls_x509write_crt_free(mbedtls_x509write_cert*ctx);

    intmbedtls_x509write_crt_der(mbedtls_x509write_cert*ctx,unsignedchar*buf,size_tsize,
    mbedtls_f_rng_t*f_rng,
    void*p_rng);

    #ifdefined(MBEDTLS_PEM_WRITE_C)
    intmbedtls_x509write_crt_pem(mbedtls_x509write_cert*ctx,unsignedchar*buf,size_tsize,
    mbedtls_f_rng_t*f_rng,
    void*p_rng);
    #endif/*MBEDTLS_PEM_WRITE_C*/
    #endif/*MBEDTLS_X509_CRT_WRITE_C*/

    #ifdef__cplusplus
    }
    #endif

    #endif/*mbedtls_x509_crt.h*/