RE: AES-256 CBC encrypt/decrypt usage problem

2010-05-25 Thread David Schwartz
Kunal Sharma wrote: >What I see happening is this: >ENCRYPT - size of /etc/rgconf on disk is 157043 bytes >ENCRYPT - size of /etc/rgconf_encrypted on disk is 157044 bytes. >BROWSER saves the file to disk - size is 136 bytes (How ???) You called 'strlen' on something that was not a string, so it

Re: AES-256 CBC encrypt/decrypt usage problem

2010-05-25 Thread ~ Kunal Sharma ~
Friends, I was able to resolve the problem with my web application not able to read the entire contents of encrypted file. Now my encryption and decryption is working ok. Thanks for all the help. Kunal On Sat, May 22, 2010 at 12:34 AM, ~ Kunal Sharma ~ wrote: > Ok friends. I'm back after tryi

Re: AES-256 CBC encrypt/decrypt usage problem

2010-05-21 Thread ~ Kunal Sharma ~
Ok friends. I'm back after trying out EVP stuff. Here's my code: DECRYPT int wfd; if((wfd = creat("/etc/rgconf_encrypted",0644)) == -1) { console_printf("Couldn't open output file for writingn"); }else{ console_printf("\nuser input encrypted file len

Re: AES-256 CBC encrypt/decrypt usage problem

2010-05-21 Thread ~ Kunal Sharma ~
Thanks Jeff, Carter. I'm in the process of trying out EVP routines to do my stuff now. Will post an update once I'm done. Thanks again for your time. - Kunal On Fri, May 21, 2010 at 5:55 PM, Carter Browne wrote: > Kunal, > > If your data can include NULs, you should not use strlen to calculat

Re: AES-256 CBC encrypt/decrypt usage problem

2010-05-21 Thread Carter Browne
Kunal, If your data can include NULs, you should not use strlen to calculate the length of the buffer, you need to provide the length in some other way - in your example presumably as an additional parameter. Carter Carter Browne CBCS cbro...@cbcs-usa.com 781-721-2890 On 5/21/2010 2:30 AM, ~ K

Re: AES-256 CBC encrypt/decrypt usage problem

2010-05-21 Thread Jeffrey Walton
Hi Kunal, > I was also wondering about the cipher block size. I was thinking > of using 16 as block size, read the input ... You have no choice. AES is a 16-byte block cipher. Using the EVP_* functions is easier. Jeff On Fri, May 21, 2010 at 2:30 AM, ~ Kunal Sharma ~ wrote: > David, > Thanks f

Re: AES-256 CBC encrypt/decrypt usage problem

2010-05-20 Thread ~ Kunal Sharma ~
David, Thanks for taking out time to review my code and reply. 1) I agree that using sizeof was a blunder on my part. 2) I'm calling decode2 with rg_conf_buf_dup and rg_conf_buf_dup_2, second one being the output buffer. So I'm certain that I don't modify the input buffer (though I just zero out

RE: AES-256 CBC encrypt/decrypt usage problem

2010-05-20 Thread David Schwartz
Kunal Sharma wrote: void encode2(char *inbuf,char *outbuf) { unsigned char key32[] = "As different as chalk and cheese"; unsigned char iv[] = "As dark as pitch"; AES_KEY aeskey; memset(outbuf, 0, sizeof(outbuf)); AES_set_encrypt_key(key32, 32*8,

AES-256 CBC encrypt/decrypt usage problem

2010-05-20 Thread ~ Kunal Sharma ~
Friends, This is the first time I'm using Openssl for some small job to encrypt and decrypt buffers for my application usage. My requirement is simple: 1) My application gets a buffer that needs to be encrypted. 2) My application gets a buffer that needs to be decrypted. This buffer can be exactl