Maurice,
There is a similar (identical?) function in the OpenSSL crypto library
called RSA_sign() that you can look at and compare to your engine
implementation. If this engine version is to behave the same as RSA_sign(),
the type argument tells you what digest algorithm OID you must put in the
payload block that gets RSA private-key encrypted. RSA_sign() is supposed to
produce an RSA signature as specified in PKCS #1, v1.5, section 10
(http://www.rsalabs.com/pkcs/pkcs-1/index.html) (except for the SSL MD5+SHA1
type, which gets RSA encrypted directly with no digest algorithm OID). The
data block that gets encrypted with the RSA private key looks like (from
high-order byte on the left to low-order byte on the right):
00 01 FF FF ...FF 00 D1 D2 ... Dn
The D1 .. Dn are just the ASN.1 encoding of a DigestInfo structure which is
defined in PKCS#1 as:
DigestInfo ::= SEQUENCE {
digestAlgorithm DigestAlgorithmIdentifier,
digest OCTET STRING
}
The digest part is just m[0] ... m[m_len-1], properly encoded as an OCTET
STRING. The digestAlgorithm is the trickier part, since all you are given is
an integer ID. You must map this ID into the correct string of OID bytes to
put in there, but again you can just grab the stuff you need from RSA_sign()
and the stuff in crypto/objects.
I would imagine that, at a minimum, you need to support MD5, SHA1, and the
special SSL MD5+SHA1 hashing algorithms, which correspond to type argumenst
of NID_md5, NID_sha1, and NID_md5_sha1. The SSL MD5_SHA1 algorithm is just
direct RSA encryption, so the data block looks like
00 01 FF FF ... FF 00 D1 D2 ... D36
_____________________________________
Greg Stark
Ethentica, Inc.
[EMAIL PROTECTED]
_____________________________________
----- Original Message -----
From: "Maurice Gittens" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, April 13, 2001 8:48 AM
Subject: Implementing engine sign method
> Hi,
>
> working on the implemention of a driver for a hardware crypto device I've
> encountered a little problem.
>
> The prototype for the RSA sign method in the openssl engine code contains
a
> type argument
> which specifies the type of signature to be generated.
>
> int rsa_sign(int type, unsigned char *m, unsigned int m_len,
> unsigned char *sigret, unsigned int *siglen, RSA *rsa)
>
> My questions are:
> 1. How can I find out more about the types of signatures I will need to
> generate in the driver?
> 2. Is the data supplied to the sign function encoded in some special way?
>
> Any help will be appreciated.
>
> With kind regards from Maurice.
>
>
> ______________________________________________________________________
> OpenSSL Project http://www.openssl.org
> Development Mailing List [EMAIL PROTECTED]
> Automated List Manager [EMAIL PROTECTED]
______________________________________________________________________
OpenSSL Project http://www.openssl.org
Development Mailing List [EMAIL PROTECTED]
Automated List Manager [EMAIL PROTECTED]