Skip to content

Commit

Permalink
Reorder and add some cosmetic changes (#35)
Browse files Browse the repository at this point in the history
* Reorder encoding tests
* Add separate decoding vectors
* Remove invalid nonce test
  • Loading branch information
tuupola authored Jan 18, 2021
1 parent f759808 commit 527997e
Showing 1 changed file with 129 additions and 57 deletions.
186 changes: 129 additions & 57 deletions test_vectors.json
Original file line number Diff line number Diff line change
@@ -1,108 +1,178 @@
{
"version": "0.1",
"numberOfTests": 18,
"version": "0.2.0",
"numberOfTests": 25,
"testGroups": [
{
"testType": "encoding",
"tests": [
{
"id": 0,
"comment": "Non-utf8 is correct.",
"comment": "Hello world with zero timestamp",
"key": "supersecretkeyyoushouldnotcommit",
"nonce": "beefbeefbeefbeefbeefbeefbeefbeefbeefbeefbeefbeef",
"timestamp": 123206400,
"token": "K9u6d0zjXp8RXNUGDyXAsB9AtPo60CD3xxQ2ulL8aQoTzXbvockRff0y1eXoHm",
"msg": "80",
"timestamp": 0,
"token": "870S4BYxgHw0KnP3W9fgVUHEhT5g86vJ17etaC5Kh5uIraWHCI1psNQGv298ZmjPwoYbjDQ9chy2z",
"msg": "48656c6c6f20776f726c6421",
"isValid": true
},
{
"id": 1,
"comment": "Empty input message is correct.",
"comment": "Hello world with max timestamp",
"key": "supersecretkeyyoushouldnotcommit",
"nonce": "beefbeefbeefbeefbeefbeefbeefbeefbeefbeefbeefbeef",
"timestamp": 0,
"token": "4sfD0vPFhIif8cy4nB3BQkHeJqkOkDvinI4zIhMjYX4YXZU5WIq9ycCVjGzB5",
"msg": "",
"timestamp": 4294967295,
"token": "89i7YCwu5tWAJNHUDdmIqhzOi5hVHOd4afjZcGMcVmM4enl4yeLiDyYv41eMkNmTX6IwYEFErCSqr",
"msg": "48656c6c6f20776f726c6421",
"isValid": true
},
{
"id": 2,
"comment": "Invalid nonce (NOTE: token is invalid as well).",
"comment": "Hello world with November 27 timestamp",
"key": "supersecretkeyyoushouldnotcommit",
"nonce": "dead",
"timestamp": 0,
"token": "870S4BYkkjLle9LOsVbkF2iLHt55PcPSXBDnBTVyXdIZ8OHTMtya7FA29IITW1bYphyllRWGmsGIg",
"nonce": "beefbeefbeefbeefbeefbeefbeefbeefbeefbeefbeefbeef",
"timestamp": 123206400,
"token": "875GH23U0Dr6nHFA63DhOyd9LkYudBkX8RsCTOMz5xoYAMw9sMd5QwcEqLDRnTDHPenOX7nP2trlT",
"msg": "48656c6c6f20776f726c6421",
"isValid": false
"isValid": true
},
{
"id": 3,
"comment": "Zero timestamp.",
"comment": "Eight null bytes with zero timestamp",
"key": "supersecretkeyyoushouldnotcommit",
"nonce": "beefbeefbeefbeefbeefbeefbeefbeefbeefbeefbeefbeef",
"timestamp": 0,
"token": "870S4BYxgHw0KnP3W9fgVUHEhT5g86vJ17etaC5Kh5uIraWHCI1psNQGv298ZmjPwoYbjDQ9chy2z",
"msg": "48656c6c6f20776f726c6421",
"token": "1jIBheHbDdkCDFQmtgw4RUZeQoOJgGwTFJSpwOAk3XYpJJr52DEpILLmmwYl4tjdSbbNqcF1",
"msg": "0000000000000000",
"isValid": true
},
{
"id": 4,
"comment": "Max timestamp.",
"comment": "Eight null bytes with max timestamp",
"key": "supersecretkeyyoushouldnotcommit",
"nonce": "beefbeefbeefbeefbeefbeefbeefbeefbeefbeefbeefbeef",
"timestamp": 4294967295,
"token": "89i7YCwu5tWAJNHUDdmIqhzOi5hVHOd4afjZcGMcVmM4enl4yeLiDyYv41eMkNmTX6IwYEFErCSqr",
"msg": "48656c6c6f20776f726c6421",
"token": "1jrx6DUu5q06oxykef2e2ZMyTcDRTQot9ZnwgifUtzAphGtjsxfbxXNhQyBEOGtpbkBgvIQx",
"msg": "0000000000000000",
"isValid": true
},
{
"id": 5,
"comment": "November 27th timestamp.",
"comment": "Eight null bytes with November 27th timestamp",
"key": "supersecretkeyyoushouldnotcommit",
"nonce": "beefbeefbeefbeefbeefbeefbeefbeefbeefbeefbeefbeef",
"timestamp": 123206400,
"token": "875GH23U0Dr6nHFA63DhOyd9LkYudBkX8RsCTOMz5xoYAMw9sMd5QwcEqLDRnTDHPenOX7nP2trlT",
"msg": "48656c6c6f20776f726c6421",
"token": "1jJDJOEjuwVb9Csz1Ypw1KBWSkr0YDpeBeJN6NzJWx1VgPLmcBhu2SbkpQ9JjZ3nfUf7Aytp",
"msg": "0000000000000000",
"isValid": true
},
{
"id": 6,
"comment": "Eight null bytes with zero timestamp.",
"comment": "Empty payload",
"key": "supersecretkeyyoushouldnotcommit",
"nonce": "beefbeefbeefbeefbeefbeefbeefbeefbeefbeefbeefbeef",
"timestamp": 0,
"token": "1jIBheHbDdkCDFQmtgw4RUZeQoOJgGwTFJSpwOAk3XYpJJr52DEpILLmmwYl4tjdSbbNqcF1",
"msg": "0000000000000000",
"token": "4sfD0vPFhIif8cy4nB3BQkHeJqkOkDvinI4zIhMjYX4YXZU5WIq9ycCVjGzB5",
"msg": "",
"isValid": true
},
{
"id": 7,
"comment": "Eight null bytes with max timestamp.",
"comment": "Non-UTF8 payload",
"key": "supersecretkeyyoushouldnotcommit",
"nonce": "beefbeefbeefbeefbeefbeefbeefbeefbeefbeefbeefbeef",
"timestamp": 123206400,
"token": "K9u6d0zjXp8RXNUGDyXAsB9AtPo60CD3xxQ2ulL8aQoTzXbvockRff0y1eXoHm",
"msg": "80",
"isValid": true
}
]
},
{
"testType": "decoding",
"tests": [
{
"id": 8,
"comment": "Hello world with zero timestamp",
"key": "supersecretkeyyoushouldnotcommit",
"nonce": null,
"timestamp": 0,
"token": "870S4BYxgHw0KnP3W9fgVUHEhT5g86vJ17etaC5Kh5uIraWHCI1psNQGv298ZmjPwoYbjDQ9chy2z",
"msg": "48656c6c6f20776f726c6421",
"isValid": true
},
{
"id": 9,
"comment": "Hello world with max timestamp",
"key": "supersecretkeyyoushouldnotcommit",
"nonce": null,
"timestamp": 4294967295,
"token": "89i7YCwu5tWAJNHUDdmIqhzOi5hVHOd4afjZcGMcVmM4enl4yeLiDyYv41eMkNmTX6IwYEFErCSqr",
"msg": "48656c6c6f20776f726c6421",
"isValid": true
},
{
"id": 10,
"comment": "Hello world with November 27 timestamp",
"key": "supersecretkeyyoushouldnotcommit",
"nonce": null,
"timestamp": 123206400,
"token": "875GH23U0Dr6nHFA63DhOyd9LkYudBkX8RsCTOMz5xoYAMw9sMd5QwcEqLDRnTDHPenOX7nP2trlT",
"msg": "48656c6c6f20776f726c6421",
"isValid": true
},
{
"id": 11,
"comment": "Eight null bytes with zero timestamp",
"key": "supersecretkeyyoushouldnotcommit",
"nonce": null,
"timestamp": 0,
"token": "1jIBheHbDdkCDFQmtgw4RUZeQoOJgGwTFJSpwOAk3XYpJJr52DEpILLmmwYl4tjdSbbNqcF1",
"msg": "0000000000000000",
"isValid": true
},
{
"id": 12,
"comment": "Eight null bytes with max timestamp",
"key": "supersecretkeyyoushouldnotcommit",
"nonce": null,
"timestamp": 4294967295,
"token": "1jrx6DUu5q06oxykef2e2ZMyTcDRTQot9ZnwgifUtzAphGtjsxfbxXNhQyBEOGtpbkBgvIQx",
"msg": "0000000000000000",
"isValid": true
},
{
"id": 8,
"comment": "Eight null bytes with november 27th timestamp.",
"id": 13,
"comment": "Eight null bytes with November 27th timestamp",
"key": "supersecretkeyyoushouldnotcommit",
"nonce": "beefbeefbeefbeefbeefbeefbeefbeefbeefbeefbeefbeef",
"nonce": null,
"timestamp": 123206400,
"token": "1jJDJOEjuwVb9Csz1Ypw1KBWSkr0YDpeBeJN6NzJWx1VgPLmcBhu2SbkpQ9JjZ3nfUf7Aytp",
"msg": "0000000000000000",
"isValid": true
}
]
},
{
"testType": "decoding",
"tests": [
},
{
"id": 9,
"comment": "Wrong version - this token was created with version 0xBB.",
"id": 14,
"comment": "Empty payload",
"key": "supersecretkeyyoushouldnotcommit",
"nonce": null,
"timestamp": 0,
"token": "4sfD0vPFhIif8cy4nB3BQkHeJqkOkDvinI4zIhMjYX4YXZU5WIq9ycCVjGzB5",
"msg": "",
"isValid": true
},
{
"id": 15,
"comment": "Non-UTF8 payload",
"key": "supersecretkeyyoushouldnotcommit",
"nonce": null,
"timestamp": 123206400,
"token": "K9u6d0zjXp8RXNUGDyXAsB9AtPo60CD3xxQ2ulL8aQoTzXbvockRff0y1eXoHm",
"msg": "80",
"isValid": true
},
{
"id": 16,
"comment": "Wrong version 0xBB",
"key": "supersecretkeyyoushouldnotcommit",
"nonce": null,
"timestamp": 0,
Expand All @@ -111,8 +181,8 @@
"isValid": false
},
{
"id": 10,
"comment": "Invalid base62.",
"id": 17,
"comment": "Invalid base62 characters",
"key": "supersecretkeyyoushouldnotcommit",
"nonce": null,
"timestamp": 123206400,
Expand All @@ -121,38 +191,40 @@
"isValid": false
},
{
"id": 11,
"comment": "Modified version after token creation.",
"id": 18,
"comment": "Modified version",
"key": "supersecretkeyyoushouldnotcommit",
"nonce": null,
"timestamp": 0,
"token": "89i7YCx9usiQoaTtdaibIQ7goaYbRkXRDRAoEcg3g99OwFaKlb1kyo25vCzJZEzmT7tzFTqYV9xhM",
"token": "89mvl3S0BE0UCMIY94xxIux4eg1w5oXrhvCEXrDAjusSbO0Yk7AU6FjjTnbTWTqogLfNPJLzecHVb",
"msg": "48656c6c6f20776f726c6421",
"isValid": false
},
{
"id": 12,
"comment": "Modified first byte of the nonce.",
"id": 19,
"comment": "Modified first byte of the nonce",
"key": "supersecretkeyyoushouldnotcommit",
"nonce": null,
"timestamp": 0,
"token": "875GH233SUysT7fQ711EWd9BXpwOjB72ng3ZLnjWFrmOqVy49Bv93b78JU5331LbcY0EEzhLfpmSx",
"msg": "48656c6c6f20776f726c6421",
"isValid": false
},

{
"id": 13,
"comment": "Modified first byte of the timestamp.",
"id": 20,
"comment": "Modified timestamp",
"key": "supersecretkeyyoushouldnotcommit",
"nonce": null,
"timestamp": 0,
"token": "870g1RCk4lW1YInhaU3TP8u2hGtfol16ettLcTOSoA0JIpjCaQRW7tQeP6dQmTvFIB2s6wL5deMXr",
"msg": "48656c6c6f20776f726c6421",
"isValid": false
},

{
"id": 14,
"comment": "Modified last byte of the ciphertext.",
"id": 21,
"comment": "Modified last byte of the ciphertext",
"key": "supersecretkeyyoushouldnotcommit",
"nonce": null,
"timestamp": 0,
Expand All @@ -161,8 +233,8 @@
"isValid": false
},
{
"id": 15,
"comment": "Modified last byte of the Poly1305 tag.",
"id": 22,
"comment": "Modified last byte of the Poly1305 tag",
"key": "supersecretkeyyoushouldnotcommit",
"nonce": null,
"timestamp": 0,
Expand All @@ -171,8 +243,8 @@
"isValid": false
},
{
"id": 16,
"comment": "Wrong key - different key was used to create token.",
"id": 23,
"comment": "Wrong key",
"key": "wrongsecretkeyyoushouldnotcommit",
"nonce": null,
"timestamp": 0,
Expand All @@ -181,8 +253,8 @@
"isValid": false
},
{
"id": 17,
"comment": "Invalid key - one bytes less than required.",
"id": 24,
"comment": "Invalid key",
"key": "tooshortkey",
"nonce": null,
"timestamp": 0,
Expand All @@ -191,6 +263,6 @@
"isValid": false
}
]
}
}
]
}

0 comments on commit 527997e

Please sign in to comment.