xref: /onnv-gate/usr/src/common/openssl/doc/crypto/RSA_sign.pod (revision 2175:b0b2f052a486)
1*2175Sjp161948=pod
2*2175Sjp161948
3*2175Sjp161948=head1 NAME
4*2175Sjp161948
5*2175Sjp161948RSA_sign, RSA_verify - RSA signatures
6*2175Sjp161948
7*2175Sjp161948=head1 SYNOPSIS
8*2175Sjp161948
9*2175Sjp161948 #include <openssl/rsa.h>
10*2175Sjp161948
11*2175Sjp161948 int RSA_sign(int type, const unsigned char *m, unsigned int m_len,
12*2175Sjp161948    unsigned char *sigret, unsigned int *siglen, RSA *rsa);
13*2175Sjp161948
14*2175Sjp161948 int RSA_verify(int type, const unsigned char *m, unsigned int m_len,
15*2175Sjp161948    unsigned char *sigbuf, unsigned int siglen, RSA *rsa);
16*2175Sjp161948
17*2175Sjp161948=head1 DESCRIPTION
18*2175Sjp161948
19*2175Sjp161948RSA_sign() signs the message digest B<m> of size B<m_len> using the
20*2175Sjp161948private key B<rsa> as specified in PKCS #1 v2.0. It stores the
21*2175Sjp161948signature in B<sigret> and the signature size in B<siglen>. B<sigret>
22*2175Sjp161948must point to RSA_size(B<rsa>) bytes of memory.
23*2175Sjp161948
24*2175Sjp161948B<type> denotes the message digest algorithm that was used to generate
25*2175Sjp161948B<m>. It usually is one of B<NID_sha1>, B<NID_ripemd160> and B<NID_md5>;
26*2175Sjp161948see L<objects(3)|objects(3)> for details. If B<type> is B<NID_md5_sha1>,
27*2175Sjp161948an SSL signature (MD5 and SHA1 message digests with PKCS #1 padding
28*2175Sjp161948and no algorithm identifier) is created.
29*2175Sjp161948
30*2175Sjp161948RSA_verify() verifies that the signature B<sigbuf> of size B<siglen>
31*2175Sjp161948matches a given message digest B<m> of size B<m_len>. B<type> denotes
32*2175Sjp161948the message digest algorithm that was used to generate the signature.
33*2175Sjp161948B<rsa> is the signer's public key.
34*2175Sjp161948
35*2175Sjp161948=head1 RETURN VALUES
36*2175Sjp161948
37*2175Sjp161948RSA_sign() returns 1 on success, 0 otherwise.  RSA_verify() returns 1
38*2175Sjp161948on successful verification, 0 otherwise.
39*2175Sjp161948
40*2175Sjp161948The error codes can be obtained by L<ERR_get_error(3)|ERR_get_error(3)>.
41*2175Sjp161948
42*2175Sjp161948=head1 BUGS
43*2175Sjp161948
44*2175Sjp161948Certain signatures with an improper algorithm identifier are accepted
45*2175Sjp161948for compatibility with SSLeay 0.4.5 :-)
46*2175Sjp161948
47*2175Sjp161948=head1 CONFORMING TO
48*2175Sjp161948
49*2175Sjp161948SSL, PKCS #1 v2.0
50*2175Sjp161948
51*2175Sjp161948=head1 SEE ALSO
52*2175Sjp161948
53*2175Sjp161948L<ERR_get_error(3)|ERR_get_error(3)>, L<objects(3)|objects(3)>,
54*2175Sjp161948L<rsa(3)|rsa(3)>, L<RSA_private_encrypt(3)|RSA_private_encrypt(3)>,
55*2175Sjp161948L<RSA_public_decrypt(3)|RSA_public_decrypt(3)>
56*2175Sjp161948
57*2175Sjp161948=head1 HISTORY
58*2175Sjp161948
59*2175Sjp161948RSA_sign() and RSA_verify() are available in all versions of SSLeay
60*2175Sjp161948and OpenSSL.
61*2175Sjp161948
62*2175Sjp161948=cut
63