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