@@ -75,6 +75,26 @@ void test_crypto_asymmetric_encrypt_decrypt(void)
75
75
mbedtls_psa_crypto_free ();
76
76
}
77
77
78
+ void test_crypto_hash_verify (void )
79
+ {
80
+ psa_algorithm_t alg = PSA_ALG_SHA_256;
81
+ psa_hash_operation_t operation;
82
+ /* SHA-256 hash of an empty string */
83
+ static const unsigned char hash[] = {
84
+ 0xe3 , 0xb0 , 0xc4 , 0x42 , 0x98 , 0xfc , 0x1c , 0x14 , 0x9a , 0xfb , 0xf4 , 0xc8 ,
85
+ 0x99 , 0x6f , 0xb9 , 0x24 , 0x27 , 0xae , 0x41 , 0xe4 , 0x64 , 0x9b , 0x93 , 0x4c ,
86
+ 0xa4 , 0x95 , 0x99 , 0x1b , 0x78 , 0x52 , 0xb8 , 0x55
87
+ };
88
+
89
+ TEST_ASSERT_EQUAL (PSA_SUCCESS, psa_crypto_init ());
90
+
91
+ TEST_ASSERT_EQUAL (PSA_SUCCESS, psa_hash_setup (&operation, alg));
92
+ TEST_ASSERT_EQUAL (PSA_SUCCESS, psa_hash_verify (&operation, hash, sizeof (hash)));
93
+ TEST_ASSERT_EQUAL (PSA_SUCCESS, psa_hash_abort (&operation));
94
+
95
+ mbedtls_psa_crypto_free ();
96
+ }
97
+
78
98
utest::v1::status_t case_failure_handler (const Case *const source, const failure_t reason)
79
99
{
80
100
mbedtls_psa_crypto_free ();
@@ -91,6 +111,7 @@ utest::v1::status_t test_setup(const size_t number_of_cases)
91
111
Case cases[] = {
92
112
Case (" mbed-crypto random" , test_crypto_random, case_failure_handler),
93
113
Case (" mbed-crypto asymmetric encrypt/decrypt" , test_crypto_asymmetric_encrypt_decrypt, case_failure_handler),
114
+ Case (" mbed-crypto hash verify" , test_crypto_hash_verify, case_failure_handler),
94
115
};
95
116
96
117
Specification specification (test_setup, cases);
0 commit comments