On Wed, Sep 01, 2004, Fabrício Abrão Costa wrote:

> Hi There,
> I have a doubt about the encryption using the EVP_PKEY estructure.
> What happens is that I need get a private key from a Engine. This part is
> ok, I got the private key using the ENGINE_load_private_key.
> The next step is encrypt a plain text using the EVP_PKEY that I got, but the
> unique plain text cypher function I found is RSA_private_encrypt.
> I can´t get the RSA key from the EVP_PKEY estructure using the
> EVP_PKEY_get1_RSA because the engine, so I tryed use RSA_private encrypt
> function that´s way:
> return = RSA_private_encrypt(__messageLen,__plainMessage,
> out,__pKey->pkey.rsa, RSA_PKCS1_PADDING) where __pKey is a EVP_PKEY private
> key, but it didn´t worked, the function had the -1 return value.
> What I´m doing wrong? What I need do to encrypt a plain text using a
> EVP_PKEY structure?

I don't see why you can't call EVP_PKEY_get1_RSA() in fact your call above
does pretty much that.

Its not clear why that function failed: read the FAQ to see how to diagnose
function failures.

Also RSA_private_encrypt() is nearer a "sign" function that an "encrypt"
operation. If you want something only readable by someone with access to the
private key then RSA_public_encrypt() is more appropriate.

For general encryption its normal to combine RSA with a symmetric cipher using
the EVP_Seal*()/EVP_Open*() functions for example.

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]

Reply via email to