My fault Dr. Henson. The segmentation fault exists in the statement: err = EVP_PBE_CipherInit (alg->algorithm, passwd, strlen(passwd), alg->parameter, &ctx, 1);
Once again the code is a shortened version of the actual encrypt/decrypt code.
int main()
{
EVP_CIPHER_CTX ctx;
X509_ALGOR *alg=NULL;
unsigned char *passwd = "password";
unsigned char *message = "Test message";
unsigned char *salt = "salt";
int bytes_enc, bytes_final, bytes_dec, err;
unsigned char *dec_buff = NULL, *enc_buff = NULL;
OpenSSL_add_all_algorithms();
ERR_load_crypto_strings();
alg = PKCS5_pbe2_set (EVP_des_ede3_cbc(), 1024, salt, strlen(salt));
if (alg == NULL)
{
ERR_print_errors_fp(stderr);
exit(1);
}
err = EVP_PBE_CipherInit (alg->algorithm, passwd, strlen(passwd), alg->parameter, &ctx, 1);
if ( err == 0 )
{
ERR_print_errors_fp(stderr);
exit(1);
}
}
Also, the salt is just for testing.....thanx for the advice anyways.
Thanks,
Joe
"Dr. Stephen Henson" <[EMAIL PROTECTED]> wrote:
"Dr. Stephen Henson" <[EMAIL PROTECTED]> wrote:
On Mon, Jul 19, 2004, Joe smith wrote:
> Hi,
> I tried modifying the code and now I get a segmentation fault on this line:
>
> err = EVP_CipherUpdate (&ctx, enc_buff, &bytes_enc, message, strlen(message));
>
[code snipped]
Hard to say since the call to EVP_CipherUpdate() isn't included. If enc_buff
is NULL then that would cause that problem. enc_buff should be at least one
block size larger than the plaintext length.
Oh and BTW setting 'salt' to a constant string isn't a good idea. If you keep
it as NULL and the length as -1 a random salt will be used.
Steve.
--
Dr Stephen N. Henson. Email, S/MIME and PGP keys: see homepage
OpenSSL project core developer and freelance consultant.
Funding needed! Details on homepage.
Homepage: http://www.drh-consultancy.demon.co.uk
______________________________________________________________________
OpenSSL Project http://www.openssl.org
User Support Mailing List [EMAIL PROTECTED]
Automated List Manager [EMAIL PROTECTED]
Do you Yahoo!?
Vote for the stars of Yahoo!'s next ad campaign!