2

I am an a-level student writing an encryption program using an rc4 implementation I have written myself. I have the basic algorithm coded correctly (and I have checked that some ciphertext for a given key and plaintext matched another online rc4 implementation by a credible source). I have added a drop(n) method that discards n bytes of the keystream (768 by default).

I am aware of rc4's vulnerabilities and understand that it is a lot more effort to patch these flaws than to use a different method of encryption. But in the quest for understanding over security, how would I combine a reused key and a unique initialization vector in a secure way? How would I store the initialization vector for use when decrypting. Finally how strong is a key that is a created by the user?

1

how would I combine a reused key and a unique initialization vector in a secure way?

The standard method of combining the key and IV in RC4 to avoid vulnerabilities is to concatenate them and pass them through a cryptographic hash, and use that hash's digest as your RC4 key. This defeats the severe related key attacks that can allow recovery of the key by destroying the exploitable relations.

How would I store the initialization vector for use when decrypting.

This entirely depends on the protocol. The IV can be either stored, or derived deterministically in a way that is guaranteed to be unique (such as from a session ID, packet number, or monotonic counter).

Finally how strong is a key that is a created by the user?

If the key is composed of at least 16 completely random bytes, then it should be sufficiently secure that brute force attacks will not be an issue. Note that RC4 is still not a great cipher even if the key is very strong. Even when dropping the early keystream, there are still long-lived biases that can be exploited

  • the t target key problem of Block ciphers exists here, too. If you have a billion target (~2^30) the cost will be ~2^98 to find one of the target keys. – kelalaka Apr 7 at 13:29
  • @kelalaka Yeah but if you're using RC4, you have more serious things to worry about than batch attacks. – forest Apr 8 at 2:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.