Lines Matching refs:ctx

52 void mbedtls_x509write_crt_init( mbedtls_x509write_cert *ctx )  in mbedtls_x509write_crt_init()  argument
54 memset( ctx, 0, sizeof(mbedtls_x509write_cert) ); in mbedtls_x509write_crt_init()
56 mbedtls_mpi_init( &ctx->serial ); in mbedtls_x509write_crt_init()
57 ctx->version = MBEDTLS_X509_CRT_VERSION_3; in mbedtls_x509write_crt_init()
60 void mbedtls_x509write_crt_free( mbedtls_x509write_cert *ctx ) in mbedtls_x509write_crt_free() argument
62 mbedtls_mpi_free( &ctx->serial ); in mbedtls_x509write_crt_free()
64 mbedtls_asn1_free_named_data_list( &ctx->subject ); in mbedtls_x509write_crt_free()
65 mbedtls_asn1_free_named_data_list( &ctx->issuer ); in mbedtls_x509write_crt_free()
66 mbedtls_asn1_free_named_data_list( &ctx->extensions ); in mbedtls_x509write_crt_free()
68 mbedtls_zeroize( ctx, sizeof(mbedtls_x509write_cert) ); in mbedtls_x509write_crt_free()
71 void mbedtls_x509write_crt_set_version( mbedtls_x509write_cert *ctx, int version ) in mbedtls_x509write_crt_set_version() argument
73 ctx->version = version; in mbedtls_x509write_crt_set_version()
76 void mbedtls_x509write_crt_set_md_alg( mbedtls_x509write_cert *ctx, mbedtls_md_type_t md_alg ) in mbedtls_x509write_crt_set_md_alg() argument
78 ctx->md_alg = md_alg; in mbedtls_x509write_crt_set_md_alg()
81 void mbedtls_x509write_crt_set_subject_key( mbedtls_x509write_cert *ctx, mbedtls_pk_context *key ) in mbedtls_x509write_crt_set_subject_key() argument
83 ctx->subject_key = key; in mbedtls_x509write_crt_set_subject_key()
86 void mbedtls_x509write_crt_set_issuer_key( mbedtls_x509write_cert *ctx, mbedtls_pk_context *key ) in mbedtls_x509write_crt_set_issuer_key() argument
88 ctx->issuer_key = key; in mbedtls_x509write_crt_set_issuer_key()
91 int mbedtls_x509write_crt_set_subject_name( mbedtls_x509write_cert *ctx, in mbedtls_x509write_crt_set_subject_name() argument
94 return mbedtls_x509_string_to_names( &ctx->subject, subject_name ); in mbedtls_x509write_crt_set_subject_name()
97 int mbedtls_x509write_crt_set_issuer_name( mbedtls_x509write_cert *ctx, in mbedtls_x509write_crt_set_issuer_name() argument
100 return mbedtls_x509_string_to_names( &ctx->issuer, issuer_name ); in mbedtls_x509write_crt_set_issuer_name()
103 int mbedtls_x509write_crt_set_serial( mbedtls_x509write_cert *ctx, const mbedtls_mpi *serial ) in mbedtls_x509write_crt_set_serial() argument
107 if( ( ret = mbedtls_mpi_copy( &ctx->serial, serial ) ) != 0 ) in mbedtls_x509write_crt_set_serial()
113 int mbedtls_x509write_crt_set_validity( mbedtls_x509write_cert *ctx, const char *not_before, in mbedtls_x509write_crt_set_validity() argument
121 strncpy( ctx->not_before, not_before, MBEDTLS_X509_RFC5280_UTC_TIME_LEN ); in mbedtls_x509write_crt_set_validity()
122 strncpy( ctx->not_after , not_after , MBEDTLS_X509_RFC5280_UTC_TIME_LEN ); in mbedtls_x509write_crt_set_validity()
123 ctx->not_before[MBEDTLS_X509_RFC5280_UTC_TIME_LEN - 1] = 'Z'; in mbedtls_x509write_crt_set_validity()
124 ctx->not_after[MBEDTLS_X509_RFC5280_UTC_TIME_LEN - 1] = 'Z'; in mbedtls_x509write_crt_set_validity()
129 int mbedtls_x509write_crt_set_extension( mbedtls_x509write_cert *ctx, in mbedtls_x509write_crt_set_extension() argument
134 return mbedtls_x509_set_extension( &ctx->extensions, oid, oid_len, in mbedtls_x509write_crt_set_extension()
138 int mbedtls_x509write_crt_set_basic_constraints( mbedtls_x509write_cert *ctx, in mbedtls_x509write_crt_set_basic_constraints() argument
164 return mbedtls_x509write_crt_set_extension( ctx, MBEDTLS_OID_BASIC_CONSTRAINTS, in mbedtls_x509write_crt_set_basic_constraints()
170 int mbedtls_x509write_crt_set_subject_key_identifier( mbedtls_x509write_cert *ctx ) in mbedtls_x509write_crt_set_subject_key_identifier() argument
178 MBEDTLS_ASN1_CHK_ADD( len, mbedtls_pk_write_pubkey( &c, buf, ctx->subject_key ) ); in mbedtls_x509write_crt_set_subject_key_identifier()
187 return mbedtls_x509write_crt_set_extension( ctx, MBEDTLS_OID_SUBJECT_KEY_IDENTIFIER, in mbedtls_x509write_crt_set_subject_key_identifier()
192 int mbedtls_x509write_crt_set_authority_key_identifier( mbedtls_x509write_cert *ctx ) in mbedtls_x509write_crt_set_authority_key_identifier() argument
200 MBEDTLS_ASN1_CHK_ADD( len, mbedtls_pk_write_pubkey( &c, buf, ctx->issuer_key ) ); in mbedtls_x509write_crt_set_authority_key_identifier()
213 return mbedtls_x509write_crt_set_extension( ctx, MBEDTLS_OID_AUTHORITY_KEY_IDENTIFIER, in mbedtls_x509write_crt_set_authority_key_identifier()
219 int mbedtls_x509write_crt_set_key_usage( mbedtls_x509write_cert *ctx, in mbedtls_x509write_crt_set_key_usage() argument
236 ret = mbedtls_x509write_crt_set_extension( ctx, MBEDTLS_OID_KEY_USAGE, in mbedtls_x509write_crt_set_key_usage()
245 int mbedtls_x509write_crt_set_ns_cert_type( mbedtls_x509write_cert *ctx, in mbedtls_x509write_crt_set_ns_cert_type() argument
257 ret = mbedtls_x509write_crt_set_extension( ctx, MBEDTLS_OID_NS_CERT_TYPE, in mbedtls_x509write_crt_set_ns_cert_type()
295 int mbedtls_x509write_crt_der( mbedtls_x509write_cert *ctx, unsigned char *buf, size_t size, in mbedtls_x509write_crt_der() argument
316 pk_alg = mbedtls_pk_get_type( ctx->issuer_key ); in mbedtls_x509write_crt_der()
320 if( ( ret = mbedtls_oid_get_oid_by_sig_alg( pk_alg, ctx->md_alg, in mbedtls_x509write_crt_der()
329 MBEDTLS_ASN1_CHK_ADD( len, mbedtls_x509_write_extensions( &c, tmp_buf, ctx->extensions ) ); in mbedtls_x509write_crt_der()
340 MBEDTLS_ASN1_CHK_ADD( pub_len, mbedtls_pk_write_pubkey_der( ctx->subject_key, in mbedtls_x509write_crt_der()
348 MBEDTLS_ASN1_CHK_ADD( len, mbedtls_x509_write_names( &c, tmp_buf, ctx->subject ) ); in mbedtls_x509write_crt_der()
357 MBEDTLS_ASN1_CHK_ADD( sub_len, x509_write_time( &c, tmp_buf, ctx->not_after, in mbedtls_x509write_crt_der()
360 MBEDTLS_ASN1_CHK_ADD( sub_len, x509_write_time( &c, tmp_buf, ctx->not_before, in mbedtls_x509write_crt_der()
371 MBEDTLS_ASN1_CHK_ADD( len, mbedtls_x509_write_names( &c, tmp_buf, ctx->issuer ) ); in mbedtls_x509write_crt_der()
382 MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_mpi( &c, tmp_buf, &ctx->serial ) ); in mbedtls_x509write_crt_der()
388 MBEDTLS_ASN1_CHK_ADD( sub_len, mbedtls_asn1_write_int( &c, tmp_buf, ctx->version ) ); in mbedtls_x509write_crt_der()
401 mbedtls_md( mbedtls_md_info_from_type( ctx->md_alg ), c, len, hash ); in mbedtls_x509write_crt_der()
403 if( ( ret = mbedtls_pk_sign( ctx->issuer_key, ctx->md_alg, hash, 0, sig, &sig_len, in mbedtls_x509write_crt_der()