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@openssl.org
Automated List Manager                           majord...@openssl.org

Reply via email to