diff --git a/reference-implementation/examples/test_vectors.rs b/reference-implementation/examples/test_vectors.rs index 7f1de99..93bb427 100644 --- a/reference-implementation/examples/test_vectors.rs +++ b/reference-implementation/examples/test_vectors.rs @@ -52,7 +52,7 @@ mod header { "~~~ kid: 0x{kid:016x} ctr: 0x{ctr:016x} -header: {encoded} +header: {encoded:8} ~~~" ) } @@ -187,13 +187,13 @@ mod aes_ctr_hmac { format!( "~~~ cipher_suite: 0x{cipher_suite:04x} -key: {key} -enc_key: {enc_key} -auth_key: {auth_key} -nonce: {nonce} -aad: {aad} -pt: {pt} -ct: {ct} +key: {key:5} +enc_key: {enc_key:9} +auth_key: {auth_key:10} +nonce: {nonce:7} +aad: {aad:5} +pt: {pt:4} +ct: {ct:4} ~~~" ) } @@ -306,41 +306,49 @@ mod sframe { cipher_suite: 0x{cipher_suite:04x} kid: 0x{kid:016x} ctr: 0x{ctr:016x} -base_key: {base_key} -sframe_key_label: {sframe_key_label} -sframe_salt_label: {sframe_salt_label} -sframe_secret: {sframe_secret} -sframe_key: {sframe_key} -sframe_salt: {sframe_salt} -metadata: {metadata} -nonce: {nonce} -aad: {aad} -pt: {pt} -ct: {ct} +base_key: {base_key:10} +sframe_key_label: {sframe_key_label:18} +sframe_salt_label: {sframe_salt_label:19} +sframe_secret: {sframe_secret:15} +sframe_key: {sframe_key:12} +sframe_salt: {sframe_salt:13} +metadata: {metadata:10} +nonce: {nonce:7} +aad: {aad:5} +pt: {pt:4} +ct: {ct:4} ~~~" ) } } } -use std::fmt::Display; - use clap::{Parser, Subcommand, ValueEnum}; use serde::{Deserialize, Serialize}; +use std::fmt::Display; +/// Type Hex encapsulates a byte string that will serialize as a single hex string in JSON, or as a +/// chunked, line-wrapped, and padded hex string in Markdown. struct Hex(Vec); impl Display for Hex { + // Divide the hex string into 16-byte chunks, each on its own line, and aligned to make space + // for a field name. We abuse the "width" formatting parameter to specify how much each line + // after the first should be indented. fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - for (i, c) in self.0.chunks(8).enumerate() { - if i % 3 == 0 { - if i > 0 { - f.write_str("\n ")?; - } - } else { - f.write_str(" ")?; + const SIZE: usize = 16; + + let n_chunks = (self.0.len() + (SIZE - 1)) / SIZE; + for (i, c) in self.0.chunks(SIZE).enumerate() { + if i > 0 { + f.pad("")?; } + f.write_str(&hex::encode(c))?; + + if i < n_chunks - 1 { + f.write_str("\n")?; + } } Ok(()) } diff --git a/test-vectors/aes-ctr-hmac.md b/test-vectors/aes-ctr-hmac.md index ed6a62f..b6af997 100644 --- a/test-vectors/aes-ctr-hmac.md +++ b/test-vectors/aes-ctr-hmac.md @@ -1,42 +1,48 @@ ~~~ cipher_suite: 0x0001 -key: 0001020304050607 08090a0b0c0d0e0f 1011121314151617 - 18191a1b1c1d1e1f 2021222324252627 28292a2b2c2d2e2f -enc_key: 0001020304050607 08090a0b0c0d0e0f -auth_key: 1011121314151617 18191a1b1c1d1e1f 2021222324252627 - 28292a2b2c2d2e2f -nonce: 1011121314151617 18191a1b -aad: 4945544620534672 616d65205747 -pt: 64726166742d6965 74662d736672616d 652d656e63 -ct: 6339af04ada1d064 688a442b8dc69d5b 6bfa40f4bef0583e - 8081069cc60705 +key: 000102030405060708090a0b0c0d0e0f + 101112131415161718191a1b1c1d1e1f + 202122232425262728292a2b2c2d2e2f +enc_key: 000102030405060708090a0b0c0d0e0f +auth_key: 101112131415161718191a1b1c1d1e1f + 202122232425262728292a2b2c2d2e2f +nonce: 101112131415161718191a1b +aad: 4945544620534672616d65205747 +pt: 64726166742d696574662d736672616d + 652d656e63 +ct: 6339af04ada1d064688a442b8dc69d5b + 6bfa40f4bef0583e8081069cc60705 ~~~ ~~~ cipher_suite: 0x0002 -key: 0001020304050607 08090a0b0c0d0e0f 1011121314151617 - 18191a1b1c1d1e1f 2021222324252627 28292a2b2c2d2e2f -enc_key: 0001020304050607 08090a0b0c0d0e0f -auth_key: 1011121314151617 18191a1b1c1d1e1f 2021222324252627 - 28292a2b2c2d2e2f -nonce: 1011121314151617 18191a1b -aad: 4945544620534672 616d65205747 -pt: 64726166742d6965 74662d736672616d 652d656e63 -ct: 6339af04ada1d064 688a442b8dc69d5b 6bfa40f4be6e93b7 - da076927bb +key: 000102030405060708090a0b0c0d0e0f + 101112131415161718191a1b1c1d1e1f + 202122232425262728292a2b2c2d2e2f +enc_key: 000102030405060708090a0b0c0d0e0f +auth_key: 101112131415161718191a1b1c1d1e1f + 202122232425262728292a2b2c2d2e2f +nonce: 101112131415161718191a1b +aad: 4945544620534672616d65205747 +pt: 64726166742d696574662d736672616d + 652d656e63 +ct: 6339af04ada1d064688a442b8dc69d5b + 6bfa40f4be6e93b7da076927bb ~~~ ~~~ cipher_suite: 0x0003 -key: 0001020304050607 08090a0b0c0d0e0f 1011121314151617 - 18191a1b1c1d1e1f 2021222324252627 28292a2b2c2d2e2f -enc_key: 0001020304050607 08090a0b0c0d0e0f -auth_key: 1011121314151617 18191a1b1c1d1e1f 2021222324252627 - 28292a2b2c2d2e2f -nonce: 1011121314151617 18191a1b -aad: 4945544620534672 616d65205747 -pt: 64726166742d6965 74662d736672616d 652d656e63 -ct: 6339af04ada1d064 688a442b8dc69d5b 6bfa40f4be094805 - 09 +key: 000102030405060708090a0b0c0d0e0f + 101112131415161718191a1b1c1d1e1f + 202122232425262728292a2b2c2d2e2f +enc_key: 000102030405060708090a0b0c0d0e0f +auth_key: 101112131415161718191a1b1c1d1e1f + 202122232425262728292a2b2c2d2e2f +nonce: 101112131415161718191a1b +aad: 4945544620534672616d65205747 +pt: 64726166742d696574662d736672616d + 652d656e63 +ct: 6339af04ada1d064688a442b8dc69d5b + 6bfa40f4be09480509 ~~~ diff --git a/test-vectors/header.md b/test-vectors/header.md index 81fccef..c15c280 100644 --- a/test-vectors/header.md +++ b/test-vectors/header.md @@ -91,13 +91,13 @@ header: 0effffffffffffff ~~~ kid: 0x0000000000000000 ctr: 0x0100000000000000 -header: 0f01000000000000 00 +header: 0f0100000000000000 ~~~ ~~~ kid: 0x0000000000000000 ctr: 0xffffffffffffffff -header: 0fffffffffffffff ff +header: 0fffffffffffffffff ~~~ ~~~ @@ -193,13 +193,13 @@ header: 1effffffffffffff ~~~ kid: 0x0000000000000001 ctr: 0x0100000000000000 -header: 1f01000000000000 00 +header: 1f0100000000000000 ~~~ ~~~ kid: 0x0000000000000001 ctr: 0xffffffffffffffff -header: 1fffffffffffffff ff +header: 1fffffffffffffffff ~~~ ~~~ @@ -283,25 +283,25 @@ header: 8dffffffffffffff ~~~ kid: 0x00000000000000ff ctr: 0x0001000000000000 -header: 8eff010000000000 00 +header: 8eff01000000000000 ~~~ ~~~ kid: 0x00000000000000ff ctr: 0x00ffffffffffffff -header: 8effffffffffffff ff +header: 8effffffffffffffff ~~~ ~~~ kid: 0x00000000000000ff ctr: 0x0100000000000000 -header: 8fff010000000000 0000 +header: 8fff0100000000000000 ~~~ ~~~ kid: 0x00000000000000ff ctr: 0xffffffffffffffff -header: 8fffffffffffffff ffff +header: 8fffffffffffffffffff ~~~ ~~~ @@ -373,37 +373,37 @@ header: 9c0100ffffffffff ~~~ kid: 0x0000000000000100 ctr: 0x0000010000000000 -header: 9d01000100000000 00 +header: 9d0100010000000000 ~~~ ~~~ kid: 0x0000000000000100 ctr: 0x0000ffffffffffff -header: 9d0100ffffffffff ff +header: 9d0100ffffffffffff ~~~ ~~~ kid: 0x0000000000000100 ctr: 0x0001000000000000 -header: 9e01000100000000 0000 +header: 9e010001000000000000 ~~~ ~~~ kid: 0x0000000000000100 ctr: 0x00ffffffffffffff -header: 9e0100ffffffffff ffff +header: 9e0100ffffffffffffff ~~~ ~~~ kid: 0x0000000000000100 ctr: 0x0100000000000000 -header: 9f01000100000000 000000 +header: 9f01000100000000000000 ~~~ ~~~ kid: 0x0000000000000100 ctr: 0xffffffffffffffff -header: 9f0100ffffffffff ffffff +header: 9f0100ffffffffffffffff ~~~ ~~~ @@ -475,37 +475,37 @@ header: 9cffffffffffffff ~~~ kid: 0x000000000000ffff ctr: 0x0000010000000000 -header: 9dffff0100000000 00 +header: 9dffff010000000000 ~~~ ~~~ kid: 0x000000000000ffff ctr: 0x0000ffffffffffff -header: 9dffffffffffffff ff +header: 9dffffffffffffffff ~~~ ~~~ kid: 0x000000000000ffff ctr: 0x0001000000000000 -header: 9effff0100000000 0000 +header: 9effff01000000000000 ~~~ ~~~ kid: 0x000000000000ffff ctr: 0x00ffffffffffffff -header: 9effffffffffffff ffff +header: 9effffffffffffffffff ~~~ ~~~ kid: 0x000000000000ffff ctr: 0x0100000000000000 -header: 9fffff0100000000 000000 +header: 9fffff0100000000000000 ~~~ ~~~ kid: 0x000000000000ffff ctr: 0xffffffffffffffff -header: 9fffffffffffffff ffffff +header: 9fffffffffffffffffffff ~~~ ~~~ @@ -565,49 +565,49 @@ header: ab010000ffffffff ~~~ kid: 0x0000000000010000 ctr: 0x0000000100000000 -header: ac01000001000000 00 +header: ac0100000100000000 ~~~ ~~~ kid: 0x0000000000010000 ctr: 0x000000ffffffffff -header: ac010000ffffffff ff +header: ac010000ffffffffff ~~~ ~~~ kid: 0x0000000000010000 ctr: 0x0000010000000000 -header: ad01000001000000 0000 +header: ad010000010000000000 ~~~ ~~~ kid: 0x0000000000010000 ctr: 0x0000ffffffffffff -header: ad010000ffffffff ffff +header: ad010000ffffffffffff ~~~ ~~~ kid: 0x0000000000010000 ctr: 0x0001000000000000 -header: ae01000001000000 000000 +header: ae01000001000000000000 ~~~ ~~~ kid: 0x0000000000010000 ctr: 0x00ffffffffffffff -header: ae010000ffffffff ffffff +header: ae010000ffffffffffffff ~~~ ~~~ kid: 0x0000000000010000 ctr: 0x0100000000000000 -header: af01000001000000 00000000 +header: af0100000100000000000000 ~~~ ~~~ kid: 0x0000000000010000 ctr: 0xffffffffffffffff -header: af010000ffffffff ffffffff +header: af010000ffffffffffffffff ~~~ ~~~ @@ -667,49 +667,49 @@ header: abffffffffffffff ~~~ kid: 0x0000000000ffffff ctr: 0x0000000100000000 -header: acffffff01000000 00 +header: acffffff0100000000 ~~~ ~~~ kid: 0x0000000000ffffff ctr: 0x000000ffffffffff -header: acffffffffffffff ff +header: acffffffffffffffff ~~~ ~~~ kid: 0x0000000000ffffff ctr: 0x0000010000000000 -header: adffffff01000000 0000 +header: adffffff010000000000 ~~~ ~~~ kid: 0x0000000000ffffff ctr: 0x0000ffffffffffff -header: adffffffffffffff ffff +header: adffffffffffffffffff ~~~ ~~~ kid: 0x0000000000ffffff ctr: 0x0001000000000000 -header: aeffffff01000000 000000 +header: aeffffff01000000000000 ~~~ ~~~ kid: 0x0000000000ffffff ctr: 0x00ffffffffffffff -header: aeffffffffffffff ffffff +header: aeffffffffffffffffffff ~~~ ~~~ kid: 0x0000000000ffffff ctr: 0x0100000000000000 -header: afffffff01000000 00000000 +header: afffffff0100000000000000 ~~~ ~~~ kid: 0x0000000000ffffff ctr: 0xffffffffffffffff -header: afffffffffffffff ffffffff +header: afffffffffffffffffffffff ~~~ ~~~ @@ -757,61 +757,61 @@ header: ba01000000ffffff ~~~ kid: 0x0000000001000000 ctr: 0x0000000001000000 -header: bb01000000010000 00 +header: bb0100000001000000 ~~~ ~~~ kid: 0x0000000001000000 ctr: 0x00000000ffffffff -header: bb01000000ffffff ff +header: bb01000000ffffffff ~~~ ~~~ kid: 0x0000000001000000 ctr: 0x0000000100000000 -header: bc01000000010000 0000 +header: bc010000000100000000 ~~~ ~~~ kid: 0x0000000001000000 ctr: 0x000000ffffffffff -header: bc01000000ffffff ffff +header: bc01000000ffffffffff ~~~ ~~~ kid: 0x0000000001000000 ctr: 0x0000010000000000 -header: bd01000000010000 000000 +header: bd01000000010000000000 ~~~ ~~~ kid: 0x0000000001000000 ctr: 0x0000ffffffffffff -header: bd01000000ffffff ffffff +header: bd01000000ffffffffffff ~~~ ~~~ kid: 0x0000000001000000 ctr: 0x0001000000000000 -header: be01000000010000 00000000 +header: be0100000001000000000000 ~~~ ~~~ kid: 0x0000000001000000 ctr: 0x00ffffffffffffff -header: be01000000ffffff ffffffff +header: be01000000ffffffffffffff ~~~ ~~~ kid: 0x0000000001000000 ctr: 0x0100000000000000 -header: bf01000000010000 0000000000 +header: bf010000000100000000000000 ~~~ ~~~ kid: 0x0000000001000000 ctr: 0xffffffffffffffff -header: bf01000000ffffff ffffffffff +header: bf01000000ffffffffffffffff ~~~ ~~~ @@ -859,61 +859,61 @@ header: baffffffffffffff ~~~ kid: 0x00000000ffffffff ctr: 0x0000000001000000 -header: bbffffffff010000 00 +header: bbffffffff01000000 ~~~ ~~~ kid: 0x00000000ffffffff ctr: 0x00000000ffffffff -header: bbffffffffffffff ff +header: bbffffffffffffffff ~~~ ~~~ kid: 0x00000000ffffffff ctr: 0x0000000100000000 -header: bcffffffff010000 0000 +header: bcffffffff0100000000 ~~~ ~~~ kid: 0x00000000ffffffff ctr: 0x000000ffffffffff -header: bcffffffffffffff ffff +header: bcffffffffffffffffff ~~~ ~~~ kid: 0x00000000ffffffff ctr: 0x0000010000000000 -header: bdffffffff010000 000000 +header: bdffffffff010000000000 ~~~ ~~~ kid: 0x00000000ffffffff ctr: 0x0000ffffffffffff -header: bdffffffffffffff ffffff +header: bdffffffffffffffffffff ~~~ ~~~ kid: 0x00000000ffffffff ctr: 0x0001000000000000 -header: beffffffff010000 00000000 +header: beffffffff01000000000000 ~~~ ~~~ kid: 0x00000000ffffffff ctr: 0x00ffffffffffffff -header: beffffffffffffff ffffffff +header: beffffffffffffffffffffff ~~~ ~~~ kid: 0x00000000ffffffff ctr: 0x0100000000000000 -header: bfffffffff010000 0000000000 +header: bfffffffff0100000000000000 ~~~ ~~~ kid: 0x00000000ffffffff ctr: 0xffffffffffffffff -header: bfffffffffffffff ffffffffff +header: bfffffffffffffffffffffffff ~~~ ~~~ @@ -949,73 +949,73 @@ header: c90100000000ffff ~~~ kid: 0x0000000100000000 ctr: 0x0000000000010000 -header: ca01000000000100 00 +header: ca0100000000010000 ~~~ ~~~ kid: 0x0000000100000000 ctr: 0x0000000000ffffff -header: ca0100000000ffff ff +header: ca0100000000ffffff ~~~ ~~~ kid: 0x0000000100000000 ctr: 0x0000000001000000 -header: cb01000000000100 0000 +header: cb010000000001000000 ~~~ ~~~ kid: 0x0000000100000000 ctr: 0x00000000ffffffff -header: cb0100000000ffff ffff +header: cb0100000000ffffffff ~~~ ~~~ kid: 0x0000000100000000 ctr: 0x0000000100000000 -header: cc01000000000100 000000 +header: cc01000000000100000000 ~~~ ~~~ kid: 0x0000000100000000 ctr: 0x000000ffffffffff -header: cc0100000000ffff ffffff +header: cc0100000000ffffffffff ~~~ ~~~ kid: 0x0000000100000000 ctr: 0x0000010000000000 -header: cd01000000000100 00000000 +header: cd0100000000010000000000 ~~~ ~~~ kid: 0x0000000100000000 ctr: 0x0000ffffffffffff -header: cd0100000000ffff ffffffff +header: cd0100000000ffffffffffff ~~~ ~~~ kid: 0x0000000100000000 ctr: 0x0001000000000000 -header: ce01000000000100 0000000000 +header: ce010000000001000000000000 ~~~ ~~~ kid: 0x0000000100000000 ctr: 0x00ffffffffffffff -header: ce0100000000ffff ffffffffff +header: ce0100000000ffffffffffffff ~~~ ~~~ kid: 0x0000000100000000 ctr: 0x0100000000000000 -header: cf01000000000100 000000000000 +header: cf01000000000100000000000000 ~~~ ~~~ kid: 0x0000000100000000 ctr: 0xffffffffffffffff -header: cf0100000000ffff ffffffffffff +header: cf0100000000ffffffffffffffff ~~~ ~~~ @@ -1051,73 +1051,73 @@ header: c9ffffffffffffff ~~~ kid: 0x000000ffffffffff ctr: 0x0000000000010000 -header: caffffffffff0100 00 +header: caffffffffff010000 ~~~ ~~~ kid: 0x000000ffffffffff ctr: 0x0000000000ffffff -header: caffffffffffffff ff +header: caffffffffffffffff ~~~ ~~~ kid: 0x000000ffffffffff ctr: 0x0000000001000000 -header: cbffffffffff0100 0000 +header: cbffffffffff01000000 ~~~ ~~~ kid: 0x000000ffffffffff ctr: 0x00000000ffffffff -header: cbffffffffffffff ffff +header: cbffffffffffffffffff ~~~ ~~~ kid: 0x000000ffffffffff ctr: 0x0000000100000000 -header: ccffffffffff0100 000000 +header: ccffffffffff0100000000 ~~~ ~~~ kid: 0x000000ffffffffff ctr: 0x000000ffffffffff -header: ccffffffffffffff ffffff +header: ccffffffffffffffffffff ~~~ ~~~ kid: 0x000000ffffffffff ctr: 0x0000010000000000 -header: cdffffffffff0100 00000000 +header: cdffffffffff010000000000 ~~~ ~~~ kid: 0x000000ffffffffff ctr: 0x0000ffffffffffff -header: cdffffffffffffff ffffffff +header: cdffffffffffffffffffffff ~~~ ~~~ kid: 0x000000ffffffffff ctr: 0x0001000000000000 -header: ceffffffffff0100 0000000000 +header: ceffffffffff01000000000000 ~~~ ~~~ kid: 0x000000ffffffffff ctr: 0x00ffffffffffffff -header: ceffffffffffffff ffffffffff +header: ceffffffffffffffffffffffff ~~~ ~~~ kid: 0x000000ffffffffff ctr: 0x0100000000000000 -header: cfffffffffff0100 000000000000 +header: cfffffffffff0100000000000000 ~~~ ~~~ kid: 0x000000ffffffffff ctr: 0xffffffffffffffff -header: cfffffffffffffff ffffffffffff +header: cfffffffffffffffffffffffffff ~~~ ~~~ @@ -1141,85 +1141,85 @@ header: d8010000000000ff ~~~ kid: 0x0000010000000000 ctr: 0x0000000000000100 -header: d901000000000001 00 +header: d90100000000000100 ~~~ ~~~ kid: 0x0000010000000000 ctr: 0x000000000000ffff -header: d9010000000000ff ff +header: d9010000000000ffff ~~~ ~~~ kid: 0x0000010000000000 ctr: 0x0000000000010000 -header: da01000000000001 0000 +header: da010000000000010000 ~~~ ~~~ kid: 0x0000010000000000 ctr: 0x0000000000ffffff -header: da010000000000ff ffff +header: da010000000000ffffff ~~~ ~~~ kid: 0x0000010000000000 ctr: 0x0000000001000000 -header: db01000000000001 000000 +header: db01000000000001000000 ~~~ ~~~ kid: 0x0000010000000000 ctr: 0x00000000ffffffff -header: db010000000000ff ffffff +header: db010000000000ffffffff ~~~ ~~~ kid: 0x0000010000000000 ctr: 0x0000000100000000 -header: dc01000000000001 00000000 +header: dc0100000000000100000000 ~~~ ~~~ kid: 0x0000010000000000 ctr: 0x000000ffffffffff -header: dc010000000000ff ffffffff +header: dc010000000000ffffffffff ~~~ ~~~ kid: 0x0000010000000000 ctr: 0x0000010000000000 -header: dd01000000000001 0000000000 +header: dd010000000000010000000000 ~~~ ~~~ kid: 0x0000010000000000 ctr: 0x0000ffffffffffff -header: dd010000000000ff ffffffffff +header: dd010000000000ffffffffffff ~~~ ~~~ kid: 0x0000010000000000 ctr: 0x0001000000000000 -header: de01000000000001 000000000000 +header: de01000000000001000000000000 ~~~ ~~~ kid: 0x0000010000000000 ctr: 0x00ffffffffffffff -header: de010000000000ff ffffffffffff +header: de010000000000ffffffffffffff ~~~ ~~~ kid: 0x0000010000000000 ctr: 0x0100000000000000 -header: df01000000000001 00000000000000 +header: df0100000000000100000000000000 ~~~ ~~~ kid: 0x0000010000000000 ctr: 0xffffffffffffffff -header: df010000000000ff ffffffffffffff +header: df010000000000ffffffffffffffff ~~~ ~~~ @@ -1243,85 +1243,85 @@ header: d8ffffffffffffff ~~~ kid: 0x0000ffffffffffff ctr: 0x0000000000000100 -header: d9ffffffffffff01 00 +header: d9ffffffffffff0100 ~~~ ~~~ kid: 0x0000ffffffffffff ctr: 0x000000000000ffff -header: d9ffffffffffffff ff +header: d9ffffffffffffffff ~~~ ~~~ kid: 0x0000ffffffffffff ctr: 0x0000000000010000 -header: daffffffffffff01 0000 +header: daffffffffffff010000 ~~~ ~~~ kid: 0x0000ffffffffffff ctr: 0x0000000000ffffff -header: daffffffffffffff ffff +header: daffffffffffffffffff ~~~ ~~~ kid: 0x0000ffffffffffff ctr: 0x0000000001000000 -header: dbffffffffffff01 000000 +header: dbffffffffffff01000000 ~~~ ~~~ kid: 0x0000ffffffffffff ctr: 0x00000000ffffffff -header: dbffffffffffffff ffffff +header: dbffffffffffffffffffff ~~~ ~~~ kid: 0x0000ffffffffffff ctr: 0x0000000100000000 -header: dcffffffffffff01 00000000 +header: dcffffffffffff0100000000 ~~~ ~~~ kid: 0x0000ffffffffffff ctr: 0x000000ffffffffff -header: dcffffffffffffff ffffffff +header: dcffffffffffffffffffffff ~~~ ~~~ kid: 0x0000ffffffffffff ctr: 0x0000010000000000 -header: ddffffffffffff01 0000000000 +header: ddffffffffffff010000000000 ~~~ ~~~ kid: 0x0000ffffffffffff ctr: 0x0000ffffffffffff -header: ddffffffffffffff ffffffffff +header: ddffffffffffffffffffffffff ~~~ ~~~ kid: 0x0000ffffffffffff ctr: 0x0001000000000000 -header: deffffffffffff01 000000000000 +header: deffffffffffff01000000000000 ~~~ ~~~ kid: 0x0000ffffffffffff ctr: 0x00ffffffffffffff -header: deffffffffffffff ffffffffffff +header: deffffffffffffffffffffffffff ~~~ ~~~ kid: 0x0000ffffffffffff ctr: 0x0100000000000000 -header: dfffffffffffff01 00000000000000 +header: dfffffffffffff0100000000000000 ~~~ ~~~ kid: 0x0000ffffffffffff ctr: 0xffffffffffffffff -header: dfffffffffffffff ffffffffffffff +header: dfffffffffffffffffffffffffffff ~~~ ~~~ @@ -1339,91 +1339,91 @@ header: e101000000000000 ~~~ kid: 0x0001000000000000 ctr: 0x00000000000000ff -header: e801000000000000 ff +header: e801000000000000ff ~~~ ~~~ kid: 0x0001000000000000 ctr: 0x0000000000000100 -header: e901000000000000 0100 +header: e9010000000000000100 ~~~ ~~~ kid: 0x0001000000000000 ctr: 0x000000000000ffff -header: e901000000000000 ffff +header: e901000000000000ffff ~~~ ~~~ kid: 0x0001000000000000 ctr: 0x0000000000010000 -header: ea01000000000000 010000 +header: ea01000000000000010000 ~~~ ~~~ kid: 0x0001000000000000 ctr: 0x0000000000ffffff -header: ea01000000000000 ffffff +header: ea01000000000000ffffff ~~~ ~~~ kid: 0x0001000000000000 ctr: 0x0000000001000000 -header: eb01000000000000 01000000 +header: eb0100000000000001000000 ~~~ ~~~ kid: 0x0001000000000000 ctr: 0x00000000ffffffff -header: eb01000000000000 ffffffff +header: eb01000000000000ffffffff ~~~ ~~~ kid: 0x0001000000000000 ctr: 0x0000000100000000 -header: ec01000000000000 0100000000 +header: ec010000000000000100000000 ~~~ ~~~ kid: 0x0001000000000000 ctr: 0x000000ffffffffff -header: ec01000000000000 ffffffffff +header: ec01000000000000ffffffffff ~~~ ~~~ kid: 0x0001000000000000 ctr: 0x0000010000000000 -header: ed01000000000000 010000000000 +header: ed01000000000000010000000000 ~~~ ~~~ kid: 0x0001000000000000 ctr: 0x0000ffffffffffff -header: ed01000000000000 ffffffffffff +header: ed01000000000000ffffffffffff ~~~ ~~~ kid: 0x0001000000000000 ctr: 0x0001000000000000 -header: ee01000000000000 01000000000000 +header: ee0100000000000001000000000000 ~~~ ~~~ kid: 0x0001000000000000 ctr: 0x00ffffffffffffff -header: ee01000000000000 ffffffffffffff +header: ee01000000000000ffffffffffffff ~~~ ~~~ kid: 0x0001000000000000 ctr: 0x0100000000000000 -header: ef01000000000000 0100000000000000 +header: ef010000000000000100000000000000 ~~~ ~~~ kid: 0x0001000000000000 ctr: 0xffffffffffffffff -header: ef01000000000000 ffffffffffffffff +header: ef01000000000000ffffffffffffffff ~~~ ~~~ @@ -1441,294 +1441,298 @@ header: e1ffffffffffffff ~~~ kid: 0x00ffffffffffffff ctr: 0x00000000000000ff -header: e8ffffffffffffff ff +header: e8ffffffffffffffff ~~~ ~~~ kid: 0x00ffffffffffffff ctr: 0x0000000000000100 -header: e9ffffffffffffff 0100 +header: e9ffffffffffffff0100 ~~~ ~~~ kid: 0x00ffffffffffffff ctr: 0x000000000000ffff -header: e9ffffffffffffff ffff +header: e9ffffffffffffffffff ~~~ ~~~ kid: 0x00ffffffffffffff ctr: 0x0000000000010000 -header: eaffffffffffffff 010000 +header: eaffffffffffffff010000 ~~~ ~~~ kid: 0x00ffffffffffffff ctr: 0x0000000000ffffff -header: eaffffffffffffff ffffff +header: eaffffffffffffffffffff ~~~ ~~~ kid: 0x00ffffffffffffff ctr: 0x0000000001000000 -header: ebffffffffffffff 01000000 +header: ebffffffffffffff01000000 ~~~ ~~~ kid: 0x00ffffffffffffff ctr: 0x00000000ffffffff -header: ebffffffffffffff ffffffff +header: ebffffffffffffffffffffff ~~~ ~~~ kid: 0x00ffffffffffffff ctr: 0x0000000100000000 -header: ecffffffffffffff 0100000000 +header: ecffffffffffffff0100000000 ~~~ ~~~ kid: 0x00ffffffffffffff ctr: 0x000000ffffffffff -header: ecffffffffffffff ffffffffff +header: ecffffffffffffffffffffffff ~~~ ~~~ kid: 0x00ffffffffffffff ctr: 0x0000010000000000 -header: edffffffffffffff 010000000000 +header: edffffffffffffff010000000000 ~~~ ~~~ kid: 0x00ffffffffffffff ctr: 0x0000ffffffffffff -header: edffffffffffffff ffffffffffff +header: edffffffffffffffffffffffffff ~~~ ~~~ kid: 0x00ffffffffffffff ctr: 0x0001000000000000 -header: eeffffffffffffff 01000000000000 +header: eeffffffffffffff01000000000000 ~~~ ~~~ kid: 0x00ffffffffffffff ctr: 0x00ffffffffffffff -header: eeffffffffffffff ffffffffffffff +header: eeffffffffffffffffffffffffffff ~~~ ~~~ kid: 0x00ffffffffffffff ctr: 0x0100000000000000 -header: efffffffffffffff 0100000000000000 +header: efffffffffffffff0100000000000000 ~~~ ~~~ kid: 0x00ffffffffffffff ctr: 0xffffffffffffffff -header: efffffffffffffff ffffffffffffffff +header: efffffffffffffffffffffffffffffff ~~~ ~~~ kid: 0x0100000000000000 ctr: 0x0000000000000000 -header: f001000000000000 00 +header: f00100000000000000 ~~~ ~~~ kid: 0x0100000000000000 ctr: 0x0000000000000001 -header: f101000000000000 00 +header: f10100000000000000 ~~~ ~~~ kid: 0x0100000000000000 ctr: 0x00000000000000ff -header: f801000000000000 00ff +header: f80100000000000000ff ~~~ ~~~ kid: 0x0100000000000000 ctr: 0x0000000000000100 -header: f901000000000000 000100 +header: f901000000000000000100 ~~~ ~~~ kid: 0x0100000000000000 ctr: 0x000000000000ffff -header: f901000000000000 00ffff +header: f90100000000000000ffff ~~~ ~~~ kid: 0x0100000000000000 ctr: 0x0000000000010000 -header: fa01000000000000 00010000 +header: fa0100000000000000010000 ~~~ ~~~ kid: 0x0100000000000000 ctr: 0x0000000000ffffff -header: fa01000000000000 00ffffff +header: fa0100000000000000ffffff ~~~ ~~~ kid: 0x0100000000000000 ctr: 0x0000000001000000 -header: fb01000000000000 0001000000 +header: fb010000000000000001000000 ~~~ ~~~ kid: 0x0100000000000000 ctr: 0x00000000ffffffff -header: fb01000000000000 00ffffffff +header: fb0100000000000000ffffffff ~~~ ~~~ kid: 0x0100000000000000 ctr: 0x0000000100000000 -header: fc01000000000000 000100000000 +header: fc01000000000000000100000000 ~~~ ~~~ kid: 0x0100000000000000 ctr: 0x000000ffffffffff -header: fc01000000000000 00ffffffffff +header: fc0100000000000000ffffffffff ~~~ ~~~ kid: 0x0100000000000000 ctr: 0x0000010000000000 -header: fd01000000000000 00010000000000 +header: fd0100000000000000010000000000 ~~~ ~~~ kid: 0x0100000000000000 ctr: 0x0000ffffffffffff -header: fd01000000000000 00ffffffffffff +header: fd0100000000000000ffffffffffff ~~~ ~~~ kid: 0x0100000000000000 ctr: 0x0001000000000000 -header: fe01000000000000 0001000000000000 +header: fe010000000000000001000000000000 ~~~ ~~~ kid: 0x0100000000000000 ctr: 0x00ffffffffffffff -header: fe01000000000000 00ffffffffffffff +header: fe0100000000000000ffffffffffffff ~~~ ~~~ kid: 0x0100000000000000 ctr: 0x0100000000000000 -header: ff01000000000000 0001000000000000 00 +header: ff010000000000000001000000000000 + 00 ~~~ ~~~ kid: 0x0100000000000000 ctr: 0xffffffffffffffff -header: ff01000000000000 00ffffffffffffff ff +header: ff0100000000000000ffffffffffffff + ff ~~~ ~~~ kid: 0xffffffffffffffff ctr: 0x0000000000000000 -header: f0ffffffffffffff ff +header: f0ffffffffffffffff ~~~ ~~~ kid: 0xffffffffffffffff ctr: 0x0000000000000001 -header: f1ffffffffffffff ff +header: f1ffffffffffffffff ~~~ ~~~ kid: 0xffffffffffffffff ctr: 0x00000000000000ff -header: f8ffffffffffffff ffff +header: f8ffffffffffffffffff ~~~ ~~~ kid: 0xffffffffffffffff ctr: 0x0000000000000100 -header: f9ffffffffffffff ff0100 +header: f9ffffffffffffffff0100 ~~~ ~~~ kid: 0xffffffffffffffff ctr: 0x000000000000ffff -header: f9ffffffffffffff ffffff +header: f9ffffffffffffffffffff ~~~ ~~~ kid: 0xffffffffffffffff ctr: 0x0000000000010000 -header: faffffffffffffff ff010000 +header: faffffffffffffffff010000 ~~~ ~~~ kid: 0xffffffffffffffff ctr: 0x0000000000ffffff -header: faffffffffffffff ffffffff +header: faffffffffffffffffffffff ~~~ ~~~ kid: 0xffffffffffffffff ctr: 0x0000000001000000 -header: fbffffffffffffff ff01000000 +header: fbffffffffffffffff01000000 ~~~ ~~~ kid: 0xffffffffffffffff ctr: 0x00000000ffffffff -header: fbffffffffffffff ffffffffff +header: fbffffffffffffffffffffffff ~~~ ~~~ kid: 0xffffffffffffffff ctr: 0x0000000100000000 -header: fcffffffffffffff ff0100000000 +header: fcffffffffffffffff0100000000 ~~~ ~~~ kid: 0xffffffffffffffff ctr: 0x000000ffffffffff -header: fcffffffffffffff ffffffffffff +header: fcffffffffffffffffffffffffff ~~~ ~~~ kid: 0xffffffffffffffff ctr: 0x0000010000000000 -header: fdffffffffffffff ff010000000000 +header: fdffffffffffffffff010000000000 ~~~ ~~~ kid: 0xffffffffffffffff ctr: 0x0000ffffffffffff -header: fdffffffffffffff ffffffffffffff +header: fdffffffffffffffffffffffffffff ~~~ ~~~ kid: 0xffffffffffffffff ctr: 0x0001000000000000 -header: feffffffffffffff ff01000000000000 +header: feffffffffffffffff01000000000000 ~~~ ~~~ kid: 0xffffffffffffffff ctr: 0x00ffffffffffffff -header: feffffffffffffff ffffffffffffffff +header: feffffffffffffffffffffffffffffff ~~~ ~~~ kid: 0xffffffffffffffff ctr: 0x0100000000000000 -header: ffffffffffffffff ff01000000000000 00 +header: ffffffffffffffffff01000000000000 + 00 ~~~ ~~~ kid: 0xffffffffffffffff ctr: 0xffffffffffffffff -header: ffffffffffffffff ffffffffffffffff ff +header: ffffffffffffffffffffffffffffffff + ff ~~~ diff --git a/test-vectors/sframe.md b/test-vectors/sframe.md index 45170c0..44455a5 100644 --- a/test-vectors/sframe.md +++ b/test-vectors/sframe.md @@ -2,109 +2,132 @@ cipher_suite: 0x0001 kid: 0x0000000000000123 ctr: 0x0000000000004567 -base_key: 0001020304050607 08090a0b0c0d0e0f -sframe_key_label: 534672616d652031 2e30205365637265 74206b6579200000 - 0000000001230001 -sframe_salt_label: 534672616d652031 2e30205365637265 742073616c742000 - 0000000000012300 01 -sframe_secret: d926952ca8b7ec4a 95941d1ada3a5203 ceff8cceee34f574 - d23909eb314c40c0 -sframe_key: 3f7d9a7c83ae8e1c 8a11ae695ab59314 b367e359fadac7b9 - c46b2bc6f81f46e1 6b96f0811868d594 02b7e870102720b3 -sframe_salt: 50b29329a04dc0f1 84ac3168 -metadata: 4945544620534672 616d65205747 -nonce: 50b29329a04dc0f1 84ac740f -aad: 9901234567494554 4620534672616d65 205747 -pt: 64726166742d6965 74662d736672616d 652d656e63 -ct: 9901234567449408 b6f490086165b9d6 f62b24ae1a59a564 - 86b4ae8ed036b889 12e24f11 +base_key: 000102030405060708090a0b0c0d0e0f +sframe_key_label: 534672616d6520312e30205365637265 + 74206b65792000000000000001230001 +sframe_salt_label: 534672616d6520312e30205365637265 + 742073616c7420000000000000012300 + 01 +sframe_secret: d926952ca8b7ec4a95941d1ada3a5203 + ceff8cceee34f574d23909eb314c40c0 +sframe_key: 3f7d9a7c83ae8e1c8a11ae695ab59314 + b367e359fadac7b9c46b2bc6f81f46e1 + 6b96f0811868d59402b7e870102720b3 +sframe_salt: 50b29329a04dc0f184ac3168 +metadata: 4945544620534672616d65205747 +nonce: 50b29329a04dc0f184ac740f +aad: 99012345674945544620534672616d65 + 205747 +pt: 64726166742d696574662d736672616d + 652d656e63 +ct: 9901234567449408b6f490086165b9d6 + f62b24ae1a59a56486b4ae8ed036b889 + 12e24f11 ~~~ ~~~ cipher_suite: 0x0002 kid: 0x0000000000000123 ctr: 0x0000000000004567 -base_key: 0001020304050607 08090a0b0c0d0e0f -sframe_key_label: 534672616d652031 2e30205365637265 74206b6579200000 - 0000000001230002 -sframe_salt_label: 534672616d652031 2e30205365637265 742073616c742000 - 0000000000012300 02 -sframe_secret: d926952ca8b7ec4a 95941d1ada3a5203 ceff8cceee34f574 - d23909eb314c40c0 -sframe_key: e2ec5c7975403104 83b16bf6e7a570d2 a27d192fe869c7cc - d8584a8d9dab9154 9fbe553f5113461e c6aa83bf3865553e -sframe_salt: e68ac8dd3d02fbcd 368c5577 -metadata: 4945544620534672 616d65205747 -nonce: e68ac8dd3d02fbcd 368c1010 -aad: 9901234567494554 4620534672616d65 205747 -pt: 64726166742d6965 74662d736672616d 652d656e63 -ct: 99012345673f3143 8db4d09434e43afa 0f8a2f00867a2be0 - 85046a9f5cb4f101 d607 +base_key: 000102030405060708090a0b0c0d0e0f +sframe_key_label: 534672616d6520312e30205365637265 + 74206b65792000000000000001230002 +sframe_salt_label: 534672616d6520312e30205365637265 + 742073616c7420000000000000012300 + 02 +sframe_secret: d926952ca8b7ec4a95941d1ada3a5203 + ceff8cceee34f574d23909eb314c40c0 +sframe_key: e2ec5c797540310483b16bf6e7a570d2 + a27d192fe869c7ccd8584a8d9dab9154 + 9fbe553f5113461ec6aa83bf3865553e +sframe_salt: e68ac8dd3d02fbcd368c5577 +metadata: 4945544620534672616d65205747 +nonce: e68ac8dd3d02fbcd368c1010 +aad: 99012345674945544620534672616d65 + 205747 +pt: 64726166742d696574662d736672616d + 652d656e63 +ct: 99012345673f31438db4d09434e43afa + 0f8a2f00867a2be085046a9f5cb4f101 + d607 ~~~ ~~~ cipher_suite: 0x0003 kid: 0x0000000000000123 ctr: 0x0000000000004567 -base_key: 0001020304050607 08090a0b0c0d0e0f -sframe_key_label: 534672616d652031 2e30205365637265 74206b6579200000 - 0000000001230003 -sframe_salt_label: 534672616d652031 2e30205365637265 742073616c742000 - 0000000000012300 03 -sframe_secret: d926952ca8b7ec4a 95941d1ada3a5203 ceff8cceee34f574 - d23909eb314c40c0 -sframe_key: 2c5703089cbb8c58 3475e4fc461d97d1 8809df79b6d550f7 - 8eb6d50ffa80d892 11d57909934f46f5 405e38cd583c69fe -sframe_salt: 38c16e4f5159700c 00c7f350 -metadata: 4945544620534672 616d65205747 -nonce: 38c16e4f5159700c 00c7b637 -aad: 9901234567494554 4620534672616d65 205747 -pt: 64726166742d6965 74662d736672616d 652d656e63 -ct: 990123456717fc8a f28a5a695afcfc6c 8df6358a17e26b2f - cb3bae32e443 +base_key: 000102030405060708090a0b0c0d0e0f +sframe_key_label: 534672616d6520312e30205365637265 + 74206b65792000000000000001230003 +sframe_salt_label: 534672616d6520312e30205365637265 + 742073616c7420000000000000012300 + 03 +sframe_secret: d926952ca8b7ec4a95941d1ada3a5203 + ceff8cceee34f574d23909eb314c40c0 +sframe_key: 2c5703089cbb8c583475e4fc461d97d1 + 8809df79b6d550f78eb6d50ffa80d892 + 11d57909934f46f5405e38cd583c69fe +sframe_salt: 38c16e4f5159700c00c7f350 +metadata: 4945544620534672616d65205747 +nonce: 38c16e4f5159700c00c7b637 +aad: 99012345674945544620534672616d65 + 205747 +pt: 64726166742d696574662d736672616d + 652d656e63 +ct: 990123456717fc8af28a5a695afcfc6c + 8df6358a17e26b2fcb3bae32e443 ~~~ ~~~ cipher_suite: 0x0004 kid: 0x0000000000000123 ctr: 0x0000000000004567 -base_key: 0001020304050607 08090a0b0c0d0e0f -sframe_key_label: 534672616d652031 2e30205365637265 74206b6579200000 - 0000000001230004 -sframe_salt_label: 534672616d652031 2e30205365637265 742073616c742000 - 0000000000012300 04 -sframe_secret: d926952ca8b7ec4a 95941d1ada3a5203 ceff8cceee34f574 - d23909eb314c40c0 -sframe_key: d34f547f4ca4f9a7 447006fe7fcbf768 -sframe_salt: 75234edefe078190 26751816 -metadata: 4945544620534672 616d65205747 -nonce: 75234edefe078190 26755d71 -aad: 9901234567494554 4620534672616d65 205747 -pt: 64726166742d6965 74662d736672616d 652d656e63 -ct: 9901234567b7412c 2513a1b66dbb4884 1bbaf17f59875117 - 6ad847681a69c6d0 b091c07018ce4adb 34eb +base_key: 000102030405060708090a0b0c0d0e0f +sframe_key_label: 534672616d6520312e30205365637265 + 74206b65792000000000000001230004 +sframe_salt_label: 534672616d6520312e30205365637265 + 742073616c7420000000000000012300 + 04 +sframe_secret: d926952ca8b7ec4a95941d1ada3a5203 + ceff8cceee34f574d23909eb314c40c0 +sframe_key: d34f547f4ca4f9a7447006fe7fcbf768 +sframe_salt: 75234edefe07819026751816 +metadata: 4945544620534672616d65205747 +nonce: 75234edefe07819026755d71 +aad: 99012345674945544620534672616d65 + 205747 +pt: 64726166742d696574662d736672616d + 652d656e63 +ct: 9901234567b7412c2513a1b66dbb4884 + 1bbaf17f598751176ad847681a69c6d0 + b091c07018ce4adb34eb ~~~ ~~~ cipher_suite: 0x0005 kid: 0x0000000000000123 ctr: 0x0000000000004567 -base_key: 0001020304050607 08090a0b0c0d0e0f -sframe_key_label: 534672616d652031 2e30205365637265 74206b6579200000 - 0000000001230005 -sframe_salt_label: 534672616d652031 2e30205365637265 742073616c742000 - 0000000000012300 05 -sframe_secret: 0fc3ea6de6aac97a 35f194cf9bed94d4 b5230f1cb45a785c - 9fe5dce9c188938a b6ba005bc4c0a191 81599e9d1bcf7b74 - aca48b60bf5e254e 546d809313e083a3 -sframe_key: d3e27b0d4a5ae9e5 5df01a70e6d4d28d 969b246e2936f4b7 - a5d9b494da6b9633 -sframe_salt: 84991c167b8cd23c 93708ec7 -metadata: 4945544620534672 616d65205747 -nonce: 84991c167b8cd23c 9370cba0 -aad: 9901234567494554 4620534672616d65 205747 -pt: 64726166742d6965 74662d736672616d 652d656e63 -ct: 990123456794f509 d36e9beacb0e261d 99c7d1e972f1fed7 - 87d4049f17ca2135 3c1cc24d56ceabce d279 +base_key: 000102030405060708090a0b0c0d0e0f +sframe_key_label: 534672616d6520312e30205365637265 + 74206b65792000000000000001230005 +sframe_salt_label: 534672616d6520312e30205365637265 + 742073616c7420000000000000012300 + 05 +sframe_secret: 0fc3ea6de6aac97a35f194cf9bed94d4 + b5230f1cb45a785c9fe5dce9c188938a + b6ba005bc4c0a19181599e9d1bcf7b74 + aca48b60bf5e254e546d809313e083a3 +sframe_key: d3e27b0d4a5ae9e55df01a70e6d4d28d + 969b246e2936f4b7a5d9b494da6b9633 +sframe_salt: 84991c167b8cd23c93708ec7 +metadata: 4945544620534672616d65205747 +nonce: 84991c167b8cd23c9370cba0 +aad: 99012345674945544620534672616d65 + 205747 +pt: 64726166742d696574662d736672616d + 652d656e63 +ct: 990123456794f509d36e9beacb0e261d + 99c7d1e972f1fed787d4049f17ca2135 + 3c1cc24d56ceabced279 ~~~