2 @subheading gnutls_cipher_add_auth
3 @anchor{gnutls_cipher_add_auth}
4 @deftypefun {int} {gnutls_cipher_add_auth} (gnutls_cipher_hd_t @var{handle}, const void * @var{text}, size_t @var{text_size})
5 @var{handle}: is a @code{gnutls_cipher_hd_t} structure.
7 @var{text}: the data to be authenticated
9 @var{text_size}: The length of the data
11 This function operates on authenticated encryption with
12 associated data (AEAD) ciphers and authenticate the
13 input data. This function can only be called once
14 and before any encryption operations.
16 @strong{Returns:} Zero or a negative error code on error.
21 @subheading gnutls_cipher_decrypt
22 @anchor{gnutls_cipher_decrypt}
23 @deftypefun {int} {gnutls_cipher_decrypt} (gnutls_cipher_hd_t @var{handle}, void * @var{ciphertext}, size_t @var{ciphertextlen})
24 @var{handle}: is a @code{gnutls_cipher_hd_t} structure.
26 @var{ciphertext}: the data to encrypt
28 @var{ciphertextlen}: The length of data to encrypt
30 This function will decrypt the given data using the algorithm
31 specified by the context.
33 Note that in AEAD ciphers, this will not check the tag. You will
34 need to compare the tag sent with the value returned from @code{gnutls_cipher_tag()} .
36 @strong{Returns:} Zero or a negative error code on error.
38 @strong{Since:} 2.10.0
41 @subheading gnutls_cipher_decrypt2
42 @anchor{gnutls_cipher_decrypt2}
43 @deftypefun {int} {gnutls_cipher_decrypt2} (gnutls_cipher_hd_t @var{handle}, const void * @var{ciphertext}, size_t @var{ciphertextlen}, void * @var{text}, size_t @var{textlen})
44 @var{handle}: is a @code{gnutls_cipher_hd_t} structure.
46 @var{ciphertext}: the data to encrypt
48 @var{ciphertextlen}: The length of data to encrypt
50 @var{text}: the decrypted data
52 @var{textlen}: The available length for decrypted data
54 This function will decrypt the given data using the algorithm
55 specified by the context.
57 Note that in AEAD ciphers, this will not check the tag. You will
58 need to compare the tag sent with the value returned from @code{gnutls_cipher_tag()} .
60 @strong{Returns:} Zero or a negative error code on error.
62 @strong{Since:} 2.12.0
65 @subheading gnutls_cipher_deinit
66 @anchor{gnutls_cipher_deinit}
67 @deftypefun {void} {gnutls_cipher_deinit} (gnutls_cipher_hd_t @var{handle})
68 @var{handle}: is a @code{gnutls_cipher_hd_t} structure.
70 This function will deinitialize all resources occupied by the given
73 @strong{Since:} 2.10.0
76 @subheading gnutls_cipher_encrypt
77 @anchor{gnutls_cipher_encrypt}
78 @deftypefun {int} {gnutls_cipher_encrypt} (gnutls_cipher_hd_t @var{handle}, void * @var{text}, size_t @var{textlen})
79 @var{handle}: is a @code{gnutls_cipher_hd_t} structure.
81 @var{text}: the data to encrypt
83 @var{textlen}: The length of data to encrypt
85 This function will encrypt the given data using the algorithm
86 specified by the context.
88 @strong{Returns:} Zero or a negative error code on error.
90 @strong{Since:} 2.10.0
93 @subheading gnutls_cipher_encrypt2
94 @anchor{gnutls_cipher_encrypt2}
95 @deftypefun {int} {gnutls_cipher_encrypt2} (gnutls_cipher_hd_t @var{handle}, const void * @var{text}, size_t @var{textlen}, void * @var{ciphertext}, size_t @var{ciphertextlen})
96 @var{handle}: is a @code{gnutls_cipher_hd_t} structure.
98 @var{text}: the data to encrypt
100 @var{textlen}: The length of data to encrypt
102 @var{ciphertext}: the encrypted data
104 @var{ciphertextlen}: The available length for encrypted data
106 This function will encrypt the given data using the algorithm
107 specified by the context.
109 @strong{Returns:} Zero or a negative error code on error.
111 @strong{Since:} 2.12.0
114 @subheading gnutls_cipher_get_block_size
115 @anchor{gnutls_cipher_get_block_size}
116 @deftypefun {int} {gnutls_cipher_get_block_size} (gnutls_cipher_algorithm_t @var{algorithm})
117 @var{algorithm}: is an encryption algorithm
120 @strong{Returns:} the block size of the encryption algorithm.
122 @strong{Since:} 2.10.0
125 @subheading gnutls_cipher_get_iv_size
126 @anchor{gnutls_cipher_get_iv_size}
127 @deftypefun {int} {gnutls_cipher_get_iv_size} (gnutls_cipher_algorithm_t @var{algorithm})
128 @var{algorithm}: is an encryption algorithm
130 Get block size for encryption algorithm.
132 @strong{Returns:} block size for encryption algorithm.
134 @strong{Since:} 3.2.0
137 @subheading gnutls_cipher_get_tag_size
138 @anchor{gnutls_cipher_get_tag_size}
139 @deftypefun {int} {gnutls_cipher_get_tag_size} (gnutls_cipher_algorithm_t @var{algorithm})
140 @var{algorithm}: is an encryption algorithm
143 @strong{Returns:} the tag size of the authenticated encryption algorithm.
145 @strong{Since:} 3.2.2
148 @subheading gnutls_cipher_init
149 @anchor{gnutls_cipher_init}
150 @deftypefun {int} {gnutls_cipher_init} (gnutls_cipher_hd_t * @var{handle}, gnutls_cipher_algorithm_t @var{cipher}, const gnutls_datum_t * @var{key}, const gnutls_datum_t * @var{iv})
151 @var{handle}: is a @code{gnutls_cipher_hd_t} structure.
153 @var{cipher}: the encryption algorithm to use
155 @var{key}: The key to be used for encryption
157 @var{iv}: The IV to use (if not applicable set NULL)
159 This function will initialize an context that can be used for
160 encryption/decryption of data. This will effectively use the
161 current crypto backend in use by gnutls or the cryptographic
164 @strong{Returns:} Zero or a negative error code on error.
166 @strong{Since:} 2.10.0
169 @subheading gnutls_cipher_set_iv
170 @anchor{gnutls_cipher_set_iv}
171 @deftypefun {void} {gnutls_cipher_set_iv} (gnutls_cipher_hd_t @var{handle}, void * @var{iv}, size_t @var{ivlen})
172 @var{handle}: is a @code{gnutls_cipher_hd_t} structure.
174 @var{iv}: the IV to set
176 @var{ivlen}: The length of the IV
178 This function will set the IV to be used for the next
184 @subheading gnutls_cipher_tag
185 @anchor{gnutls_cipher_tag}
186 @deftypefun {int} {gnutls_cipher_tag} (gnutls_cipher_hd_t @var{handle}, void * @var{tag}, size_t @var{tag_size})
187 @var{handle}: is a @code{gnutls_cipher_hd_t} structure.
189 @var{tag}: will hold the tag
191 @var{tag_size}: The length of the tag to return
193 This function operates on authenticated encryption with
194 associated data (AEAD) ciphers and will return the
197 @strong{Returns:} Zero or a negative error code on error.
202 @subheading gnutls_hash
204 @deftypefun {int} {gnutls_hash} (gnutls_hash_hd_t @var{handle}, const void * @var{text}, size_t @var{textlen})
205 @var{handle}: is a @code{gnutls_cipher_hd_t} structure.
207 @var{text}: the data to hash
209 @var{textlen}: The length of data to hash
211 This function will hash the given data using the algorithm
212 specified by the context.
214 @strong{Returns:} Zero or a negative error code on error.
216 @strong{Since:} 2.10.0
219 @subheading gnutls_hash_deinit
220 @anchor{gnutls_hash_deinit}
221 @deftypefun {void} {gnutls_hash_deinit} (gnutls_hash_hd_t @var{handle}, void * @var{digest})
222 @var{handle}: is a @code{gnutls_hash_hd_t} structure.
224 @var{digest}: is the output value of the hash
226 This function will deinitialize all resources occupied by
227 the given hash context.
229 @strong{Since:} 2.10.0
232 @subheading gnutls_hash_fast
233 @anchor{gnutls_hash_fast}
234 @deftypefun {int} {gnutls_hash_fast} (gnutls_digest_algorithm_t @var{algorithm}, const void * @var{text}, size_t @var{textlen}, void * @var{digest})
235 @var{algorithm}: the hash algorithm to use
237 @var{text}: the data to hash
239 @var{textlen}: The length of data to hash
241 @var{digest}: is the output value of the hash
243 This convenience function will hash the given data and return output
246 @strong{Returns:} Zero or a negative error code on error.
248 @strong{Since:} 2.10.0
251 @subheading gnutls_hash_get_len
252 @anchor{gnutls_hash_get_len}
253 @deftypefun {int} {gnutls_hash_get_len} (gnutls_digest_algorithm_t @var{algorithm})
254 @var{algorithm}: the hash algorithm to use
256 This function will return the length of the output data
257 of the given hash algorithm.
259 @strong{Returns:} The length or zero on error.
261 @strong{Since:} 2.10.0
264 @subheading gnutls_hash_init
265 @anchor{gnutls_hash_init}
266 @deftypefun {int} {gnutls_hash_init} (gnutls_hash_hd_t * @var{dig}, gnutls_digest_algorithm_t @var{algorithm})
267 @var{dig}: is a @code{gnutls_hash_hd_t} structure.
269 @var{algorithm}: the hash algorithm to use
271 This function will initialize an context that can be used to
272 produce a Message Digest of data. This will effectively use the
273 current crypto backend in use by gnutls or the cryptographic
276 @strong{Returns:} Zero or a negative error code on error.
278 @strong{Since:} 2.10.0
281 @subheading gnutls_hash_output
282 @anchor{gnutls_hash_output}
283 @deftypefun {void} {gnutls_hash_output} (gnutls_hash_hd_t @var{handle}, void * @var{digest})
284 @var{handle}: is a @code{gnutls_hash_hd_t} structure.
286 @var{digest}: is the output value of the hash
288 This function will output the current hash value
289 and reset the state of the hash.
291 @strong{Since:} 2.10.0
294 @subheading gnutls_hmac
296 @deftypefun {int} {gnutls_hmac} (gnutls_hmac_hd_t @var{handle}, const void * @var{text}, size_t @var{textlen})
297 @var{handle}: is a @code{gnutls_cipher_hd_t} structure.
299 @var{text}: the data to hash
301 @var{textlen}: The length of data to hash
303 This function will hash the given data using the algorithm
304 specified by the context.
306 @strong{Returns:} Zero or a negative error code on error.
308 @strong{Since:} 2.10.0
311 @subheading gnutls_hmac_deinit
312 @anchor{gnutls_hmac_deinit}
313 @deftypefun {void} {gnutls_hmac_deinit} (gnutls_hmac_hd_t @var{handle}, void * @var{digest})
314 @var{handle}: is a @code{gnutls_hmac_hd_t} structure.
316 @var{digest}: is the output value of the MAC
318 This function will deinitialize all resources occupied by
319 the given hmac context.
321 @strong{Since:} 2.10.0
324 @subheading gnutls_hmac_fast
325 @anchor{gnutls_hmac_fast}
326 @deftypefun {int} {gnutls_hmac_fast} (gnutls_mac_algorithm_t @var{algorithm}, const void * @var{key}, size_t @var{keylen}, const void * @var{text}, size_t @var{textlen}, void * @var{digest})
327 @var{algorithm}: the hash algorithm to use
329 @var{key}: the key to use
331 @var{keylen}: The length of the key
333 @var{text}: the data to hash
335 @var{textlen}: The length of data to hash
337 @var{digest}: is the output value of the hash
339 This convenience function will hash the given data and return output
342 @strong{Returns:} Zero or a negative error code on error.
344 @strong{Since:} 2.10.0
347 @subheading gnutls_hmac_get_len
348 @anchor{gnutls_hmac_get_len}
349 @deftypefun {int} {gnutls_hmac_get_len} (gnutls_mac_algorithm_t @var{algorithm})
350 @var{algorithm}: the hmac algorithm to use
352 This function will return the length of the output data
353 of the given hmac algorithm.
355 @strong{Returns:} The length or zero on error.
357 @strong{Since:} 2.10.0
360 @subheading gnutls_hmac_init
361 @anchor{gnutls_hmac_init}
362 @deftypefun {int} {gnutls_hmac_init} (gnutls_hmac_hd_t * @var{dig}, gnutls_mac_algorithm_t @var{algorithm}, const void * @var{key}, size_t @var{keylen})
363 @var{dig}: is a @code{gnutls_hmac_hd_t} structure.
365 @var{algorithm}: the HMAC algorithm to use
367 @var{key}: The key to be used for encryption
369 @var{keylen}: The length of the key
371 This function will initialize an context that can be used to
372 produce a Message Authentication Code (MAC) of data. This will
373 effectively use the current crypto backend in use by gnutls or the
374 cryptographic accelerator in use.
376 Note that despite the name of this function, it can be used
377 for other MAC algorithms than HMAC.
379 @strong{Returns:} Zero or a negative error code on error.
381 @strong{Since:} 2.10.0
384 @subheading gnutls_hmac_output
385 @anchor{gnutls_hmac_output}
386 @deftypefun {void} {gnutls_hmac_output} (gnutls_hmac_hd_t @var{handle}, void * @var{digest})
387 @var{handle}: is a @code{gnutls_hmac_hd_t} structure.
389 @var{digest}: is the output value of the MAC
391 This function will output the current MAC value
392 and reset the state of the MAC.
394 @strong{Since:} 2.10.0
397 @subheading gnutls_hmac_set_nonce
398 @anchor{gnutls_hmac_set_nonce}
399 @deftypefun {void} {gnutls_hmac_set_nonce} (gnutls_hmac_hd_t @var{handle}, const void * @var{nonce}, size_t @var{nonce_len})
400 @var{handle}: is a @code{gnutls_cipher_hd_t} structure.
402 @var{nonce}: the data to set as nonce
404 @var{nonce_len}: The length of data
406 This function will set the nonce in the MAC algorithm.
408 @strong{Since:} 3.2.0
411 @subheading gnutls_mac_get_nonce_size
412 @anchor{gnutls_mac_get_nonce_size}
413 @deftypefun {size_t} {gnutls_mac_get_nonce_size} (gnutls_mac_algorithm_t @var{algorithm})
414 @var{algorithm}: is an encryption algorithm
416 Returns the size of the nonce used by the MAC in TLS.
418 @strong{Returns:} length (in bytes) of the given MAC nonce size, or 0.
420 @strong{Since:} 3.2.0
423 @subheading gnutls_rnd
425 @deftypefun {int} {gnutls_rnd} (gnutls_rnd_level_t @var{level}, void * @var{data}, size_t @var{len})
426 @var{level}: a security level
428 @var{data}: place to store random bytes
430 @var{len}: The requested size
432 This function will generate random data and store it to output
435 This function is thread-safe and also fork-safe.
437 @strong{Returns:} Zero on success, or a negative error code on error.
439 @strong{Since:} 2.12.0
442 @subheading gnutls_rnd_refresh
443 @anchor{gnutls_rnd_refresh}
444 @deftypefun {void} {gnutls_rnd_refresh} ()
446 This function refreshes the random generator state.
447 That is the current precise time, CPU usage, and
448 other values are input into its state.
450 On a slower rate input from /dev/urandom is mixed too.
452 @strong{Since:} 3.1.7