blob: 41532b89ee32a6533185f19c97f2911a9259f951 [file] [log] [blame]
rsccfa37a72004-04-10 18:53:55 +00001.TH DSA 3
2.SH NAME
rsc30f6ae12005-02-13 23:44:12 +00003asn1toDSApriv, dsagen, dsasign, dsaverify, dsapuballoc, dsapubfree, dsaprivalloc, dsaprivfree, dsasigalloc, dsasigfree, dsaprivtopub - digital signature algorithm
rsccfa37a72004-04-10 18:53:55 +00004.SH SYNOPSIS
5.B #include <u.h>
6.br
7.B #include <libc.h>
8.br
9.B #include <mp.h>
10.br
11.B #include <libsec.h>
12.PP
13.B
14DSApriv* dsagen(DSApub *opub)
15.PP
16.B
17DSAsig* dsasign(DSApriv *k, mpint *m)
18.PP
19.B
20int dsaverify(DSApub *k, DSAsig *sig, mpint *m)
21.PP
22.B
23DSApub* dsapuballoc(void)
24.PP
25.B
26void dsapubfree(DSApub*)
27.PP
28.B
29DSApriv* dsaprivalloc(void)
30.PP
31.B
32void dsaprivfree(DSApriv*)
33.PP
34.B
35DSAsig* dsasigalloc(void)
36.PP
37.B
38void dsasigfree(DSAsig*)
39.PP
40.B
41DSApub* dsaprivtopub(DSApriv*)
rsc30f6ae12005-02-13 23:44:12 +000042.PP
43.B
44DSApriv* asn1toDSApriv(uchar *priv, int npriv)
rsccfa37a72004-04-10 18:53:55 +000045.SH DESCRIPTION
46.PP
47DSA is the NIST approved digital signature algorithm. The owner of a key publishes
48the public part of the key:
49.EX
50 struct DSApub
51 {
52 mpint *p; // modulus
53 mpint *q; // group order, q divides p-1
54 mpint *alpha; // group generator
55 mpint *key; // alpha**secret mod p
56 };
57.EE
58This part can be used for verifying signatures (with
59.IR dsaverify )
60created by the owner.
61The owner signs (with
62.IR dsasign )
63using his private key:
64.EX
65 struct DSApriv
66 {
67 DSApub pub;
68 mpint *secret; // (decryption key)
69 };
70.EE
71.PP
72Keys are generated using
73.IR dsagen .
74If
75.IR dsagen 's
76argument
77.I opub
78is
79.BR nil ,
80a key is created using a new
81.B p
82and
83.B q
84generated by
rsc058b0112005-01-03 06:40:20 +000085.IR DSAprimes
86(see
87.IR prime (3)).
rsccfa37a72004-04-10 18:53:55 +000088Otherwise,
89.B p
90and
91.B q
92are copied from the old key.
93.PP
94.I Dsaprivtopub
95returns a newly allocated copy of the public key
96corresponding to the private key.
97.PP
98The routines
99.IR dsapuballoc ,
100.IR dsapubfree ,
101.IR dsaprivalloc ,
102and
103.I dsaprivfree
104are provided to manage key storage.
105.PP
106.I Dsasign
107signs message
108.I m
109using a private key
110.I k
111yielding a
112.EX
113 struct DSAsig
114 {
115 mpint *r, *s;
116 };
117.EE
118.I Dsaverify
119returns 0 if the signature is valid and \-1 if not.
120.PP
121The routines
122.I dsasigalloc
123and
124.I dsasigfree
125are provided to manage signature storage.
rsc30f6ae12005-02-13 23:44:12 +0000126.PP
127.I Asn1toDSApriv
128converts an ASN1 formatted DSA private key into the corresponding
129.B DSApriv
130structure; see
131.IR rsa (3)
132for other ASN1 routines.
rsccfa37a72004-04-10 18:53:55 +0000133.SH SOURCE
rscc3674de2005-01-11 17:37:33 +0000134.B \*9/src/libsec
rsccfa37a72004-04-10 18:53:55 +0000135.SH SEE ALSO
rscbf8a59f2004-04-11 03:42:27 +0000136.IR mp (3),
137.IR aes (3),
138.IR blowfish (3),
139.IR des (3),
140.IR rc4 (3),
141.IR rsa (3),
142.IR sechash (3),
143.IR prime (3),
144.IR rand (3)