/openthread-latest/third_party/mbedtls/repo/library/ |
D | pk_ecc.c | 17 int mbedtls_pk_ecc_set_group(mbedtls_pk_context *pk, mbedtls_ecp_group_id grp_id) in mbedtls_pk_ecc_set_group() argument 24 if ((pk->ec_family != 0 && pk->ec_family != ec_family) || in mbedtls_pk_ecc_set_group() 25 (pk->ec_bits != 0 && pk->ec_bits != ec_bits)) { in mbedtls_pk_ecc_set_group() 30 pk->ec_family = ec_family; in mbedtls_pk_ecc_set_group() 31 pk->ec_bits = ec_bits; in mbedtls_pk_ecc_set_group() 35 mbedtls_ecp_keypair *ecp = mbedtls_pk_ec_rw(*pk); in mbedtls_pk_ecc_set_group() 38 if (mbedtls_pk_ec_ro(*pk)->grp.id != MBEDTLS_ECP_DP_NONE && in mbedtls_pk_ecc_set_group() 39 mbedtls_pk_ec_ro(*pk)->grp.id != grp_id) { in mbedtls_pk_ecc_set_group() 48 int mbedtls_pk_ecc_set_key(mbedtls_pk_context *pk, unsigned char *key, size_t key_len) in mbedtls_pk_ecc_set_key() argument 55 psa_set_key_type(&attributes, PSA_KEY_TYPE_ECC_KEY_PAIR(pk->ec_family)); in mbedtls_pk_ecc_set_key() [all …]
|
D | pk_internal.h | 60 static inline const mbedtls_ecp_keypair *mbedtls_pk_ec_ro(const mbedtls_pk_context pk) in mbedtls_pk_ec_ro() argument 62 switch (mbedtls_pk_get_type(&pk)) { in mbedtls_pk_ec_ro() 66 return (const mbedtls_ecp_keypair *) (pk).MBEDTLS_PRIVATE(pk_ctx); in mbedtls_pk_ec_ro() 72 static inline mbedtls_ecp_keypair *mbedtls_pk_ec_rw(const mbedtls_pk_context pk) in mbedtls_pk_ec_rw() argument 74 switch (mbedtls_pk_get_type(&pk)) { in mbedtls_pk_ec_rw() 78 return (mbedtls_ecp_keypair *) (pk).MBEDTLS_PRIVATE(pk_ctx); in mbedtls_pk_ec_rw() 86 static inline mbedtls_ecp_group_id mbedtls_pk_get_ec_group_id(const mbedtls_pk_context *pk) in mbedtls_pk_get_ec_group_id() argument 91 if (mbedtls_pk_get_type(pk) == MBEDTLS_PK_OPAQUE) { in mbedtls_pk_get_ec_group_id() 96 if (psa_get_key_attributes(pk->priv_id, &opaque_attrs) != PSA_SUCCESS) { in mbedtls_pk_get_ec_group_id() 107 id = mbedtls_ecc_group_from_psa(pk->ec_family, pk->ec_bits); in mbedtls_pk_get_ec_group_id() [all …]
|
D | pkwrite.c | 63 const mbedtls_pk_context *pk) in pk_write_rsa_der() argument 66 if (mbedtls_pk_get_type(pk) == MBEDTLS_PK_OPAQUE) { in pk_write_rsa_der() 70 if (psa_export_key(pk->priv_id, tmp, sizeof(tmp), &tmp_len) != PSA_SUCCESS) { in pk_write_rsa_der() 81 return mbedtls_rsa_write_key(mbedtls_pk_rsa(*pk), buf, p); in pk_write_rsa_der() 91 const mbedtls_pk_context *pk) in pk_write_ec_pubkey() argument 96 if (mbedtls_pk_get_type(pk) == MBEDTLS_PK_OPAQUE) { in pk_write_ec_pubkey() 97 if (psa_export_public_key(pk->priv_id, buf, sizeof(buf), &len) != PSA_SUCCESS) { in pk_write_ec_pubkey() 101 len = pk->pub_raw_len; in pk_write_ec_pubkey() 102 memcpy(buf, pk->pub_raw, len); in pk_write_ec_pubkey() 116 const mbedtls_pk_context *pk) in pk_write_ec_pubkey() argument [all …]
|
D | pkparse.c | 389 static int pk_use_ecparams(const mbedtls_asn1_buf *params, mbedtls_pk_context *pk) in pk_use_ecparams() argument 405 return mbedtls_pk_ecc_set_group(pk, grp_id); in pk_use_ecparams() 415 mbedtls_pk_context *pk) in pk_use_ecparams_rfc8410() argument 421 return mbedtls_pk_ecc_set_group(pk, grp_id); in pk_use_ecparams_rfc8410() 429 static int pk_parse_key_rfc8410_der(mbedtls_pk_context *pk, in pk_parse_key_rfc8410_der() argument 447 ret = mbedtls_pk_ecc_set_key(pk, key, len); in pk_parse_key_rfc8410_der() 455 if ((ret = mbedtls_pk_ecc_set_pubkey_from_prv(pk, key, len, f_rng, p_rng)) != 0) { in pk_parse_key_rfc8410_der() 518 mbedtls_pk_context *pk) in mbedtls_pk_parse_subpubkey() argument 551 if ((ret = mbedtls_pk_setup(pk, pk_info)) != 0) { in mbedtls_pk_parse_subpubkey() 557 ret = mbedtls_rsa_parse_pubkey(mbedtls_pk_rsa(*pk), *p, (size_t) (end - *p)); in mbedtls_pk_parse_subpubkey() [all …]
|
D | pk_wrap.c | 58 static size_t rsa_get_bitlen(mbedtls_pk_context *pk) in rsa_get_bitlen() argument 60 const mbedtls_rsa_context *rsa = (const mbedtls_rsa_context *) pk->pk_ctx; in rsa_get_bitlen() 65 static int rsa_verify_wrap(mbedtls_pk_context *pk, mbedtls_md_type_t md_alg, in rsa_verify_wrap() argument 69 mbedtls_rsa_context *rsa = (mbedtls_rsa_context *) pk->pk_ctx; in rsa_verify_wrap() 130 static int rsa_verify_wrap(mbedtls_pk_context *pk, mbedtls_md_type_t md_alg, in rsa_verify_wrap() argument 135 mbedtls_rsa_context *rsa = (mbedtls_rsa_context *) pk->pk_ctx; in rsa_verify_wrap() 230 static int rsa_sign_wrap(mbedtls_pk_context *pk, mbedtls_md_type_t md_alg, in rsa_sign_wrap() argument 244 if (mbedtls_rsa_get_padding_mode(mbedtls_pk_rsa(*pk)) == MBEDTLS_RSA_PKCS_V21) { in rsa_sign_wrap() 250 return mbedtls_pk_psa_rsa_sign_ext(psa_alg, pk->pk_ctx, hash, hash_len, in rsa_sign_wrap() 254 static int rsa_sign_wrap(mbedtls_pk_context *pk, mbedtls_md_type_t md_alg, in rsa_sign_wrap() argument [all …]
|
D | pk.c | 404 int mbedtls_pk_get_psa_attributes(const mbedtls_pk_context *pk, in mbedtls_pk_get_psa_attributes() argument 408 mbedtls_pk_type_t pk_type = mbedtls_pk_get_type(pk); in mbedtls_pk_get_psa_attributes() 445 mbedtls_rsa_context *rsa = mbedtls_pk_rsa(*pk); in mbedtls_pk_get_psa_attributes() 453 psa_set_key_bits(attributes, mbedtls_pk_get_bitlen(pk)); in mbedtls_pk_get_psa_attributes() 468 psa_ecc_family_t family = pk->ec_family; in mbedtls_pk_get_psa_attributes() 469 size_t bits = pk->ec_bits; in mbedtls_pk_get_psa_attributes() 471 if (pk->priv_id != MBEDTLS_SVC_KEY_ID_INIT) { in mbedtls_pk_get_psa_attributes() 475 const mbedtls_ecp_keypair *ec = mbedtls_pk_ec_ro(*pk); in mbedtls_pk_get_psa_attributes() 527 status = psa_get_key_attributes(pk->priv_id, &old_attributes); in mbedtls_pk_get_psa_attributes() 645 static int import_pair_into_psa(const mbedtls_pk_context *pk, in import_pair_into_psa() argument [all …]
|
D | pk_wrap.h | 30 size_t (*get_bitlen)(mbedtls_pk_context *pk); 36 int (*verify_func)(mbedtls_pk_context *pk, mbedtls_md_type_t md_alg, 41 int (*sign_func)(mbedtls_pk_context *pk, mbedtls_md_type_t md_alg, 49 int (*verify_rs_func)(mbedtls_pk_context *pk, mbedtls_md_type_t md_alg, 55 int (*sign_rs_func)(mbedtls_pk_context *pk, mbedtls_md_type_t md_alg, 63 int (*decrypt_func)(mbedtls_pk_context *pk, const unsigned char *input, size_t ilen, 69 int (*encrypt_func)(mbedtls_pk_context *pk, const unsigned char *input, size_t ilen, 94 void (*debug_func)(mbedtls_pk_context *pk, mbedtls_pk_debug_item *items);
|
D | ecdsa.c | 255 mbedtls_mpi *pk = &k, *pr = r; in mbedtls_ecdsa_sign_restartable() local 277 pk = &rs_ctx->sig->k; in mbedtls_ecdsa_sign_restartable() 308 MBEDTLS_MPI_CHK(mbedtls_ecp_gen_privkey(grp, pk, f_rng, p_rng)); in mbedtls_ecdsa_sign_restartable() 317 MBEDTLS_MPI_CHK(mbedtls_ecp_mul_restartable(grp, &R, pk, &grp->G, in mbedtls_ecdsa_sign_restartable() 355 MBEDTLS_MPI_CHK(mbedtls_mpi_mul_mpi(pk, pk, &t)); in mbedtls_ecdsa_sign_restartable() 356 MBEDTLS_MPI_CHK(mbedtls_mpi_mod_mpi(pk, pk, &grp->N)); in mbedtls_ecdsa_sign_restartable() 357 MBEDTLS_MPI_CHK(mbedtls_mpi_inv_mod(s, pk, &grp->N)); in mbedtls_ecdsa_sign_restartable()
|
D | debug.c | 235 const char *text, const mbedtls_pk_context *pk) in mbedtls_debug_print_psa_ec() argument 250 coord_len = (pk->pub_raw_len - 1)/2; in mbedtls_debug_print_psa_ec() 253 coord_start = pk->pub_raw + 1; in mbedtls_debug_print_psa_ec() 318 const char *text, const mbedtls_pk_context *pk) in debug_print_pk() argument 326 if (mbedtls_pk_debug(pk, items) != 0) { in debug_print_pk() 408 debug_print_pk(ssl, level, file, line, "crt->", &crt->pk); in mbedtls_debug_print_crt()
|
/openthread-latest/third_party/mbedtls/repo/tests/suites/ |
D | test_suite_pk.function | 2 #include "mbedtls/pk.h" 189 static int pk_genkey_ec(mbedtls_pk_context *pk, mbedtls_ecp_group_id grp_id) 206 if (mbedtls_pk_get_type(pk) != MBEDTLS_PK_ECDSA) { 210 if (mbedtls_pk_get_type(pk) != MBEDTLS_PK_ECKEY_DH && 229 status = psa_generate_key(&key_attr, &pk->priv_id); 234 status = psa_export_public_key(pk->priv_id, pk->pub_raw, sizeof(pk->pub_raw), 235 &pk->pub_raw_len); 241 pk->ec_family = curve; 242 pk->ec_bits = curve_bits; 247 status = psa_destroy_key(pk->priv_id); [all …]
|
D | test_suite_pkparse.function | 2 #include "mbedtls/pk.h" 73 /* Whether a pk key can do ECDSA. Opaque keys are not supported since this 269 mbedtls_pk_context pk; 271 mbedtls_pk_init(&pk); 274 TEST_ASSERT(mbedtls_pk_parse_key(&pk, buf->x, buf->len, NULL, 0, 278 mbedtls_pk_free(&pk); 286 mbedtls_pk_context pk; 288 mbedtls_pk_init(&pk); 291 TEST_EQUAL(mbedtls_pk_parse_key_pkcs8_encrypted_der(&pk, buf->x, buf->len, 296 mbedtls_pk_free(&pk); [all …]
|
D | test_suite_pk.data | 758 PSA attributes for pk: NONE (bad) 764 PSA attributes for pk: RSA usage=0 (bad) 769 PSA attributes for pk: RSA usage=EXPORT (bad) 774 PSA attributes for pk: RSA usage=DECRYPT|EXPORT (bad) 779 PSA attributes for pk: RSA usage=DECRYPT|SIGN_MESSAGE (bad) 784 PSA attributes for pk: RSA usage=SIGN_MESSAGE|SIGN_HASH (bad) 789 PSA attributes for pk: RSA usage=SIGN_MESSAGE|VERIFY_MESSAGE (bad) 793 PSA attributes for pk: RSA v15 pair DECRYPT 797 PSA attributes for pk: RSA v21 SHA-256 pair DECRYPT 801 PSA attributes for pk: RSA v21 SHA-512 pair DECRYPT [all …]
|
D | test_suite_pkwrite.function | 31 static int pk_write_any_key(mbedtls_pk_context *pk, unsigned char **p, 38 ret = mbedtls_pk_write_pubkey_der(pk, *p, *buf_len); 40 ret = mbedtls_pk_write_key_der(pk, *p, *buf_len); 51 ret = mbedtls_pk_write_pubkey_pem(pk, *p, *buf_len); 53 ret = mbedtls_pk_write_key_pem(pk, *p, *buf_len);
|
/openthread-latest/third_party/mbedtls/repo/programs/fuzz/ |
D | fuzz_pubkey.c | 9 mbedtls_pk_context pk; in LLVMFuzzerTestOneInput() local 11 mbedtls_pk_init(&pk); in LLVMFuzzerTestOneInput() 18 ret = mbedtls_pk_parse_public_key(&pk, Data, Size); in LLVMFuzzerTestOneInput() 21 if (mbedtls_pk_get_type(&pk) == MBEDTLS_PK_RSA) { in LLVMFuzzerTestOneInput() 29 rsa = mbedtls_pk_rsa(pk); in LLVMFuzzerTestOneInput() 47 if (mbedtls_pk_get_type(&pk) == MBEDTLS_PK_ECKEY || in LLVMFuzzerTestOneInput() 48 mbedtls_pk_get_type(&pk) == MBEDTLS_PK_ECKEY_DH) { in LLVMFuzzerTestOneInput() 49 mbedtls_ecp_keypair *ecp = mbedtls_pk_ec(pk); in LLVMFuzzerTestOneInput() 83 mbedtls_pk_free(&pk); in LLVMFuzzerTestOneInput()
|
D | fuzz_privkey.c | 20 mbedtls_pk_context pk; in LLVMFuzzerTestOneInput() local 31 mbedtls_pk_init(&pk); in LLVMFuzzerTestOneInput() 45 ret = mbedtls_pk_parse_key(&pk, Data, Size, NULL, 0, in LLVMFuzzerTestOneInput() 49 if (mbedtls_pk_get_type(&pk) == MBEDTLS_PK_RSA) { in LLVMFuzzerTestOneInput() 57 rsa = mbedtls_pk_rsa(pk); in LLVMFuzzerTestOneInput() 71 if (mbedtls_pk_get_type(&pk) == MBEDTLS_PK_ECKEY || in LLVMFuzzerTestOneInput() 72 mbedtls_pk_get_type(&pk) == MBEDTLS_PK_ECKEY_DH) { in LLVMFuzzerTestOneInput() 73 mbedtls_ecp_keypair *ecp = mbedtls_pk_ec(pk); in LLVMFuzzerTestOneInput() 94 mbedtls_pk_free(&pk); in LLVMFuzzerTestOneInput()
|
/openthread-latest/third_party/mbedtls/repo/programs/pkey/ |
D | rsa_verify_pss.c | 42 mbedtls_pk_context pk; in main() local 47 mbedtls_pk_init(&pk); in main() 71 if ((ret = mbedtls_pk_parse_public_keyfile(&pk, argv[1])) != 0) { in main() 77 if (!mbedtls_pk_can_do(&pk, MBEDTLS_PK_RSA)) { in main() 82 if ((ret = mbedtls_rsa_set_padding(mbedtls_pk_rsa(pk), in main() 117 if ((ret = mbedtls_pk_verify(&pk, MBEDTLS_MD_SHA256, hash, 0, in main() 128 mbedtls_pk_free(&pk); in main()
|
D | rsa_sign_pss.c | 42 mbedtls_pk_context pk; in main() local 52 mbedtls_pk_init(&pk); in main() 87 if ((ret = mbedtls_pk_parse_keyfile(&pk, argv[1], "", in main() 94 if (!mbedtls_pk_can_do(&pk, MBEDTLS_PK_RSA)) { in main() 99 if ((ret = mbedtls_rsa_set_padding(mbedtls_pk_rsa(pk), in main() 120 if ((ret = mbedtls_pk_sign(&pk, MBEDTLS_MD_SHA256, hash, 0, in main() 150 mbedtls_pk_free(&pk); in main()
|
D | key_app.c | 143 mbedtls_pk_context pk; in main() local 152 mbedtls_pk_init(&pk); in main() 250 ret = mbedtls_pk_parse_keyfile(&pk, opt.filename, opt.password, in main() 266 if (mbedtls_pk_get_type(&pk) == MBEDTLS_PK_RSA) { in main() 267 mbedtls_rsa_context *rsa = mbedtls_pk_rsa(pk); in main() 286 if (mbedtls_pk_get_type(&pk) == MBEDTLS_PK_ECKEY) { in main() 287 if (show_ecp_key(mbedtls_pk_ec(pk), 1) != 0) { in main() 304 ret = mbedtls_pk_parse_public_keyfile(&pk, opt.filename); in main() 316 if (mbedtls_pk_get_type(&pk) == MBEDTLS_PK_RSA) { in main() 317 mbedtls_rsa_context *rsa = mbedtls_pk_rsa(pk); in main() [all …]
|
D | pk_verify.c | 39 mbedtls_pk_context pk; in main() local 44 mbedtls_pk_init(&pk); in main() 68 if ((ret = mbedtls_pk_parse_public_keyfile(&pk, argv[1])) != 0) { in main() 102 if ((ret = mbedtls_pk_verify(&pk, MBEDTLS_MD_SHA256, hash, 0, in main() 113 mbedtls_pk_free(&pk); in main()
|
D | pk_decrypt.c | 44 mbedtls_pk_context pk; in main() local 52 mbedtls_pk_init(&pk); in main() 91 if ((ret = mbedtls_pk_parse_keyfile(&pk, argv[1], "", in main() 121 if ((ret = mbedtls_pk_decrypt(&pk, buf, i, result, &olen, sizeof(result), in main() 136 mbedtls_pk_free(&pk); in main()
|
D | pk_encrypt.c | 43 mbedtls_pk_context pk; in main() local 52 mbedtls_pk_init(&pk); in main() 87 if ((ret = mbedtls_pk_parse_public_keyfile(&pk, argv[1])) != 0) { in main() 106 if ((ret = mbedtls_pk_encrypt(&pk, input, strlen(argv[2]), in main() 137 mbedtls_pk_free(&pk); in main()
|
D | pk_sign.c | 41 mbedtls_pk_context pk; in main() local 52 mbedtls_pk_init(&pk); in main() 87 if ((ret = mbedtls_pk_parse_keyfile(&pk, argv[1], "", in main() 107 if ((ret = mbedtls_pk_sign(&pk, MBEDTLS_MD_SHA256, hash, 0, in main() 137 mbedtls_pk_free(&pk); in main()
|
/openthread-latest/third_party/mbedtls/repo/include/mbedtls/ |
D | pk.h | 592 int mbedtls_pk_get_psa_attributes(const mbedtls_pk_context *pk, 639 int mbedtls_pk_import_into_psa(const mbedtls_pk_context *pk, 677 int mbedtls_pk_copy_from_psa(mbedtls_svc_key_id_t key_id, mbedtls_pk_context *pk); 710 int mbedtls_pk_copy_public_from_psa(mbedtls_svc_key_id_t key_id, mbedtls_pk_context *pk); 1029 static inline mbedtls_rsa_context *mbedtls_pk_rsa(const mbedtls_pk_context pk) in mbedtls_pk_rsa() argument 1031 switch (mbedtls_pk_get_type(&pk)) { in mbedtls_pk_rsa() 1033 return (mbedtls_rsa_context *) (pk).MBEDTLS_PRIVATE(pk_ctx); in mbedtls_pk_rsa() 1052 static inline mbedtls_ecp_keypair *mbedtls_pk_ec(const mbedtls_pk_context pk) in mbedtls_pk_ec() argument 1054 switch (mbedtls_pk_get_type(&pk)) { in mbedtls_pk_ec() 1058 return (mbedtls_ecp_keypair *) (pk).MBEDTLS_PRIVATE(pk_ctx); in mbedtls_pk_ec() [all …]
|
/openthread-latest/src/core/crypto/ |
D | crypto_platform.cpp | 498 mbedtls_pk_context pk; in otPlatCryptoEcdsaGenerateKey() local 501 mbedtls_pk_init(&pk); in otPlatCryptoEcdsaGenerateKey() 503 ret = mbedtls_pk_setup(&pk, mbedtls_pk_info_from_type(MBEDTLS_PK_ECKEY)); in otPlatCryptoEcdsaGenerateKey() 506 …ret = mbedtls_ecp_gen_key(MBEDTLS_ECP_DP_SECP256R1, mbedtls_pk_ec(pk), MbedTls::CryptoSecurePrng, … in otPlatCryptoEcdsaGenerateKey() 509 ret = mbedtls_pk_write_key_der(&pk, aKeyPair->mDerBytes, OT_CRYPTO_ECDSA_MAX_DER_SIZE); in otPlatCryptoEcdsaGenerateKey() 518 mbedtls_pk_free(&pk); in otPlatCryptoEcdsaGenerateKey() 527 mbedtls_pk_context pk; in otPlatCryptoEcdsaGetPublicKey() local 531 mbedtls_pk_init(&pk); in otPlatCryptoEcdsaGetPublicKey() 533 …VerifyOrExit(mbedtls_pk_setup(&pk, mbedtls_pk_info_from_type(MBEDTLS_PK_ECKEY)) == 0, error = kErr… in otPlatCryptoEcdsaGetPublicKey() 536 VerifyOrExit(mbedtls_pk_parse_key(&pk, aKeyPair->mDerBytes, aKeyPair->mDerLength, nullptr, 0, in otPlatCryptoEcdsaGetPublicKey() [all …]
|
/openthread-latest/third_party/mbedtls/repo/programs/ssl/ |
D | ssl_test_lib.c | 279 int pk_wrap_as_opaque(mbedtls_pk_context *pk, psa_algorithm_t psa_alg, psa_algorithm_t psa_alg2, in pk_wrap_as_opaque() argument 285 ret = mbedtls_pk_get_psa_attributes(pk, PSA_KEY_USAGE_SIGN_HASH, &key_attr); in pk_wrap_as_opaque() 294 ret = mbedtls_pk_import_into_psa(pk, &key_attr, key_id); in pk_wrap_as_opaque() 298 mbedtls_pk_free(pk); in pk_wrap_as_opaque() 299 mbedtls_pk_init(pk); in pk_wrap_as_opaque() 300 ret = mbedtls_pk_setup_opaque(pk, *key_id); in pk_wrap_as_opaque()
|