# How to crack Vigenere ciphertext if multiple keys of coprime length are used?

I came across the idea of using multiple Vigenere keys of coprime lengths here. The idea is, what if you use multiple keys, whose lengths are all co-prime? Then your effective key length would be the product of the length of all keys since they never line up with each other until that point.

It would be fantastic for key management since with keys of lengths 29, 31, and 37, your effective key length would be over 33,000! You could reuse them for many messages as long as you keep track of effective key length usage.

How would one go about cracking such a ciphertext, when its length is shorter than the product of N keys, whose lengths are all co-prime?

I posted this same question on Reddit here and got this apparent solution, but it's too vague for me to follow since the author didn't have the time to go into more detail.

• Do we assume that we have some plaintext as the in reddit? – kelalaka Sep 12 '18 at 8:08
• No, assume you only have ciphertext but know the lengths of the keys. – Meler Lawler Sep 12 '18 at 15:54

## 2 Answers

Turns out the way you break it is by using the Kullback Test.

If you have significant known plain text, you should be able to crack this even if you never encrypt more than the product of the key lengths.

Let's take keys of length p and q If the attacker doesn't know p there aren't likely to be many options so we can iterate over them.

For known p we look for known plain text fragments positioned a multiple of p apart. Reduce the ciphertext by the plain text, the differences at distance p*i give us the length q key. Which we remove and then we trivially find also the length p key.

• Would using more keys prevent this solution or just complicate it? – Meler Lawler Sep 14 '18 at 18:58
• Off the top of my head I can't think how to do this with many keys and when keeping a good distance from the product bound. If you can guess the product N and have known text i*N/p appart, same attack works. I suspect you can do better. – Meir Maor Sep 15 '18 at 4:08