Hi Christian,

On Fri, 24 Aug 2012 08:11:25 +0200 Christian Hohnstaedt wrote:
> please see my comments below:
> (rather Qt and memory related)

Thank you for your feedback. Now I'm trying the implement the function
which does exactly the opposite: Take the public and private key in
the PEM format from the server and import it in a RSA structure:

void Encryption::pem2key(QString publickey, QString privatekey, QString 
password)
{
    BIO *pubBio = BIO_new_mem_buf(publickey.toLocal8Bit().data(), 
strlen(publickey.toLocal8Bit().data()));
    BIO *privBio =  BIO_new_mem_buf(privatekey.toLocal8Bit().data(), 
strlen(privatekey.toLocal8Bit().data()));
    RSA *rsa = RSA_new();

    PEM_read_bio_RSAPublicKey(pubBio, &rsa, 0, NULL);
    PEM_read_bio_RSAPrivateKey(privBio, &rsa, 0, password.toLocal8Bit().data());

    Keymanager::Instance()->setRSAkey(rsa);

    BIO_free_all(pubBio);
    BIO_free_all(privBio);
}


The program compiles and run without a problem. But if I call the
key2pem() function with the newly imported RSA key. I get two quite
short keys back (only half a line of data). So something seems to go
wrong during import of the PEM encoded keys.

Any idea what I'm doing wrong in the pem2key() function?

Thanks!
Björn

______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    openssl-users@openssl.org
Automated List Manager                           majord...@openssl.org

Reply via email to