Lines Matching defs:key
1 /** Code to exercise a PSA key object, i.e. validate that it seems well-formed
41 static int check_key_attributes_sanity(mbedtls_svc_key_id_t key,
50 psa_status_t status = psa_get_key_attributes(key, &attributes);
52 /* The key has been destroyed. */
100 /* MAX macros concerning specific key types */
120 static int exercise_mac_key(mbedtls_svc_key_id_t key,
136 status = psa_mac_sign_setup(&operation, key, alg);
138 /* The key has been destroyed. */
155 status = psa_mac_verify_setup(&operation, key, alg);
157 /* The key has been destroyed. */
175 static int exercise_cipher_key(mbedtls_svc_key_id_t key,
192 PSA_ASSERT(psa_get_key_attributes(key, &attributes));
197 status = psa_cipher_encrypt_setup(&operation, key, alg);
199 /* The key has been destroyed. */
225 status = psa_cipher_decrypt_setup(&operation, key, alg);
227 /* The key has been destroyed. */
263 static int exercise_aead_key(mbedtls_svc_key_id_t key,
283 PSA_ASSERT(psa_get_key_attributes(key, &attributes));
288 status = psa_aead_encrypt(key, alg,
295 /* The key has been destroyed. */
306 status = psa_aead_decrypt(key, alg,
313 /* The key has been destroyed. */
338 static int exercise_signature_key(mbedtls_svc_key_id_t key,
372 status = psa_sign_hash(key, alg,
377 /* The key has been destroyed. */
388 status = psa_verify_hash(key, alg,
392 /* The key has been destroyed. */
406 status = psa_sign_message(key, alg,
411 /* The key has been destroyed. */
422 status = psa_verify_message(key, alg,
426 /* The key has been destroyed. */
439 static int exercise_asymmetric_encryption_key(mbedtls_svc_key_id_t key,
452 status = psa_asymmetric_encrypt(key, alg,
458 /* The key has been destroyed. */
465 status = psa_asymmetric_decrypt(key, alg,
471 /* The key has been destroyed. */
488 mbedtls_svc_key_id_t key,
502 key);
504 /* The key has been destroyed. */
518 key);
520 /* The key has been destroyed. */
527 key);
529 /* The key has been destroyed. */
544 key);
546 /* The key has been destroyed. */
563 key);
565 /* The key has been destroyed. */
588 static int exercise_key_derivation_key(mbedtls_svc_key_id_t key,
602 if (!mbedtls_test_psa_setup_key_derivation_wrap(&operation, key, alg,
613 /* The key has been destroyed. */
627 /* We need two keys to exercise key agreement. Exercise the
628 * private key against its own public key. */
631 mbedtls_svc_key_id_t key, int key_destroyable)
640 psa_status_t status = psa_get_key_attributes(key, &attributes);
642 /* The key has been destroyed. */
653 status = psa_export_public_key(key, public_key, public_key_length,
656 /* The key has been destroyed. */
663 operation, PSA_KEY_DERIVATION_INPUT_SECRET, key,
666 /* The key has been destroyed. */
681 /* We need two keys to exercise key agreement. Exercise the
682 * private key against its own public key. */
685 mbedtls_svc_key_id_t key,
697 psa_status_t status = psa_get_key_attributes(key, &attributes);
699 /* The key has been destroyed. */
710 status = psa_export_public_key(key,
714 /* The key has been destroyed. */
720 status = psa_raw_key_agreement(alg, key,
724 /* The key has been destroyed. */
747 static int exercise_raw_key_agreement_key(mbedtls_svc_key_id_t key,
755 /* We need two keys to exercise key agreement. Exercise the
756 * private key against its own public key. */
757 PSA_ASSERT(mbedtls_test_psa_raw_key_agreement_with_self(alg, key,
766 static int exercise_key_agreement_key(mbedtls_svc_key_id_t key,
779 /* We need two keys to exercise key agreement. Exercise the
780 * private key against its own public key. */
796 to expected PRK size. In practice it means that key bits must match
800 psa_status_t status = psa_get_key_attributes(key, &attributes);
802 /* The key has been destroyed. */
814 TEST_EQUAL(mbedtls_test_psa_key_agreement_with_self(&operation, key,
954 /* The representation of an ECC Montgomery public key is
958 /* The representation of an ECC Edwards public key is
962 /* The representation of an ECC Weierstrass public key is:
979 TEST_FAIL("Sanity check not implemented for this key type");
1005 static int exercise_export_key(mbedtls_svc_key_id_t key,
1015 psa_status_t status = psa_get_key_attributes(key, &attributes);
1017 /* The key has been destroyed. */
1028 status = psa_export_key(key, exported, exported_size, &exported_length);
1030 /* The key has been destroyed. */
1055 static int exercise_export_public_key(mbedtls_svc_key_id_t key,
1065 psa_status_t status = psa_get_key_attributes(key, &attributes);
1067 /* The key has been destroyed. */
1078 status = psa_export_public_key(key, exported,
1081 /* The key has been destroyed. */
1096 status = psa_export_public_key(key, exported,
1099 /* The key has been destroyed. */
1119 int mbedtls_test_psa_exercise_key(mbedtls_svc_key_id_t key,
1126 if (!check_key_attributes_sanity(key, key_destroyable)) {
1133 ok = exercise_mac_key(key, usage, alg, key_destroyable);
1135 ok = exercise_cipher_key(key, usage, alg, key_destroyable);
1137 ok = exercise_aead_key(key, usage, alg, key_destroyable);
1139 ok = exercise_signature_key(key, usage, alg, key_destroyable);
1141 ok = exercise_asymmetric_encryption_key(key, usage, alg,
1144 ok = exercise_key_derivation_key(key, usage, alg, key_destroyable);
1146 ok = exercise_raw_key_agreement_key(key, usage, alg, key_destroyable);
1148 ok = exercise_key_agreement_key(key, usage, alg, key_destroyable);
1153 ok = ok && exercise_export_key(key,
1156 ok = ok && exercise_export_public_key(key,