Skip to content

Commit

Permalink
OCB3 test vectors for 104, 112, and 120-bit nonces (#7009)
Browse files Browse the repository at this point in the history
  • Loading branch information
reaperhulk committed Mar 29, 2022
1 parent 9d357cf commit 4a4f4d9
Show file tree
Hide file tree
Showing 4 changed files with 347 additions and 1 deletion.
3 changes: 2 additions & 1 deletion docs/development/test-vectors.rst
Expand Up @@ -830,7 +830,7 @@ Symmetric ciphers

* AES (CBC, CFB, ECB, GCM, OFB, CCM) from `NIST CAVP`_.
* AES CTR from :rfc:`3686`.
* AES OCB3 from :rfc:`7253`.
* AES OCB3 from :rfc:`7253` and `dkg's additional OCB3 vectors`_.
* AES SIV from OpenSSL's `evpciph_aes_siv.txt`_.
* 3DES (CBC, CFB, ECB, OFB) from `NIST CAVP`_.
* ARC4 (KEY-LENGTH: 40, 56, 64, 80, 128, 192, 256) from :rfc:`6229`.
Expand Down Expand Up @@ -945,3 +945,4 @@ header format (substituting the correct information):
.. _`server-ed25519-cert.pem`: https://github.com/openssl/openssl/blob/2a1e2fe145c6eb8e75aa2e1b3a8c3a49384b2852/test/certs/server-ed25519-cert.pem
.. _`server-ed448-cert.pem`: https://github.com/openssl/openssl/blob/2a1e2fe145c6eb8e75aa2e1b3a8c3a49384b2852/test/certs/server-ed448-cert.pem
.. _`evpciph_aes_siv.txt`: https://github.com/openssl/openssl/blob/d830526c711074fdcd82c70c24c31444366a1ed8/test/recipes/30-test_evp_data/evpciph_aes_siv.txt
.. _`dkg's additional OCB3 vectors`: https://gitlab.com/dkg/ocb-test-vectors
@@ -0,0 +1,115 @@
# Vectors https://gitlab.com/dkg/ocb-test-vectors/-/blob/ec0131616679f588c3be0ac7c33b7a663e1a47d4/test-vector-1-nonce104.txt
# 104-bit nonce forms of RFC 7253
# Reformatted to work with our NIST loader

COUNT = 0
Key = 000102030405060708090A0B0C0D0E0F
Nonce = CCBBAA99887766554433221100
AAD =
Plaintext =
Ciphertext = 1AF957957B85C3D7F6CA08C7C5FC8F4A

COUNT = 1
Key = 000102030405060708090A0B0C0D0E0F
Nonce = CCBBAA99887766554433221101
AAD = 0001020304050607
Plaintext = 0001020304050607
Ciphertext = F4132F7B364D13A2303ACE52DDF90774E24E3E8895AC7F88

COUNT = 2
Key = 000102030405060708090A0B0C0D0E0F
Nonce = CCBBAA99887766554433221102
AAD = 0001020304050607
Plaintext =
Ciphertext = 20E9B13D02F7B19AFDC4659344960BED

COUNT = 3
Key = 000102030405060708090A0B0C0D0E0F
Nonce = CCBBAA99887766554433221103
AAD =
Plaintext = 0001020304050607
Ciphertext = 4A2A7E6D7A0A0EA4D652CC24F2208986E47B3251A66B5944

COUNT = 4
Key = 000102030405060708090A0B0C0D0E0F
Nonce = CCBBAA99887766554433221104
AAD = 000102030405060708090A0B0C0D0E0F
Plaintext = 000102030405060708090A0B0C0D0E0F
Ciphertext = EEED2C9E7CFA9580551B03DCDB2E1DFA4A60E8225633281B98173DD6F1F1A57F

COUNT = 5
Key = 000102030405060708090A0B0C0D0E0F
Nonce = CCBBAA99887766554433221105
AAD = 000102030405060708090A0B0C0D0E0F
Plaintext =
Ciphertext = 19BAE49F721302071167C34E02A8BE9B

COUNT = 6
Key = 000102030405060708090A0B0C0D0E0F
Nonce = CCBBAA99887766554433221106
AAD =
Plaintext = 000102030405060708090A0B0C0D0E0F
Ciphertext = E254116668AEC1D2663E3E9B914AC47D0337401A0B16E4605B94A2C45F0F53CB

COUNT = 7
Key = 000102030405060708090A0B0C0D0E0F
Nonce = CCBBAA99887766554433221107
AAD = 000102030405060708090A0B0C0D0E0F1011121314151617
Plaintext = 000102030405060708090A0B0C0D0E0F1011121314151617
Ciphertext = 0C0299BEE2D5B65CBC82A6EE119543B7B89DE85561D149BFC1CBE6EC8749065C6068E046FB2BA7F7

COUNT = 8
Key = 000102030405060708090A0B0C0D0E0F
Nonce = CCBBAA99887766554433221108
AAD = 000102030405060708090A0B0C0D0E0F1011121314151617
Plaintext =
Ciphertext = F4E603C017B49123CD3EEBF0F342DE31

COUNT = 9
Key = 000102030405060708090A0B0C0D0E0F
Nonce = CCBBAA99887766554433221109
AAD =
Plaintext = 000102030405060708090A0B0C0D0E0F1011121314151617
Ciphertext = 9A2D75CA34639FF92CACDD3A881ED446B0E790D719A9DFD680C97FAE8ECE18A03A4C67DC1C0763B6

COUNT = 10
Key = 000102030405060708090A0B0C0D0E0F
Nonce = CCBBAA9988776655443322110A
AAD = 000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F
Plaintext = 000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F
Ciphertext = 0FEBCFA18BF3D2C4C155266755817F843DFA5A5CFD8987D87BE45F3669599D66B2D98602565E18AC31AD88C7C51A6988

COUNT = 11
Key = 000102030405060708090A0B0C0D0E0F
Nonce = CCBBAA9988776655443322110B
AAD = 000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F
Plaintext =
Ciphertext = 6F48A1E1F0D43023CFA84F4143E286B8

COUNT = 12
Key = 000102030405060708090A0B0C0D0E0F
Nonce = CCBBAA9988776655443322110C
AAD =
Plaintext = 000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F
Ciphertext = 1DF09EC159EB74B3B4AC4B440D2D382ADE25D3A26D9A2A2EDCF23F41002FB7EB53417D8AFED547BFD54056BC9EA9C590

COUNT = 13
Key = 000102030405060708090A0B0C0D0E0F
Nonce = CCBBAA9988776655443322110D
AAD = 000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F2021222324252627
Plaintext = 000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F2021222324252627
Ciphertext = 3BCFFDEAC246CB305D367A25489ACE1F8FF0317260401B9E1A08DA6C11A0CC490871BD1A5E4FA29FF0E0A7326F0F871583AA3FAE224DD5EB

COUNT = 14
Key = 000102030405060708090A0B0C0D0E0F
Nonce = CCBBAA9988776655443322110E
AAD = 000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F2021222324252627
Plaintext =
Ciphertext = FA7B7AC1ABD4097F4D547BE9FD5D0BB2

COUNT = 15
Key = 000102030405060708090A0B0C0D0E0F
Nonce = CCBBAA9988776655443322110F
AAD =
Plaintext = 000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F2021222324252627
Ciphertext = C8B16DA1C0AC72E4C993AC75EBD800D0ECDC45EE9DDC2D70C74BA3E4EFCC98A9DF77F8560D7EB2C33EDE4A46D9A2AD0CCAEB653BB6D38725
@@ -0,0 +1,115 @@
# Vectors from https://gitlab.com/dkg/ocb-test-vectors/-/blob/ec0131616679f588c3be0ac7c33b7a663e1a47d4/test-vector-1-nonce112.txt
# 112-bit nonce forms of RFC 7253
# Reformatted to work with our NIST loader

COUNT = 0
Key = 000102030405060708090A0B0C0D0E0F
Nonce = DDCCBBAA99887766554433221100
AAD =
Plaintext =
Ciphertext = B22774052013981C3038DA65757A55E4

COUNT = 1
Key = 000102030405060708090A0B0C0D0E0F
Nonce = DDCCBBAA99887766554433221101
AAD = 0001020304050607
Plaintext = 0001020304050607
Ciphertext = 3791C1215BB0F2E3B008F1A9BFF0A2069BD2B3B93168AD17

COUNT = 2
Key = 000102030405060708090A0B0C0D0E0F
Nonce = DDCCBBAA99887766554433221102
AAD = 0001020304050607
Plaintext =
Ciphertext = C07EDDBB4359D5E68F7618E7D397BFAC

COUNT = 3
Key = 000102030405060708090A0B0C0D0E0F
Nonce = DDCCBBAA99887766554433221103
AAD =
Plaintext = 0001020304050607
Ciphertext = AF02506326B86248936845A600CEC91888F52C214ED1674A

COUNT = 4
Key = 000102030405060708090A0B0C0D0E0F
Nonce = DDCCBBAA99887766554433221104
AAD = 000102030405060708090A0B0C0D0E0F
Plaintext = 000102030405060708090A0B0C0D0E0F
Ciphertext = 165A060B6A9ED2F930A7D6DEC0195B5B19722619DD37749A1B97FF6C63393009

COUNT = 5
Key = 000102030405060708090A0B0C0D0E0F
Nonce = DDCCBBAA99887766554433221105
AAD = 000102030405060708090A0B0C0D0E0F
Plaintext =
Ciphertext = E1616FC25D8A300D8C64CD2018071BFE

COUNT = 6
Key = 000102030405060708090A0B0C0D0E0F
Nonce = DDCCBBAA99887766554433221106
AAD =
Plaintext = 000102030405060708090A0B0C0D0E0F
Ciphertext = 14F2D292673A8F1DA6B80543658784F5DEE9FF8FF1B0A40FD16720E2B2970549

COUNT = 7
Key = 000102030405060708090A0B0C0D0E0F
Nonce = DDCCBBAA99887766554433221107
AAD = 000102030405060708090A0B0C0D0E0F1011121314151617
Plaintext = 000102030405060708090A0B0C0D0E0F1011121314151617
Ciphertext = 98B9D538E13A8D12CE94C53F7C36675C77C0A8C9BDE234FDB02E92506483A49976AE5585F1777360

COUNT = 8
Key = 000102030405060708090A0B0C0D0E0F
Nonce = DDCCBBAA99887766554433221108
AAD = 000102030405060708090A0B0C0D0E0F1011121314151617
Plaintext =
Ciphertext = 8B3F1EA59A0D5D7C9FD369B6CEE0F4A6

COUNT = 9
Key = 000102030405060708090A0B0C0D0E0F
Nonce = DDCCBBAA99887766554433221109
AAD =
Plaintext = 000102030405060708090A0B0C0D0E0F1011121314151617
Ciphertext = AB910BACF2F2409EE871D2818AC31ADFAA39DA637E2D1BF2D87985B4B532966CAF43B13EE754AB07

COUNT = 10
Key = 000102030405060708090A0B0C0D0E0F
Nonce = DDCCBBAA9988776655443322110A
AAD = 000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F
Plaintext = 000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F
Ciphertext = 635623537A7D54ABB68F5B23E151FFAA77A6E0EC19DF46117C2E990154C74539393E11FBC726AACB37023175DD592667

COUNT = 11
Key = 000102030405060708090A0B0C0D0E0F
Nonce = DDCCBBAA9988776655443322110B
AAD = 000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F
Plaintext =
Ciphertext = 97CC4DE80C67DD335771E498944288BF

COUNT = 12
Key = 000102030405060708090A0B0C0D0E0F
Nonce = DDCCBBAA9988776655443322110C
AAD =
Plaintext = 000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F
Ciphertext = A159D066AB9BF3C2B3DC4881BD4DE3A197B12548F11F91972D3B0E881A811AED6427067C99276B1CD0E4382C4C9A8709

COUNT = 13
Key = 000102030405060708090A0B0C0D0E0F
Nonce = DDCCBBAA9988776655443322110D
AAD = 000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F2021222324252627
Plaintext = 000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F2021222324252627
Ciphertext = 259731C171E61C6FEE8E55A7B784DAB3B4B75AC8DE8C4A3CC01C96F19EAFA7F4FC49C84220893993A0B48DF8A969ACECD84BBAA996375A4F

COUNT = 14
Key = 000102030405060708090A0B0C0D0E0F
Nonce = DDCCBBAA9988776655443322110E
AAD = 000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F2021222324252627
Plaintext =
Ciphertext = F03AF5CB012CF7228FCAEC2B2B0FFF69

COUNT = 15
Key = 000102030405060708090A0B0C0D0E0F
Nonce = DDCCBBAA9988776655443322110F
AAD =
Plaintext = 000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F2021222324252627
Ciphertext = 45979D0ACA9A7DA537C96BCDBE1F40A288C9FD0E608148C904DA17ACAC18407E3F5D1D5A9546EA59F9F3A1D13EEF2A13676101371D0BAB20
@@ -0,0 +1,115 @@
# Vectors from https://gitlab.com/dkg/ocb-test-vectors/-/blob/4db265280d1669d57f6a8458ee6c5e8a6db6bd0e/test-vector-1-nonce120.txt
# 120-bit nonce forms of RFC 7253
# Reformatted to work with our NIST loader

COUNT = 0
Key = 000102030405060708090A0B0C0D0E0F
Nonce = EEDDCCBBAA99887766554433221100
AAD =
Plaintext =
Ciphertext = 752ACD2132C41E020E41FB223EFD77B6

COUNT = 1
Key = 000102030405060708090A0B0C0D0E0F
Nonce = EEDDCCBBAA99887766554433221101
AAD = 0001020304050607
Plaintext = 0001020304050607
Ciphertext = 201FE4D89EA7BD1EB5B1577DB16283B8AED1715AD6BE5149

COUNT = 2
Key = 000102030405060708090A0B0C0D0E0F
Nonce = EEDDCCBBAA99887766554433221102
AAD = 0001020304050607
Plaintext =
Ciphertext = 710960B9EE00B8F44D2E8120AABA63AE

COUNT = 3
Key = 000102030405060708090A0B0C0D0E0F
Nonce = EEDDCCBBAA99887766554433221103
AAD =
Plaintext = 0001020304050607
Ciphertext = 084E869570194BD25032FE9E5328E45D507E74F3366E20D2

COUNT = 4
Key = 000102030405060708090A0B0C0D0E0F
Nonce = EEDDCCBBAA99887766554433221104
AAD = 000102030405060708090A0B0C0D0E0F
Plaintext = 000102030405060708090A0B0C0D0E0F
Ciphertext = 9676EE37FD645C07C0D4F70AABF686688E39B2FB3FC4FF30DCD1827B36A298D3

COUNT = 5
Key = 000102030405060708090A0B0C0D0E0F
Nonce = EEDDCCBBAA99887766554433221105
AAD = 000102030405060708090A0B0C0D0E0F
Plaintext =
Ciphertext = 9D510F56EDF72FFA34969BCEF91E6DE9

COUNT = 6
Key = 000102030405060708090A0B0C0D0E0F
Nonce = EEDDCCBBAA99887766554433221106
AAD =
Plaintext = 000102030405060708090A0B0C0D0E0F
Ciphertext = D5E15AA1D232AB57F234366DFFB25574A3636A5F3E3433EA4590CBF4F9AC1F4D

COUNT = 7
Key = 000102030405060708090A0B0C0D0E0F
Nonce = EEDDCCBBAA99887766554433221107
AAD = 000102030405060708090A0B0C0D0E0F1011121314151617
Plaintext = 000102030405060708090A0B0C0D0E0F1011121314151617
Ciphertext = 1C4B6777B7F137C30971A93DE3C56CC735686A6F7703142FAB8ACC987C1406DFF96273C5376E6210

COUNT = 8
Key = 000102030405060708090A0B0C0D0E0F
Nonce = EEDDCCBBAA99887766554433221108
AAD = 000102030405060708090A0B0C0D0E0F1011121314151617
Plaintext =
Ciphertext = 96E670C0238FB969B7ACE4ABAF7438C7

COUNT = 9
Key = 000102030405060708090A0B0C0D0E0F
Nonce = EEDDCCBBAA99887766554433221109
AAD =
Plaintext = 000102030405060708090A0B0C0D0E0F1011121314151617
Ciphertext = 1290A686D825F712E594BE4039C04D3E44F7D1342B84FFCAD68BBDFA04B580EA9A01E2F4565399C3

COUNT = 10
Key = 000102030405060708090A0B0C0D0E0F
Nonce = EEDDCCBBAA9988776655443322110A
AAD = 000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F
Plaintext = 000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F
Ciphertext = FBDFC11F749217BB7FAE5D4036B8F22803712EFF9EF94342FE1B684968D0E3E381A277DAAB83579406A01E2675A082C9

COUNT = 11
Key = 000102030405060708090A0B0C0D0E0F
Nonce = EEDDCCBBAA9988776655443322110B
AAD = 000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F
Plaintext =
Ciphertext = 90CDA8A05161D2873361374B76F95430

COUNT = 12
Key = 000102030405060708090A0B0C0D0E0F
Nonce = EEDDCCBBAA9988776655443322110C
AAD =
Plaintext = 000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F
Ciphertext = D1320AF4B6FF8AFEECEE7921395D4E8692717753EE15F5038EB674DA43D6EA8DBE7831E723BE471F62D9E7F49A7D3B32

COUNT = 13
Key = 000102030405060708090A0B0C0D0E0F
Nonce = EEDDCCBBAA9988776655443322110D
AAD = 000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F2021222324252627
Plaintext = 000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F2021222324252627
Ciphertext = 5C79F1C4B9A204ED3323616D576FC500E4A71939F03A3C3DE2C097AF2C6C81DC3F0309E76082B1F50FF8522959FFE41F37EF507E9076D32C

COUNT = 14
Key = 000102030405060708090A0B0C0D0E0F
Nonce = EEDDCCBBAA9988776655443322110E
AAD = 000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F2021222324252627
Plaintext =
Ciphertext = 3BF158B7DE76C5151EF6086A825D0CC4

COUNT = 15
Key = 000102030405060708090A0B0C0D0E0F
Nonce = EEDDCCBBAA9988776655443322110F
AAD =
Plaintext = 000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F2021222324252627
Ciphertext = 34DA59D2EB08F47822D48C85B6A1D23694E1D3DE680D616D7B1B59472C13E369C68DCA699DA1686A339D5452803632810B0840E6804AB020

0 comments on commit 4a4f4d9

Please sign in to comment.