Blob


1 .TH DSA 3
2 .SH NAME
3 dsagen, dsasign, dsaverify, dsapuballoc, dsapubfree, dsaprivalloc, dsaprivfree, dsasigalloc, dsasigfree, dsaprivtopub - digital signature algorithm
4 .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
14 DSApriv* dsagen(DSApub *opub)
15 .PP
16 .B
17 DSAsig* dsasign(DSApriv *k, mpint *m)
18 .PP
19 .B
20 int dsaverify(DSApub *k, DSAsig *sig, mpint *m)
21 .PP
22 .B
23 DSApub* dsapuballoc(void)
24 .PP
25 .B
26 void dsapubfree(DSApub*)
27 .PP
28 .B
29 DSApriv* dsaprivalloc(void)
30 .PP
31 .B
32 void dsaprivfree(DSApriv*)
33 .PP
34 .B
35 DSAsig* dsasigalloc(void)
36 .PP
37 .B
38 void dsasigfree(DSAsig*)
39 .PP
40 .B
41 DSApub* dsaprivtopub(DSApriv*)
42 .SH DESCRIPTION
43 .PP
44 DSA is the NIST approved digital signature algorithm. The owner of a key publishes
45 the public part of the key:
46 .EX
47 struct DSApub
48 {
49 mpint *p; // modulus
50 mpint *q; // group order, q divides p-1
51 mpint *alpha; // group generator
52 mpint *key; // alpha**secret mod p
53 };
54 .EE
55 This part can be used for verifying signatures (with
56 .IR dsaverify )
57 created by the owner.
58 The owner signs (with
59 .IR dsasign )
60 using his private key:
61 .EX
62 struct DSApriv
63 {
64 DSApub pub;
65 mpint *secret; // (decryption key)
66 };
67 .EE
68 .PP
69 Keys are generated using
70 .IR dsagen .
71 If
72 .IR dsagen 's
73 argument
74 .I opub
75 is
76 .BR nil ,
77 a key is created using a new
78 .B p
79 and
80 .B q
81 generated by
82 .IR DSAprimes
83 (see
84 .IR prime (3)).
85 Otherwise,
86 .B p
87 and
88 .B q
89 are copied from the old key.
90 .PP
91 .I Dsaprivtopub
92 returns a newly allocated copy of the public key
93 corresponding to the private key.
94 .PP
95 The routines
96 .IR dsapuballoc ,
97 .IR dsapubfree ,
98 .IR dsaprivalloc ,
99 and
100 .I dsaprivfree
101 are provided to manage key storage.
102 .PP
103 .I Dsasign
104 signs message
105 .I m
106 using a private key
107 .I k
108 yielding a
109 .EX
110 struct DSAsig
112 mpint *r, *s;
113 };
114 .EE
115 .I Dsaverify
116 returns 0 if the signature is valid and \-1 if not.
117 .PP
118 The routines
119 .I dsasigalloc
120 and
121 .I dsasigfree
122 are provided to manage signature storage.
123 .SH SOURCE
124 .B \*9/src/libsec
125 .SH SEE ALSO
126 .IR mp (3),
127 .IR aes (3),
128 .IR blowfish (3),
129 .IR des (3),
130 .IR rc4 (3),
131 .IR rsa (3),
132 .IR sechash (3),
133 .IR prime (3),
134 .IR rand (3)