Lines Matching refs:ctx

40 void mbedtls_x509write_crt_init(mbedtls_x509write_cert *ctx)  in mbedtls_x509write_crt_init()  argument
42 memset(ctx, 0, sizeof(mbedtls_x509write_cert)); in mbedtls_x509write_crt_init()
44 ctx->version = MBEDTLS_X509_CRT_VERSION_3; in mbedtls_x509write_crt_init()
47 void mbedtls_x509write_crt_free(mbedtls_x509write_cert *ctx) in mbedtls_x509write_crt_free() argument
49 if (ctx == NULL) { in mbedtls_x509write_crt_free()
53 mbedtls_asn1_free_named_data_list(&ctx->subject); in mbedtls_x509write_crt_free()
54 mbedtls_asn1_free_named_data_list(&ctx->issuer); in mbedtls_x509write_crt_free()
55 mbedtls_asn1_free_named_data_list(&ctx->extensions); in mbedtls_x509write_crt_free()
57 mbedtls_platform_zeroize(ctx, sizeof(mbedtls_x509write_cert)); in mbedtls_x509write_crt_free()
60 void mbedtls_x509write_crt_set_version(mbedtls_x509write_cert *ctx, in mbedtls_x509write_crt_set_version() argument
63 ctx->version = version; in mbedtls_x509write_crt_set_version()
66 void mbedtls_x509write_crt_set_md_alg(mbedtls_x509write_cert *ctx, in mbedtls_x509write_crt_set_md_alg() argument
69 ctx->md_alg = md_alg; in mbedtls_x509write_crt_set_md_alg()
72 void mbedtls_x509write_crt_set_subject_key(mbedtls_x509write_cert *ctx, in mbedtls_x509write_crt_set_subject_key() argument
75 ctx->subject_key = key; in mbedtls_x509write_crt_set_subject_key()
78 void mbedtls_x509write_crt_set_issuer_key(mbedtls_x509write_cert *ctx, in mbedtls_x509write_crt_set_issuer_key() argument
81 ctx->issuer_key = key; in mbedtls_x509write_crt_set_issuer_key()
84 int mbedtls_x509write_crt_set_subject_name(mbedtls_x509write_cert *ctx, in mbedtls_x509write_crt_set_subject_name() argument
87 return mbedtls_x509_string_to_names(&ctx->subject, subject_name); in mbedtls_x509write_crt_set_subject_name()
90 int mbedtls_x509write_crt_set_issuer_name(mbedtls_x509write_cert *ctx, in mbedtls_x509write_crt_set_issuer_name() argument
93 return mbedtls_x509_string_to_names(&ctx->issuer, issuer_name); in mbedtls_x509write_crt_set_issuer_name()
97 int mbedtls_x509write_crt_set_serial(mbedtls_x509write_cert *ctx, in mbedtls_x509write_crt_set_serial() argument
109 ctx->serial_len = tmp_len; in mbedtls_x509write_crt_set_serial()
111 ret = mbedtls_mpi_write_binary(serial, ctx->serial, tmp_len); in mbedtls_x509write_crt_set_serial()
120 int mbedtls_x509write_crt_set_serial_raw(mbedtls_x509write_cert *ctx, in mbedtls_x509write_crt_set_serial_raw() argument
127 ctx->serial_len = serial_len; in mbedtls_x509write_crt_set_serial_raw()
128 memcpy(ctx->serial, serial, serial_len); in mbedtls_x509write_crt_set_serial_raw()
133 int mbedtls_x509write_crt_set_validity(mbedtls_x509write_cert *ctx, in mbedtls_x509write_crt_set_validity() argument
141 strncpy(ctx->not_before, not_before, MBEDTLS_X509_RFC5280_UTC_TIME_LEN); in mbedtls_x509write_crt_set_validity()
142 strncpy(ctx->not_after, not_after, MBEDTLS_X509_RFC5280_UTC_TIME_LEN); in mbedtls_x509write_crt_set_validity()
143 ctx->not_before[MBEDTLS_X509_RFC5280_UTC_TIME_LEN - 1] = 'Z'; in mbedtls_x509write_crt_set_validity()
144 ctx->not_after[MBEDTLS_X509_RFC5280_UTC_TIME_LEN - 1] = 'Z'; in mbedtls_x509write_crt_set_validity()
149 int mbedtls_x509write_crt_set_subject_alternative_name(mbedtls_x509write_cert *ctx, in mbedtls_x509write_crt_set_subject_alternative_name() argument
152 return mbedtls_x509_write_set_san_common(&ctx->extensions, san_list); in mbedtls_x509write_crt_set_subject_alternative_name()
156 int mbedtls_x509write_crt_set_extension(mbedtls_x509write_cert *ctx, in mbedtls_x509write_crt_set_extension() argument
161 return mbedtls_x509_set_extension(&ctx->extensions, oid, oid_len, in mbedtls_x509write_crt_set_extension()
165 int mbedtls_x509write_crt_set_basic_constraints(mbedtls_x509write_cert *ctx, in mbedtls_x509write_crt_set_basic_constraints() argument
193 mbedtls_x509write_crt_set_extension(ctx, MBEDTLS_OID_BASIC_CONSTRAINTS, in mbedtls_x509write_crt_set_basic_constraints()
199 static int mbedtls_x509write_crt_set_key_identifier(mbedtls_x509write_cert *ctx, in mbedtls_x509write_crt_set_key_identifier() argument
217 ctx->issuer_key : in mbedtls_x509write_crt_set_key_identifier()
218 ctx->subject_key)); in mbedtls_x509write_crt_set_key_identifier()
256 return mbedtls_x509write_crt_set_extension(ctx, in mbedtls_x509write_crt_set_key_identifier()
262 return mbedtls_x509write_crt_set_extension(ctx, in mbedtls_x509write_crt_set_key_identifier()
270 int mbedtls_x509write_crt_set_subject_key_identifier(mbedtls_x509write_cert *ctx) in mbedtls_x509write_crt_set_subject_key_identifier() argument
272 return mbedtls_x509write_crt_set_key_identifier(ctx, in mbedtls_x509write_crt_set_subject_key_identifier()
277 int mbedtls_x509write_crt_set_authority_key_identifier(mbedtls_x509write_cert *ctx) in mbedtls_x509write_crt_set_authority_key_identifier() argument
279 return mbedtls_x509write_crt_set_key_identifier(ctx, in mbedtls_x509write_crt_set_authority_key_identifier()
285 int mbedtls_x509write_crt_set_key_usage(mbedtls_x509write_cert *ctx, in mbedtls_x509write_crt_set_key_usage() argument
316 ret = mbedtls_x509write_crt_set_extension(ctx, MBEDTLS_OID_KEY_USAGE, in mbedtls_x509write_crt_set_key_usage()
326 int mbedtls_x509write_crt_set_ext_key_usage(mbedtls_x509write_cert *ctx, in mbedtls_x509write_crt_set_ext_key_usage() argument
361 return mbedtls_x509write_crt_set_extension(ctx, in mbedtls_x509write_crt_set_ext_key_usage()
367 int mbedtls_x509write_crt_set_ns_cert_type(mbedtls_x509write_cert *ctx, in mbedtls_x509write_crt_set_ns_cert_type() argument
381 ret = mbedtls_x509write_crt_set_extension(ctx, MBEDTLS_OID_NS_CERT_TYPE, in mbedtls_x509write_crt_set_ns_cert_type()
419 int mbedtls_x509write_crt_der(mbedtls_x509write_cert *ctx, in mbedtls_x509write_crt_der() argument
450 if (mbedtls_pk_can_do(ctx->issuer_key, MBEDTLS_PK_RSA)) { in mbedtls_x509write_crt_der()
452 } else if (mbedtls_pk_can_do(ctx->issuer_key, MBEDTLS_PK_ECDSA)) { in mbedtls_x509write_crt_der()
458 if ((ret = mbedtls_oid_get_oid_by_sig_alg(pk_alg, ctx->md_alg, in mbedtls_x509write_crt_der()
468 if (ctx->version == MBEDTLS_X509_CRT_VERSION_3) { in mbedtls_x509write_crt_der()
471 buf, ctx->extensions)); in mbedtls_x509write_crt_der()
488 mbedtls_pk_write_pubkey_der(ctx->subject_key, in mbedtls_x509write_crt_der()
498 ctx->subject)); in mbedtls_x509write_crt_der()
508 x509_write_time(&c, buf, ctx->not_after, in mbedtls_x509write_crt_der()
512 x509_write_time(&c, buf, ctx->not_before, in mbedtls_x509write_crt_der()
526 ctx->issuer)); in mbedtls_x509write_crt_der()
556 ctx->serial, ctx->serial_len)); in mbedtls_x509write_crt_der()
564 ctx->serial_len + 1)); in mbedtls_x509write_crt_der()
567 ctx->serial_len)); in mbedtls_x509write_crt_der()
577 if (ctx->version != MBEDTLS_X509_CRT_VERSION_1) { in mbedtls_x509write_crt_der()
580 mbedtls_asn1_write_int(&c, buf, ctx->version)); in mbedtls_x509write_crt_der()
601 psa_algorithm = mbedtls_md_psa_alg_from_type(ctx->md_alg); in mbedtls_x509write_crt_der()
613 if ((ret = mbedtls_md(mbedtls_md_info_from_type(ctx->md_alg), c, in mbedtls_x509write_crt_der()
620 if ((ret = mbedtls_pk_sign(ctx->issuer_key, ctx->md_alg, in mbedtls_x509write_crt_der()