aboutsummaryrefslogtreecommitdiff
path: root/man/man3/elgamal.html
blob: a651846838299ca051868dc36015777a9c59ad82 (plain)
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
<head>
<title>elgamal(3) - Plan 9 from User Space</title>
<meta content="text/html; charset=utf-8" http-equiv=Content-Type>
</head>
<body bgcolor=#ffffff>
<table border=0 cellpadding=0 cellspacing=0 width=100%>
<tr height=10><td>
<tr><td width=20><td>
<tr><td width=20><td><b>ELGAMAL(3)</b><td align=right><b>ELGAMAL(3)</b>
<tr><td width=20><td colspan=2>
    <br>
<p><font size=+1><b>NAME     </b></font><br>

<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>

    eggen, egencrypt, egdecrypt, egsign, egverify, egpuballoc, egpubfree,
    egprivalloc, egprivfree, egsigalloc, egsigfree, egprivtopub -
    elgamal encryption<br>
    
</table>
<p><font size=+1><b>SYNOPSIS     </b></font><br>

<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>

    <tt><font size=+1>#include &lt;u.h&gt;<br>
    #include &lt;libc.h&gt;<br>
    #include &lt;mp.h&gt;<br>
    #include &lt;libsec.h&gt; 
    <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
    </font></tt>
    <tt><font size=+1>EGpriv* &nbsp;&nbsp;&nbsp;&nbsp;eggen(int nlen, int nrep) 
    <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
    </font></tt>
    <tt><font size=+1>mpint* &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;egencrypt(EGpub *k, mpint *in, mpint *out) 
    <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
    </font></tt>
    <tt><font size=+1>mpint* &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;egdecrypt(EGpriv *k, mpint *in, mpint *out) 
    <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
    </font></tt>
    <tt><font size=+1>EGsig* &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;egsign(EGpriv *k, mpint *m) 
    <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
    </font></tt>
    <tt><font size=+1>int  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;egverify(EGpub *k, EGsig *sig, mpint *m) 
    <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
    </font></tt>
    <tt><font size=+1>EGpub* &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;egpuballoc(void) 
    <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
    </font></tt>
    <tt><font size=+1>void  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;egpubfree(EGpub*) 
    <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
    </font></tt>
    <tt><font size=+1>EGpriv* &nbsp;&nbsp;&nbsp;&nbsp;egprivalloc(void) 
    <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
    </font></tt>
    <tt><font size=+1>void  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;egprivfree(EGpriv*) 
    <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
    </font></tt>
    <tt><font size=+1>EGsig* &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;egsigalloc(void) 
    <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
    </font></tt>
    <tt><font size=+1>void  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;egsigfree(EGsig*) 
    <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
    </font></tt>
    <tt><font size=+1>EGpub* &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;egprivtopub(EGpriv*)<br>
    </font></tt>
</table>
<p><font size=+1><b>DESCRIPTION     </b></font><br>

<table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>


<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>

    Elgamal is a public key encryption and signature algorithm. The
    owner of a key publishes the public part of the key:<br>
    
    <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>

        <tt><font size=+1>struct EGpub<br>
        {<br>
         
        <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>

            mpint &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*p; &nbsp;&nbsp;&nbsp;// modulus<br>
             mpint &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*alpha; &nbsp;&nbsp;&nbsp;&nbsp;// generator<br>
             mpint &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*key; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// (encryption key) alpha**secret mod p<br>
            
        </table>
        };<br>
        </font></tt>
    </table>
    This part can be used for encrypting data (with <i>egencrypt</i>) to
    be sent to the owner. The owner decrypts (with <i>egdecrypt</i>) using
    his private key:<br>
    
    <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>

        <tt><font size=+1>struct EGpriv<br>
        {<br>
         
        <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>

            EGpub &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pub;<br>
             mpint &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*secret; // (decryption key)<br>
            
        </table>
        };<br>
        
        <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
        </font></tt>
        
    </table>
    Keys are generated using <i>eggen</i>. <i>Eggen</i> takes both bit length of
    the modulus and the number of repetitions of the Miller-Rabin
    primality test to run. If the latter is 0, it does the default
    number of rounds. <i>Egprivtopub</i> returns a newly allocated copy of
    the public key corresponding to the private key. 
    <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
    
    The routines <i>egpuballoc</i>, <i>egpubfree</i>, <i>egprivalloc</i>, and <i>egprivfree</i>
    are provided to manage key storage. 
    <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
    
    <i>Egsign</i> signs message <i>m</i> using a private key <i>k</i> yielding a<br>
    
    <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>

        <tt><font size=+1>struct EGsig<br>
        {<br>
         
        <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>

            mpint &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*r, *s;<br>
            
        </table>
        };<br>
        </font></tt>
    </table>
    <i>Egverify</i> returns 0 if the signature is valid and &ndash;1 if not. 
    <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
    
    The routines <i>egsigalloc</i> and <i>egsigfree</i> are provided to manage signature
    storage.<br>
    
</table>
<p><font size=+1><b>SOURCE     </b></font><br>

<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>

    <tt><font size=+1>/usr/local/plan9/src/libsec<br>
    </font></tt>
</table>
<p><font size=+1><b>SEE ALSO    </b></font><br>

<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>

    <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/dsa.html"><i>dsa</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>,
    <a href="../man3/prime.html"><i>prime</i>(3)</a>, <a href="../man3/rand.html"><i>rand</i>(3)</a><br>
    
</table>

<td width=20>
<tr height=20><td>
</table>
<!-- TRAILER -->
<table border=0 cellpadding=0 cellspacing=0 width=100%>
<tr height=15><td width=10><td><td width=10>
<tr><td><td>
<center>
<a href="../../"><img src="../../dist/spaceglenda100.png" alt="Space Glenda" border=1></a>
</center>
</table>
<!-- TRAILER -->
</body></html>