On Thu, Oct 28, 2010, Bob Dijck wrote:

> Hello,
> 
> I am trying to implement a signing function in C++ using RSA.  Here's how I
> wanted to do this: - First I calculate the SHA1 hash (not using openssl but
> another implementation).  - But then what? Should I use RSA_private_encrypt
> or rsa_sign? When I use RSA_private_encrypt the result is different from
> when I use rsa_sign... The openssl support pages mention that in case of
> RSA_PKCS1_PADDING (that's the one I use) I should use rsa_sign. Is there any
> way around this?
> 
> I thought that signing was a two step process: hash + RSA encryption of
> hash. Am I doing something wrong?
> 

The usual form of RSA signature is a three step process. Calculate hash,
encapsulate hash in a DigestInfo structure, RSA private key encrypt the
structure.

If you use RSA_sign() all three steps are performed, for RSA_private_encrypt()
the encapsulation is not performed.

Steve.
--
Dr Stephen N. Henson. OpenSSL project core developer.
Commercial tech support now available see: http://www.openssl.org
______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    openssl-users@openssl.org
Automated List Manager                           majord...@openssl.org

Reply via email to