mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-11-30 19:44:18 +01:00
Merge remote-tracking branch 'psa/pr/54' into feature-psa
This commit is contained in:
commit
ad44f11257
@ -169,6 +169,54 @@ PSA Symmetric encryption + decryption multipart: AES-CBC-PKCS#7 padding, 4+12 by
|
|||||||
depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_CBC:MBEDTLS_CIPHER_PADDING_PKCS7
|
depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_CBC:MBEDTLS_CIPHER_PADDING_PKCS7
|
||||||
cipher_verify_output_multipart:PSA_ALG_CBC_BASE | PSA_ALG_BLOCK_CIPHER_PAD_PKCS7:PSA_KEY_TYPE_AES:"2b7e151628aed2a6abf7158809cf4f3c":"a076ec9dfbe47d52afc357336f20743b":4
|
cipher_verify_output_multipart:PSA_ALG_CBC_BASE | PSA_ALG_BLOCK_CIPHER_PAD_PKCS7:PSA_KEY_TYPE_AES:"2b7e151628aed2a6abf7158809cf4f3c":"a076ec9dfbe47d52afc357336f20743b":4
|
||||||
|
|
||||||
|
PSA AEAD Encrypt-Decrypt, AES CCM 19-bytes input - 1
|
||||||
|
aead_encrypt_decrypt:PSA_KEY_TYPE_AES:"C0C1C2C3C4C5C6C7C8C9CACBCCCDCECF":PSA_ALG_CCM:"0C0D0E0F101112131415161718191A1B1C1D1E":"000102030405060708090A0B":"000102030405060708090A0B":PSA_SUCCESS
|
||||||
|
|
||||||
|
PSA AEAD Encrypt-Decrypt, AES CCM 19-bytes input - 2
|
||||||
|
aead_encrypt_decrypt:PSA_KEY_TYPE_AES:"D7828D13B2B0BDC325A76236DF93CC6B":PSA_ALG_CCM:"B96B49E21D621741632875DB7F6C9243D2D7C2":"000102030405060708090A0B":"EC46BB63B02520C33C49FD70":PSA_SUCCESS
|
||||||
|
|
||||||
|
PSA AEAD Encrypt-Decrypt, Fail Scenario - Invalid key type
|
||||||
|
aead_encrypt_decrypt:PSA_KEY_TYPE_DES:"D7828D13B2B0BDC325A76236DF93CC6B":PSA_ALG_CCM:"B96B49E21D621741632875DB7F6C9243D2D7C2":"000102030405060708090A0B":"EC46BB63B02520C33C49FD70":PSA_ERROR_NOT_SUPPORTED
|
||||||
|
|
||||||
|
PSA AEAD Encrypt, AES CCM - 23-bytes input
|
||||||
|
aead_encrypt:PSA_KEY_TYPE_AES:"D7828D13B2B0BDC325A76236DF93CC6B":PSA_ALG_CCM:"08E8CF97D820EA258460E96AD9CF5289054D895CEAC47C":"0BE1A88BACE018B1":"00412B4EA9CDBE3C9696766CFA":"4CB97F86A2A4689A877947AB8091EF5386A6FFBDD080F8120333D1FCB691F3406CBF531F83A4D8"
|
||||||
|
|
||||||
|
PSA AEAD Encrypt, AES CCM - 24-bytes input
|
||||||
|
aead_encrypt:PSA_KEY_TYPE_AES:"4189351B5CAEA375A0299E81C621BF43":PSA_ALG_CCM:"4535d12b4377928a7c0a61c9f825a48671ea05910748c8ef":"40a27c1d1e23ea3dbe8056b2774861a4a201cce49f19997d19206d8c8a343951":"48c0906930561e0ab0ef4cd972":"26c56961c035a7e452cce61bc6ee220d77b3f94d18fd10b6d80e8bf80f4a46cab06d4313f0db9be9"
|
||||||
|
|
||||||
|
PSA AEAD Decrypt, AES CCM - 39-bytes input
|
||||||
|
aead_decrypt:PSA_KEY_TYPE_AES:"D7828D13B2B0BDC325A76236DF93CC6B":PSA_ALG_CCM:"4CB97F86A2A4689A877947AB8091EF5386A6FFBDD080F8120333D1FCB691F3406CBF531F83A4D8":"0BE1A88BACE018B1":"00412B4EA9CDBE3C9696766CFA":"08E8CF97D820EA258460E96AD9CF5289054D895CEAC47C":PSA_SUCCESS
|
||||||
|
|
||||||
|
PSA AEAD Decrypt, AES CCM - 40-bytes input
|
||||||
|
aead_decrypt:PSA_KEY_TYPE_AES:"4189351B5CAEA375A0299E81C621BF43":PSA_ALG_CCM:"26c56961c035a7e452cce61bc6ee220d77b3f94d18fd10b6d80e8bf80f4a46cab06d4313f0db9be9":"40a27c1d1e23ea3dbe8056b2774861a4a201cce49f19997d19206d8c8a343951":"48c0906930561e0ab0ef4cd972":"4535d12b4377928a7c0a61c9f825a48671ea05910748c8ef":PSA_SUCCESS
|
||||||
|
|
||||||
|
PSA AEAD Decrypt, AES CCM - invalid signature
|
||||||
|
aead_decrypt:PSA_KEY_TYPE_AES:"4189351B5CAEA375A0299E81C621BF43":PSA_ALG_CCM:"26d56961c035a7e452cce61bc6ee220d77b3f94d18fd10b6d80e8bf80f4a46cab06d4313f0db9be9":"40a27c1d1e23ea3dbe8056b2774861a4a201cce49f19997d19206d8c8a343951":"48c0906930561e0ab0ef4cd972":"4535d12b4377928a7c0a61c9f825a48671ea05910748c8ef":PSA_ERROR_INVALID_SIGNATURE
|
||||||
|
|
||||||
|
PSA AEAD Encrypt-Decrypt, AES GCM 19-bytes input - 1
|
||||||
|
aead_encrypt_decrypt:PSA_KEY_TYPE_AES:"C0C1C2C3C4C5C6C7C8C9CACBCCCDCECF":PSA_ALG_GCM:"0C0D0E0F101112131415161718191A1B1C1D1E":"000102030405060708090A0B0C0D0E0F":"000102030405060708090A0B":PSA_SUCCESS
|
||||||
|
|
||||||
|
PSA AEAD Encrypt-Decrypt, AES GCM 19-bytes input - 2
|
||||||
|
aead_encrypt_decrypt:PSA_KEY_TYPE_AES:"D7828D13B2B0BDC325A76236DF93CC6B":PSA_ALG_GCM:"B96B49E21D621741632875DB7F6C9243D2D7C2":"000102030405060708090A0B0C0D0E0F":"EC46BB63B02520C33C49FD70":PSA_SUCCESS
|
||||||
|
|
||||||
|
PSA AEAD Encrypt, AES GCM - 128-bytes input - 1
|
||||||
|
aead_encrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_GCM:"5431d93278c35cfcd7ffa9ce2de5c6b922edffd5055a9eaa5b54cae088db007cf2d28efaf9edd1569341889073e87c0a88462d77016744be62132fd14a243ed6e30e12cd2f7d08a8daeec161691f3b27d4996df8745d74402ee208e4055615a8cb069d495cf5146226490ac615d7b17ab39fb4fdd098e4e7ee294d34c1312826":"a3cfcb832e935eb5bc3812583b3a1b2e82920c07fda3668a35d939d8f11379bb606d39e6416b2ef336fffb15aec3f47a71e191f4ff6c56ff15913562619765b26ae094713d60bab6ab82bfc36edaaf8c7ce2cf5906554dcc5933acdb9cb42c1d24718efdc4a09256020b024b224cfe602772bd688c6c8f1041a46f7ec7d51208":"00e440846db73a490573deaf3728c94f":"3b6de52f6e582d317f904ee768895bd4d0790912efcf27b58651d0eb7eb0b2f07222c6ffe9f7e127d98ccb132025b098a67dc0ec0083235e9f83af1ae1297df4319547cbcb745cebed36abc1f32a059a05ede6c00e0da097521ead901ad6a73be20018bda4c323faa135169e21581e5106ac20853642e9d6b17f1dd925c872814365847fe0b7b7fbed325953df344a96"
|
||||||
|
|
||||||
|
PSA AEAD Encrypt, AES GCM - 128-bytes input - 2
|
||||||
|
aead_encrypt:PSA_KEY_TYPE_AES:"fe96eab10ff48c7942025422583d0377":PSA_ALG_GCM:"194c8bbbfae4a671386b8cd38f390f46f9df6b8661b470c310921a1c858a938045834bb10380037fbf5f5e00688554537be0fcafe8270b9b59068fa056ab1268fc166c2d729243a06650a171c929c7845c85330c04568d62977eedf3b1ba9dca13bdb8f9522817c8cb99e635e37465ec1c9f6f148d51437aa9f994a62e1bd013":"127628b6dcbce6fc8a8ef60798eb67b2088415635119697d20bb878c24d9c6f9c29e148521cb5e0feff892c7855d4f1c0bfb32ad33420976714dce87a0bbc18e4378bd1ef35197d0ca73051148f1199010f63caf122df5f71ad8d9c71df3eb2fbe3b2529d0ba657570358d3776f687bdb9c96d5e0e9e00c4b42d5d7a268d6a08":"97ce3f848276783599c6875de324361e":"12495120056ca3cac70d583603a476821bac6c57c9733b81cfb83538dc9e850f8bdf46065069591c23ebcbc6d1e2523375fb7efc80c09507fa25477ed07cee54fc4eb90168b3ef988f651fc40652474a644b1b311decf899660aef2347bb081af48950f06ebf799911e37120de94c55c20e5f0a77119be06e2b6e557f872fa0f6bac793bdc2190a195122c98544ccf56"
|
||||||
|
|
||||||
|
PSA AEAD Decrypt, AES GCM - 144-bytes input - 1
|
||||||
|
aead_decrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_GCM:"3b6de52f6e582d317f904ee768895bd4d0790912efcf27b58651d0eb7eb0b2f07222c6ffe9f7e127d98ccb132025b098a67dc0ec0083235e9f83af1ae1297df4319547cbcb745cebed36abc1f32a059a05ede6c00e0da097521ead901ad6a73be20018bda4c323faa135169e21581e5106ac20853642e9d6b17f1dd925c872814365847fe0b7b7fbed325953df344a96":"a3cfcb832e935eb5bc3812583b3a1b2e82920c07fda3668a35d939d8f11379bb606d39e6416b2ef336fffb15aec3f47a71e191f4ff6c56ff15913562619765b26ae094713d60bab6ab82bfc36edaaf8c7ce2cf5906554dcc5933acdb9cb42c1d24718efdc4a09256020b024b224cfe602772bd688c6c8f1041a46f7ec7d51208":"00e440846db73a490573deaf3728c94f":"5431d93278c35cfcd7ffa9ce2de5c6b922edffd5055a9eaa5b54cae088db007cf2d28efaf9edd1569341889073e87c0a88462d77016744be62132fd14a243ed6e30e12cd2f7d08a8daeec161691f3b27d4996df8745d74402ee208e4055615a8cb069d495cf5146226490ac615d7b17ab39fb4fdd098e4e7ee294d34c1312826":PSA_SUCCESS
|
||||||
|
|
||||||
|
PSA AEAD Decrypt, AES GCM - 144-bytes input - 2
|
||||||
|
aead_decrypt:PSA_KEY_TYPE_AES:"fe96eab10ff48c7942025422583d0377":PSA_ALG_GCM:"12495120056ca3cac70d583603a476821bac6c57c9733b81cfb83538dc9e850f8bdf46065069591c23ebcbc6d1e2523375fb7efc80c09507fa25477ed07cee54fc4eb90168b3ef988f651fc40652474a644b1b311decf899660aef2347bb081af48950f06ebf799911e37120de94c55c20e5f0a77119be06e2b6e557f872fa0f6bac793bdc2190a195122c98544ccf56":"127628b6dcbce6fc8a8ef60798eb67b2088415635119697d20bb878c24d9c6f9c29e148521cb5e0feff892c7855d4f1c0bfb32ad33420976714dce87a0bbc18e4378bd1ef35197d0ca73051148f1199010f63caf122df5f71ad8d9c71df3eb2fbe3b2529d0ba657570358d3776f687bdb9c96d5e0e9e00c4b42d5d7a268d6a08":"97ce3f848276783599c6875de324361e":"194c8bbbfae4a671386b8cd38f390f46f9df6b8661b470c310921a1c858a938045834bb10380037fbf5f5e00688554537be0fcafe8270b9b59068fa056ab1268fc166c2d729243a06650a171c929c7845c85330c04568d62977eedf3b1ba9dca13bdb8f9522817c8cb99e635e37465ec1c9f6f148d51437aa9f994a62e1bd013":PSA_SUCCESS
|
||||||
|
|
||||||
|
PSA AEAD Decrypt, AES GCM - invalid signature
|
||||||
|
aead_decrypt:PSA_KEY_TYPE_AES:"fe96eab10ff48c7942025422583d0377":PSA_ALG_GCM:"12195120056ca3cac70d583603a476821bac6c57c9733b81cfb83538dc9e850f8bdf46065069591c23ebcbc6d1e2523375fb7efc80c09507fa25477ed07cee54fc4eb90168b3ef988f651fc40652474a644b1b311decf899660aef2347bb081af48950f06ebf799911e37120de94c55c20e5f0a77119be06e2b6e557f872fa0f6bac793bdc2190a195122c98544ccf56":"127628b6dcbce6fc8a8ef60798eb67b2088415635119697d20bb878c24d9c6f9c29e148521cb5e0feff892c7855d4f1c0bfb32ad33420976714dce87a0bbc18e4378bd1ef35197d0ca73051148f1199010f63caf122df5f71ad8d9c71df3eb2fbe3b2529d0ba657570358d3776f687bdb9c96d5e0e9e00c4b42d5d7a268d6a08":"97ce3f848276783599c6875de324361e":"194c8bbbfae4a671386b8cd38f390f46f9df6b8661b470c310921a1c858a938045834bb10380037fbf5f5e00688554537be0fcafe8270b9b59068fa056ab1268fc166c2d729243a06650a171c929c7845c85330c04568d62977eedf3b1ba9dca13bdb8f9522817c8cb99e635e37465ec1c9f6f148d51437aa9f994a62e1bd013":PSA_ERROR_INVALID_SIGNATURE
|
||||||
|
|
||||||
|
PSA AEAD Encrypt-Decrypt, Fail Scenario - Invalid algorithm
|
||||||
|
aead_encrypt_decrypt:PSA_KEY_TYPE_AES:"D7828D13B2B0BDC325A76236DF93CC6B":PSA_ALG_CTR:"B96B49E21D621741632875DB7F6C9243D2D7C2":"000102030405060708090A0B0C0D0E0F":"EC46BB63B02520C33C49FD70":PSA_ERROR_NOT_SUPPORTED
|
||||||
|
|
||||||
PSA signature size: RSA keypair, 1024 bits, PKCS#1 v1.5 raw
|
PSA signature size: RSA keypair, 1024 bits, PKCS#1 v1.5 raw
|
||||||
signature_size:PSA_KEY_TYPE_RSA_KEYPAIR:1024:PSA_ALG_RSA_PKCS1V15_SIGN_RAW:128
|
signature_size:PSA_KEY_TYPE_RSA_KEYPAIR:1024:PSA_ALG_RSA_PKCS1V15_SIGN_RAW:128
|
||||||
|
|
||||||
@ -236,51 +284,3 @@ sign_fail:PSA_KEY_TYPE_ECC_KEYPAIR(PSA_KEY_TYPE_ECC_CURVE_NISTP256R1):"307802010
|
|||||||
PSA verify ECDSA SECP256R1 SHA-256
|
PSA verify ECDSA SECP256R1 SHA-256
|
||||||
depends_on:MBEDTLS_PK_C:MBEDTLS_PK_PARSE_C:MBEDTLS_ECP_C:MBEDTLS_ECP_DP_SECP256R1_ENABLED
|
depends_on:MBEDTLS_PK_C:MBEDTLS_PK_PARSE_C:MBEDTLS_ECP_C:MBEDTLS_ECP_DP_SECP256R1_ENABLED
|
||||||
asymmetric_verify:PSA_KEY_TYPE_ECC_KEYPAIR(PSA_KEY_TYPE_ECC_CURVE_NISTP256R1):"3078020101042100ab45435712649cb30bbddac49197eebf2740ffc7f874d9244c3460f54f322d3aa00a06082a8648ce3d030107a14403420004dea5e45d0ea37fc566232a508f4ad20ea13d47e4bf5fa4d54a57a0ba012042087097496efc583fed8b24a5b9be9a51de063f5a00a8b698a16fd7f29b5485f320":PSA_ALG_SHA_256:"9ac4335b469bbd791439248504dd0d49c71349a295fee5a1c68507f45a9e1c7b":"304502206a3399f69421ffe1490377adf2ea1f117d81a63cf5bf22e918d51175eb259151022100ce95d7c26cc04e25503e2f7a1ec3573e3c2412534bb4a19b3a7811742f49f50f"
|
asymmetric_verify:PSA_KEY_TYPE_ECC_KEYPAIR(PSA_KEY_TYPE_ECC_CURVE_NISTP256R1):"3078020101042100ab45435712649cb30bbddac49197eebf2740ffc7f874d9244c3460f54f322d3aa00a06082a8648ce3d030107a14403420004dea5e45d0ea37fc566232a508f4ad20ea13d47e4bf5fa4d54a57a0ba012042087097496efc583fed8b24a5b9be9a51de063f5a00a8b698a16fd7f29b5485f320":PSA_ALG_SHA_256:"9ac4335b469bbd791439248504dd0d49c71349a295fee5a1c68507f45a9e1c7b":"304502206a3399f69421ffe1490377adf2ea1f117d81a63cf5bf22e918d51175eb259151022100ce95d7c26cc04e25503e2f7a1ec3573e3c2412534bb4a19b3a7811742f49f50f"
|
||||||
|
|
||||||
PSA AEAD Encrypt-Decrypt, AES CCM 19-bytes input - 1
|
|
||||||
aead_encrypt_decrypt:PSA_KEY_TYPE_AES:"C0C1C2C3C4C5C6C7C8C9CACBCCCDCECF":PSA_ALG_CCM:"0C0D0E0F101112131415161718191A1B1C1D1E":"000102030405060708090A0B":"000102030405060708090A0B":PSA_SUCCESS
|
|
||||||
|
|
||||||
PSA AEAD Encrypt-Decrypt, AES CCM 19-bytes input - 2
|
|
||||||
aead_encrypt_decrypt:PSA_KEY_TYPE_AES:"D7828D13B2B0BDC325A76236DF93CC6B":PSA_ALG_CCM:"B96B49E21D621741632875DB7F6C9243D2D7C2":"000102030405060708090A0B":"EC46BB63B02520C33C49FD70":PSA_SUCCESS
|
|
||||||
|
|
||||||
PSA AEAD Encrypt-Decrypt, Fail Scenario - Invalid key type
|
|
||||||
aead_encrypt_decrypt:PSA_KEY_TYPE_DES:"D7828D13B2B0BDC325A76236DF93CC6B":PSA_ALG_CCM:"B96B49E21D621741632875DB7F6C9243D2D7C2":"000102030405060708090A0B":"EC46BB63B02520C33C49FD70":PSA_ERROR_NOT_SUPPORTED
|
|
||||||
|
|
||||||
PSA AEAD Encrypt, AES CCM - 23-bytes input
|
|
||||||
aead_encrypt:PSA_KEY_TYPE_AES:"D7828D13B2B0BDC325A76236DF93CC6B":PSA_ALG_CCM:"08E8CF97D820EA258460E96AD9CF5289054D895CEAC47C":"0BE1A88BACE018B1":"00412B4EA9CDBE3C9696766CFA":"4CB97F86A2A4689A877947AB8091EF5386A6FFBDD080F8120333D1FCB691F3406CBF531F83A4D8"
|
|
||||||
|
|
||||||
PSA AEAD Encrypt, AES CCM - 24-bytes input
|
|
||||||
aead_encrypt:PSA_KEY_TYPE_AES:"4189351B5CAEA375A0299E81C621BF43":PSA_ALG_CCM:"4535d12b4377928a7c0a61c9f825a48671ea05910748c8ef":"40a27c1d1e23ea3dbe8056b2774861a4a201cce49f19997d19206d8c8a343951":"48c0906930561e0ab0ef4cd972":"26c56961c035a7e452cce61bc6ee220d77b3f94d18fd10b6d80e8bf80f4a46cab06d4313f0db9be9"
|
|
||||||
|
|
||||||
PSA AEAD Decrypt, AES CCM - 39-bytes input
|
|
||||||
aead_decrypt:PSA_KEY_TYPE_AES:"D7828D13B2B0BDC325A76236DF93CC6B":PSA_ALG_CCM:"4CB97F86A2A4689A877947AB8091EF5386A6FFBDD080F8120333D1FCB691F3406CBF531F83A4D8":"0BE1A88BACE018B1":"00412B4EA9CDBE3C9696766CFA":"08E8CF97D820EA258460E96AD9CF5289054D895CEAC47C":PSA_SUCCESS
|
|
||||||
|
|
||||||
PSA AEAD Decrypt, AES CCM - 40-bytes input
|
|
||||||
aead_decrypt:PSA_KEY_TYPE_AES:"4189351B5CAEA375A0299E81C621BF43":PSA_ALG_CCM:"26c56961c035a7e452cce61bc6ee220d77b3f94d18fd10b6d80e8bf80f4a46cab06d4313f0db9be9":"40a27c1d1e23ea3dbe8056b2774861a4a201cce49f19997d19206d8c8a343951":"48c0906930561e0ab0ef4cd972":"4535d12b4377928a7c0a61c9f825a48671ea05910748c8ef":PSA_SUCCESS
|
|
||||||
|
|
||||||
PSA AEAD Decrypt, AES CCM - invalid signature
|
|
||||||
aead_decrypt:PSA_KEY_TYPE_AES:"4189351B5CAEA375A0299E81C621BF43":PSA_ALG_CCM:"26d56961c035a7e452cce61bc6ee220d77b3f94d18fd10b6d80e8bf80f4a46cab06d4313f0db9be9":"40a27c1d1e23ea3dbe8056b2774861a4a201cce49f19997d19206d8c8a343951":"48c0906930561e0ab0ef4cd972":"4535d12b4377928a7c0a61c9f825a48671ea05910748c8ef":PSA_ERROR_INVALID_SIGNATURE
|
|
||||||
|
|
||||||
PSA AEAD Encrypt-Decrypt, AES GCM 19-bytes input - 1
|
|
||||||
aead_encrypt_decrypt:PSA_KEY_TYPE_AES:"C0C1C2C3C4C5C6C7C8C9CACBCCCDCECF":PSA_ALG_GCM:"0C0D0E0F101112131415161718191A1B1C1D1E":"000102030405060708090A0B0C0D0E0F":"000102030405060708090A0B":PSA_SUCCESS
|
|
||||||
|
|
||||||
PSA AEAD Encrypt-Decrypt, AES GCM 19-bytes input - 2
|
|
||||||
aead_encrypt_decrypt:PSA_KEY_TYPE_AES:"D7828D13B2B0BDC325A76236DF93CC6B":PSA_ALG_GCM:"B96B49E21D621741632875DB7F6C9243D2D7C2":"000102030405060708090A0B0C0D0E0F":"EC46BB63B02520C33C49FD70":PSA_SUCCESS
|
|
||||||
|
|
||||||
PSA AEAD Encrypt, AES GCM - 128-bytes input - 1
|
|
||||||
aead_encrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_GCM:"5431d93278c35cfcd7ffa9ce2de5c6b922edffd5055a9eaa5b54cae088db007cf2d28efaf9edd1569341889073e87c0a88462d77016744be62132fd14a243ed6e30e12cd2f7d08a8daeec161691f3b27d4996df8745d74402ee208e4055615a8cb069d495cf5146226490ac615d7b17ab39fb4fdd098e4e7ee294d34c1312826":"a3cfcb832e935eb5bc3812583b3a1b2e82920c07fda3668a35d939d8f11379bb606d39e6416b2ef336fffb15aec3f47a71e191f4ff6c56ff15913562619765b26ae094713d60bab6ab82bfc36edaaf8c7ce2cf5906554dcc5933acdb9cb42c1d24718efdc4a09256020b024b224cfe602772bd688c6c8f1041a46f7ec7d51208":"00e440846db73a490573deaf3728c94f":"3b6de52f6e582d317f904ee768895bd4d0790912efcf27b58651d0eb7eb0b2f07222c6ffe9f7e127d98ccb132025b098a67dc0ec0083235e9f83af1ae1297df4319547cbcb745cebed36abc1f32a059a05ede6c00e0da097521ead901ad6a73be20018bda4c323faa135169e21581e5106ac20853642e9d6b17f1dd925c872814365847fe0b7b7fbed325953df344a96"
|
|
||||||
|
|
||||||
PSA AEAD Encrypt, AES GCM - 128-bytes input - 2
|
|
||||||
aead_encrypt:PSA_KEY_TYPE_AES:"fe96eab10ff48c7942025422583d0377":PSA_ALG_GCM:"194c8bbbfae4a671386b8cd38f390f46f9df6b8661b470c310921a1c858a938045834bb10380037fbf5f5e00688554537be0fcafe8270b9b59068fa056ab1268fc166c2d729243a06650a171c929c7845c85330c04568d62977eedf3b1ba9dca13bdb8f9522817c8cb99e635e37465ec1c9f6f148d51437aa9f994a62e1bd013":"127628b6dcbce6fc8a8ef60798eb67b2088415635119697d20bb878c24d9c6f9c29e148521cb5e0feff892c7855d4f1c0bfb32ad33420976714dce87a0bbc18e4378bd1ef35197d0ca73051148f1199010f63caf122df5f71ad8d9c71df3eb2fbe3b2529d0ba657570358d3776f687bdb9c96d5e0e9e00c4b42d5d7a268d6a08":"97ce3f848276783599c6875de324361e":"12495120056ca3cac70d583603a476821bac6c57c9733b81cfb83538dc9e850f8bdf46065069591c23ebcbc6d1e2523375fb7efc80c09507fa25477ed07cee54fc4eb90168b3ef988f651fc40652474a644b1b311decf899660aef2347bb081af48950f06ebf799911e37120de94c55c20e5f0a77119be06e2b6e557f872fa0f6bac793bdc2190a195122c98544ccf56"
|
|
||||||
|
|
||||||
PSA AEAD Decrypt, AES GCM - 144-bytes input - 1
|
|
||||||
aead_decrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_GCM:"3b6de52f6e582d317f904ee768895bd4d0790912efcf27b58651d0eb7eb0b2f07222c6ffe9f7e127d98ccb132025b098a67dc0ec0083235e9f83af1ae1297df4319547cbcb745cebed36abc1f32a059a05ede6c00e0da097521ead901ad6a73be20018bda4c323faa135169e21581e5106ac20853642e9d6b17f1dd925c872814365847fe0b7b7fbed325953df344a96":"a3cfcb832e935eb5bc3812583b3a1b2e82920c07fda3668a35d939d8f11379bb606d39e6416b2ef336fffb15aec3f47a71e191f4ff6c56ff15913562619765b26ae094713d60bab6ab82bfc36edaaf8c7ce2cf5906554dcc5933acdb9cb42c1d24718efdc4a09256020b024b224cfe602772bd688c6c8f1041a46f7ec7d51208":"00e440846db73a490573deaf3728c94f":"5431d93278c35cfcd7ffa9ce2de5c6b922edffd5055a9eaa5b54cae088db007cf2d28efaf9edd1569341889073e87c0a88462d77016744be62132fd14a243ed6e30e12cd2f7d08a8daeec161691f3b27d4996df8745d74402ee208e4055615a8cb069d495cf5146226490ac615d7b17ab39fb4fdd098e4e7ee294d34c1312826":PSA_SUCCESS
|
|
||||||
|
|
||||||
PSA AEAD Decrypt, AES GCM - 144-bytes input - 2
|
|
||||||
aead_decrypt:PSA_KEY_TYPE_AES:"fe96eab10ff48c7942025422583d0377":PSA_ALG_GCM:"12495120056ca3cac70d583603a476821bac6c57c9733b81cfb83538dc9e850f8bdf46065069591c23ebcbc6d1e2523375fb7efc80c09507fa25477ed07cee54fc4eb90168b3ef988f651fc40652474a644b1b311decf899660aef2347bb081af48950f06ebf799911e37120de94c55c20e5f0a77119be06e2b6e557f872fa0f6bac793bdc2190a195122c98544ccf56":"127628b6dcbce6fc8a8ef60798eb67b2088415635119697d20bb878c24d9c6f9c29e148521cb5e0feff892c7855d4f1c0bfb32ad33420976714dce87a0bbc18e4378bd1ef35197d0ca73051148f1199010f63caf122df5f71ad8d9c71df3eb2fbe3b2529d0ba657570358d3776f687bdb9c96d5e0e9e00c4b42d5d7a268d6a08":"97ce3f848276783599c6875de324361e":"194c8bbbfae4a671386b8cd38f390f46f9df6b8661b470c310921a1c858a938045834bb10380037fbf5f5e00688554537be0fcafe8270b9b59068fa056ab1268fc166c2d729243a06650a171c929c7845c85330c04568d62977eedf3b1ba9dca13bdb8f9522817c8cb99e635e37465ec1c9f6f148d51437aa9f994a62e1bd013":PSA_SUCCESS
|
|
||||||
|
|
||||||
PSA AEAD Decrypt, AES GCM - invalid signature
|
|
||||||
aead_decrypt:PSA_KEY_TYPE_AES:"fe96eab10ff48c7942025422583d0377":PSA_ALG_GCM:"12195120056ca3cac70d583603a476821bac6c57c9733b81cfb83538dc9e850f8bdf46065069591c23ebcbc6d1e2523375fb7efc80c09507fa25477ed07cee54fc4eb90168b3ef988f651fc40652474a644b1b311decf899660aef2347bb081af48950f06ebf799911e37120de94c55c20e5f0a77119be06e2b6e557f872fa0f6bac793bdc2190a195122c98544ccf56":"127628b6dcbce6fc8a8ef60798eb67b2088415635119697d20bb878c24d9c6f9c29e148521cb5e0feff892c7855d4f1c0bfb32ad33420976714dce87a0bbc18e4378bd1ef35197d0ca73051148f1199010f63caf122df5f71ad8d9c71df3eb2fbe3b2529d0ba657570358d3776f687bdb9c96d5e0e9e00c4b42d5d7a268d6a08":"97ce3f848276783599c6875de324361e":"194c8bbbfae4a671386b8cd38f390f46f9df6b8661b470c310921a1c858a938045834bb10380037fbf5f5e00688554537be0fcafe8270b9b59068fa056ab1268fc166c2d729243a06650a171c929c7845c85330c04568d62977eedf3b1ba9dca13bdb8f9522817c8cb99e635e37465ec1c9f6f148d51437aa9f994a62e1bd013":PSA_ERROR_INVALID_SIGNATURE
|
|
||||||
|
|
||||||
PSA AEAD Encrypt-Decrypt, Fail Scenario - Invalid algorithm
|
|
||||||
aead_encrypt_decrypt:PSA_KEY_TYPE_AES:"D7828D13B2B0BDC325A76236DF93CC6B":PSA_ALG_CTR:"B96B49E21D621741632875DB7F6C9243D2D7C2":"000102030405060708090A0B0C0D0E0F":"EC46BB63B02520C33C49FD70":PSA_ERROR_NOT_SUPPORTED
|
|
||||||
|
@ -829,6 +829,242 @@ exit:
|
|||||||
}
|
}
|
||||||
/* END_CASE */
|
/* END_CASE */
|
||||||
|
|
||||||
|
/* BEGIN_CASE */
|
||||||
|
void aead_encrypt_decrypt( int key_type_arg, char * key_hex,
|
||||||
|
int alg_arg, char * input_hex, char * nonce_hex,
|
||||||
|
char * add_data, int expected_result_arg )
|
||||||
|
{
|
||||||
|
int slot = 1;
|
||||||
|
psa_key_type_t key_type = key_type_arg;
|
||||||
|
psa_algorithm_t alg = alg_arg;
|
||||||
|
unsigned char *key_data = NULL;
|
||||||
|
size_t key_size;
|
||||||
|
unsigned char *input_data = NULL;
|
||||||
|
size_t input_size;
|
||||||
|
unsigned char *output_data = NULL;
|
||||||
|
size_t output_size = 0;
|
||||||
|
size_t output_length = 0;
|
||||||
|
unsigned char *output_data2 = NULL;
|
||||||
|
size_t output_length2 = 0;
|
||||||
|
uint8_t* nonce;
|
||||||
|
size_t nonce_length = 16;
|
||||||
|
size_t tag_length = 16;
|
||||||
|
unsigned char *additional_data = NULL;
|
||||||
|
size_t additional_data_length = 0;
|
||||||
|
psa_status_t expected_result = (psa_status_t) expected_result_arg;
|
||||||
|
psa_key_policy_t policy = {0};
|
||||||
|
|
||||||
|
|
||||||
|
key_data = unhexify_alloc( key_hex, &key_size );
|
||||||
|
TEST_ASSERT( key_data != NULL );
|
||||||
|
input_data = unhexify_alloc( input_hex, &input_size );
|
||||||
|
TEST_ASSERT( input_data != NULL );
|
||||||
|
additional_data = unhexify_alloc( add_data, &additional_data_length );
|
||||||
|
TEST_ASSERT( input_data != NULL );
|
||||||
|
output_size = input_size + tag_length;
|
||||||
|
output_data = mbedtls_calloc( 1, output_size );
|
||||||
|
TEST_ASSERT( output_data != NULL );
|
||||||
|
nonce = unhexify_alloc( nonce_hex, &nonce_length );
|
||||||
|
TEST_ASSERT( nonce != NULL );
|
||||||
|
|
||||||
|
TEST_ASSERT( psa_crypto_init( ) == PSA_SUCCESS );
|
||||||
|
|
||||||
|
psa_key_policy_init( &policy );
|
||||||
|
|
||||||
|
psa_key_policy_set_usage( &policy, PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT , alg );
|
||||||
|
|
||||||
|
TEST_ASSERT( psa_set_key_policy( slot, &policy ) == PSA_SUCCESS );
|
||||||
|
|
||||||
|
TEST_ASSERT( psa_import_key( slot, key_type,
|
||||||
|
key_data, key_size ) == PSA_SUCCESS );
|
||||||
|
|
||||||
|
TEST_ASSERT( psa_aead_encrypt( slot, alg,
|
||||||
|
nonce, nonce_length,
|
||||||
|
additional_data, additional_data_length,
|
||||||
|
input_data, input_size, output_data,
|
||||||
|
output_size, &output_length ) == expected_result );
|
||||||
|
|
||||||
|
if( PSA_SUCCESS == expected_result )
|
||||||
|
{
|
||||||
|
output_data2 = mbedtls_calloc( 1, output_length );
|
||||||
|
TEST_ASSERT( output_data2 != NULL );
|
||||||
|
|
||||||
|
TEST_ASSERT( psa_aead_decrypt( slot, alg,
|
||||||
|
nonce, nonce_length,
|
||||||
|
additional_data, additional_data_length,
|
||||||
|
output_data, output_length, output_data2,
|
||||||
|
output_length, &output_length2 ) == expected_result );
|
||||||
|
|
||||||
|
|
||||||
|
TEST_ASSERT( memcmp( input_data, output_data2,
|
||||||
|
input_size ) == 0 );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
exit:
|
||||||
|
psa_destroy_key( slot );
|
||||||
|
mbedtls_free( key_data );
|
||||||
|
mbedtls_free( input_data );
|
||||||
|
mbedtls_free( additional_data );
|
||||||
|
mbedtls_free( output_data );
|
||||||
|
mbedtls_free( output_data2 );
|
||||||
|
mbedtls_psa_crypto_free( );
|
||||||
|
}
|
||||||
|
/* END_CASE */
|
||||||
|
|
||||||
|
/* BEGIN_CASE */
|
||||||
|
void aead_encrypt( int key_type_arg, char * key_hex,
|
||||||
|
int alg_arg, char * input_hex,
|
||||||
|
char * add_data, char * nonce_hex,
|
||||||
|
char * expected_result_hex )
|
||||||
|
{
|
||||||
|
int slot = 1;
|
||||||
|
psa_key_type_t key_type = key_type_arg;
|
||||||
|
psa_algorithm_t alg = alg_arg;
|
||||||
|
unsigned char *key_data = NULL;
|
||||||
|
size_t key_size;
|
||||||
|
unsigned char *input_data = NULL;
|
||||||
|
size_t input_size;
|
||||||
|
unsigned char *output_data = NULL;
|
||||||
|
size_t output_size = 0;
|
||||||
|
size_t output_length = 0;
|
||||||
|
unsigned char *expected_result = NULL;
|
||||||
|
size_t expected_result_length = 0;
|
||||||
|
uint8_t* nonce = NULL;
|
||||||
|
size_t nonce_length = 0;
|
||||||
|
size_t tag_length = 16;
|
||||||
|
unsigned char *additional_data = NULL;
|
||||||
|
size_t additional_data_length = 0;
|
||||||
|
psa_key_policy_t policy = {0};
|
||||||
|
|
||||||
|
|
||||||
|
key_data = unhexify_alloc( key_hex, &key_size );
|
||||||
|
TEST_ASSERT( key_data != NULL );
|
||||||
|
input_data = unhexify_alloc( input_hex, &input_size );
|
||||||
|
TEST_ASSERT( input_data != NULL );
|
||||||
|
additional_data = unhexify_alloc( add_data, &additional_data_length );
|
||||||
|
TEST_ASSERT( input_data != NULL );
|
||||||
|
output_size = input_size + tag_length;
|
||||||
|
output_data = mbedtls_calloc( 1, output_size );
|
||||||
|
TEST_ASSERT( output_data != NULL );
|
||||||
|
nonce = unhexify_alloc( nonce_hex, &nonce_length );
|
||||||
|
TEST_ASSERT( nonce != NULL );
|
||||||
|
expected_result = unhexify_alloc( expected_result_hex, &expected_result_length );
|
||||||
|
TEST_ASSERT( expected_result != NULL );
|
||||||
|
|
||||||
|
TEST_ASSERT( psa_crypto_init( ) == PSA_SUCCESS );
|
||||||
|
|
||||||
|
psa_key_policy_init( &policy );
|
||||||
|
|
||||||
|
psa_key_policy_set_usage( &policy, PSA_KEY_USAGE_ENCRYPT , alg );
|
||||||
|
|
||||||
|
TEST_ASSERT( psa_set_key_policy( slot, &policy ) == PSA_SUCCESS );
|
||||||
|
|
||||||
|
TEST_ASSERT( psa_import_key( slot, key_type,
|
||||||
|
key_data, key_size ) == PSA_SUCCESS );
|
||||||
|
|
||||||
|
TEST_ASSERT( psa_aead_encrypt( slot, alg,
|
||||||
|
nonce, nonce_length,
|
||||||
|
additional_data, additional_data_length,
|
||||||
|
input_data, input_size, output_data,
|
||||||
|
output_size, &output_length ) == PSA_SUCCESS );
|
||||||
|
|
||||||
|
|
||||||
|
TEST_ASSERT( memcmp( output_data, expected_result,
|
||||||
|
output_length ) == 0 );
|
||||||
|
|
||||||
|
|
||||||
|
exit:
|
||||||
|
psa_destroy_key( slot );
|
||||||
|
mbedtls_free( key_data );
|
||||||
|
mbedtls_free( input_data );
|
||||||
|
mbedtls_free( additional_data );
|
||||||
|
mbedtls_free( output_data );
|
||||||
|
mbedtls_free( nonce );
|
||||||
|
mbedtls_free( expected_result );
|
||||||
|
mbedtls_psa_crypto_free( );
|
||||||
|
}
|
||||||
|
/* END_CASE */
|
||||||
|
|
||||||
|
/* BEGIN_CASE */
|
||||||
|
void aead_decrypt( int key_type_arg, char * key_hex,
|
||||||
|
int alg_arg, char * input_hex,
|
||||||
|
char * add_data, char * nonce_hex,
|
||||||
|
char * expected_result_hex, int expected_result_arg )
|
||||||
|
{
|
||||||
|
int slot = 1;
|
||||||
|
psa_key_type_t key_type = key_type_arg;
|
||||||
|
psa_algorithm_t alg = alg_arg;
|
||||||
|
unsigned char *key_data = NULL;
|
||||||
|
size_t key_size;
|
||||||
|
unsigned char *input_data = NULL;
|
||||||
|
size_t input_size;
|
||||||
|
unsigned char *output_data = NULL;
|
||||||
|
size_t output_size = 0;
|
||||||
|
size_t output_length = 0;
|
||||||
|
unsigned char *expected_data = NULL;
|
||||||
|
size_t expected_result_length = 0;
|
||||||
|
uint8_t* nonce = NULL;
|
||||||
|
size_t nonce_length = 0;
|
||||||
|
size_t tag_length = 16;
|
||||||
|
unsigned char *additional_data = NULL;
|
||||||
|
size_t additional_data_length = 0;
|
||||||
|
psa_key_policy_t policy = {0};
|
||||||
|
psa_status_t expected_result = (psa_status_t) expected_result_arg;
|
||||||
|
|
||||||
|
|
||||||
|
key_data = unhexify_alloc( key_hex, &key_size );
|
||||||
|
TEST_ASSERT( key_data != NULL );
|
||||||
|
input_data = unhexify_alloc( input_hex, &input_size );
|
||||||
|
TEST_ASSERT( input_data != NULL );
|
||||||
|
additional_data = unhexify_alloc( add_data, &additional_data_length );
|
||||||
|
TEST_ASSERT( input_data != NULL );
|
||||||
|
output_size = input_size + tag_length;
|
||||||
|
output_data = mbedtls_calloc( 1, output_size );
|
||||||
|
TEST_ASSERT( output_data != NULL );
|
||||||
|
nonce = unhexify_alloc( nonce_hex, &nonce_length );
|
||||||
|
TEST_ASSERT( nonce != NULL );
|
||||||
|
expected_data = unhexify_alloc( expected_result_hex, &expected_result_length );
|
||||||
|
TEST_ASSERT( expected_data != NULL );
|
||||||
|
|
||||||
|
TEST_ASSERT( psa_crypto_init( ) == PSA_SUCCESS );
|
||||||
|
|
||||||
|
psa_key_policy_init( &policy );
|
||||||
|
|
||||||
|
psa_key_policy_set_usage( &policy, PSA_KEY_USAGE_DECRYPT , alg );
|
||||||
|
|
||||||
|
TEST_ASSERT( psa_set_key_policy( slot, &policy ) == PSA_SUCCESS );
|
||||||
|
|
||||||
|
TEST_ASSERT( psa_import_key( slot, key_type,
|
||||||
|
key_data, key_size ) == PSA_SUCCESS );
|
||||||
|
|
||||||
|
TEST_ASSERT( psa_aead_decrypt( slot, alg,
|
||||||
|
nonce, nonce_length,
|
||||||
|
additional_data, additional_data_length,
|
||||||
|
input_data, input_size, output_data,
|
||||||
|
output_size, &output_length ) == expected_result );
|
||||||
|
|
||||||
|
|
||||||
|
if ( expected_result == PSA_SUCCESS )
|
||||||
|
{
|
||||||
|
TEST_ASSERT( memcmp( output_data, expected_data,
|
||||||
|
output_length ) == 0 );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
exit:
|
||||||
|
psa_destroy_key( slot );
|
||||||
|
mbedtls_free( key_data );
|
||||||
|
mbedtls_free( input_data );
|
||||||
|
mbedtls_free( additional_data );
|
||||||
|
mbedtls_free( output_data );
|
||||||
|
mbedtls_free( nonce );
|
||||||
|
mbedtls_free( expected_data );
|
||||||
|
mbedtls_psa_crypto_free( );
|
||||||
|
}
|
||||||
|
/* END_CASE */
|
||||||
|
|
||||||
/* BEGIN_CASE */
|
/* BEGIN_CASE */
|
||||||
void signature_size( int type_arg, int bits, int alg_arg, int expected_size_arg )
|
void signature_size( int type_arg, int bits, int alg_arg, int expected_size_arg )
|
||||||
{
|
{
|
||||||
@ -1142,239 +1378,3 @@ exit:
|
|||||||
mbedtls_psa_crypto_free( );
|
mbedtls_psa_crypto_free( );
|
||||||
}
|
}
|
||||||
/* END_CASE */
|
/* END_CASE */
|
||||||
|
|
||||||
/* BEGIN_CASE */
|
|
||||||
void aead_encrypt_decrypt( int key_type_arg, char * key_hex,
|
|
||||||
int alg_arg, char * input_hex, char * nonce_hex,
|
|
||||||
char * add_data, int expected_result_arg )
|
|
||||||
{
|
|
||||||
int slot = 1;
|
|
||||||
psa_key_type_t key_type = key_type_arg;
|
|
||||||
psa_algorithm_t alg = alg_arg;
|
|
||||||
unsigned char *key_data = NULL;
|
|
||||||
size_t key_size;
|
|
||||||
unsigned char *input_data = NULL;
|
|
||||||
size_t input_size;
|
|
||||||
unsigned char *output_data = NULL;
|
|
||||||
size_t output_size = 0;
|
|
||||||
size_t output_length = 0;
|
|
||||||
unsigned char *output_data2 = NULL;
|
|
||||||
size_t output_length2 = 0;
|
|
||||||
uint8_t* nonce;
|
|
||||||
size_t nonce_length = 16;
|
|
||||||
size_t tag_length = 16;
|
|
||||||
unsigned char *additional_data = NULL;
|
|
||||||
size_t additional_data_length = 0;
|
|
||||||
psa_status_t expected_result = (psa_status_t) expected_result_arg;
|
|
||||||
psa_key_policy_t policy = {0};
|
|
||||||
|
|
||||||
|
|
||||||
key_data = unhexify_alloc( key_hex, &key_size );
|
|
||||||
TEST_ASSERT( key_data != NULL );
|
|
||||||
input_data = unhexify_alloc( input_hex, &input_size );
|
|
||||||
TEST_ASSERT( input_data != NULL );
|
|
||||||
additional_data = unhexify_alloc( add_data, &additional_data_length );
|
|
||||||
TEST_ASSERT( input_data != NULL );
|
|
||||||
output_size = input_size + tag_length;
|
|
||||||
output_data = mbedtls_calloc( 1, output_size );
|
|
||||||
TEST_ASSERT( output_data != NULL );
|
|
||||||
nonce = unhexify_alloc( nonce_hex, &nonce_length );
|
|
||||||
TEST_ASSERT( nonce != NULL );
|
|
||||||
|
|
||||||
TEST_ASSERT( psa_crypto_init( ) == PSA_SUCCESS );
|
|
||||||
|
|
||||||
psa_key_policy_init( &policy );
|
|
||||||
|
|
||||||
psa_key_policy_set_usage( &policy, PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT , alg );
|
|
||||||
|
|
||||||
TEST_ASSERT( psa_set_key_policy( slot, &policy ) == PSA_SUCCESS );
|
|
||||||
|
|
||||||
TEST_ASSERT( psa_import_key( slot, key_type,
|
|
||||||
key_data, key_size ) == PSA_SUCCESS );
|
|
||||||
|
|
||||||
TEST_ASSERT( psa_aead_encrypt( slot, alg,
|
|
||||||
nonce, nonce_length,
|
|
||||||
additional_data, additional_data_length,
|
|
||||||
input_data, input_size, output_data,
|
|
||||||
output_size, &output_length ) == expected_result );
|
|
||||||
|
|
||||||
if( PSA_SUCCESS == expected_result )
|
|
||||||
{
|
|
||||||
output_data2 = mbedtls_calloc( 1, output_length );
|
|
||||||
TEST_ASSERT( output_data2 != NULL );
|
|
||||||
|
|
||||||
TEST_ASSERT( psa_aead_decrypt( slot, alg,
|
|
||||||
nonce, nonce_length,
|
|
||||||
additional_data, additional_data_length,
|
|
||||||
output_data, output_length, output_data2,
|
|
||||||
output_length, &output_length2 ) == expected_result );
|
|
||||||
|
|
||||||
|
|
||||||
TEST_ASSERT( memcmp( input_data, output_data2,
|
|
||||||
input_size ) == 0 );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
exit:
|
|
||||||
psa_destroy_key( slot );
|
|
||||||
mbedtls_free( key_data );
|
|
||||||
mbedtls_free( input_data );
|
|
||||||
mbedtls_free( additional_data );
|
|
||||||
mbedtls_free( output_data );
|
|
||||||
mbedtls_free( output_data2 );
|
|
||||||
mbedtls_psa_crypto_free( );
|
|
||||||
}
|
|
||||||
/* END_CASE */
|
|
||||||
|
|
||||||
/* BEGIN_CASE */
|
|
||||||
void aead_encrypt( int key_type_arg, char * key_hex,
|
|
||||||
int alg_arg, char * input_hex,
|
|
||||||
char * add_data, char * nonce_hex,
|
|
||||||
char * expected_result_hex )
|
|
||||||
{
|
|
||||||
int slot = 1;
|
|
||||||
psa_key_type_t key_type = key_type_arg;
|
|
||||||
psa_algorithm_t alg = alg_arg;
|
|
||||||
unsigned char *key_data = NULL;
|
|
||||||
size_t key_size;
|
|
||||||
unsigned char *input_data = NULL;
|
|
||||||
size_t input_size;
|
|
||||||
unsigned char *output_data = NULL;
|
|
||||||
size_t output_size = 0;
|
|
||||||
size_t output_length = 0;
|
|
||||||
unsigned char *expected_result = NULL;
|
|
||||||
size_t expected_result_length = 0;
|
|
||||||
uint8_t* nonce = NULL;
|
|
||||||
size_t nonce_length = 0;
|
|
||||||
size_t tag_length = 16;
|
|
||||||
unsigned char *additional_data = NULL;
|
|
||||||
size_t additional_data_length = 0;
|
|
||||||
psa_key_policy_t policy = {0};
|
|
||||||
|
|
||||||
|
|
||||||
key_data = unhexify_alloc( key_hex, &key_size );
|
|
||||||
TEST_ASSERT( key_data != NULL );
|
|
||||||
input_data = unhexify_alloc( input_hex, &input_size );
|
|
||||||
TEST_ASSERT( input_data != NULL );
|
|
||||||
additional_data = unhexify_alloc( add_data, &additional_data_length );
|
|
||||||
TEST_ASSERT( input_data != NULL );
|
|
||||||
output_size = input_size + tag_length;
|
|
||||||
output_data = mbedtls_calloc( 1, output_size );
|
|
||||||
TEST_ASSERT( output_data != NULL );
|
|
||||||
nonce = unhexify_alloc( nonce_hex, &nonce_length );
|
|
||||||
TEST_ASSERT( nonce != NULL );
|
|
||||||
expected_result = unhexify_alloc( expected_result_hex, &expected_result_length );
|
|
||||||
TEST_ASSERT( expected_result != NULL );
|
|
||||||
|
|
||||||
TEST_ASSERT( psa_crypto_init( ) == PSA_SUCCESS );
|
|
||||||
|
|
||||||
psa_key_policy_init( &policy );
|
|
||||||
|
|
||||||
psa_key_policy_set_usage( &policy, PSA_KEY_USAGE_ENCRYPT , alg );
|
|
||||||
|
|
||||||
TEST_ASSERT( psa_set_key_policy( slot, &policy ) == PSA_SUCCESS );
|
|
||||||
|
|
||||||
TEST_ASSERT( psa_import_key( slot, key_type,
|
|
||||||
key_data, key_size ) == PSA_SUCCESS );
|
|
||||||
|
|
||||||
TEST_ASSERT( psa_aead_encrypt( slot, alg,
|
|
||||||
nonce, nonce_length,
|
|
||||||
additional_data, additional_data_length,
|
|
||||||
input_data, input_size, output_data,
|
|
||||||
output_size, &output_length ) == PSA_SUCCESS );
|
|
||||||
|
|
||||||
|
|
||||||
TEST_ASSERT( memcmp( output_data, expected_result,
|
|
||||||
output_length ) == 0 );
|
|
||||||
|
|
||||||
|
|
||||||
exit:
|
|
||||||
psa_destroy_key( slot );
|
|
||||||
mbedtls_free( key_data );
|
|
||||||
mbedtls_free( input_data );
|
|
||||||
mbedtls_free( additional_data );
|
|
||||||
mbedtls_free( output_data );
|
|
||||||
mbedtls_free( nonce );
|
|
||||||
mbedtls_free( expected_result );
|
|
||||||
mbedtls_psa_crypto_free( );
|
|
||||||
}
|
|
||||||
/* END_CASE */
|
|
||||||
|
|
||||||
/* BEGIN_CASE */
|
|
||||||
void aead_decrypt( int key_type_arg, char * key_hex,
|
|
||||||
int alg_arg, char * input_hex,
|
|
||||||
char * add_data, char * nonce_hex,
|
|
||||||
char * expected_result_hex, int expected_result_arg )
|
|
||||||
{
|
|
||||||
int slot = 1;
|
|
||||||
psa_key_type_t key_type = key_type_arg;
|
|
||||||
psa_algorithm_t alg = alg_arg;
|
|
||||||
unsigned char *key_data = NULL;
|
|
||||||
size_t key_size;
|
|
||||||
unsigned char *input_data = NULL;
|
|
||||||
size_t input_size;
|
|
||||||
unsigned char *output_data = NULL;
|
|
||||||
size_t output_size = 0;
|
|
||||||
size_t output_length = 0;
|
|
||||||
unsigned char *expected_data = NULL;
|
|
||||||
size_t expected_result_length = 0;
|
|
||||||
uint8_t* nonce = NULL;
|
|
||||||
size_t nonce_length = 0;
|
|
||||||
size_t tag_length = 16;
|
|
||||||
unsigned char *additional_data = NULL;
|
|
||||||
size_t additional_data_length = 0;
|
|
||||||
psa_key_policy_t policy = {0};
|
|
||||||
psa_status_t expected_result = (psa_status_t) expected_result_arg;
|
|
||||||
|
|
||||||
|
|
||||||
key_data = unhexify_alloc( key_hex, &key_size );
|
|
||||||
TEST_ASSERT( key_data != NULL );
|
|
||||||
input_data = unhexify_alloc( input_hex, &input_size );
|
|
||||||
TEST_ASSERT( input_data != NULL );
|
|
||||||
additional_data = unhexify_alloc( add_data, &additional_data_length );
|
|
||||||
TEST_ASSERT( input_data != NULL );
|
|
||||||
output_size = input_size + tag_length;
|
|
||||||
output_data = mbedtls_calloc( 1, output_size );
|
|
||||||
TEST_ASSERT( output_data != NULL );
|
|
||||||
nonce = unhexify_alloc( nonce_hex, &nonce_length );
|
|
||||||
TEST_ASSERT( nonce != NULL );
|
|
||||||
expected_data = unhexify_alloc( expected_result_hex, &expected_result_length );
|
|
||||||
TEST_ASSERT( expected_data != NULL );
|
|
||||||
|
|
||||||
TEST_ASSERT( psa_crypto_init( ) == PSA_SUCCESS );
|
|
||||||
|
|
||||||
psa_key_policy_init( &policy );
|
|
||||||
|
|
||||||
psa_key_policy_set_usage( &policy, PSA_KEY_USAGE_DECRYPT , alg );
|
|
||||||
|
|
||||||
TEST_ASSERT( psa_set_key_policy( slot, &policy ) == PSA_SUCCESS );
|
|
||||||
|
|
||||||
TEST_ASSERT( psa_import_key( slot, key_type,
|
|
||||||
key_data, key_size ) == PSA_SUCCESS );
|
|
||||||
|
|
||||||
TEST_ASSERT( psa_aead_decrypt( slot, alg,
|
|
||||||
nonce, nonce_length,
|
|
||||||
additional_data, additional_data_length,
|
|
||||||
input_data, input_size, output_data,
|
|
||||||
output_size, &output_length ) == expected_result );
|
|
||||||
|
|
||||||
|
|
||||||
if ( expected_result == PSA_SUCCESS )
|
|
||||||
{
|
|
||||||
TEST_ASSERT( memcmp( output_data, expected_data,
|
|
||||||
output_length ) == 0 );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
exit:
|
|
||||||
psa_destroy_key( slot );
|
|
||||||
mbedtls_free( key_data );
|
|
||||||
mbedtls_free( input_data );
|
|
||||||
mbedtls_free( additional_data );
|
|
||||||
mbedtls_free( output_data );
|
|
||||||
mbedtls_free( nonce );
|
|
||||||
mbedtls_free( expected_data );
|
|
||||||
mbedtls_psa_crypto_free( );
|
|
||||||
}
|
|
||||||
/* END_CASE */
|
|
||||||
|
Loading…
Reference in New Issue
Block a user