[Cryptography] How do I tell if a byte sequence repeats?
Pierre Abbat
phma at bezitopo.org
Fri Aug 22 20:06:53 EDT 2025
I'm doing a chosen-plaintext attack on my stream cipher Daphne with reduced
key length. (The shift register is as long as the key.) I take a Daphne, make
two copies of it, and feed them the same byte sequence except that two
different bytes are exchanged at or near the beginning. The attack stops when
each Daphne has been fed 2^32 bytes (I may increase this in the future)
without noticing a statistical anomaly, or when it's been fed twice as many
bytes as when a statistical anomaly is noticed (the number of times a byte
pair has occured is too far from i/65536, where i is the iteration number). I
then plot a heat map of the byte pairs and a density plot (smoothed histogram)
of the numbers of times the byte pairs occur.
I've seen different appearances of the graphs:
* The heat map looks like snow, the density looks normal, and it ran all the
way to 2^32. This is good.
* The heat map looks like a diagonal line, and the density is bimodal with one
bump much smaller than the other. I haven't seen this plotted; I was still
looking at the console when it happened. This was when a 4-byte Daphne was fed
random bytes, and the two Daphnes fell together after a while.
* The heat map looks like tartan, and the density looks normalish but is too
wide. The input was all zeros except for a single nonzero byte at the
beginning. I think the two Daphnes fell into different loops with period a few
thousand.
* The heat map looks like snow, and the density looks normalish but is too
wide. I think the Daphnes fell into two different loops with period between
2^16 and 2^24.
The last case is what I'm asking about, and with longer keys there may be
longer loops. I don't want to store the entire 8 GiB output of the Daphnes to
measure the period. I know how to measure the period of a sequence where each
number in the period occurs only once, but this is a sequence of bytes that
repeats with a period that may be in the millions. How can I measure the
period without storing the whole sequence?
Pierre
--
The Black Garden on the Mountain is not on the Black Mountain.
More information about the cryptography
mailing list