159191Skris=pod 259191Skris 359191Skris=head1 NAME 459191Skris 559191SkrisDSA_sign, DSA_sign_setup, DSA_verify - DSA signatures 659191Skris 759191Skris=head1 SYNOPSIS 859191Skris 959191Skris #include <openssl/dsa.h> 1059191Skris 1159191Skris int DSA_sign(int type, const unsigned char *dgst, int len, 1259191Skris unsigned char *sigret, unsigned int *siglen, DSA *dsa); 1359191Skris 1459191Skris int DSA_sign_setup(DSA *dsa, BN_CTX *ctx, BIGNUM **kinvp, 1559191Skris BIGNUM **rp); 1659191Skris 1759191Skris int DSA_verify(int type, const unsigned char *dgst, int len, 1859191Skris unsigned char *sigbuf, int siglen, DSA *dsa); 1959191Skris 2059191Skris=head1 DESCRIPTION 2159191Skris 2259191SkrisDSA_sign() computes a digital signature on the B<len> byte message 2359191Skrisdigest B<dgst> using the private key B<dsa> and places its ASN.1 DER 2459191Skrisencoding at B<sigret>. The length of the signature is places in 2559191Skris*B<siglen>. B<sigret> must point to DSA_size(B<dsa>) bytes of memory. 2659191Skris 2759191SkrisDSA_sign_setup() may be used to precompute part of the signing 2859191Skrisoperation in case signature generation is time-critical. It expects 2959191SkrisB<dsa> to contain DSA parameters. It places the precomputed values 3059191Skrisin newly allocated B<BIGNUM>s at *B<kinvp> and *B<rp>, after freeing 3159191Skristhe old ones unless *B<kinvp> and *B<rp> are NULL. These values may 3259191Skrisbe passed to DSA_sign() in B<dsa-E<gt>kinv> and B<dsa-E<gt>r>. 3359191SkrisB<ctx> is a pre-allocated B<BN_CTX> or NULL. 34337982SjkimThe precomputed values from DSA_sign_setup() B<MUST NOT be used> for 35337982Sjkimmore than one signature: using the same B<dsa-E<gt>kinv> and 36337982SjkimB<dsa-E<gt>r> pair twice under the same private key on different 37337982Sjkimplaintexts will result in permanently exposing the DSA private key. 3859191Skris 3959191SkrisDSA_verify() verifies that the signature B<sigbuf> of size B<siglen> 4059191Skrismatches a given message digest B<dgst> of size B<len>. 4159191SkrisB<dsa> is the signer's public key. 4259191Skris 4359191SkrisThe B<type> parameter is ignored. 4459191Skris 4559191SkrisThe PRNG must be seeded before DSA_sign() (or DSA_sign_setup()) 4659191Skrisis called. 4759191Skris 4859191Skris=head1 RETURN VALUES 4959191Skris 5059191SkrisDSA_sign() and DSA_sign_setup() return 1 on success, 0 on error. 5159191SkrisDSA_verify() returns 1 for a valid signature, 0 for an incorrect 5259191Skrissignature and -1 on error. The error codes can be obtained by 5359191SkrisL<ERR_get_error(3)|ERR_get_error(3)>. 5459191Skris 5559191Skris=head1 CONFORMING TO 5659191Skris 5759191SkrisUS Federal Information Processing Standard FIPS 186 (Digital Signature 5859191SkrisStandard, DSS), ANSI X9.30 5959191Skris 6059191Skris=head1 SEE ALSO 6159191Skris 62109998SmarkmL<dsa(3)|dsa(3)>, L<ERR_get_error(3)|ERR_get_error(3)>, L<rand(3)|rand(3)>, 6359191SkrisL<DSA_do_sign(3)|DSA_do_sign(3)> 6459191Skris 6559191Skris=head1 HISTORY 6659191Skris 6759191SkrisDSA_sign() and DSA_verify() are available in all versions of SSLeay. 6859191SkrisDSA_sign_setup() was added in SSLeay 0.8. 6959191Skris 7059191Skris=cut 71