Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

Re: Crypt::CipherSaber replacement... Crypt::CBC?

by hardburn (Abbot)
on Apr 30, 2010 at 16:02 UTC ( #837807=note: print w/replies, xml ) Need Help??

in reply to Crypt::CipherSaber replacement... Crypt::CBC?

I'm going to have to disagree with the above posters--stay away from RC4. Although it's technically not busted straight out, it's very fragile to use in practice. Microsoft has a whole list of bugs regarding RC4 going back to NT3 and up through at least the first XBox. WEP's insecurity also stems from poor use of RC4.

I'd suggest going with Crypt::CBC using AES (Rijndael).

"There is no shame in being self-taught, only in not trying to learn in the first place." -- Atrus, Myst: The Book of D'ni.

  • Comment on Re: Crypt::CipherSaber replacement... Crypt::CBC?

Replies are listed 'Best First'.
Re^2: Crypt::CipherSaber replacement... Crypt::CBC?
by hardburn (Abbot) on Apr 30, 2010 at 16:46 UTC

    After thinking about it some more, I can almost guarantee your system is insecure.

    The way stream ciphers like RC4 work is to take a key as a seed value to a pseudo-random number generation function. Each bit of output in the PRNG is XOR'd with the data (much like an OTP).

    The problem with this is that if you use the same encryption key twice (which I assume your password database would be, and is also where Microsoft screwed up with NT3), an attacker can easily recover the key by comparing the two encrypted values. This can also be a problem when encrypting large amounts of data with the same key (which is where WEP screwed up).

    The solution is to stick with block ciphers like AES.

    "There is no shame in being self-taught, only in not trying to learn in the first place." -- Atrus, Myst: The Book of D'ni.

      I can actually nearly guarantee his system is secure...

      You are correct that using the same key twice with the RC4 algorithm alone would indeed create two streams that could be used to derive the keystream. However, this is what the initialization vector is for. It's appended to the key before encryption and sent in the clear to be used for decryption. It's not part of the key (it's no secret), but it ensures that two identical messages sent with identical keys will always result in different keystreams (and ciphertext). Two examples of ciphersaber-created ciphertext cannot simply be XOR'd together to glean anything useful.

      The way these IV's are chosen and they way they express themselves in the ciphertext can be determined looking at a rather large number of messages with the same key. THIS is why WEP is screwed up. If you create the key array more than once (ciphersaber-2 does this), or don't use the key many times, it's secure.

      I know this is very old, but I can't leave a page that's relatively prevalent on Google searches with significant errors on it. RC4 with properly chosen keys is not broken by any means.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://837807]
[Corion]: haukex: Yes, but if it's only supposed to run on my machine, I can be far more liberal with how I extract the code etc.
[Corion]: haukex: Yes - I see the benefit of using Dist::Zilla for people with 150+ modules on CPAN, but I don't see it for myself, and I'm always put off from contributing to such modules because they require a lot of toolchain setup that I don't want to ...
[Corion]: ... spend time on if I only want to provide a short patch
[haukex]: Corion: Yes exactly, in the author tests I don't worry about portability as much, I also don't list the author tests' dependencies in Makefile.PL
[haukex]: I figure someone who wants to contribute will know how to install the missing modules ;-) Not the nicest way to go but I don't think many people are using my modules yet
[ambrus]: Corion: some of these stupid syntax highlighters assume that too. just look at the table in http://perldoc. functions/pack. html for example.

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (11)
As of 2017-02-27 12:37 GMT
Find Nodes?
    Voting Booth?
    Before electricity was invented, what was the Electric Eel called?

    Results (385 votes). Check out past polls.