Skip to content

Commit

Permalink
Update test vectors, remove stale test code
Browse files Browse the repository at this point in the history
We now use the KnownAnswerTest class to validate the test vectors stored in JSON files.
  • Loading branch information
paragonie-security committed Jul 29, 2021
1 parent 75c2424 commit 7e72e5f
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 1,130 deletions.
18 changes: 9 additions & 9 deletions docs/03-Implementation-Guide/Test-Vectors/v3.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"name": "3-E-1",
"key": "707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f",
"nonce": "0000000000000000000000000000000000000000000000000000000000000000",
"token": "v3.local.AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABLt5-kR6TZW6LYCBsWla5Tmn_7cLt0zT1OyRnIPjuAYLA0ZdlHrd_BiMIUzVbI7ma_lO6UNJWYiR2v0joy6WvesFN0kAhnZgpPRQVFEJTK2GSwDbWErD1NbI4MbWgC3djoYw4g0kXuZXY5qbkGWugNzOoTKAI",
"token": "v3.local.AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADbfcIURX_0pVZVU1mAESUzrKZAsRm2EsD6yBoZYn6cpVZNzSJOhSDN-sRaWjfLU-yn9OJH1J_B8GKtOQ9gSQlb8yk9IzbzzgMcrDxhuj1pG3ise-XA3D1jiGQlW0rCMMFoOXbejl9Hfbg4pIiGw7FZH-2nDPI",
"payload": {
"data": "this is a secret message",
"exp": "2022-01-01T00:00:00+00:00"
Expand All @@ -17,7 +17,7 @@
"name": "3-E-2",
"key": "707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f",
"nonce": "0000000000000000000000000000000000000000000000000000000000000000",
"token": "v3.local.AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABLt5-kR6TZW6LYCBsWla5Tmn_7a7dz2z1UyRnIPjuAYLA0ZdlHrd_BiMIUzVbI7ma_lO6UNJWYiR2v0joy6WvesFN0kAh_A0APZdJXUREr7ZyeXfxgyMiT_F08jZiPxbj2opNIw5u9rJO8Y9eOruTakJng3bc",
"token": "v3.local.AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADbfcIURX_0pVZVU1mAESUzrKZAqhWxBMDgyBoZYn6cpVZNzSJOhSDN-sRaWjfLU-yn9OJH1J_B8GKtOQ9gSQlb8yk9IzbUtxJRXsRcaF6JZZ4aMMSmenSnEEZaqHz4gCAGFu41847FQSRTkMClQxmZUYk51So",
"payload": {
"data": "this is a hidden message",
"exp": "2022-01-01T00:00:00+00:00"
Expand All @@ -29,7 +29,7 @@
"name": "3-E-3",
"nonce": "26f7553354482a1d91d4784627854b8da6b8042a7966523c2b404e8dbbe7f7f2",
"key": "707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f",
"token": "v3.local.JvdVM1RIKh2R1HhGJ4VLjaa4BCp5ZlI8K0BOjbvn9_Kageg3IiCFuPpx6-8kGD1SdE0doDkavZyIu4DeN1zq9HtEhw4IU0o_kdeWV-J_U7rJinQ5eCsyDoeGDlyRBoJ5cz3hNkvPoevaXFtzOv_tMxxYt_i7afc2avjyDp69TX3lchI-Ed6l7aLMgJvoSzxQZaJuM-E",
"token": "v3.local.JvdVM1RIKh2R1HhGJ4VLjaa4BCp5ZlI8K0BOjbvn9_LwY78vQnDait-Q-sjhF88dG2B0ROIIykcrGHn8wzPbTrqObHhyoKpjy3cwZQzLdiwRsdEK5SDvl02_HjWKJW2oqGMOQJlwsimt2qKsqDM3k0bW7MAZHZZ3DwyndDd_Fv5a3yrDP2nWbkkCm40ZiFbQ6pU3O44",
"payload": {
"data": "this is a secret message",
"exp": "2022-01-01T00:00:00+00:00"
Expand All @@ -41,7 +41,7 @@
"name": "3-E-4",
"nonce": "26f7553354482a1d91d4784627854b8da6b8042a7966523c2b404e8dbbe7f7f2",
"key": "707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f",
"token": "v3.local.JvdVM1RIKh2R1HhGJ4VLjaa4BCp5ZlI8K0BOjbvn9_Kageg3IiCFuPpx6-8kGD1SdE0duzUdq5ySu4DeN1zq9HtEhw4IU0o_kdeWV-J_U7rJinQ5eCsyDoeGDlyRBoJ5cz3hNksGsq5I4rtEgvE-WgP9V2p5j-Am6AzMTnYk--x0jGcBFkJWtSRbvh62QEWu1gYxw8E",
"token": "v3.local.JvdVM1RIKh2R1HhGJ4VLjaa4BCp5ZlI8K0BOjbvn9_LwY78vQnDait-Q-sjhF88dG2B0X-4P3EcxGHn8wzPbTrqObHhyoKpjy3cwZQzLdiwRsdEK5SDvl02_HjWKJW2oqGMOQJlGjHamYbS6Tp5YkB6EGH_dvzKzWOrxGVl0HD8Nh7DEC9XX0CXOrVm_eda1dWnxi8A",
"payload": {
"data": "this is a hidden message",
"exp": "2022-01-01T00:00:00+00:00"
Expand All @@ -53,7 +53,7 @@
"name": "3-E-5",
"nonce": "26f7553354482a1d91d4784627854b8da6b8042a7966523c2b404e8dbbe7f7f2",
"key": "707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f",
"token": "v3.local.JvdVM1RIKh2R1HhGJ4VLjaa4BCp5ZlI8K0BOjbvn9_Kageg3IiCFuPpx6-8kGD1SdE0doDkavZyIu4DeN1zq9HtEhw4IU0o_kdeWV-J_U7rJinQ5eCsyDoeGDlyRBoJ5cz3hNkuTL6D0bKlatkgbNuYdzL_Ngw8XG9-CfzVF18KL7WFTBaAXuBHJxAaz2ChQZEIOrwM.eyJraWQiOiJVYmtLOFk2aXY0R1poRnA2VHgzSVdMV0xmTlhTRXZKY2RUM3pkUjY1WVp4byJ9",
"token": "v3.local.JvdVM1RIKh2R1HhGJ4VLjaa4BCp5ZlI8K0BOjbvn9_LwY78vQnDait-Q-sjhF88dG2B0ROIIykcrGHn8wzPbTrqObHhyoKpjy3cwZQzLdiwRsdEK5SDvl02_HjWKJW2oqGMOQJmfSWLQOS8wfy8kO9cjM0RiGh3X4VNev7uiMo9elqV2cKTNcG2-9AVqEcx5lTJqSBM.eyJraWQiOiJVYmtLOFk2aXY0R1poRnA2VHgzSVdMV0xmTlhTRXZKY2RUM3pkUjY1WVp4byJ9",
"payload": {
"data": "this is a secret message",
"exp": "2022-01-01T00:00:00+00:00"
Expand All @@ -65,7 +65,7 @@
"name": "3-E-6",
"nonce": "26f7553354482a1d91d4784627854b8da6b8042a7966523c2b404e8dbbe7f7f2",
"key": "707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f",
"token": "v3.local.JvdVM1RIKh2R1HhGJ4VLjaa4BCp5ZlI8K0BOjbvn9_Kageg3IiCFuPpx6-8kGD1SdE0duzUdq5ySu4DeN1zq9HtEhw4IU0o_kdeWV-J_U7rJinQ5eCsyDoeGDlyRBoJ5cz3hNkvNhmzXOmA4g5FcC1fmqpw5-BrmNDSscZLd-VZEsfofAzzYBltIapOPuOAGDI0sJ8I.eyJraWQiOiJVYmtLOFk2aXY0R1poRnA2VHgzSVdMV0xmTlhTRXZKY2RUM3pkUjY1WVp4byJ9",
"token": "v3.local.JvdVM1RIKh2R1HhGJ4VLjaa4BCp5ZlI8K0BOjbvn9_LwY78vQnDait-Q-sjhF88dG2B0X-4P3EcxGHn8wzPbTrqObHhyoKpjy3cwZQzLdiwRsdEK5SDvl02_HjWKJW2oqGMOQJkGF0zrfdykirmpjpVcgpIWntFSESlQZR7aoYlg_vREEepxOmacdxRvAjLbVshFeUs.eyJraWQiOiJVYmtLOFk2aXY0R1poRnA2VHgzSVdMV0xmTlhTRXZKY2RUM3pkUjY1WVp4byJ9",
"payload": {
"data": "this is a hidden message",
"exp": "2022-01-01T00:00:00+00:00"
Expand All @@ -77,7 +77,7 @@
"name": "3-E-7",
"nonce": "26f7553354482a1d91d4784627854b8da6b8042a7966523c2b404e8dbbe7f7f2",
"key": "707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f",
"token": "v3.local.JvdVM1RIKh2R1HhGJ4VLjaa4BCp5ZlI8K0BOjbvn9_Kageg3IiCFuPpx6-8kGD1SdE0doDkavZyIu4DeN1zq9HtEhw4IU0o_kdeWV-J_U7rJinQ5eCsyDoeGDlyRBoJ5cz3hNktkR5lvQgZEoo5SUPbSk-dEpEa9GVDgm05bdwI-TLWIIpFKal0igpgJwWNlpkKwo2M.eyJraWQiOiJVYmtLOFk2aXY0R1poRnA2VHgzSVdMV0xmTlhTRXZKY2RUM3pkUjY1WVp4byJ9",
"token": "v3.local.JvdVM1RIKh2R1HhGJ4VLjaa4BCp5ZlI8K0BOjbvn9_LwY78vQnDait-Q-sjhF88dG2B0ROIIykcrGHn8wzPbTrqObHhyoKpjy3cwZQzLdiwRsdEK5SDvl02_HjWKJW2oqGMOQJkvnotYbXpUICkKfoMEK5kCeXcbFcSJCjbQEvYDNX2IS7EQDHiHb7RqpfcjgqYnPVw.eyJraWQiOiJVYmtLOFk2aXY0R1poRnA2VHgzSVdMV0xmTlhTRXZKY2RUM3pkUjY1WVp4byJ9",
"payload": {
"data": "this is a secret message",
"exp": "2022-01-01T00:00:00+00:00"
Expand All @@ -89,7 +89,7 @@
"name": "3-E-8",
"nonce": "26f7553354482a1d91d4784627854b8da6b8042a7966523c2b404e8dbbe7f7f2",
"key": "707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f",
"token": "v3.local.JvdVM1RIKh2R1HhGJ4VLjaa4BCp5ZlI8K0BOjbvn9_Kageg3IiCFuPpx6-8kGD1SdE0duzUdq5ySu4DeN1zq9HtEhw4IU0o_kdeWV-J_U7rJinQ5eCsyDoeGDlyRBoJ5cz3hNksGPtABBONQk8vDq4rCGeXENQ0Tx26j0ymtaZbFGK7upNRyqfEwKKsAt73vAEEZCm8.eyJraWQiOiJVYmtLOFk2aXY0R1poRnA2VHgzSVdMV0xmTlhTRXZKY2RUM3pkUjY1WVp4byJ9",
"token": "v3.local.JvdVM1RIKh2R1HhGJ4VLjaa4BCp5ZlI8K0BOjbvn9_LwY78vQnDait-Q-sjhF88dG2B0X-4P3EcxGHn8wzPbTrqObHhyoKpjy3cwZQzLdiwRsdEK5SDvl02_HjWKJW2oqGMOQJn5IfmIsSxeSCBBl_tklEcYw6Cr8ErCUexR-258f3tTWieacJeUhCEz23DX75j2ia0.eyJraWQiOiJVYmtLOFk2aXY0R1poRnA2VHgzSVdMV0xmTlhTRXZKY2RUM3pkUjY1WVp4byJ9",
"payload": {
"data": "this is a hidden message",
"exp": "2022-01-01T00:00:00+00:00"
Expand All @@ -101,7 +101,7 @@
"name": "3-E-9",
"nonce": "26f7553354482a1d91d4784627854b8da6b8042a7966523c2b404e8dbbe7f7f2",
"key": "707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f",
"token": "v3.local.JvdVM1RIKh2R1HhGJ4VLjaa4BCp5ZlI8K0BOjbvn9_Kageg3IiCFuPpx6-8kGD1SdE0duzUdq5ySu4DeN1zq9HtEhw4IU0o_kdeWV-J_U7rJinQ5eCsyDoeGDlyRBoJ5cz3hNks-m5Cvwe_NjI-lXaQLJWj0p1ck66xYdF_hTFR_1NIG2rht6CwM047F5qQueJikyvU.YXJiaXRyYXJ5LXN0cmluZy10aGF0LWlzbid0LWpzb24",
"token": "v3.local.JvdVM1RIKh2R1HhGJ4VLjaa4BCp5ZlI8K0BOjbvn9_LwY78vQnDait-Q-sjhF88dG2B0X-4P3EcxGHn8wzPbTrqObHhyoKpjy3cwZQzLdiwRsdEK5SDvl02_HjWKJW2oqGMOQJknAux2nLsAtei06Hmo1VF8MV_QZ1DW2EQE2v8XeAOlaV6zoldDbymzXJHVXMyqkPg.YXJiaXRyYXJ5LXN0cmluZy10aGF0LWlzbid0LWpzb24",
"payload": {
"data": "this is a hidden message",
"exp": "2022-01-01T00:00:00+00:00"
Expand Down
6 changes: 2 additions & 4 deletions src/Keys/SymmetricKey.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,17 +180,15 @@ public function splitV3(string $salt = null): array
'sha384',
$this->key,
48,
self::INFO_ENCRYPTION,
$salt
self::INFO_ENCRYPTION . ($salt ?? '')
);
$encKey = Binary::safeSubstr($tmp, 0, 32);
$nonce = Binary::safeSubstr($tmp, 32, 16);
$authKey = Util::HKDF(
'sha384',
$this->key,
32,
self::INFO_AUTHENTICATION,
$salt
self::INFO_AUTHENTICATION . ($salt ?? '')
);
return [$encKey, $authKey, $nonce];
}
Expand Down
206 changes: 0 additions & 206 deletions tests/Version1VectorTest.php

This file was deleted.

Loading

0 comments on commit 7e72e5f

Please sign in to comment.