[Q] How to encrypt using DES?

View: New views
4 Messages — Rating Filter:   Alert me  

[Q] How to encrypt using DES?

by JongAm Park-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello. May I ask how to encrypt a key in DES?

According to its MAN page, it says to generate a DES_key_schedule  
first, and do the actual encryption.

So, I called functions like this.


DES_cblock aKey;

DES_random_key( &aKey );

DES_key_schedule keySchedule;
int result;

result = DES_set_key_checked( &aKey, &keySchedule );

DES_ecb_encrypt( ?, ?, &keySchedule);

So, to encrypt an original string to cyphertext, the 1st parameter  
seems to contain the original text.
However, it should be of type DES_cblock or const_DES_cblock. Then is  
it same to the "aKey"?
Then how to seed the key, "aKey"?

Or if I try this..

DES_cblock inputBlock = {
                'E', 'n', 'c', 'o', 'd', 'e', 'M', 'e'
        };

       
DES_cblock outputBlock;
       
DES_key_schedule keySchedule;

int result;
result = DES_set_key_checked( &inputBlock, &keySchedule );
       
DES_ecb_encrypt( &inputBlock, &outputBlock, &keySchedule, DES_ENCRYPT );

The result is -1 when the DES_set_key_checked() is called. Should I  
use DES_set_key_unchecked()?

I would appreciate any help.
I am lost totally!

JongAm Park
______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    openssl-users@...
Automated List Manager                           majordomo@...

Re: [Q] How to encrypt using DES?

by Dr. Stephen Henson :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Sun, Nov 08, 2009, JongAm Park wrote:

> Hello. May I ask how to encrypt a key in DES?
>
> According to its MAN page, it says to generate a DES_key_schedule first,
> and do the actual encryption.
>

Actually I'd say you're beginning from the wrong place. The low level APIs
like DES shouldn't really be used directly if at all possible. If you start
with the higher level EVP_EncryptInit_ex() API you should find it easier: that
is a common interface to all ciphers.

Steve.
--
Dr Stephen N. Henson. OpenSSL project core developer.
Commercial tech support now available see: http://www.openssl.org
______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    openssl-users@...
Automated List Manager                           majordomo@...

Re: [Q] How to encrypt using DES?

by JongAm Park-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thank you for your reply.

Is there any tutorial or code samples?

Thank you.
JongAm Park

On Nov 8, 2009, at 3:42 PM, Dr. Stephen Henson wrote:

EVP_EncryptInit_ex


Re: [Q] How to encrypt using DES?

by JongAm Park-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thank you very much.

I could figure out how to use functions to cipher/decipher using DES
algorithm with the high level function.
I rewrote codes written with low level functions.

I also found something weird, but reasonable behavour of *Update*
functions, and posted a blog entry to my blog. (It's written in Korean,
though. )

Thank you again for guiding me. :)
JongAm Park

Dr. Stephen Henson wrote:

> On Sun, Nov 08, 2009, JongAm Park wrote:
>
>  
>> Hello. May I ask how to encrypt a key in DES?
>>
>> According to its MAN page, it says to generate a DES_key_schedule first,
>> and do the actual encryption.
>>
>>    
>
> Actually I'd say you're beginning from the wrong place. The low level APIs
> like DES shouldn't really be used directly if at all possible. If you start
> with the higher level EVP_EncryptInit_ex() API you should find it easier: that
> is a common interface to all ciphers.
>
> Steve.
> --
> Dr Stephen N. Henson. OpenSSL project core developer.
> Commercial tech support now available see: http://www.openssl.org
> ______________________________________________________________________
> OpenSSL Project                                 http://www.openssl.org
> User Support Mailing List                    openssl-users@...
> Automated List Manager                           majordomo@...
>
>  

______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    openssl-users@...
Automated List Manager                           majordomo@...