Thank you very much,
Regards
Nigel
Dr. Stephen Henson wrote:
Comments inline:
On Wed, Sep 02, 2009, Nigel Sollars wrote:
Hi,
After looking at other examples, decided to go back to basic tried a simple
approach at taking a string argv and passing that to the enc/dec methods,
Seems i have the same errorcode as before. I have provided the testfile
any help with this one would be very much appreciated.
unsigned char *iv[8];
unsigned char *password[16];
Definitions of iv, password are wrong. Get rid of the '*'.
string = argv[1];
RAND_bytes(iv, 8);
RAND_bytes(password, 16);
printf("Entering Encryption Stage:\n\n");
printf("String to encrypt: %s\n\n", string);
EVP_CIPHER_CTX_init(&ectx);
EVP_EncryptInit(&ectx, EVP_bf_cbc(), password, iv);
bzero (&enc_inbuf, input_buf_size);
if(!EVP_EncryptUpdate(&ectx, enc_outbuf, &encoutlen, string,
strlen(string)))
{
printf("Error whilst EncryptUpdate\n");
return 0;
}
if(!EVP_EncryptFinal(&ectx, enc_outbuf + encoutlen, &enctotallen))
{
printf("Error Whilst EncryptFinal\n");
return 0;
}
encoutlen += enctotallen;
OK, you've got the total length of the encrypted data as "encoutlen" at this
point.
printf("Encryption Successful\n\n");
printf("Entering Decryption Stage\n\n");
EVP_CIPHER_CTX_init(&dctx);
EVP_DecryptInit(&dctx, EVP_bf_cbc(), password, iv);
bzero (&dec_inbuf, output_buf_size);
bzero (&dec_outbuf, input_buf_size);
if (!(EVP_DecryptUpdate(&dctx, dec_outbuf, &decoutlen, enc_outbuf,
output_buf_size)))
{
printf("Error Whilst DecryptUpdate\n");
return 0;
}
But above you are passing the length as output_buf_size.
Steve.
--
Dr Stephen N. Henson. OpenSSL project core developer.
Commercial tech support now available see: http://www.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