Home
last modified time | relevance | path

Searched refs:len (Results 1 – 25 of 229) sorted by relevance

12345678910

/mbedtls-3.6.0/library/
Dasn1write.c23 int mbedtls_asn1_write_len(unsigned char **p, const unsigned char *start, size_t len) in mbedtls_asn1_write_len() argument
26 if (len > 0xFFFFFFFF) { in mbedtls_asn1_write_len()
33 if (len >= 0x80) { in mbedtls_asn1_write_len()
34 for (size_t l = len; l != 0; l >>= 8) { in mbedtls_asn1_write_len()
44 *--(*p) = MBEDTLS_BYTE_0(len); in mbedtls_asn1_write_len()
45 len >>= 8; in mbedtls_asn1_write_len()
46 } while (len); in mbedtls_asn1_write_len()
70 size_t len, in mbedtls_asn1_write_len_and_tag() argument
75 MBEDTLS_ASN1_CHK_ADD(len, mbedtls_asn1_write_len(p, start, len)); in mbedtls_asn1_write_len_and_tag()
76 MBEDTLS_ASN1_CHK_ADD(len, mbedtls_asn1_write_tag(p, start, tag)); in mbedtls_asn1_write_len_and_tag()
[all …]
Dx509write_crt.c166 size_t len = 0; in mbedtls_x509write_crt_set_basic_constraints() local
176 MBEDTLS_ASN1_CHK_ADD(len, mbedtls_asn1_write_int(&c, buf, in mbedtls_x509write_crt_set_basic_constraints()
179 MBEDTLS_ASN1_CHK_ADD(len, mbedtls_asn1_write_bool(&c, buf, 1)); in mbedtls_x509write_crt_set_basic_constraints()
182 MBEDTLS_ASN1_CHK_ADD(len, mbedtls_asn1_write_len(&c, buf, len)); in mbedtls_x509write_crt_set_basic_constraints()
183 MBEDTLS_ASN1_CHK_ADD(len, mbedtls_asn1_write_tag(&c, buf, in mbedtls_x509write_crt_set_basic_constraints()
190 is_ca, buf + sizeof(buf) - len, len); in mbedtls_x509write_crt_set_basic_constraints()
201 size_t len = 0; in mbedtls_x509write_crt_set_key_identifier() local
208 MBEDTLS_ASN1_CHK_ADD(len, in mbedtls_x509write_crt_set_key_identifier()
218 buf + sizeof(buf) - len, in mbedtls_x509write_crt_set_key_identifier()
219 len, in mbedtls_x509write_crt_set_key_identifier()
[all …]
Dasn1parse.c29 size_t *len) in mbedtls_asn1_get_len() argument
36 *len = *(*p)++; in mbedtls_asn1_get_len()
45 *len = 0; in mbedtls_asn1_get_len()
48 *len = (*len << 8) | **p; in mbedtls_asn1_get_len()
53 if (*len > (size_t) (end - *p)) { in mbedtls_asn1_get_len()
62 size_t *len, int tag) in mbedtls_asn1_get_tag() argument
74 return mbedtls_asn1_get_len(p, end, len); in mbedtls_asn1_get_tag()
84 size_t len; in mbedtls_asn1_get_bool() local
86 if ((ret = mbedtls_asn1_get_tag(p, end, &len, MBEDTLS_ASN1_BOOLEAN)) != 0) { in mbedtls_asn1_get_bool()
90 if (len != 1) { in mbedtls_asn1_get_bool()
[all …]
Dpkwrite.c115 size_t len = 0; in pk_write_rsa_pubkey() local
126 len += ret; in pk_write_rsa_pubkey()
133 len += ret; in pk_write_rsa_pubkey()
142 MBEDTLS_ASN1_CHK_ADD(len, mbedtls_asn1_write_len(p, start, len)); in pk_write_rsa_pubkey()
143 MBEDTLS_ASN1_CHK_ADD(len, mbedtls_asn1_write_tag(p, start, MBEDTLS_ASN1_CONSTRUCTED | in pk_write_rsa_pubkey()
146 return (int) len; in pk_write_rsa_pubkey()
155 size_t len = 0; in pk_write_ec_pubkey() local
159 if (psa_export_public_key(pk->priv_id, buf, sizeof(buf), &len) != PSA_SUCCESS) { in pk_write_ec_pubkey()
163 len = pk->pub_raw_len; in pk_write_ec_pubkey()
164 memcpy(buf, pk->pub_raw, len); in pk_write_ec_pubkey()
[all …]
Dx509_create.c139 int len, in parse_attribute_value_string() argument
144 const char *end = s + len; in parse_attribute_value_string()
203 size_t len, in parse_attribute_value_hex_der_encoded() argument
211 if (len % 2 != 0) { in parse_attribute_value_hex_der_encoded()
215 size_t const der_length = len / 2; in parse_attribute_value_hex_der_encoded()
285 mbedtls_asn1_buf oid = { .p = NULL, .len = 0, .tag = MBEDTLS_ASN1_NULL }; in mbedtls_x509_string_to_names()
305 oid.len = strlen(attr_descr->oid); in mbedtls_x509_string_to_names()
306 oid.p = mbedtls_calloc(1, oid.len); in mbedtls_x509_string_to_names()
307 memcpy(oid.p, attr_descr->oid, oid.len); in mbedtls_x509_string_to_names()
345 mbedtls_asn1_store_named_data(head, (char *) oid.p, oid.len, in mbedtls_x509_string_to_names()
[all …]
Dx509write_csr.c143 size_t len = 0; in x509write_csr_der_internal() local
153 MBEDTLS_ASN1_CHK_ADD(len, mbedtls_x509_write_extensions(&c, buf, in x509write_csr_der_internal()
156 if (len) { in x509write_csr_der_internal()
157 MBEDTLS_ASN1_CHK_ADD(len, mbedtls_asn1_write_len(&c, buf, len)); in x509write_csr_der_internal()
158 MBEDTLS_ASN1_CHK_ADD(len, in x509write_csr_der_internal()
163 MBEDTLS_ASN1_CHK_ADD(len, mbedtls_asn1_write_len(&c, buf, len)); in x509write_csr_der_internal()
164 MBEDTLS_ASN1_CHK_ADD(len, in x509write_csr_der_internal()
169 MBEDTLS_ASN1_CHK_ADD(len, in x509write_csr_der_internal()
174 MBEDTLS_ASN1_CHK_ADD(len, mbedtls_asn1_write_len(&c, buf, len)); in x509write_csr_der_internal()
175 MBEDTLS_ASN1_CHK_ADD(len, in x509write_csr_der_internal()
[all …]
Dpkcs7.c41 size_t *len) in pkcs7_get_next_content_len() argument
45 ret = mbedtls_asn1_get_tag(p, end, len, MBEDTLS_ASN1_CONSTRUCTED in pkcs7_get_next_content_len()
49 } else if ((size_t) (end - *p) != *len) { in pkcs7_get_next_content_len()
88 size_t len = 0; in pkcs7_get_content_info_type() local
92 ret = mbedtls_asn1_get_tag(p, end, &len, MBEDTLS_ASN1_CONSTRUCTED in pkcs7_get_content_info_type()
98 *seq_end = *p + len; in pkcs7_get_content_info_type()
99 ret = mbedtls_asn1_get_tag(p, *seq_end, &len, MBEDTLS_ASN1_OID); in pkcs7_get_content_info_type()
106 pkcs7->len = len; in pkcs7_get_content_info_type()
108 *p += len; in pkcs7_get_content_info_type()
137 size_t len = 0; in pkcs7_get_digest_algorithm_set() local
[all …]
Dentropy_poll.c43 int mbedtls_platform_entropy_poll(void *data, unsigned char *output, size_t len, in mbedtls_platform_entropy_poll() argument
54 while (len != 0) { in mbedtls_platform_entropy_poll()
56 (len > ULONG_MAX) ? ULONG_MAX : (unsigned long) len; in mbedtls_platform_entropy_poll()
64 len -= ulong_bytes; in mbedtls_platform_entropy_poll()
128 size_t len; in sysctl_arnd_wrapper() local
134 len = buflen > 256 ? 256 : buflen; in sysctl_arnd_wrapper()
135 if (sysctl(name, 2, buf, &len, NULL, 0) == -1) { in sysctl_arnd_wrapper()
138 buflen -= len; in sysctl_arnd_wrapper()
139 buf += len; in sysctl_arnd_wrapper()
149 unsigned char *output, size_t len, size_t *olen) in mbedtls_platform_entropy_poll() argument
[all …]
Dx509.c81 if ((ret = mbedtls_asn1_get_len(p, end, &serial->len)) != 0) { in mbedtls_x509_get_serial()
86 *p += serial->len; in mbedtls_x509_get_serial()
185 size_t len; in x509_get_hash_alg() local
194 end = p + alg->len; in x509_get_hash_alg()
204 if ((ret = mbedtls_asn1_get_tag(&p, end, &md_oid.len, MBEDTLS_ASN1_OID)) != 0) { in x509_get_hash_alg()
209 p += md_oid.len; in x509_get_hash_alg()
221 if ((ret = mbedtls_asn1_get_tag(&p, end, &len, MBEDTLS_ASN1_NULL)) != 0 || len != 0) { in x509_get_hash_alg()
252 size_t len; in mbedtls_x509_get_rsassa_pss_params() local
267 end = p + params->len; in mbedtls_x509_get_rsassa_pss_params()
276 if ((ret = mbedtls_asn1_get_tag(&p, end, &len, in mbedtls_x509_get_rsassa_pss_params()
[all …]
Dpkparse.c189 if ((ret = mbedtls_asn1_get_tag(p, end, &params->len, params->tag)) != 0) { in pk_get_ecparams()
194 *p += params->len; in pk_get_ecparams()
228 const unsigned char *const end = params->p + params->len; in pk_group_from_specified()
230 size_t len; in pk_group_from_specified() local
248 if ((ret = mbedtls_asn1_get_tag(&p, end, &len, in pk_group_from_specified()
253 end_field = p + len; in pk_group_from_specified()
263 if ((ret = mbedtls_asn1_get_tag(&p, end_field, &len, MBEDTLS_ASN1_OID)) != 0) { in pk_group_from_specified()
267 if (len != MBEDTLS_OID_SIZE(MBEDTLS_OID_ANSI_X9_62_PRIME_FIELD) || in pk_group_from_specified()
268 memcmp(p, MBEDTLS_OID_ANSI_X9_62_PRIME_FIELD, len) != 0) { in pk_group_from_specified()
272 p += len; in pk_group_from_specified()
[all …]
Decjpake.c98 size_t len) in mbedtls_ecjpake_setup() argument
116 MBEDTLS_MPI_CHK(mbedtls_mpi_read_binary(&ctx->s, secret, len)); in mbedtls_ecjpake_setup()
163 size_t len; in ecjpake_write_len_point() local
171 &len, *p + 4, end - (*p + 4)); in ecjpake_write_len_point()
176 MBEDTLS_PUT_UINT32_BE(len, *p, 0); in ecjpake_write_len_point()
178 *p += 4 + len; in ecjpake_write_len_point()
329 size_t len; in ecjpake_zkp_write() local
349 pf, &len, *p, end - *p)); in ecjpake_zkp_write()
350 *p += len; in ecjpake_zkp_write()
352 len = mbedtls_mpi_size(&h); /* actually r */ in ecjpake_zkp_write()
[all …]
Dx509_csr.c67 size_t len; in x509_csr_parse_extensions() local
74 if ((ret = mbedtls_asn1_get_tag(p, end, &len, in x509_csr_parse_extensions()
79 end_ext_data = *p + len; in x509_csr_parse_extensions()
82 if ((ret = mbedtls_asn1_get_tag(p, end_ext_data, &extn_oid.len, in x509_csr_parse_extensions()
89 *p += extn_oid.len; in x509_csr_parse_extensions()
92 if ((ret = mbedtls_asn1_get_tag(p, end_ext_data, &len, in x509_csr_parse_extensions()
97 if (*p + len != end_ext_data) { in x509_csr_parse_extensions()
162 size_t len; in x509_csr_parse_attributes() local
169 if ((ret = mbedtls_asn1_get_tag(p, end, &len, in x509_csr_parse_attributes()
173 end_attr_data = *p + len; in x509_csr_parse_attributes()
[all …]
Dx509_crt.c245 static int x509_memcasecmp(const void *s1, const void *s2, size_t len) in x509_memcasecmp() argument
251 for (i = 0; i < len; i++) { in x509_memcasecmp()
279 if (name->len < 3 || name->p[0] != '*' || name->p[1] != '.') { in x509_check_wildcard()
294 if (cn_len - cn_idx == name->len - 1 && in x509_check_wildcard()
295 x509_memcasecmp(name->p + 1, cn + cn_idx, name->len - 1) == 0) { in x509_check_wildcard()
311 a->len == b->len && in x509_string_cmp()
312 memcmp(a->p, b->p, b->len) == 0) { in x509_string_cmp()
318 a->len == b->len && in x509_string_cmp()
319 x509_memcasecmp(a->p, b->p, b->len) == 0) { in x509_string_cmp()
346 a->oid.len != b->oid.len || in x509_name_cmp()
[all …]
/mbedtls-3.6.0/tests/suites/
Dtest_suite_ccm.function19 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 TEST_CALLOC(output, tag->len);
52 TEST_EQUAL(0, mbedtls_ccm_finish(ctx, output, tag->len));
53 TEST_MEMORY_COMPARE(output, tag->len, tag->x, tag->len);
[all …]
Dtest_suite_gcm.function19 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 TEST_CALLOC(output, tag->len);
53 TEST_EQUAL(0, mbedtls_gcm_finish(ctx, NULL, 0, &olen, output, tag->len));
55 TEST_MEMORY_COMPARE(output, tag->len, tag->x, tag->len);
78 TEST_EQUAL(input->len, expected_output->len);
[all …]
Dtest_suite_hmac_drbg.function7 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;
50 entropy.len = sizeof(buf);
71 TEST_EQUAL(sizeof(buf) - entropy.len, expected_consumed_entropy);
80 TEST_EQUAL(sizeof(buf) - entropy.len, expected_consumed_entropy);
91 TEST_EQUAL(sizeof(buf) - entropy.len, expected_consumed_entropy);
[all …]
Dtest_suite_shax.function16 TEST_ASSERT(mbedtls_sha1(src_str->x, src_str->len, output) == 0);
18 TEST_ASSERT(mbedtls_test_hexcmp(output, hash->x, 20, hash->len) == 0);
50 TEST_EQUAL(mbedtls_sha256(src_str->x, src_str->len, output, 1), 0);
52 TEST_EQUAL(mbedtls_test_hexcmp(output, hash->x, 28, hash->len), 0);
64 TEST_EQUAL(mbedtls_sha256(src_str->x, src_str->len, output, 0), 0);
66 TEST_EQUAL(mbedtls_test_hexcmp(output, hash->x, 32, hash->len), 0);
98 TEST_EQUAL(mbedtls_sha512(src_str->x, src_str->len, output, 1), 0);
100 TEST_EQUAL(mbedtls_test_hexcmp(output, hash->x, 48, hash->len), 0);
112 TEST_EQUAL(mbedtls_sha512(src_str->x, src_str->len, output, 0), 0);
114 TEST_EQUAL(mbedtls_test_hexcmp(output, hash->x, 64, hash->len), 0);
[all …]
Dtest_suite_pkcs12.function39 password_len = password_arg->len;
45 salt_len = salt_arg->len;
62 TEST_MEMORY_COMPARE(expected_output->x, expected_output->len,
90 pbe_params.len = params_hex->len;
96 md_alg, pw->x, pw->len, data->x, data->len, my_out);
100 ASSERT_COMPARE(my_out, ref_out->len,
101 ref_out->x, ref_out->len);
108 pbe_params.len = params_hex->len;
112 md_alg, pw->x, pw->len, data->x, data->len, my_out,
117 ref_out->x, ref_out->len);
[all …]
Dtest_suite_pkcs5.function18 TEST_ASSERT(mbedtls_pkcs5_pbkdf2_hmac_ext(hash, pw_str->x, pw_str->len,
19 salt_str->x, salt_str->len,
23 key_len, result_key_string->len) == 0);
45 params.len = params_hex->len;
52 pw->x, pw->len, data->x, data->len, my_out);
56 ASSERT_COMPARE(my_out, ref_out->len,
57 ref_out->x, ref_out->len);
63 pw->x, pw->len, data->x, data->len, my_out,
68 ref_out->x, ref_out->len);
94 params.len = params_hex->len;
[all …]
Dtest_suite_lmots.function42 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 …]
Dtest_suite_aria.function72 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 TEST_MEMORY_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 TEST_MEMORY_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 …]
Dtest_suite_lms.function27 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 …]
/mbedtls-3.6.0/programs/ssl/
Dssl_test_common_source.c49 size_t len = 0; in nss_keylog_export() local
61 len += sprintf(nss_keylog_line + len, in nss_keylog_export()
65 len += sprintf(nss_keylog_line + len, in nss_keylog_export()
69 len += sprintf(nss_keylog_line + len, " "); in nss_keylog_export()
72 len += sprintf(nss_keylog_line + len, in nss_keylog_export()
76 len += sprintf(nss_keylog_line + len, "\n"); in nss_keylog_export()
77 nss_keylog_line[len] = '\0'; in nss_keylog_export()
95 if (fwrite(nss_keylog_line, 1, len, f) != len) { in nss_keylog_export()
135 unsigned char const *buf, size_t len) in ssl_check_record() argument
142 tmp_buf = mbedtls_calloc(1, len); in ssl_check_record()
[all …]
Dssl_mail_client.c207 static int write_ssl_data(mbedtls_ssl_context *ssl, unsigned char *buf, size_t len) in write_ssl_data() argument
212 while (len && (ret = mbedtls_ssl_write(ssl, buf, len)) <= 0) { in write_ssl_data()
222 static int write_ssl_and_get_response(mbedtls_ssl_context *ssl, unsigned char *buf, size_t len) in write_ssl_and_get_response() argument
230 while (len && (ret = mbedtls_ssl_write(ssl, buf, len)) <= 0) { in write_ssl_and_get_response()
238 len = sizeof(data) - 1; in write_ssl_and_get_response()
240 ret = mbedtls_ssl_read(ssl, data, len); in write_ssl_and_get_response()
256 len = ret; in write_ssl_and_get_response()
257 for (i = 0; i < len; i++) { in write_ssl_and_get_response()
275 static int write_and_get_response(mbedtls_net_context *sock_fd, unsigned char *buf, size_t len) in write_and_get_response() argument
283 if (len && (ret = mbedtls_net_send(sock_fd, buf, len)) <= 0) { in write_and_get_response()
[all …]
/mbedtls-3.6.0/tests/src/
Drandom.c31 size_t len) in mbedtls_test_rnd_std_rand() argument
40 for (i = 0; i < len; ++i) { in mbedtls_test_rnd_std_rand()
48 arc4random_buf(output, len); in mbedtls_test_rnd_std_rand()
56 size_t len) in mbedtls_test_rnd_zero_rand() argument
62 memset(output, 0, len); in mbedtls_test_rnd_zero_rand()
69 size_t len) in mbedtls_test_rnd_buffer_rand() argument
75 return mbedtls_test_rnd_std_rand(NULL, output, len); in mbedtls_test_rnd_buffer_rand()
78 use_len = len; in mbedtls_test_rnd_buffer_rand()
79 if (len > info->length) { in mbedtls_test_rnd_buffer_rand()
89 if (len - use_len > 0) { in mbedtls_test_rnd_buffer_rand()
[all …]

12345678910