1*2175Sjp161948=pod 2*2175Sjp161948 3*2175Sjp161948=head1 NAME 4*2175Sjp161948 5*2175Sjp161948DSA_sign, DSA_sign_setup, DSA_verify - DSA signatures 6*2175Sjp161948 7*2175Sjp161948=head1 SYNOPSIS 8*2175Sjp161948 9*2175Sjp161948 #include <openssl/dsa.h> 10*2175Sjp161948 11*2175Sjp161948 int DSA_sign(int type, const unsigned char *dgst, int len, 12*2175Sjp161948 unsigned char *sigret, unsigned int *siglen, DSA *dsa); 13*2175Sjp161948 14*2175Sjp161948 int DSA_sign_setup(DSA *dsa, BN_CTX *ctx, BIGNUM **kinvp, 15*2175Sjp161948 BIGNUM **rp); 16*2175Sjp161948 17*2175Sjp161948 int DSA_verify(int type, const unsigned char *dgst, int len, 18*2175Sjp161948 unsigned char *sigbuf, int siglen, DSA *dsa); 19*2175Sjp161948 20*2175Sjp161948=head1 DESCRIPTION 21*2175Sjp161948 22*2175Sjp161948DSA_sign() computes a digital signature on the B<len> byte message 23*2175Sjp161948digest B<dgst> using the private key B<dsa> and places its ASN.1 DER 24*2175Sjp161948encoding at B<sigret>. The length of the signature is places in 25*2175Sjp161948*B<siglen>. B<sigret> must point to DSA_size(B<dsa>) bytes of memory. 26*2175Sjp161948 27*2175Sjp161948DSA_sign_setup() may be used to precompute part of the signing 28*2175Sjp161948operation in case signature generation is time-critical. It expects 29*2175Sjp161948B<dsa> to contain DSA parameters. It places the precomputed values 30*2175Sjp161948in newly allocated B<BIGNUM>s at *B<kinvp> and *B<rp>, after freeing 31*2175Sjp161948the old ones unless *B<kinvp> and *B<rp> are NULL. These values may 32*2175Sjp161948be passed to DSA_sign() in B<dsa-E<gt>kinv> and B<dsa-E<gt>r>. 33*2175Sjp161948B<ctx> is a pre-allocated B<BN_CTX> or NULL. 34*2175Sjp161948 35*2175Sjp161948DSA_verify() verifies that the signature B<sigbuf> of size B<siglen> 36*2175Sjp161948matches a given message digest B<dgst> of size B<len>. 37*2175Sjp161948B<dsa> is the signer's public key. 38*2175Sjp161948 39*2175Sjp161948The B<type> parameter is ignored. 40*2175Sjp161948 41*2175Sjp161948The PRNG must be seeded before DSA_sign() (or DSA_sign_setup()) 42*2175Sjp161948is called. 43*2175Sjp161948 44*2175Sjp161948=head1 RETURN VALUES 45*2175Sjp161948 46*2175Sjp161948DSA_sign() and DSA_sign_setup() return 1 on success, 0 on error. 47*2175Sjp161948DSA_verify() returns 1 for a valid signature, 0 for an incorrect 48*2175Sjp161948signature and -1 on error. The error codes can be obtained by 49*2175Sjp161948L<ERR_get_error(3)|ERR_get_error(3)>. 50*2175Sjp161948 51*2175Sjp161948=head1 CONFORMING TO 52*2175Sjp161948 53*2175Sjp161948US Federal Information Processing Standard FIPS 186 (Digital Signature 54*2175Sjp161948Standard, DSS), ANSI X9.30 55*2175Sjp161948 56*2175Sjp161948=head1 SEE ALSO 57*2175Sjp161948 58*2175Sjp161948L<dsa(3)|dsa(3)>, L<ERR_get_error(3)|ERR_get_error(3)>, L<rand(3)|rand(3)>, 59*2175Sjp161948L<DSA_do_sign(3)|DSA_do_sign(3)> 60*2175Sjp161948 61*2175Sjp161948=head1 HISTORY 62*2175Sjp161948 63*2175Sjp161948DSA_sign() and DSA_verify() are available in all versions of SSLeay. 64*2175Sjp161948DSA_sign_setup() was added in SSLeay 0.8. 65*2175Sjp161948 66*2175Sjp161948=cut 67