/mbedtls-3.5.0/library/ |
D | asn1write.c | 31 int mbedtls_asn1_write_len(unsigned char **p, const unsigned char *start, size_t len) in mbedtls_asn1_write_len() argument 33 if (len < 0x80) { in mbedtls_asn1_write_len() 38 *--(*p) = (unsigned char) len; in mbedtls_asn1_write_len() 42 if (len <= 0xFF) { in mbedtls_asn1_write_len() 47 *--(*p) = (unsigned char) len; in mbedtls_asn1_write_len() 52 if (len <= 0xFFFF) { in mbedtls_asn1_write_len() 57 *--(*p) = MBEDTLS_BYTE_0(len); in mbedtls_asn1_write_len() 58 *--(*p) = MBEDTLS_BYTE_1(len); in mbedtls_asn1_write_len() 63 if (len <= 0xFFFFFF) { in mbedtls_asn1_write_len() 68 *--(*p) = MBEDTLS_BYTE_0(len); in mbedtls_asn1_write_len() [all …]
|
D | x509write_crt.c | 171 size_t len = 0; in mbedtls_x509write_crt_set_basic_constraints() local 181 MBEDTLS_ASN1_CHK_ADD(len, mbedtls_asn1_write_int(&c, buf, in mbedtls_x509write_crt_set_basic_constraints() 184 MBEDTLS_ASN1_CHK_ADD(len, mbedtls_asn1_write_bool(&c, buf, 1)); in mbedtls_x509write_crt_set_basic_constraints() 187 MBEDTLS_ASN1_CHK_ADD(len, mbedtls_asn1_write_len(&c, buf, len)); in mbedtls_x509write_crt_set_basic_constraints() 188 MBEDTLS_ASN1_CHK_ADD(len, mbedtls_asn1_write_tag(&c, buf, in mbedtls_x509write_crt_set_basic_constraints() 195 is_ca, buf + sizeof(buf) - len, len); in mbedtls_x509write_crt_set_basic_constraints() 206 size_t len = 0; in mbedtls_x509write_crt_set_key_identifier() local 213 MBEDTLS_ASN1_CHK_ADD(len, in mbedtls_x509write_crt_set_key_identifier() 223 buf + sizeof(buf) - len, in mbedtls_x509write_crt_set_key_identifier() 224 len, in mbedtls_x509write_crt_set_key_identifier() [all …]
|
D | asn1parse.c | 41 size_t *len) in mbedtls_asn1_get_len() argument 48 *len = *(*p)++; in mbedtls_asn1_get_len() 56 *len = (*p)[1]; in mbedtls_asn1_get_len() 65 *len = ((size_t) (*p)[1] << 8) | (*p)[2]; in mbedtls_asn1_get_len() 74 *len = ((size_t) (*p)[1] << 16) | in mbedtls_asn1_get_len() 84 *len = ((size_t) (*p)[1] << 24) | ((size_t) (*p)[2] << 16) | in mbedtls_asn1_get_len() 94 if (*len > (size_t) (end - *p)) { in mbedtls_asn1_get_len() 103 size_t *len, int tag) in mbedtls_asn1_get_tag() argument 115 return mbedtls_asn1_get_len(p, end, len); in mbedtls_asn1_get_tag() 123 size_t len; in mbedtls_asn1_get_bool() local [all …]
|
D | x509_create.c | 235 size_t len = 0; in x509_write_name() local 237 size_t oid_len = cur_name->oid.len; in x509_write_name() 239 size_t name_len = cur_name->val.len; in x509_write_name() 242 MBEDTLS_ASN1_CHK_ADD(len, mbedtls_asn1_write_tagged_string(p, start, in x509_write_name() 248 MBEDTLS_ASN1_CHK_ADD(len, mbedtls_asn1_write_oid(p, start, oid, in x509_write_name() 251 MBEDTLS_ASN1_CHK_ADD(len, mbedtls_asn1_write_len(p, start, len)); in x509_write_name() 252 MBEDTLS_ASN1_CHK_ADD(len, mbedtls_asn1_write_tag(p, start, in x509_write_name() 256 MBEDTLS_ASN1_CHK_ADD(len, mbedtls_asn1_write_len(p, start, len)); in x509_write_name() 257 MBEDTLS_ASN1_CHK_ADD(len, mbedtls_asn1_write_tag(p, start, in x509_write_name() 261 return (int) len; in x509_write_name() [all …]
|
D | x509write_csr.c | 96 size_t len; in mbedtls_x509write_csr_set_subject_alternative_name() local 110 buflen += cur->node.san.unstructured_name.len + 4 + 1; in mbedtls_x509write_csr_set_subject_alternative_name() 133 len = 0; in mbedtls_x509write_csr_set_subject_alternative_name() 142 size_t unstructured_name_len = cur->node.san.unstructured_name.len; in mbedtls_x509write_csr_set_subject_alternative_name() 144 MBEDTLS_ASN1_CHK_CLEANUP_ADD(len, in mbedtls_x509write_csr_set_subject_alternative_name() 148 MBEDTLS_ASN1_CHK_CLEANUP_ADD(len, mbedtls_asn1_write_len( in mbedtls_x509write_csr_set_subject_alternative_name() 150 MBEDTLS_ASN1_CHK_CLEANUP_ADD(len, in mbedtls_x509write_csr_set_subject_alternative_name() 163 MBEDTLS_ASN1_CHK_CLEANUP_ADD(len, mbedtls_asn1_write_len(&p, buf, len)); in mbedtls_x509write_csr_set_subject_alternative_name() 164 MBEDTLS_ASN1_CHK_CLEANUP_ADD(len, in mbedtls_x509write_csr_set_subject_alternative_name() 174 buf + buflen - len, in mbedtls_x509write_csr_set_subject_alternative_name() [all …]
|
D | pkwrite.c | 67 size_t len = 0; in pk_write_rsa_pubkey() local 77 len += ret; in pk_write_rsa_pubkey() 84 len += ret; in pk_write_rsa_pubkey() 93 MBEDTLS_ASN1_CHK_ADD(len, mbedtls_asn1_write_len(p, start, len)); in pk_write_rsa_pubkey() 94 MBEDTLS_ASN1_CHK_ADD(len, mbedtls_asn1_write_tag(p, start, MBEDTLS_ASN1_CONSTRUCTED | in pk_write_rsa_pubkey() 97 return (int) len; in pk_write_rsa_pubkey() 109 size_t len = 0; in pk_write_ec_pubkey() local 114 &len, buf, sizeof(buf))) != 0) { in pk_write_ec_pubkey() 118 if (*p < start || (size_t) (*p - start) < len) { in pk_write_ec_pubkey() 122 *p -= len; in pk_write_ec_pubkey() [all …]
|
D | pkcs7.c | 53 size_t *len) in pkcs7_get_next_content_len() argument 57 ret = mbedtls_asn1_get_tag(p, end, len, MBEDTLS_ASN1_CONSTRUCTED in pkcs7_get_next_content_len() 61 } else if ((size_t) (end - *p) != *len) { in pkcs7_get_next_content_len() 100 size_t len = 0; in pkcs7_get_content_info_type() local 104 ret = mbedtls_asn1_get_tag(p, end, &len, MBEDTLS_ASN1_CONSTRUCTED in pkcs7_get_content_info_type() 110 *seq_end = *p + len; in pkcs7_get_content_info_type() 111 ret = mbedtls_asn1_get_tag(p, *seq_end, &len, MBEDTLS_ASN1_OID); in pkcs7_get_content_info_type() 118 pkcs7->len = len; in pkcs7_get_content_info_type() 120 *p += len; in pkcs7_get_content_info_type() 149 size_t len = 0; in pkcs7_get_digest_algorithm_set() local [all …]
|
D | pkparse.c | 188 if ((ret = mbedtls_asn1_get_tag(p, end, ¶ms->len, params->tag)) != 0) { in pk_get_ecparams() 193 *p += params->len; in pk_get_ecparams() 227 const unsigned char * const end = params->p + params->len; in pk_group_from_specified() 229 size_t len; in pk_group_from_specified() local 247 if ((ret = mbedtls_asn1_get_tag(&p, end, &len, in pk_group_from_specified() 252 end_field = p + len; in pk_group_from_specified() 262 if ((ret = mbedtls_asn1_get_tag(&p, end_field, &len, MBEDTLS_ASN1_OID)) != 0) { in pk_group_from_specified() 266 if (len != MBEDTLS_OID_SIZE(MBEDTLS_OID_ANSI_X9_62_PRIME_FIELD) || in pk_group_from_specified() 267 memcmp(p, MBEDTLS_OID_ANSI_X9_62_PRIME_FIELD, len) != 0) { in pk_group_from_specified() 271 p += len; in pk_group_from_specified() [all …]
|
D | x509.c | 89 if ((ret = mbedtls_asn1_get_len(p, end, &serial->len)) != 0) { in mbedtls_x509_get_serial() 94 *p += serial->len; in mbedtls_x509_get_serial() 189 size_t len; in x509_get_hash_alg() local 198 end = p + alg->len; in x509_get_hash_alg() 208 if ((ret = mbedtls_asn1_get_tag(&p, end, &md_oid.len, MBEDTLS_ASN1_OID)) != 0) { in x509_get_hash_alg() 213 p += md_oid.len; in x509_get_hash_alg() 225 if ((ret = mbedtls_asn1_get_tag(&p, end, &len, MBEDTLS_ASN1_NULL)) != 0 || len != 0) { in x509_get_hash_alg() 256 size_t len; in mbedtls_x509_get_rsassa_pss_params() local 271 end = p + params->len; in mbedtls_x509_get_rsassa_pss_params() 280 if ((ret = mbedtls_asn1_get_tag(&p, end, &len, in mbedtls_x509_get_rsassa_pss_params() [all …]
|
D | entropy_poll.c | 57 int mbedtls_platform_entropy_poll(void *data, unsigned char *output, size_t len, in mbedtls_platform_entropy_poll() argument 69 if (CryptGenRandom(provider, (DWORD) len, output) == FALSE) { in mbedtls_platform_entropy_poll() 75 *olen = len; in mbedtls_platform_entropy_poll() 138 size_t len; in sysctl_arnd_wrapper() local 144 len = buflen > 256 ? 256 : buflen; in sysctl_arnd_wrapper() 145 if (sysctl(name, 2, buf, &len, NULL, 0) == -1) { in sysctl_arnd_wrapper() 148 buflen -= len; in sysctl_arnd_wrapper() 149 buf += len; in sysctl_arnd_wrapper() 159 unsigned char *output, size_t len, size_t *olen) in mbedtls_platform_entropy_poll() argument 167 ret = getrandom_wrapper(output, len, 0); in mbedtls_platform_entropy_poll() [all …]
|
D | ecjpake.c | 135 size_t len) in mbedtls_ecjpake_setup() argument 159 MBEDTLS_MPI_CHK(mbedtls_mpi_read_binary(&ctx->s, secret, len)); in mbedtls_ecjpake_setup() 206 size_t len; in ecjpake_write_len_point() local 214 &len, *p + 4, end - (*p + 4)); in ecjpake_write_len_point() 219 MBEDTLS_PUT_UINT32_BE(len, *p, 0); in ecjpake_write_len_point() 221 *p += 4 + len; in ecjpake_write_len_point() 372 size_t len; in ecjpake_zkp_write() local 392 pf, &len, *p, end - *p)); in ecjpake_zkp_write() 393 *p += len; in ecjpake_zkp_write() 395 len = mbedtls_mpi_size(&h); /* actually r */ in ecjpake_zkp_write() [all …]
|
D | x509_csr.c | 79 size_t len; in x509_csr_parse_extensions() local 86 if ((ret = mbedtls_asn1_get_tag(p, end, &len, in x509_csr_parse_extensions() 91 end_ext_data = *p + len; in x509_csr_parse_extensions() 94 if ((ret = mbedtls_asn1_get_tag(p, end_ext_data, &extn_oid.len, in x509_csr_parse_extensions() 101 *p += extn_oid.len; in x509_csr_parse_extensions() 104 if ((ret = mbedtls_asn1_get_tag(p, end_ext_data, &len, in x509_csr_parse_extensions() 109 if (*p + len != end_ext_data) { in x509_csr_parse_extensions() 174 size_t len; in x509_csr_parse_attributes() local 181 if ((ret = mbedtls_asn1_get_tag(p, end, &len, in x509_csr_parse_attributes() 185 end_attr_data = *p + len; in x509_csr_parse_attributes() [all …]
|
/mbedtls-3.5.0/tests/suites/ |
D | test_suite_constant_time.data | 16 mbedtls_ct_memcmp len 1 19 mbedtls_ct_memcmp len 3 22 mbedtls_ct_memcmp len 4 25 mbedtls_ct_memcmp len 5 28 mbedtls_ct_memcmp len 15 31 mbedtls_ct_memcmp len 16 34 mbedtls_ct_memcmp len 17 37 mbedtls_ct_memcmp len 1 different 40 mbedtls_ct_memcmp len 17 different 43 mbedtls_ct_memcmp len 17 different 1 [all …]
|
D | test_suite_ccm.function | 19 size_t n2 = input->len - n1; 20 size_t n2_add = add->len - n1_add; 24 TEST_ASSERT(n1 <= input->len); 25 TEST_ASSERT(n1_add <= add->len); 26 TEST_EQUAL(input->len, expected_output->len); 27 TEST_EQUAL(0, mbedtls_ccm_starts(ctx, mode, iv->x, iv->len)); 28 TEST_EQUAL(0, mbedtls_ccm_set_lengths(ctx, add->len, input->len, tag->len)); 51 ASSERT_ALLOC(output, tag->len); 52 TEST_EQUAL(0, mbedtls_ccm_finish(ctx, output, tag->len)); 53 ASSERT_COMPARE(output, tag->len, tag->x, tag->len); [all …]
|
D | test_suite_gcm.function | 19 size_t n2 = input->len - n1; 20 size_t n2_add = add->len - n1_add; 24 TEST_ASSERT(n1 <= input->len); 25 TEST_ASSERT(n1_add <= add->len); 26 TEST_EQUAL(input->len, expected_output->len); 29 iv->x, iv->len)); 52 ASSERT_ALLOC(output, tag->len); 53 TEST_EQUAL(0, mbedtls_gcm_finish(ctx, NULL, 0, &olen, output, tag->len)); 55 ASSERT_COMPARE(output, tag->len, tag->x, tag->len); 78 TEST_EQUAL(input->len, expected_output->len); [all …]
|
D | test_suite_hmac_drbg.function | 7 size_t len; 10 static int mbedtls_test_entropy_func(void *data, unsigned char *buf, size_t len) 14 if (len > ctx->len) { 18 memcpy(buf, ctx->p, len); 20 ctx->p += len; 21 ctx->len -= len; 48 entropy.len = sizeof(buf); 69 TEST_EQUAL(sizeof(buf) - entropy.len, expected_consumed_entropy); 78 TEST_EQUAL(sizeof(buf) - entropy.len, expected_consumed_entropy); 89 TEST_EQUAL(sizeof(buf) - entropy.len, expected_consumed_entropy); [all …]
|
D | test_suite_lmots.function | 42 key_id->x, leaf_id, seed->x, seed->len), 0); 45 msg->x, msg->len, sig, sizeof(sig), NULL), 0); 46 TEST_EQUAL(mbedtls_lmots_verify(&pub_ctx, msg->x, msg->len, sig, sizeof(sig)), 0); 65 key_id->x, leaf_id, seed->x, seed->len), 0); 87 TEST_EQUAL(mbedtls_lmots_import_public_key(&ctx, pub_key->x, pub_key->len), 0); 89 TEST_EQUAL(mbedtls_lmots_verify(&ctx, msg->x, msg->len, sig->x, sig->len), expected_rc); 93 if (msg->len >= 1) { 96 TEST_EQUAL(mbedtls_lmots_verify(&ctx, msg->x, msg->len, sig->x, sig->len), 101 msg->x[msg->len - 1] ^= 1; 102 TEST_EQUAL(mbedtls_lmots_verify(&ctx, msg->x, msg->len, sig->x, sig->len), [all …]
|
D | test_suite_aria.function | 72 TEST_ASSERT(mbedtls_aria_setkey_enc(&ctx, key_str->x, key_str->len * 8) 75 for (i = 0; i < src_str->len; i += MBEDTLS_ARIA_BLOCKSIZE) { 80 ASSERT_COMPARE(output, expected_output->len, 81 expected_output->x, expected_output->len); 100 TEST_ASSERT(mbedtls_aria_setkey_dec(&ctx, key_str->x, key_str->len * 8) 103 for (i = 0; i < src_str->len; i += MBEDTLS_ARIA_BLOCKSIZE) { 108 ASSERT_COMPARE(output, expected_output->len, 109 expected_output->x, expected_output->len); 128 mbedtls_aria_setkey_enc(&ctx, key_str->x, key_str->len * 8); 130 src_str->len, iv_str->x, src_str->x, [all …]
|
D | test_suite_lms.function | 27 seed->x, seed->len), 0); 32 msg->x, msg->len, sig, sizeof(sig), 35 TEST_EQUAL(mbedtls_lms_verify(&pub_ctx, msg->x, msg->len, sig, 60 seed->x, seed->len), 0); 87 TEST_EQUAL(mbedtls_lms_import_public_key(&ctx, pub_key->x, pub_key->len), 0); 89 TEST_EQUAL(mbedtls_lms_verify(&ctx, msg->x, msg->len, sig->x, sig->len), expected_rc); 93 if (msg->len >= 1) { 96 TEST_EQUAL(mbedtls_lms_verify(&ctx, msg->x, msg->len, sig->x, sig->len), 101 msg->x[msg->len - 1] ^= 1; 102 TEST_EQUAL(mbedtls_lms_verify(&ctx, msg->x, msg->len, sig->x, sig->len), [all …]
|
D | test_suite_pkcs1_v21.function | 24 info.length = rnd_buf->len; 35 TEST_ASSERT(mbedtls_mpi_read_binary(&N, input_N->x, input_N->len) == 0); 36 TEST_ASSERT(mbedtls_mpi_read_binary(&E, input_E->x, input_E->len) == 0); 41 if (message_str->len == 0) { 46 &info, message_str->len, 50 ASSERT_COMPARE(output, ctx.len, result_str->x, result_str->len); 85 TEST_ASSERT(mbedtls_mpi_read_binary(&P, input_P->x, input_P->len) == 0); 86 TEST_ASSERT(mbedtls_mpi_read_binary(&Q, input_Q->x, input_Q->len) == 0); 87 TEST_ASSERT(mbedtls_mpi_read_binary(&N, input_N->x, input_N->len) == 0); 88 TEST_ASSERT(mbedtls_mpi_read_binary(&E, input_E->x, input_E->len) == 0); [all …]
|
D | test_suite_psa_crypto_hash.function | 24 input->x, input->len)); 28 ASSERT_COMPARE(expected_hash->x, expected_hash->len, 48 input->len)); 51 expected_hash->len)); 67 uint32_t len = 0; 76 input->x, len)); 79 input->x + len, input->len - len)); 81 input->x + len, input->len - len)); 86 ASSERT_COMPARE(expected_hash->x, expected_hash->len, 92 ASSERT_COMPARE(expected_hash->x, expected_hash->len, [all …]
|
/mbedtls-3.5.0/tests/src/ |
D | random.c | 43 size_t len) in mbedtls_test_rnd_std_rand() argument 52 for (i = 0; i < len; ++i) { in mbedtls_test_rnd_std_rand() 60 arc4random_buf(output, len); in mbedtls_test_rnd_std_rand() 68 size_t len) in mbedtls_test_rnd_zero_rand() argument 74 memset(output, 0, len); in mbedtls_test_rnd_zero_rand() 81 size_t len) in mbedtls_test_rnd_buffer_rand() argument 87 return mbedtls_test_rnd_std_rand(NULL, output, len); in mbedtls_test_rnd_buffer_rand() 90 use_len = len; in mbedtls_test_rnd_buffer_rand() 91 if (len > info->length) { in mbedtls_test_rnd_buffer_rand() 101 if (len - use_len > 0) { in mbedtls_test_rnd_buffer_rand() [all …]
|
/mbedtls-3.5.0/programs/ssl/ |
D | ssl_test_common_source.c | 61 size_t len = 0; in nss_keylog_export() local 73 len += sprintf(nss_keylog_line + len, in nss_keylog_export() 77 len += sprintf(nss_keylog_line + len, in nss_keylog_export() 81 len += sprintf(nss_keylog_line + len, " "); in nss_keylog_export() 84 len += sprintf(nss_keylog_line + len, in nss_keylog_export() 88 len += sprintf(nss_keylog_line + len, "\n"); in nss_keylog_export() 89 nss_keylog_line[len] = '\0'; in nss_keylog_export() 107 if (fwrite(nss_keylog_line, 1, len, f) != len) { in nss_keylog_export() 147 unsigned char const *buf, size_t len) in ssl_check_record() argument 154 tmp_buf = mbedtls_calloc(1, len); in ssl_check_record() [all …]
|
D | ssl_mail_client.c | 219 static int write_ssl_data(mbedtls_ssl_context *ssl, unsigned char *buf, size_t len) in write_ssl_data() argument 224 while (len && (ret = mbedtls_ssl_write(ssl, buf, len)) <= 0) { in write_ssl_data() 234 static int write_ssl_and_get_response(mbedtls_ssl_context *ssl, unsigned char *buf, size_t len) in write_ssl_and_get_response() argument 242 while (len && (ret = mbedtls_ssl_write(ssl, buf, len)) <= 0) { in write_ssl_and_get_response() 250 len = sizeof(data) - 1; in write_ssl_and_get_response() 252 ret = mbedtls_ssl_read(ssl, data, len); in write_ssl_and_get_response() 268 len = ret; in write_ssl_and_get_response() 269 for (i = 0; i < len; i++) { in write_ssl_and_get_response() 287 static int write_and_get_response(mbedtls_net_context *sock_fd, unsigned char *buf, size_t len) in write_and_get_response() argument 295 if (len && (ret = mbedtls_net_send(sock_fd, buf, len)) <= 0) { in write_and_get_response() [all …]
|
/mbedtls-3.5.0/programs/fuzz/ |
D | common.c | 25 int dummy_send(void *ctx, const unsigned char *buf, size_t len) in dummy_send() argument 32 if (len > INT_MAX) { in dummy_send() 35 return (int) len; in dummy_send() 38 int fuzz_recv(void *ctx, unsigned char *buf, size_t len) in fuzz_recv() argument 47 if (len > INT_MAX) { in fuzz_recv() 50 if (len + biomemfuzz->Offset > biomemfuzz->Size) { in fuzz_recv() 52 len = biomemfuzz->Size - biomemfuzz->Offset; in fuzz_recv() 54 memcpy(buf, biomemfuzz->Data + biomemfuzz->Offset, len); in fuzz_recv() 55 biomemfuzz->Offset += len; in fuzz_recv() 56 return (int) len; in fuzz_recv() [all …]
|