2 <title>dsa(3) - Plan 9 from User Space</title>
3 <meta content="text/html; charset=utf-8" http-equiv=Content-Type>
6 <table border=0 cellpadding=0 cellspacing=0 width=100%>
9 <tr><td width=20><td><b>DSA(3)</b><td align=right><b>DSA(3)</b>
10 <tr><td width=20><td colspan=2>
12 <p><font size=+1><b>NAME </b></font><br>
14 <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>
16 dsagen, dsasign, dsaverify, dsapuballoc, dsapubfree, dsaprivalloc,
17 dsaprivfree, dsasigalloc, dsasigfree, dsaprivtopub - digital signature
21 <p><font size=+1><b>SYNOPSIS </b></font><br>
23 <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>
25 <tt><font size=+1>#include <u.h><br>
26 #include <libc.h><br>
27 #include <mp.h><br>
28 #include <libsec.h>
29 <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
31 <tt><font size=+1>DSApriv* dsagen(DSApub *opub)
32 <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
34 <tt><font size=+1>DSAsig* dsasign(DSApriv *k, mpint *m)
35 <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
37 <tt><font size=+1>int dsaverify(DSApub *k, DSAsig *sig, mpint *m)
38 <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
40 <tt><font size=+1>DSApub* dsapuballoc(void)
41 <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
43 <tt><font size=+1>void dsapubfree(DSApub*)
44 <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
46 <tt><font size=+1>DSApriv* dsaprivalloc(void)
47 <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
49 <tt><font size=+1>void dsaprivfree(DSApriv*)
50 <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
52 <tt><font size=+1>DSAsig* dsasigalloc(void)
53 <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
55 <tt><font size=+1>void dsasigfree(DSAsig*)
56 <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
58 <tt><font size=+1>DSApub* dsaprivtopub(DSApriv*)<br>
61 <p><font size=+1><b>DESCRIPTION </b></font><br>
63 <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
66 <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>
68 DSA is the NIST approved digital signature algorithm. The owner
69 of a key publishes the public part of the key:<br>
71 <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>
73 <tt><font size=+1>struct DSApub<br>
76 <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>
78 mpint *p; // modulus<br>
79 mpint *q; // group order, q divides p−1<br>
80 mpint *alpha; // group generator<br>
81 mpint *key; // alpha**secret mod p<br>
87 This part can be used for verifying signatures (with <i>dsaverify</i>)
88 created by the owner. The owner signs (with <i>dsasign</i>) using his
91 <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>
93 <tt><font size=+1>struct DSApriv<br>
96 <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>
98 DSApub pub;<br>
99 mpint *secret; // (decryption key)<br>
104 <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
108 Keys are generated using <i>dsagen</i>. If <i>dsagen</i>’s argument <i>opub</i> is
109 <tt><font size=+1>nil</font></tt>, a key is created using a new <tt><font size=+1>p</font></tt> and <tt><font size=+1>q</font></tt> generated by <i>DSAprimes</i>
110 (see <a href="../man3/prime.html"><i>prime</i>(3)</a>). Otherwise, <tt><font size=+1>p</font></tt> and <tt><font size=+1>q</font></tt> are copied from the old key.
112 <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
114 <i>Dsaprivtopub</i> returns a newly allocated copy of the public key
115 corresponding to the private key.
116 <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
118 The routines <i>dsapuballoc</i>, <i>dsapubfree</i>, <i>dsaprivalloc</i>, and <i>dsaprivfree</i>
119 are provided to manage key storage.
120 <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
122 <i>Dsasign</i> signs message <i>m</i> using a private key <i>k</i> yielding a<br>
124 <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>
126 <tt><font size=+1>struct DSAsig<br>
129 <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>
131 mpint *r, *s;<br>
137 <i>Dsaverify</i> returns 0 if the signature is valid and –1 if not.
138 <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
140 The routines <i>dsasigalloc</i> and <i>dsasigfree</i> are provided to manage
141 signature storage.<br>
144 <p><font size=+1><b>SOURCE </b></font><br>
146 <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>
148 <tt><font size=+1>/usr/local/plan9/src/libsec<br>
151 <p><font size=+1><b>SEE ALSO </b></font><br>
153 <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>
155 <a href="../man3/mp.html"><i>mp</i>(3)</a>, <a href="../man3/aes.html"><i>aes</i>(3)</a>, <a href="../man3/blowfish.html"><i>blowfish</i>(3)</a>, <a href="../man3/des.html"><i>des</i>(3)</a>, <a href="../man3/rc4.html"><i>rc4</i>(3)</a>, <a href="../man3/rsa.html"><i>rsa</i>(3)</a>, <a href="../man3/sechash.html"><i>sechash</i>(3)</a>,
156 <a href="../man3/prime.html"><i>prime</i>(3)</a>, <a href="../man3/rand.html"><i>rand</i>(3)</a><br>
164 <table border=0 cellpadding=0 cellspacing=0 width=100%>
165 <tr height=15><td width=10><td><td width=10>
168 <a href="../../"><img src="../../dist/spaceglenda100.png" alt="Space Glenda" border=1></a>