82d7fb77cd9ecca4629982e7c336d5cce3dfe6b7
[openssl.git] / doc / crypto / dsa.pod
1 =pod
2
3 =head1 NAME
4
5 dsa - Digital Signature Algorithm
6
7 =head1 SYNOPSIS
8
9  #include <openssl/dsa.h>
10  #include <openssl/engine.h>
11
12  DSA *  DSA_new(void);
13  void   DSA_free(DSA *dsa);
14
15  int    DSA_size(DSA *dsa);
16
17  DSA *  DSA_generate_parameters(int bits, unsigned char *seed,
18                 int seed_len, int *counter_ret, unsigned long *h_ret,
19                 void (*callback)(int, int, void *), void *cb_arg);
20
21  DH *   DSA_dup_DH(DSA *r);
22
23  int    DSA_generate_key(DSA *dsa);
24
25  int    DSA_sign(int dummy, const unsigned char *dgst, int len,
26                 unsigned char *sigret, unsigned int *siglen, DSA *dsa);
27  int    DSA_sign_setup(DSA *dsa, BN_CTX *ctx, BIGNUM **kinvp,
28                 BIGNUM **rp);
29  int    DSA_verify(int dummy, const unsigned char *dgst, int len,
30                 unsigned char *sigbuf, int siglen, DSA *dsa);
31
32  void DSA_set_default_openssl_method(DSA_METHOD *meth);
33  DSA_METHOD *DSA_get_default_openssl_method(void);
34  int DSA_set_method(DSA *dsa, ENGINE *engine);
35  DSA *DSA_new_method(ENGINE *engine);
36  DSA_METHOD *DSA_OpenSSL(void);
37
38  int DSA_get_ex_new_index(long argl, char *argp, int (*new_func)(),
39              int (*dup_func)(), void (*free_func)());
40  int DSA_set_ex_data(DSA *d, int idx, char *arg);
41  char *DSA_get_ex_data(DSA *d, int idx);
42
43  DSA_SIG *DSA_SIG_new(void);
44  void   DSA_SIG_free(DSA_SIG *a);
45  int    i2d_DSA_SIG(DSA_SIG *a, unsigned char **pp);
46  DSA_SIG *d2i_DSA_SIG(DSA_SIG **v, unsigned char **pp, long length);
47
48  DSA_SIG *DSA_do_sign(const unsigned char *dgst, int dlen, DSA *dsa);
49  int    DSA_do_verify(const unsigned char *dgst, int dgst_len,
50              DSA_SIG *sig, DSA *dsa);
51
52  DSA *  d2i_DSAPublicKey(DSA **a, unsigned char **pp, long length);
53  DSA *  d2i_DSAPrivateKey(DSA **a, unsigned char **pp, long length);
54  DSA *  d2i_DSAparams(DSA **a, unsigned char **pp, long length);
55  int    i2d_DSAPublicKey(DSA *a, unsigned char **pp);
56  int    i2d_DSAPrivateKey(DSA *a, unsigned char **pp);
57  int    i2d_DSAparams(DSA *a,unsigned char **pp);
58
59  int    DSAparams_print(BIO *bp, DSA *x);
60  int    DSAparams_print_fp(FILE *fp, DSA *x);
61  int    DSA_print(BIO *bp, DSA *x, int off);
62  int    DSA_print_fp(FILE *bp, DSA *x, int off);
63
64 =head1 DESCRIPTION
65
66 These functions implement the Digital Signature Algorithm (DSA).  The
67 generation of shared DSA parameters is described in
68 L<DSA_generate_parameters(3)|DSA_generate_parameters(3)>;
69 L<DSA_generate_key(3)|DSA_generate_key(3)> describes how to
70 generate a signature key. Signature generation and verification are
71 described in L<DSA_sign(3)|DSA_sign(3)>.
72
73 The B<DSA> structure consists of several BIGNUM components.
74
75  struct
76         {
77         BIGNUM *p;              // prime number (public)
78         BIGNUM *q;              // 160-bit subprime, q | p-1 (public)
79         BIGNUM *g;              // generator of subgroup (public)
80         BIGNUM *priv_key;       // private key x
81         BIGNUM *pub_key;        // public key y = g^x
82         // ...
83         }
84  DSA;
85
86 In public keys, B<priv_key> is NULL.
87
88 =head1 CONFORMING TO
89
90 US Federal Information Processing Standard FIPS 186 (Digital Signature
91 Standard, DSS), ANSI X9.30
92
93 =head1 SEE ALSO
94
95 L<bn(3)|bn(3)>, L<dh(3)|dh(3)>, L<err(3)|err(3)>, L<rand(3)|rand(3)>,
96 L<rsa(3)|rsa(3)>, L<sha(3)|sha(3)>, L<DSA_new(3)|DSA_new(3)>,
97 L<DSA_size(3)|DSA_size(3)>,
98 L<DSA_generate_parameters(3)|DSA_generate_parameters(3)>,
99 L<DSA_dup_DH(3)|DSA_dup_DH(3)>,
100 L<DSA_generate_key(3)|DSA_generate_key(3)>,
101 L<DSA_sign(3)|DSA_sign(3)>, L<DSA_set_method(3)|DSA_set_method(3)>,
102 L<DSA_get_ex_new_index(3)|DSA_get_ex_new_index(3)>,
103 L<RSA_print(3)|RSA_print(3)>
104
105 =cut