On Wed, Oct 28, 2009 at 12:44:28AM -0700, himas wrote:
> 
> tried to run my decryption func with test vectors and got not proper result
> 
> ---------- CODE ----------
> void aes256cbc_encrypt()
> {
>     int i, outlen;
int i, outlen, tm;

>     unsigned char *outbuf = (unsigned char*)malloc(1024);
> 
>     unsigned char key[] =
> "0000000000000000000000000000000000000000000000000000000000000000";
unsigned char key[32] = {0,};

>     unsigned char iv[] = "00000000000000000000000000000000";
unsigned char iv[16] = {0,};

>     unsigned char inbuf[] = "014730f80ac625fe84f026c60bfd547d";
unsigned char inbuf[] =
   
{0x01,0x47,0x30,0xf8,0x0a,0xc6,0x25,0xfe,0x84,0xf0,0x26,0xc6,0x0b,0xfd,0x54,0x7d};
    

>     int inlen = sizeof(inbuf) - 1;
int inlen = sizeof(inbuf);

> 
>     EVP_CIPHER_CTX ctx;
>     const EVP_CIPHER *cipher;
> 
>     EVP_CIPHER_CTX_init(&ctx);
>     cipher = EVP_aes_256_cbc();
>     EVP_EncryptInit(&ctx, cipher, key, iv);
> 
>     EVP_EncryptUpdate(&ctx, outbuf, &outlen, inbuf, inlen);
>     EVP_EncryptFinal(&ctx, outbuf + outlen, &outlen);

EVP_EncryptFinal(&ctx, outbuf + outlen, &tm);
outlen += tm;

> 
>     for(i = 0; i < outlen; i++) printf("%02x", outbuf[i]);
> 
>     EVP_CIPHER_CTX_cleanup(&ctx);
>     free(outbuf);
> }
> ---------- CODE ----------
> 
> Result for this test vector should be "5c9d844ed46f9885085e5d6a4f94c7d7"
> 
> What am I doing wrong?

You mixed up ascii and binary as Mounir IDRASSI already told you before.

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

Reply via email to