Hi,
I've discovered that openssl-0.9.6 and openssl-0.9.6b (I didnt tested
other versions) produces broken PEM_read/write functions under WIN32.
Under linux works fine.
Exception occurs somewhere inside NTDLL.DLL with diagnostics:
"The instruction at "0x77f83941" referenced memory at "0x10". The
memory could not be "written".
I've compiled both with do_nasm and do_ms - results are identical.
Environment: W2k sp2, VC++6 sp5, nasm 0.96
I've tested this on 2 examples openssl\demos\selfsign.c
and the following:
=== rsa-play.c
#include <stdio.h>
#include <openssl/rsa.h>
#include <openssl/err.h>
#include <openssl/evp.h>
void genrsa_cb( int p, int n, void* x );
void main( int argc, char *argv[] ) {
RSA *rsa = NULL;
FILE *fp = NULL;
char *pp = "my passphrase";
ERR_load_crypto_strings();
printf("Generating key...\n");
fp = fopen("test-cert-store", "w");
rsa = RSA_generate_key(512, RSA_F4, genrsa_cb, NULL);
printf("Writing key...\n");
// trap here
PEM_write_RSAPrivateKey(fp, rsa, EVP_des_ede3_cbc(), pp, strlen(pp), NULL);
printf("Freeing key...\n");
RSA_free(rsa); rsa = NULL;
fclose(fp);
printf("Reading key...\n");
fp = fopen("test-cert-store", "r");
rsa = PEM_read_RSAPrivateKey(fp, NULL, NULL, NULL);
if (rsa == NULL) {
fprintf(stderr, "Unable to load private key.\n");
ERR_print_errors_fp(stderr);
} else {
RSA_print_fp(stdout, rsa, 0 );
}
RSA_free(rsa);
}
void genrsa_cb( int p, int n, void* x ) {
char c = '*';
if (p == 0) c='.';
else if (p == 1) c='+';
else if (p == 2) c='*';
else if (p == 3) c='\n';
fprintf(stderr, "%c", c);
}
=== rsa-play.c
ps: please cc me the answer, I'm not subscribed.
--
Best regards,
Andrew mailto:[EMAIL PROTECTED]
______________________________________________________________________
OpenSSL Project http://www.openssl.org
User Support Mailing List [EMAIL PROTECTED]
Automated List Manager [EMAIL PROTECTED]