Forum: Ruby Encrypting using openssl Triple-DES

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
2849c70454818746006e84ea9508bc51?d=identicon&s=25 Dani Pardo (dani)
on 2008-10-20 17:57
(Received via mailing list)
Hi, I need to encrypt some data using Triple DES in ECB mode
(DES-EDE3-ECB), but I don't know how to do it. If I create the cipher
like this:

e = OpenSSL::Cipher::Cipher.new 'DES-EDE3'

It seems (man enc) that des-ede3 is an alias for des-ede3-cbc, so
there seems to be no way of encrypting with des-ede3-ecb?

 Thanks in advance,
753dcb78b3a3651127665da4bed3c782?d=identicon&s=25 Brian Candler (candlerb)
on 2008-10-21 10:04
Dani Pardo wrote:
> Hi, I need to encrypt some data using Triple DES in ECB mode
> (DES-EDE3-ECB), but I don't know how to do it. If I create the cipher
> like this:
>
> e = OpenSSL::Cipher::Cipher.new 'DES-EDE3'
>
> It seems (man enc) that des-ede3 is an alias for des-ede3-cbc, so
> there seems to be no way of encrypting with des-ede3-ecb?

'man enc' on my system says:

        des-ede3-cbc       Three key triple DES EDE in CBC mode
        des-ede3           Three key triple DES EDE in ECB mode
        des3               Alias for des-ede3-cbc
        des-ede3-cfb       Three key triple DES EDE CFB mode
        des-ede3-ofb       Three key triple DES EDE in OFB mode

That is: "des-ede3" gives you ECB.

This is with:

ii  libssl0.9.8                            0.9.8g-4ubuntu3.3
SSL shared libraries

So perhaps you have some old version of openssl installed - or perhaps
you didn't read the manpage properly.

In any case, I'd suggest that openssl-specific questions really belong
on an openssl mailing list, since this wasn't anything to do with the
Ruby bindings.
2849c70454818746006e84ea9508bc51?d=identicon&s=25 Dani Pardo (dani)
on 2008-10-21 10:51
(Received via mailing list)
On Tue, Oct 21, 2008 at 10:02 AM, Brian Candler <b.candler@pobox.com>
wrote:
be no way of encrypting with des-ede3-ecb?
>
> This is with:
>
> ii  libssl0.9.8                            0.9.8g-4ubuntu3.3
> SSL shared libraries
>
> So perhaps you have some old version of openssl installed - or perhaps
> you didn't read the manpage properly.
>

 Indeed, on previous openssl versions, des-ede3 was an alias for
triple des with cbc mode.
 The problem now is that ruby uses its own shared library (openssl.dll
/openssl.so). And openssl doesn't seem to come with any file named
openssl.dll/.so, so I don't know how to upgrade this now, especially
on Windows. :?
This topic is locked and can not be replied to.