Dear all,

I'm trying to verify a string which has been signed by my private key, but whatever I seem to do |RSA_public_decrypt seems to crash. I just can't figure out what's going wrong. I've attached a snippet and any help is _really_ appreciated. I'm using Win32 OpenSSL 0.98e in MS Visual Studio 2005.

Regards,
Adam McCarthy
|
// unsigned char *data = "thisisateststring" but signed by the private key.

BIO *file = BIO_new_file("my_pub.pem", "r");
RSA* rsa_key = PEM_read_bio_RSA_PUBKEY(file, NULL, NULL, NULL);

ERR_clear_error();
if (rsa_key == NULL) { // No errors are logged
        std::ofstream logfile ("ssl.log", std::ios::app);
        logfile << ERR_reason_error_string(ERR_get_error()) << std::endl;
        logfile.close();
}

BIO_set_close(file, BIO_CLOSE);
BIO_free(file);

int len = RSA_size(rsa_key);
uint8_t* destination = new uint8_t[len];

// Crash
RSA_public_decrypt(sizeof(data), data, destination, rsa_key, RSA_PKCS1_PADDING);

Reply via email to