Hello,

Do not pad with spaces, look at:
http://en.wikipedia.org/wiki/Padding_%28cryptography%29

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


owner-openssl-us...@openssl.org wrote on 05/11/2012 11:08:52 PM:

> <scott...@csweber.com> 
> Sent by: owner-openssl-us...@openssl.org
> 
> 05/11/2012 11:11 PM
> 
> Please respond to
> openssl-users@openssl.org
> 
> To
> 
> openssl-users@openssl.org
> 
> cc
> 
> Subject
> 
> RE: Looking for (easy) help.
> 
> Thanks for your reply, but that's not doing it.
> I manually padded the input in the C code with spaces.  Then I manually 
padded the input file with
> spaces.  Now both cleartexts are exactly 16 bytes long.
> 
> The output from the openssl executable is now 32 bytes...?  Where did it 
decide to do that?
> 
> The API call has a value of 16 in your code, which matches the cleartext 
in your code.
> 
> So what is going on?
> 
> So, what do I decide how to pad?  How far out do I pad it?
> 
> I've been trying different combinations for two days, a lot more test 
configurations then you 
> would like to see me post here.  Under no condition can I get an output 
from the API that matches 
> the output from the openSSL executable.  Nor can I get the executable to 
decrypt any data from theAPI calls.
> 
> -------- Original Message --------
> Subject: Re: Looking for (easy) help.
> From: marek.marc...@malkom.pl
> Date: Fri, May 11, 2012 10:15 am
> To: openssl-users@openssl.org
> Cc: openssl-users@openssl.org, owner-openssl-us...@openssl.org
> 
> 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 
> ______________________________________________________________________ 
OpenSSL Project http://
> www.openssl.org User Support Mailing List openssl-users@openssl.org 
Automated List Manager 
> majord...@openssl.org 
______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    openssl-users@openssl.org
Automated List Manager                           majord...@openssl.org

Reply via email to