20 #define EMPTY_KEY_SLOT 31 24 psa_key_handle_t key_handle;
25 psa_key_type_t key_type;
28 psa_key_usage_t usage;
29 psa_algorithm_t key_alg;
30 psa_status_t expected_status;
35 #ifdef ARCH_TEST_SHA256 36 {
"Test psa_mac_sign_setup 64 Byte HMAC\n", 1, PSA_KEY_TYPE_HMAC,
37 {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c,
38 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19,
39 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26,
40 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33,
41 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f},
42 64, PSA_KEY_USAGE_SIGN, PSA_ALG_HMAC(PSA_ALG_SHA_256),
48 #ifdef ARCH_TEST_AES_128 50 {
"Test psa_mac_sign_setup 16 Byte AES - CMAC\n", 2, PSA_KEY_TYPE_AES,
51 {0x49, 0x8E, 0xC7, 0x7D, 0x01, 0x95, 0x0D, 0x94, 0x2C, 0x16, 0xA5, 0x3E, 0x99,
53 AES_16B_KEY_SIZE, PSA_KEY_USAGE_SIGN, PSA_ALG_CMAC,
59 {
"Test psa_mac_sign_setup 16 Byte AES - GMAC\n", 3, PSA_KEY_TYPE_AES,
60 {0x49, 0x8E, 0xC7, 0x7D, 0x01, 0x95, 0x0D, 0x94, 0x2C, 0x16, 0xA5, 0x3E, 0x99,
62 AES_16B_KEY_SIZE, PSA_KEY_USAGE_SIGN, PSA_ALG_GMAC,
63 PSA_ERROR_NOT_SUPPORTED
69 {
"Test psa_mac_sign_setup incompactible HMAC for CMAC\n", 4, PSA_KEY_TYPE_HMAC,
70 {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C,
72 AES_16B_KEY_SIZE, PSA_KEY_USAGE_SIGN, PSA_ALG_CMAC,
73 PSA_ERROR_NOT_SUPPORTED
77 {
"Test psa_mac_sign_setup invalid usage\n", 5, PSA_KEY_TYPE_AES,
78 {0x49, 0x8E, 0xC7, 0x7D, 0x01, 0x95, 0x0D, 0x94, 0x2C, 0x16, 0xA5, 0x3E, 0x99,
80 AES_16B_KEY_SIZE, PSA_KEY_USAGE_EXPORT, PSA_ALG_CMAC,
81 PSA_ERROR_NOT_PERMITTED
86 #ifdef ARCH_TEST_SHA256 87 {
"Test psa_mac_sign_setup invalid key type\n", 7, PSA_KEY_TYPE_RAW_DATA,
88 {0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B,
90 AES_16B_KEY_SIZE, PSA_KEY_USAGE_SIGN, PSA_ALG_HMAC(PSA_ALG_SHA_256),
91 PSA_ERROR_INVALID_ARGUMENT
98 #ifdef ARCH_TEST_SHA256 99 #ifdef ARCH_TEST_TRUNCATED_MAC 100 {
"Test psa_mac_sign_setup truncated MAC too large\n", 8, PSA_KEY_TYPE_HMAC,
101 {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c,
102 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19,
103 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26,
104 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33,
105 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f},
106 64, PSA_KEY_USAGE_SIGN, PSA_ALG_TRUNCATED_MAC(PSA_ALG_HMAC(PSA_ALG_SHA_256), 33),
107 PSA_ERROR_INVALID_ARGUMENT
110 {
"Test psa_mac_sign_setup truncated MAC too small\n", 9, PSA_KEY_TYPE_HMAC,
111 {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c,
112 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19,
113 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26,
114 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33,
115 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f},
116 64, PSA_KEY_USAGE_SIGN, PSA_ALG_TRUNCATED_MAC(PSA_ALG_HMAC(PSA_ALG_SHA_256), 1),
117 PSA_ERROR_NOT_SUPPORTED
122 #ifdef ARCH_TEST_AES_128 123 {
"Test psa_mac_sign_setup bad algorithm (unknown MAC algorithm)\n", 10, PSA_KEY_TYPE_AES,
124 {0x49, 0x8E, 0xC7, 0x7D, 0x01, 0x95, 0x0D, 0x94, 0x2C, 0x16, 0xA5, 0x3E, 0x99,
126 AES_16B_KEY_SIZE, PSA_KEY_USAGE_SIGN, PSA_ALG_HMAC(0),
127 PSA_ERROR_NOT_SUPPORTED
132 #ifdef ARCH_TEST_AES_128 133 #ifdef ARCH_TEST_CBC_NO_PADDING 134 {
"Test psa_mac_sign_setup bad algorithm (not a MAC algorithm)\n", 11, PSA_KEY_TYPE_AES,
135 {0x49, 0x8E, 0xC7, 0x7D, 0x01, 0x95, 0x0D, 0x94, 0x2C, 0x16, 0xA5, 0x3E, 0x99,
137 AES_16B_KEY_SIZE, PSA_KEY_USAGE_SIGN, PSA_ALG_CBC_NO_PADDING,
138 PSA_ERROR_INVALID_ARGUMENT
145 #ifdef ARCH_TEST_AES_128 146 #ifdef ARCH_TEST_CMAC 147 {
"Test psa_mac_sign_setup - Negative case\n", 12, PSA_KEY_TYPE_AES,
148 {0x49, 0x8E, 0xC7, 0x7D, 0x01, 0x95, 0x0D, 0x94, 0x2C, 0x16, 0xA5, 0x3E, 0x99,
150 AES_16B_KEY_SIZE, PSA_KEY_USAGE_SIGN, PSA_ALG_CMAC,
151 PSA_ERROR_INVALID_ARGUMENT
Copyright (c) 2018-2019, Arm Limited or its affiliates.