Hello,

Parametr "-nosalt" is not used in this case.

I have attached my test code, to use this example save file aes_enc.c and 
execute:

# gcc -Wall -pedantic -o aes_enc -lcrypto aes_enc.c

# ./aes_enc | od -x
0000000 e61f b8eb c202 6df8 4cc4 631e 4bf2 dedd
0000020

# ./aes_enc > enc.bin

# openssl aes-256-cbc -in enc.bin -K 
000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F -iv 
000102030405060708090A0B0C0D0E0F -d
marek

I other words, when you prepare source buffer for excryption you shoud 
manualy pad this data.

Best regards,
--
Marek Marcola <marek.marc...@malkom.pl>



owner-openssl-us...@openssl.org wrote on 05/11/2012 03:43:01 PM:

> <scott...@csweber.com> 
> Sent by: owner-openssl-us...@openssl.org
> 
> 05/11/2012 03:46 PM
> 
> Please respond to
> openssl-users@openssl.org
> 
> To
> 
> openssl-users@openssl.org
> 
> cc
> 
> Subject
> 
> Looking for (easy) help.
> 
> (resent, as I never saw this come through the list server)
> I am looking for some assistance.  This should be really easy.  But it's 
not working. 
> Any quick advice I can get would be appreciated.
> 
> When I use the API, I get a different cypher text then I get from the 
command line.
> And the command line appears to be the correct one, as it also matches 
the cypher text I
> get when I use the PHP interface.
> (Once I get the encryption working, I assume the PHP would decrypt it 
easily, which is my goal)
> 
> The clear text I am using is simply 6 letters in a file.  The file does 
NOT contain a 
> newline, and neither does the hardcoded buffer used in the C source.
> 
> The cypher I get is  (hex string):
> from openssl EXE:       aed38175d75ea94e7e59833f11400dcf
> From C code:               35709aab6f31555a378bc4a6107f3bd0 
> 
> So, here's the code.  Really easy stuff.  The Key and IV are the same, 
> 
> ---  Command line ----
> openssl
>         enc -aes-256-cbc
>         -in infile.txt -K 
3131313131313131313131313131313131313131313131313131313131313131
>         -iv fbd070327199c9df7760c5a113bed7a3
>         -nosalt -out cypher.bin
> 
> ---- C code:
> static unsigned char initVect[] = {
>         0xfb,0xd0,0x70,0x32,0x71,0x99,0xc9,0xdf,
>         0x77,0x60,0xc5,0xa1,0x13,0xbe,0xd7,0xa3
> };
> 
> static const unsigned char key32[] = 
> {"11111111111111111111111111111111"};
> 
> void AES256Encrypt(unsigned char  *dst, const char *src, int len) {
> 
>     AES_KEY aeskey;
>     unsigned char iv[sizeof(initVect)]; /* Our own personal copy of the 
initialization */
>     memcpy(iv,initVect,sizeof(initVect)); /* vector, to handle the fact 
that it's not CONST */
> 
>     AES_set_encrypt_key(key32, 256, &aeskey);
>     AES_cbc_encrypt((unsigned char *)src, (unsigned char *) dst, len, 
&aeskey, iv, AES_ENCRYPT);
> }
> 
> Any help is appreciated!
> 
> -Scott Weber
> 
> ______________________________________________________________________ 
OpenSSL Project 
> http://www.openssl.org User Support Mailing List 
openssl-users@openssl.org Automated 
> List Manager majord...@openssl.org 

Attachment: aes_enc.c
Description: Binary data

Reply via email to