summaryrefslogtreecommitdiff
path: root/doc/cipher-ref.sgml
blob: 94c773fccb93bf65613b25246dca94b85b3c98ca (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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
<!-- cipher-ref.sgml - libgcrypt reference (ciphers)
    Copyright (C) 2000 Free Software Foundation, Inc.

    This file is part of libgcrypt.

    libgcrypt is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    libgcrypt is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
-->

<!--**********************************************
***********  cipher open, close  *****************
***********************************************-->
<refentry>
  <refnamediv>
    <refname>gcry_cipher_open</refname>
    <refname>gcry_cipher_close</refname>
    <refpurpose>create and destroy an encryption context</refpurpose>
  </refnamediv>

  <refsynopsisdiv>
    <funcsynopsis>
      <funcsynopsisinfo>
      #include &lt;gcrypt.h&gt;
      </funcsynopsisinfo>
      <funcprototype>
	<funcdef>GCRY_CIPHER_HD <function>gcry_cipher_open</function></funcdef>
	<paramdef>int <parameter>algo</parameter></paramdef>
	<paramdef>int <parameter>mode</parameter></paramdef>
	<paramdef>unsigned in <parameter>flags</parameter></paramdef>
      </funcprototype>
      <funcprototype>
	<funcdef>void <function>gcry_cipher_close</function></funcdef>
	<paramdef>GCRY_CIPHER_HD <parameter>h</parameter></paramdef>
      </funcprototype>
    </funcsynopsis>
  </refsynopsisdiv>


  <refsect1><title>Description</title>
  <para>
  <indexterm><primary>cipher functions</primary>
	     <secondary>gcry_cipher_open</secondary>
	     </indexterm>
  <indexterm><primary>cipher functions</primary>
	     <secondary>gcry_cipher_close</secondary>
	     </indexterm>
  <function>gcry_cipher_open</function> creates the context required for
  most of the cipher functions.
  </para>
</refentry>


<!--**********************************************
***********  cipher control  *********************
***********************************************-->
<refentry>
  <refnamediv>
    <refname>gcry_cipher_ctl</refname>
    <refname>gcry_cipher_setkey</refname>
    <refname>gcry_cipher_setiv</refname>
    <refname>gcry_cipher_setiv</refname>
    <refpurpose>control cipher functions</refpurpose>
  </refnamediv>

  <refsynopsisdiv>
    <funcsynopsis>
      <funcsynopsisinfo>
      #include &lt;gcrypt.h&gt;
      </funcsynopsisinfo>
      <funcprototype>
	<funcdef>int <function>gcry_cipher_ctl</function></funcdef>
	<paramdef>GCRY_CIPHER_HD <parameter>h</parameter></paramdef>
	<paramdef>int <parameter>cmd</parameter></paramdef>
	<paramdef>void *<parameter>buffer</parameter></paramdef>
	<paramdef>size_t <parameter>buflen</parameter></paramdef>
      </funcprototype>
    </funcsynopsis>
  </refsynopsisdiv>


  <refsect1><title>Description</title>
  <para>
  <indexterm><primary>cipher functions</primary>
	     <secondary>gcry_cipher_ctl</secondary>
	     </indexterm>
  <function>gcry_cipher_ctl</function> controls various aspects of the
  cipher module and specific cipher contexts.  A couple of macros may
  be used for convenience:

  gcry_cipher_setkey(h,k,l)
  gcry_cipher_setiv(h,k,l)
  gcry_cipher_sync(h)

  </para>
</refentry>


<!--**********************************************
***********  cipher info   ***********************
***********************************************-->
<refentry>
  <refnamediv>
    <refname>gcry_cipher_info</refname>
    <refpurpose>return information about a cipher context</refpurpose>
  </refnamediv>

  <refsynopsisdiv>
    <funcsynopsis>
      <funcsynopsisinfo>
      #include &lt;gcrypt.h&gt;
      </funcsynopsisinfo>
      <funcprototype>
	<funcdef>int <function>gcry_cipher_info</function></funcdef>
	<paramdef>GCRY_CIPHER_HD <parameter>h</parameter></paramdef>
	<paramdef>int <parameter>what</parameter></paramdef>
      </funcprototype>
    </funcsynopsis>
  </refsynopsisdiv>


  <refsect1><title>Description</title>
  <para>
  <indexterm><primary>cipher functions</primary>
	     <secondary>gcry_cipher_info</secondary>
	     </indexterm>
  <function>gcry_cipher_info</function> is used to retrieve various
  information about a cipher context or the cipher module in general.
  Currently no information is available.
  </para>
</refentry>


<!--**********************************************
***********  cipher algo name	******************
***********************************************-->
<refentry>
  <refnamediv>
    <refname>gcry_cipher_algo_name</refname>
    <refpurpose>return the name of a cipher algorithm</refpurpose>
  </refnamediv>

  <refsynopsisdiv>
    <funcsynopsis>
      <funcsynopsisinfo>
      #include &lt;gcrypt.h&gt;
      </funcsynopsisinfo>
      <funcprototype>
	<funcdef>const char *<function>gcry_cipher_algo_name</function></funcdef>
	<paramdef>int <parameter>algo</parameter></paramdef>
      </funcprototype>
    </funcsynopsis>
  </refsynopsisdiv>


  <refsect1><title>Description</title>
  <para>
  <indexterm><primary>cipher functions</primary>
	     <secondary>gcry_cipher_algo_name</secondary>
	     </indexterm>
  <function>gcry_cipher_algo_name</function> returns a string with the
  name of the cipher algorithm <parameter>algo</parameter>.  If the algorithm
  is not known or an other error occured, an empty string is return.  This
  function will never return NULL.
  </para>
</refentry>

<!--**********************************************
***********  cipher map name  ********************
***********************************************-->
<refentry>
  <refnamediv>
    <refname>gcry_cipher_map_name</refname>
    <refpurpose>return an algorithm identifier for string</refpurpose>
  </refnamediv>

  <refsynopsisdiv>
    <funcsynopsis>
      <funcsynopsisinfo>
      #include &lt;gcrypt.h&gt;
      </funcsynopsisinfo>
      <funcprototype>
	<funcdef>int <function>gcry_cipher_map_name</function></funcdef>
	<paramdef>const char *<parameter>name</parameter></paramdef>
      </funcprototype>
    </funcsynopsis>
  </refsynopsisdiv>


  <refsect1><title>Description</title>
  <para>
  <indexterm><primary>cipher functions</primary>
	     <secondary>gcry_cipher_map_name</secondary>
	     </indexterm>
  <function>gcry_cipher_map_name</function> returns the algorithm identifier
  for the cipher algorithm described by the string <parameter>name</parameter>.
  If this algorith is not available 0 is returned.
  </para>
</refentry>

<!--**********************************************
***********  cipher en/decryptlose  **************
***********************************************-->
<refentry>
  <refnamediv>
    <refname>gcry_cipher_encrypt</refname>
    <refname>gcry_cipher_decrypt</refname>
    <refpurpose>encrypt data or decrypt data</refpurpose>
  </refnamediv>

  <refsynopsisdiv>
    <funcsynopsis>
      <funcsynopsisinfo>
      #include &lt;gcrypt.h&gt;
      </funcsynopsisinfo>
      <funcprototype>
	<funcdef>int <function>gcry_cipher_encrypt</function></funcdef>
	<paramdef>GCRY_CIPHER_HD <parameter>h</parameter></paramdef>
	<paramdef>unsigned char <parameter>out</parameter></paramdef>
	<paramdef>size_t <parameter>outsize</parameter></paramdef>
	<paramdef>unsigned char <parameter>in</parameter></paramdef>
	<paramdef>size_t <parameter>insize</parameter></paramdef>
      </funcprototype>
      <funcprototype>
	<funcdef>int <function>gcry_cipher_decrypt</function></funcdef>
	<paramdef>GCRY_CIPHER_HD <parameter>h</parameter></paramdef>
	<paramdef>unsigned char <parameter>out</parameter></paramdef>
	<paramdef>size_t <parameter>outsize</parameter></paramdef>
	<paramdef>unsigned char <parameter>in</parameter></paramdef>
	<paramdef>size_t <parameter>insize</parameter></paramdef>
      </funcprototype>
    </funcsynopsis>
  </refsynopsisdiv>


  <refsect1><title>Description</title>
  <para>
  <indexterm><primary>cipher functions</primary>
	     <secondary>gcry_cipher_encrypt</secondary>
	     </indexterm>
  <indexterm><primary>cipher functions</primary>
	     <secondary>gcry_cipher_decrypt</secondary>
	     </indexterm>
  <function>gcry_cipher_encrypt</function> is used to encrypt the data.
  the complemetary function <function>gcry_cipher_decrypt</function> is
  be used to decrypt the data. The calling convention for both functions
  is the same.
  </para>
  <para>These functions can either work in place or with two buffers.
  Overlapping buffers are not allowed.
  </para>
</refentry>