[Cryptography] creating test vectors

Pierre Abbat phma at bezitopo.org
Wed Sep 2 04:27:37 EDT 2026


On Tuesday, September 1, 2026 5:44:44 AM EDT Joachim Strömbergson wrote:
> Typically you see:
> 
> - “abc”
> - all zero, all ones

I've done this.

> - every even, every odd bit set

I haven't used these; I guess I should also use Thue-Morse (0x69969669).

> - Known text snippets. Makes it easy to read when decrypted

Check

> - Test vectors that verify block boundaries, any padding schemes (like
> forcing one extra block in the case of SHA-256 for example.). Edge cases -

For Twistree, a hash function with a 32-byte block, I used 31-byte, 96-byte, 
and 33-byte known text snippets. A plaintext whose size is a multiple of 32 
has a whole block of padding added. These are the texts:
text31 = "בראשית ברא אלהים " #-start of Bible
text33 = "árvíztűrő tükörfúrógépek"
key96 = "Водворетраванатраведрова.Нерубидрованатраведвора!"
# key96 is also used as a plaintext for hashing because 32|96.
In text31, it looks like there's a space before the first letter, but it's 
actually after the last; I cut it off after the space between "Elohim" and 
"et".

> Test vectors that check specified requirements, limits, constraints
> - Long runs - 1M blocks for block cipher, hash function

I use a 59049-byte plaintext for testing Twistree. I can check the whole hash, 
which is 32 bytes long regardless of how much text is hashed. For a cipher, 
though, I'd have to spot-check it: if you take every 8191st byte, it should be 
such and such.

> That sounds _very_ concerning.

This is just a test vector. In actual use, you wouldn't use a 96-byte key to 
encrypt a 39-byte plaintext; you'd use a shorter key, like 16 to 32 bytes, and 
make the plaintext long enough that the key is finished with at least a round 
or two left; the remaining rounds will use the key passed through an LFSR, so 
a change in the last byte of the key will result in many bytes of scheduled 
key being changed.

This is not a problem with Wring and Twistree, which have a completely 
different key schedule that derives the S-boxes from the key. I made sure that 
changing the last byte of a 96-byte key results in completely different S-
boxes.

Pierre
-- 
I believe in Yellow when I'm in Sweden and in Black when I'm in Wales.





More information about the cryptography mailing list