On 17/11/2011 16:08, Ivan Voras wrote:
> On 17/11/2011 15:21, Jakob Bohm wrote:
>> On 11/17/2011 3:05 PM, Ivan Voras wrote:
>>> Hello,
>>>
>>> I'm having trouble using AES_cfb128_encrypt() - I've isolated it to the
>>> simple example below. The problem is that the decryption doesn't work -
>>> the output (in buf3) is binary gibberish.
>>>
>>>          SHA256(key, key_size, enc_key);
>>>          AES_set_encrypt_key(enc_key, 256,&aes_enc_key);
>>>          AES_set_decrypt_key(enc_key, 256,&aes_dec_key);
>>>
>>>          memcpy(buf1, str, str_size);
>>>          dump_data(buf1, str_size, "1");
>>>
>>>          num = 0;
>>>          memset(iv, 0, 16);
>>>          AES_cfb128_encrypt(buf1, buf2, str_size,&aes_enc_key, iv,&num,
>>> AES_ENCRYPT);
>>>          dump_data(buf2, str_size, "2");
>>>
>>>          num = 0;
>>>          memset(iv, 0, 16);
>>>          AES_cfb128_encrypt(buf2, buf3, str_size,&aes_dec_key, iv,&num,
>>> AES_DECRYPT);
>> Shouldn't this be AES_cfb128_decrypt() ?
> 
> No, there is only AES_cfb128_encrypt() and it receives an argument
> telling it what to do (AES_ENCRYPT or AES_DECRYPT).

But your question was in the right direction :) Actually it was obvious
- since CFB generates a keystream, the same key must be used in both
direction (i.e. no separate key schedule for decryption).


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

Reply via email to