Thread: About 3DES CBC in OpenSSL

  1. #1
    Registered User
    Join Date
    Apr 2012
    Posts
    49

    About 3DES CBC in OpenSSL

    Can anyone provide this example for me?
    Can anyone tell me what is the meaning of IV? many thanks!!

  2. #2
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,980
    >> Can anyone provide this example for me?
    Learn how to do it on the command line first: OpenSSL: Documents, enc(1)

    >> Can anyone tell me what is the meaning of IV?
    https://en.wikipedia.org/wiki/Cipher...ning_.28CBC.29

    gg

  3. #3
    Registered User
    Join Date
    Apr 2012
    Posts
    49
    Code:
    char in[bufsize],out[bufsize],back[bufsize],workvec[bufsize];
        des_cblock key1,key2,key3,seed = {0xFE,0xDC,0xBA,0x98,0x76,0x54,0x32,0x10};
        des_key_schedule ks1,ks2,ks3;
        const char *temp="plain text";
        int len=strlen(temp);
        char clear[len+1];
        strcpy(in,temp);
        //strcpy(in,"1 2 3 4 5 6 7 8 9 a b c d e f g h i j k l m n o p q r s t u v w x y z");
        des_random_seed(seed);
        des_random_key(key1);
        des_random_key(key2);
        des_random_key(key3);
        des_set_key((C_Block *)key1,ks1);
        des_set_key((C_Block *)key2,ks2);
        des_set_key((C_Block *)key3,ks3);
        /* This work vector can be intialized t anything ...*/
        memset(workvec,0,bufsize);
        des_ede3_cbc_encrypt((C_Block *)in,(C_Block *)out,(long)strlen(in),ks1,ks2,ks3,(C_Block *)workvec,DES_ENCRYPT);

    Hi I have found a source code about the 3DES,
    Code:
    des_cblock key1,key2,key3,seed = {0xFE,0xDC,0xBA,0x98,0x76,0x54,0x32,0x10};
    <---what is the meaning the default value, the "des_ramdon_key will not random the key?

    Code:
    memset(workvec,0,bufsize);
    <------workvec is equal to IV?

  4. #4
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,980
    >> what is the meaning [of] the default value [for 'seed'], the "des_ramdon_key" will not random the key?
    By using a specific "seed" value, the same 3 keys will be generated on each run of the code (assuming a deterministic PRNG is used).

    >> workvec is equal to IV?
    Yes. So to decrypt the message, you will need to know: key1, key2, key3, and workvec.

    gg

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. openssl decryption
    By kakashi316 in forum C Programming
    Replies: 1
    Last Post: 03-24-2012, 11:02 AM
  2. Need help with OpenSSL
    By Ricardo_R5 in forum C Programming
    Replies: 0
    Last Post: 05-07-2007, 06:18 PM
  3. Using OpenSSL with Dev-C++
    By Smiley10 in forum C Programming
    Replies: 2
    Last Post: 07-08-2006, 10:27 AM
  4. openssl on win2k
    By rzcodeman in forum Networking/Device Communication
    Replies: 4
    Last Post: 04-09-2004, 07:58 PM
  5. OpenSSL and Win32 SSL API :: SSL/TLS
    By kuphryn in forum Networking/Device Communication
    Replies: 0
    Last Post: 03-10-2004, 07:46 PM