Blob


1 <head>
2 <title>dsa(3) - Plan 9 from User Space</title>
3 <meta content="text/html; charset=utf-8" http-equiv=Content-Type>
4 </head>
5 <body bgcolor=#ffffff>
6 <table border=0 cellpadding=0 cellspacing=0 width=100%>
7 <tr height=10><td>
8 <tr><td width=20><td>
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>
11 <br>
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
18 algorithm<br>
20 </table>
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 &lt;u.h&gt;<br>
26 #include &lt;libc.h&gt;<br>
27 #include &lt;mp.h&gt;<br>
28 #include &lt;libsec.h&gt;
29 <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
30 </font></tt>
31 <tt><font size=+1>DSApriv* &nbsp;&nbsp;&nbsp;dsagen(DSApub *opub)
32 <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
33 </font></tt>
34 <tt><font size=+1>DSAsig* &nbsp;&nbsp;&nbsp;&nbsp;dsasign(DSApriv *k, mpint *m)
35 <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
36 </font></tt>
37 <tt><font size=+1>int &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dsaverify(DSApub *k, DSAsig *sig, mpint *m)
38 <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
39 </font></tt>
40 <tt><font size=+1>DSApub* &nbsp;&nbsp;&nbsp;&nbsp;dsapuballoc(void)
41 <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
42 </font></tt>
43 <tt><font size=+1>void &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dsapubfree(DSApub*)
44 <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
45 </font></tt>
46 <tt><font size=+1>DSApriv* &nbsp;&nbsp;&nbsp;dsaprivalloc(void)
47 <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
48 </font></tt>
49 <tt><font size=+1>void &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dsaprivfree(DSApriv*)
50 <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
51 </font></tt>
52 <tt><font size=+1>DSAsig* &nbsp;&nbsp;&nbsp;&nbsp;dsasigalloc(void)
53 <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
54 </font></tt>
55 <tt><font size=+1>void &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dsasigfree(DSAsig*)
56 <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
57 </font></tt>
58 <tt><font size=+1>DSApub* &nbsp;&nbsp;&nbsp;&nbsp;dsaprivtopub(DSApriv*)<br>
59 </font></tt>
60 </table>
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>
74 {<br>
76 <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>
78 mpint &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*p; &nbsp;&nbsp;&nbsp;// modulus<br>
79 mpint &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*q; &nbsp;&nbsp;&nbsp;// group order, q divides p&#8722;1<br>
80 mpint &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*alpha; &nbsp;&nbsp;&nbsp;&nbsp;// group generator<br>
81 mpint &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*key; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// alpha**secret mod p<br>
83 </table>
84 };<br>
85 </font></tt>
86 </table>
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
89 private key:<br>
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>
94 {<br>
96 <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>
98 DSApub &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pub;<br>
99 mpint &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*secret; // (decryption key)<br>
101 </table>
102 };<br>
104 <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
105 </font></tt>
107 </table>
108 Keys are generated using <i>dsagen</i>. If <i>dsagen</i>&#8217;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>
127 {<br>
129 <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>
131 mpint &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*r, *s;<br>
133 </table>
134 };<br>
135 </font></tt>
136 </table>
137 <i>Dsaverify</i> returns 0 if the signature is valid and &ndash;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>
143 </table>
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>
149 </font></tt>
150 </table>
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>
158 </table>
160 <td width=20>
161 <tr height=20><td>
162 </table>
163 <!-- TRAILER -->
164 <table border=0 cellpadding=0 cellspacing=0 width=100%>
165 <tr height=15><td width=10><td><td width=10>
166 <tr><td><td>
167 <center>
168 <a href="../../"><img src="../../dist/spaceglenda100.png" alt="Space Glenda" border=1></a>
169 </center>
170 </table>
171 <!-- TRAILER -->
172 </body></html>