summaryrefslogtreecommitdiff
path: root/manual/html_node/Cryptographic-API.html
blob: d12f7a4c24b9aea1fb53c3fa2d03e2c5fb6dd471 (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
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<!-- This manual is last updated 10 February 2013 for version
3.2.6 of GnuTLS.

Copyright (C) 2001-2013 Free Software Foundation, Inc.\\
Copyright (C) 2001-2013 Nikos Mavrogiannopoulos

Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or
any later version published by the Free Software Foundation; with no
Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.  A
copy of the license is included in the section entitled "GNU Free
Documentation License". -->
<!-- Created by GNU Texinfo 5.2, http://www.gnu.org/software/texinfo/ -->
<head>
<title>GnuTLS 3.2.6: Cryptographic API</title>

<meta name="description" content="GnuTLS 3.2.6: Cryptographic API">
<meta name="keywords" content="GnuTLS 3.2.6: Cryptographic API">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="makeinfo">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link href="index.html#Top" rel="start" title="Top">
<link href="Function-and-Data-Index.html#Function-and-Data-Index" rel="index" title="Function and Data Index">
<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
<link href="API-reference.html#API-reference" rel="up" title="API reference">
<link href="Compatibility-API.html#Compatibility-API" rel="next" title="Compatibility API">
<link href="DANE-API.html#DANE-API" rel="prev" title="DANE API">
<style type="text/css">
<!--
a.summary-letter {text-decoration: none}
blockquote.smallquotation {font-size: smaller}
div.display {margin-left: 3.2em}
div.example {margin-left: 3.2em}
div.indentedblock {margin-left: 3.2em}
div.lisp {margin-left: 3.2em}
div.smalldisplay {margin-left: 3.2em}
div.smallexample {margin-left: 3.2em}
div.smallindentedblock {margin-left: 3.2em; font-size: smaller}
div.smalllisp {margin-left: 3.2em}
kbd {font-style:oblique}
pre.display {font-family: inherit}
pre.format {font-family: inherit}
pre.menu-comment {font-family: serif}
pre.menu-preformatted {font-family: serif}
pre.smalldisplay {font-family: inherit; font-size: smaller}
pre.smallexample {font-size: smaller}
pre.smallformat {font-family: inherit; font-size: smaller}
pre.smalllisp {font-size: smaller}
span.nocodebreak {white-space:nowrap}
span.nolinebreak {white-space:nowrap}
span.roman {font-family:serif; font-weight:normal}
span.sansserif {font-family:sans-serif; font-weight:normal}
ul.no-bullet {list-style: none}
body { 
	margin: 2%;
	padding: 0 5%;
	background: #ffffff;
}
h1,h2,h3,h4,h5 {
    font-weight: bold;
    padding: 5px 5px 5px 5px;
    background-color: #c2e0ff;
    color: #336699;
}
h1 {
    padding: 2em 2em 2em 5%;
    color: white;
    background: #336699;
    text-align: center;
    letter-spacing: 3px;
}
h2 { text-decoration: underline; }
pre {
  margin: 0 5%;
  padding: 0.5em;
}
pre.example,pre.verbatim {
  padding-bottom: 1em;

  border: solid #c2e0ff;
  background: #f0faff;
  border-width: 1px 1px 1px 5px;
  margin: 1em auto;
  width: 90%;
}

div.node {
  margin: 0 -5% 0 -2%;
  padding: 0.5em 0.5em;
  margin-top: 0.5em;
  margin-bottom: 0.5em;
  font-weight: bold;
}
dd, li {
  padding-top: 0.1em;
  padding-bottom: 0.1em;
}
div.float {

  margin-bottom: 0.5em;
  text-align: center;
}

table {
  text-align: left;
  margin-left:auto;
  margin-right:auto;
  width: 50%;
}

th {
  padding: 0;
  color: #336699;
  background-color: #c2e0ff;
  border: solid #000000;
  border-width: 0px;
  margin: 1em auto;
  text-align: center;
  margin-left:auto;
  margin-right:auto;
}

td {
  padding: 0;
  border: solid #000000;
  background-color: #f0faff;
  border-width: 0px;
  margin: 1em auto;
  text-align: left;
  margin-left:auto;
  margin-right:auto;
  padding-left: 1em;
}

dl {
  text-align: left;
  margin-left:auto;
  margin-right:auto;
  width: 50%;

  padding-left: 1em;
  border: solid #c2e0ff;
  background: #f0faff;
  border-width: 5px 1px 1px 1px;
  margin: 1em auto;
}

-->
</style>


</head>

<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
<a name="Cryptographic-API"></a>
<div class="header">
<p>
Next: <a href="Compatibility-API.html#Compatibility-API" accesskey="n" rel="next">Compatibility API</a>, Previous: <a href="DANE-API.html#DANE-API" accesskey="p" rel="prev">DANE API</a>, Up: <a href="API-reference.html#API-reference" accesskey="u" rel="up">API reference</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Function-and-Data-Index.html#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<hr>
<a name="Cryptographic-API-1"></a>
<h3 class="section">E.12 Cryptographic API</h3>

<p>The following functions are to be used for low-level cryptographic operations.
Their prototypes lie in <samp>gnutls/crypto.h</samp>.
</p>

<a name="gnutls_005fcipher_005fadd_005fauth-1"></a>
<h4 class="subheading">gnutls_cipher_add_auth</h4>
<a name="gnutls_005fcipher_005fadd_005fauth"></a><dl>
<dt><a name="index-gnutls_005fcipher_005fadd_005fauth"></a>Function: <em>int</em> <strong>gnutls_cipher_add_auth</strong> <em>(gnutls_cipher_hd_t <var>handle</var>, const void * <var>text</var>, size_t <var>text_size</var>)</em></dt>
<dd><p><var>handle</var>: is a <code>gnutls_cipher_hd_t</code>  structure.
</p>
<p><var>text</var>: the data to be authenticated
</p>
<p><var>text_size</var>: The length of the data
</p>
<p>This function operates on authenticated encryption with
associated data (AEAD) ciphers and authenticate the
input data. This function can only be called once
and before any encryption operations.
</p>
<p><strong>Returns:</strong> Zero or a negative error code on error.
</p>
<p><strong>Since:</strong> 3.0
</p></dd></dl>

<a name="gnutls_005fcipher_005fdecrypt-1"></a>
<h4 class="subheading">gnutls_cipher_decrypt</h4>
<a name="gnutls_005fcipher_005fdecrypt"></a><dl>
<dt><a name="index-gnutls_005fcipher_005fdecrypt"></a>Function: <em>int</em> <strong>gnutls_cipher_decrypt</strong> <em>(gnutls_cipher_hd_t <var>handle</var>, void * <var>ciphertext</var>, size_t <var>ciphertextlen</var>)</em></dt>
<dd><p><var>handle</var>: is a <code>gnutls_cipher_hd_t</code>  structure.
</p>
<p><var>ciphertext</var>: the data to encrypt
</p>
<p><var>ciphertextlen</var>: The length of data to encrypt
</p>
<p>This function will decrypt the given data using the algorithm
specified by the context.
</p>
<p>Note that in AEAD ciphers, this will not check the tag. You will
need to compare the tag sent with the value returned from <code>gnutls_cipher_tag()</code> .
</p>
<p><strong>Returns:</strong> Zero or a negative error code on error.
</p>
<p><strong>Since:</strong> 2.10.0
</p></dd></dl>

<a name="gnutls_005fcipher_005fdecrypt2-1"></a>
<h4 class="subheading">gnutls_cipher_decrypt2</h4>
<a name="gnutls_005fcipher_005fdecrypt2"></a><dl>
<dt><a name="index-gnutls_005fcipher_005fdecrypt2"></a>Function: <em>int</em> <strong>gnutls_cipher_decrypt2</strong> <em>(gnutls_cipher_hd_t <var>handle</var>, const void * <var>ciphertext</var>, size_t <var>ciphertextlen</var>, void * <var>text</var>, size_t <var>textlen</var>)</em></dt>
<dd><p><var>handle</var>: is a <code>gnutls_cipher_hd_t</code>  structure.
</p>
<p><var>ciphertext</var>: the data to encrypt
</p>
<p><var>ciphertextlen</var>: The length of data to encrypt
</p>
<p><var>text</var>: the decrypted data
</p>
<p><var>textlen</var>: The available length for decrypted data
</p>
<p>This function will decrypt the given data using the algorithm
specified by the context.
</p>
<p>Note that in AEAD ciphers, this will not check the tag. You will
need to compare the tag sent with the value returned from <code>gnutls_cipher_tag()</code> .
</p>
<p><strong>Returns:</strong> Zero or a negative error code on error.
</p>
<p><strong>Since:</strong> 2.12.0
</p></dd></dl>

<a name="gnutls_005fcipher_005fdeinit-1"></a>
<h4 class="subheading">gnutls_cipher_deinit</h4>
<a name="gnutls_005fcipher_005fdeinit"></a><dl>
<dt><a name="index-gnutls_005fcipher_005fdeinit"></a>Function: <em>void</em> <strong>gnutls_cipher_deinit</strong> <em>(gnutls_cipher_hd_t <var>handle</var>)</em></dt>
<dd><p><var>handle</var>: is a <code>gnutls_cipher_hd_t</code>  structure.
</p>
<p>This function will deinitialize all resources occupied by the given
encryption context.
</p>
<p><strong>Since:</strong> 2.10.0
</p></dd></dl>

<a name="gnutls_005fcipher_005fencrypt-1"></a>
<h4 class="subheading">gnutls_cipher_encrypt</h4>
<a name="gnutls_005fcipher_005fencrypt"></a><dl>
<dt><a name="index-gnutls_005fcipher_005fencrypt"></a>Function: <em>int</em> <strong>gnutls_cipher_encrypt</strong> <em>(gnutls_cipher_hd_t <var>handle</var>, void * <var>text</var>, size_t <var>textlen</var>)</em></dt>
<dd><p><var>handle</var>: is a <code>gnutls_cipher_hd_t</code>  structure.
</p>
<p><var>text</var>: the data to encrypt
</p>
<p><var>textlen</var>: The length of data to encrypt
</p>
<p>This function will encrypt the given data using the algorithm
specified by the context.
</p>
<p><strong>Returns:</strong> Zero or a negative error code on error.
</p>
<p><strong>Since:</strong> 2.10.0
</p></dd></dl>

<a name="gnutls_005fcipher_005fencrypt2-1"></a>
<h4 class="subheading">gnutls_cipher_encrypt2</h4>
<a name="gnutls_005fcipher_005fencrypt2"></a><dl>
<dt><a name="index-gnutls_005fcipher_005fencrypt2"></a>Function: <em>int</em> <strong>gnutls_cipher_encrypt2</strong> <em>(gnutls_cipher_hd_t <var>handle</var>, const void * <var>text</var>, size_t <var>textlen</var>, void * <var>ciphertext</var>, size_t <var>ciphertextlen</var>)</em></dt>
<dd><p><var>handle</var>: is a <code>gnutls_cipher_hd_t</code>  structure.
</p>
<p><var>text</var>: the data to encrypt
</p>
<p><var>textlen</var>: The length of data to encrypt
</p>
<p><var>ciphertext</var>: the encrypted data
</p>
<p><var>ciphertextlen</var>: The available length for encrypted data
</p>
<p>This function will encrypt the given data using the algorithm
specified by the context.
</p>
<p><strong>Returns:</strong> Zero or a negative error code on error.
</p>
<p><strong>Since:</strong> 2.12.0
</p></dd></dl>

<a name="gnutls_005fcipher_005fget_005fblock_005fsize-1"></a>
<h4 class="subheading">gnutls_cipher_get_block_size</h4>
<a name="gnutls_005fcipher_005fget_005fblock_005fsize"></a><dl>
<dt><a name="index-gnutls_005fcipher_005fget_005fblock_005fsize"></a>Function: <em>int</em> <strong>gnutls_cipher_get_block_size</strong> <em>(gnutls_cipher_algorithm_t <var>algorithm</var>)</em></dt>
<dd><p><var>algorithm</var>: is an encryption algorithm
</p>

<p><strong>Returns:</strong> the block size of the encryption algorithm.
</p>
<p><strong>Since:</strong> 2.10.0
</p></dd></dl>

<a name="gnutls_005fcipher_005fget_005fiv_005fsize-1"></a>
<h4 class="subheading">gnutls_cipher_get_iv_size</h4>
<a name="gnutls_005fcipher_005fget_005fiv_005fsize"></a><dl>
<dt><a name="index-gnutls_005fcipher_005fget_005fiv_005fsize"></a>Function: <em>int</em> <strong>gnutls_cipher_get_iv_size</strong> <em>(gnutls_cipher_algorithm_t <var>algorithm</var>)</em></dt>
<dd><p><var>algorithm</var>: is an encryption algorithm
</p>
<p>Get block size for encryption algorithm.
</p>
<p><strong>Returns:</strong> block size for encryption algorithm.
</p>
<p><strong>Since:</strong> 3.2.0
</p></dd></dl>

<a name="gnutls_005fcipher_005fget_005ftag_005fsize-1"></a>
<h4 class="subheading">gnutls_cipher_get_tag_size</h4>
<a name="gnutls_005fcipher_005fget_005ftag_005fsize"></a><dl>
<dt><a name="index-gnutls_005fcipher_005fget_005ftag_005fsize"></a>Function: <em>int</em> <strong>gnutls_cipher_get_tag_size</strong> <em>(gnutls_cipher_algorithm_t <var>algorithm</var>)</em></dt>
<dd><p><var>algorithm</var>: is an encryption algorithm
</p>

<p><strong>Returns:</strong> the tag size of the authenticated encryption algorithm.
</p>
<p><strong>Since:</strong> 3.2.2
</p></dd></dl>

<a name="gnutls_005fcipher_005finit-1"></a>
<h4 class="subheading">gnutls_cipher_init</h4>
<a name="gnutls_005fcipher_005finit"></a><dl>
<dt><a name="index-gnutls_005fcipher_005finit"></a>Function: <em>int</em> <strong>gnutls_cipher_init</strong> <em>(gnutls_cipher_hd_t * <var>handle</var>, gnutls_cipher_algorithm_t <var>cipher</var>, const gnutls_datum_t * <var>key</var>, const gnutls_datum_t * <var>iv</var>)</em></dt>
<dd><p><var>handle</var>: is a <code>gnutls_cipher_hd_t</code>  structure.
</p>
<p><var>cipher</var>: the encryption algorithm to use
</p>
<p><var>key</var>: The key to be used for encryption
</p>
<p><var>iv</var>: The IV to use (if not applicable set NULL)
</p>
<p>This function will initialize an context that can be used for
encryption/decryption of data. This will effectively use the
current crypto backend in use by gnutls or the cryptographic
accelerator in use.
</p>
<p><strong>Returns:</strong> Zero or a negative error code on error.
</p>
<p><strong>Since:</strong> 2.10.0
</p></dd></dl>

<a name="gnutls_005fcipher_005fset_005fiv-1"></a>
<h4 class="subheading">gnutls_cipher_set_iv</h4>
<a name="gnutls_005fcipher_005fset_005fiv"></a><dl>
<dt><a name="index-gnutls_005fcipher_005fset_005fiv"></a>Function: <em>void</em> <strong>gnutls_cipher_set_iv</strong> <em>(gnutls_cipher_hd_t <var>handle</var>, void * <var>iv</var>, size_t <var>ivlen</var>)</em></dt>
<dd><p><var>handle</var>: is a <code>gnutls_cipher_hd_t</code>  structure.
</p>
<p><var>iv</var>: the IV to set
</p>
<p><var>ivlen</var>: The length of the IV
</p>
<p>This function will set the IV to be used for the next
encryption block.
</p>
<p><strong>Since:</strong> 3.0
</p></dd></dl>

<a name="gnutls_005fcipher_005ftag-1"></a>
<h4 class="subheading">gnutls_cipher_tag</h4>
<a name="gnutls_005fcipher_005ftag"></a><dl>
<dt><a name="index-gnutls_005fcipher_005ftag"></a>Function: <em>int</em> <strong>gnutls_cipher_tag</strong> <em>(gnutls_cipher_hd_t <var>handle</var>, void * <var>tag</var>, size_t <var>tag_size</var>)</em></dt>
<dd><p><var>handle</var>: is a <code>gnutls_cipher_hd_t</code>  structure.
</p>
<p><var>tag</var>: will hold the tag
</p>
<p><var>tag_size</var>: The length of the tag to return
</p>
<p>This function operates on authenticated encryption with
associated data (AEAD) ciphers and will return the
output tag.
</p>
<p><strong>Returns:</strong> Zero or a negative error code on error.
</p>
<p><strong>Since:</strong> 3.0
</p></dd></dl>

<a name="gnutls_005fhash-1"></a>
<h4 class="subheading">gnutls_hash</h4>
<a name="gnutls_005fhash"></a><dl>
<dt><a name="index-gnutls_005fhash"></a>Function: <em>int</em> <strong>gnutls_hash</strong> <em>(gnutls_hash_hd_t <var>handle</var>, const void * <var>text</var>, size_t <var>textlen</var>)</em></dt>
<dd><p><var>handle</var>: is a <code>gnutls_cipher_hd_t</code>  structure.
</p>
<p><var>text</var>: the data to hash
</p>
<p><var>textlen</var>: The length of data to hash
</p>
<p>This function will hash the given data using the algorithm
specified by the context.
</p>
<p><strong>Returns:</strong> Zero or a negative error code on error.
</p>
<p><strong>Since:</strong> 2.10.0
</p></dd></dl>

<a name="gnutls_005fhash_005fdeinit-1"></a>
<h4 class="subheading">gnutls_hash_deinit</h4>
<a name="gnutls_005fhash_005fdeinit"></a><dl>
<dt><a name="index-gnutls_005fhash_005fdeinit"></a>Function: <em>void</em> <strong>gnutls_hash_deinit</strong> <em>(gnutls_hash_hd_t <var>handle</var>, void * <var>digest</var>)</em></dt>
<dd><p><var>handle</var>: is a <code>gnutls_hash_hd_t</code>  structure.
</p>
<p><var>digest</var>: is the output value of the hash
</p>
<p>This function will deinitialize all resources occupied by
the given hash context.
</p>
<p><strong>Since:</strong> 2.10.0
</p></dd></dl>

<a name="gnutls_005fhash_005ffast-1"></a>
<h4 class="subheading">gnutls_hash_fast</h4>
<a name="gnutls_005fhash_005ffast"></a><dl>
<dt><a name="index-gnutls_005fhash_005ffast"></a>Function: <em>int</em> <strong>gnutls_hash_fast</strong> <em>(gnutls_digest_algorithm_t <var>algorithm</var>, const void * <var>text</var>, size_t <var>textlen</var>, void * <var>digest</var>)</em></dt>
<dd><p><var>algorithm</var>: the hash algorithm to use
</p>
<p><var>text</var>: the data to hash
</p>
<p><var>textlen</var>: The length of data to hash
</p>
<p><var>digest</var>: is the output value of the hash
</p>
<p>This convenience function will hash the given data and return output
on a single call.
</p>
<p><strong>Returns:</strong> Zero or a negative error code on error.
</p>
<p><strong>Since:</strong> 2.10.0
</p></dd></dl>

<a name="gnutls_005fhash_005fget_005flen-1"></a>
<h4 class="subheading">gnutls_hash_get_len</h4>
<a name="gnutls_005fhash_005fget_005flen"></a><dl>
<dt><a name="index-gnutls_005fhash_005fget_005flen"></a>Function: <em>int</em> <strong>gnutls_hash_get_len</strong> <em>(gnutls_digest_algorithm_t <var>algorithm</var>)</em></dt>
<dd><p><var>algorithm</var>: the hash algorithm to use
</p>
<p>This function will return the length of the output data
of the given hash algorithm.
</p>
<p><strong>Returns:</strong> The length or zero on error.
</p>
<p><strong>Since:</strong> 2.10.0
</p></dd></dl>

<a name="gnutls_005fhash_005finit-1"></a>
<h4 class="subheading">gnutls_hash_init</h4>
<a name="gnutls_005fhash_005finit"></a><dl>
<dt><a name="index-gnutls_005fhash_005finit"></a>Function: <em>int</em> <strong>gnutls_hash_init</strong> <em>(gnutls_hash_hd_t * <var>dig</var>, gnutls_digest_algorithm_t <var>algorithm</var>)</em></dt>
<dd><p><var>dig</var>: is a <code>gnutls_hash_hd_t</code>  structure.
</p>
<p><var>algorithm</var>: the hash algorithm to use
</p>
<p>This function will initialize an context that can be used to
produce a Message Digest of data.  This will effectively use the
current crypto backend in use by gnutls or the cryptographic
accelerator in use.
</p>
<p><strong>Returns:</strong> Zero or a negative error code on error.
</p>
<p><strong>Since:</strong> 2.10.0
</p></dd></dl>

<a name="gnutls_005fhash_005foutput-1"></a>
<h4 class="subheading">gnutls_hash_output</h4>
<a name="gnutls_005fhash_005foutput"></a><dl>
<dt><a name="index-gnutls_005fhash_005foutput"></a>Function: <em>void</em> <strong>gnutls_hash_output</strong> <em>(gnutls_hash_hd_t <var>handle</var>, void * <var>digest</var>)</em></dt>
<dd><p><var>handle</var>: is a <code>gnutls_hash_hd_t</code>  structure.
</p>
<p><var>digest</var>: is the output value of the hash
</p>
<p>This function will output the current hash value
and reset the state of the hash.
</p>
<p><strong>Since:</strong> 2.10.0
</p></dd></dl>

<a name="gnutls_005fhmac-1"></a>
<h4 class="subheading">gnutls_hmac</h4>
<a name="gnutls_005fhmac"></a><dl>
<dt><a name="index-gnutls_005fhmac"></a>Function: <em>int</em> <strong>gnutls_hmac</strong> <em>(gnutls_hmac_hd_t <var>handle</var>, const void * <var>text</var>, size_t <var>textlen</var>)</em></dt>
<dd><p><var>handle</var>: is a <code>gnutls_cipher_hd_t</code>  structure.
</p>
<p><var>text</var>: the data to hash
</p>
<p><var>textlen</var>: The length of data to hash
</p>
<p>This function will hash the given data using the algorithm
specified by the context.
</p>
<p><strong>Returns:</strong> Zero or a negative error code on error.
</p>
<p><strong>Since:</strong> 2.10.0
</p></dd></dl>

<a name="gnutls_005fhmac_005fdeinit-1"></a>
<h4 class="subheading">gnutls_hmac_deinit</h4>
<a name="gnutls_005fhmac_005fdeinit"></a><dl>
<dt><a name="index-gnutls_005fhmac_005fdeinit"></a>Function: <em>void</em> <strong>gnutls_hmac_deinit</strong> <em>(gnutls_hmac_hd_t <var>handle</var>, void * <var>digest</var>)</em></dt>
<dd><p><var>handle</var>: is a <code>gnutls_hmac_hd_t</code>  structure.
</p>
<p><var>digest</var>: is the output value of the MAC
</p>
<p>This function will deinitialize all resources occupied by
the given hmac context.
</p>
<p><strong>Since:</strong> 2.10.0
</p></dd></dl>

<a name="gnutls_005fhmac_005ffast-1"></a>
<h4 class="subheading">gnutls_hmac_fast</h4>
<a name="gnutls_005fhmac_005ffast"></a><dl>
<dt><a name="index-gnutls_005fhmac_005ffast"></a>Function: <em>int</em> <strong>gnutls_hmac_fast</strong> <em>(gnutls_mac_algorithm_t <var>algorithm</var>, const void * <var>key</var>, size_t <var>keylen</var>, const void * <var>text</var>, size_t <var>textlen</var>, void * <var>digest</var>)</em></dt>
<dd><p><var>algorithm</var>: the hash algorithm to use
</p>
<p><var>key</var>: the key to use
</p>
<p><var>keylen</var>: The length of the key
</p>
<p><var>text</var>: the data to hash
</p>
<p><var>textlen</var>: The length of data to hash
</p>
<p><var>digest</var>: is the output value of the hash
</p>
<p>This convenience function will hash the given data and return output
on a single call.
</p>
<p><strong>Returns:</strong> Zero or a negative error code on error.
</p>
<p><strong>Since:</strong> 2.10.0
</p></dd></dl>

<a name="gnutls_005fhmac_005fget_005flen-1"></a>
<h4 class="subheading">gnutls_hmac_get_len</h4>
<a name="gnutls_005fhmac_005fget_005flen"></a><dl>
<dt><a name="index-gnutls_005fhmac_005fget_005flen"></a>Function: <em>int</em> <strong>gnutls_hmac_get_len</strong> <em>(gnutls_mac_algorithm_t <var>algorithm</var>)</em></dt>
<dd><p><var>algorithm</var>: the hmac algorithm to use
</p>
<p>This function will return the length of the output data
of the given hmac algorithm.
</p>
<p><strong>Returns:</strong> The length or zero on error.
</p>
<p><strong>Since:</strong> 2.10.0
</p></dd></dl>

<a name="gnutls_005fhmac_005finit-1"></a>
<h4 class="subheading">gnutls_hmac_init</h4>
<a name="gnutls_005fhmac_005finit"></a><dl>
<dt><a name="index-gnutls_005fhmac_005finit"></a>Function: <em>int</em> <strong>gnutls_hmac_init</strong> <em>(gnutls_hmac_hd_t * <var>dig</var>, gnutls_mac_algorithm_t <var>algorithm</var>, const void * <var>key</var>, size_t <var>keylen</var>)</em></dt>
<dd><p><var>dig</var>: is a <code>gnutls_hmac_hd_t</code>  structure.
</p>
<p><var>algorithm</var>: the HMAC algorithm to use
</p>
<p><var>key</var>: The key to be used for encryption
</p>
<p><var>keylen</var>: The length of the key
</p>
<p>This function will initialize an context that can be used to
produce a Message Authentication Code (MAC) of data.  This will
effectively use the current crypto backend in use by gnutls or the
cryptographic accelerator in use.
</p>
<p>Note that despite the name of this function, it can be used
for other MAC algorithms than HMAC.
</p>
<p><strong>Returns:</strong> Zero or a negative error code on error.
</p>
<p><strong>Since:</strong> 2.10.0
</p></dd></dl>

<a name="gnutls_005fhmac_005foutput-1"></a>
<h4 class="subheading">gnutls_hmac_output</h4>
<a name="gnutls_005fhmac_005foutput"></a><dl>
<dt><a name="index-gnutls_005fhmac_005foutput"></a>Function: <em>void</em> <strong>gnutls_hmac_output</strong> <em>(gnutls_hmac_hd_t <var>handle</var>, void * <var>digest</var>)</em></dt>
<dd><p><var>handle</var>: is a <code>gnutls_hmac_hd_t</code>  structure.
</p>
<p><var>digest</var>: is the output value of the MAC
</p>
<p>This function will output the current MAC value
and reset the state of the MAC.
</p>
<p><strong>Since:</strong> 2.10.0
</p></dd></dl>

<a name="gnutls_005fhmac_005fset_005fnonce-1"></a>
<h4 class="subheading">gnutls_hmac_set_nonce</h4>
<a name="gnutls_005fhmac_005fset_005fnonce"></a><dl>
<dt><a name="index-gnutls_005fhmac_005fset_005fnonce"></a>Function: <em>void</em> <strong>gnutls_hmac_set_nonce</strong> <em>(gnutls_hmac_hd_t <var>handle</var>, const void * <var>nonce</var>, size_t <var>nonce_len</var>)</em></dt>
<dd><p><var>handle</var>: is a <code>gnutls_cipher_hd_t</code>  structure.
</p>
<p><var>nonce</var>: the data to set as nonce
</p>
<p><var>nonce_len</var>: The length of data
</p>
<p>This function will set the nonce in the MAC algorithm.
</p>
<p><strong>Since:</strong> 3.2.0
</p></dd></dl>

<a name="gnutls_005fmac_005fget_005fnonce_005fsize-1"></a>
<h4 class="subheading">gnutls_mac_get_nonce_size</h4>
<a name="gnutls_005fmac_005fget_005fnonce_005fsize"></a><dl>
<dt><a name="index-gnutls_005fmac_005fget_005fnonce_005fsize"></a>Function: <em>size_t</em> <strong>gnutls_mac_get_nonce_size</strong> <em>(gnutls_mac_algorithm_t <var>algorithm</var>)</em></dt>
<dd><p><var>algorithm</var>: is an encryption algorithm
</p>
<p>Returns the size of the nonce used by the MAC in TLS.
</p>
<p><strong>Returns:</strong> length (in bytes) of the given MAC nonce size, or 0.
</p>
<p><strong>Since:</strong> 3.2.0
</p></dd></dl>

<a name="gnutls_005frnd-1"></a>
<h4 class="subheading">gnutls_rnd</h4>
<a name="gnutls_005frnd"></a><dl>
<dt><a name="index-gnutls_005frnd-1"></a>Function: <em>int</em> <strong>gnutls_rnd</strong> <em>(gnutls_rnd_level_t <var>level</var>, void * <var>data</var>, size_t <var>len</var>)</em></dt>
<dd><p><var>level</var>: a security level
</p>
<p><var>data</var>: place to store random bytes
</p>
<p><var>len</var>: The requested size
</p>
<p>This function will generate random data and store it to output
buffer.
</p>
<p><strong>Returns:</strong> Zero or a negative error code on error.
</p>
<p><strong>Since:</strong> 2.12.0
</p></dd></dl>

<a name="gnutls_005frnd_005frefresh-1"></a>
<h4 class="subheading">gnutls_rnd_refresh</h4>
<a name="gnutls_005frnd_005frefresh"></a><dl>
<dt><a name="index-gnutls_005frnd_005frefresh"></a>Function: <em>void</em> <strong>gnutls_rnd_refresh</strong> <em>()</em></dt>
<dd>
<p>This function refreshes the random generator state.
That is the current precise time, CPU usage, and
other values are input into its state.
</p>
<p>On a slower rate input from /dev/urandom is mixed too.
</p>
<p><strong>Since:</strong> 3.1.7
</p></dd></dl>


<hr>
<div class="header">
<p>
Next: <a href="Compatibility-API.html#Compatibility-API" accesskey="n" rel="next">Compatibility API</a>, Previous: <a href="DANE-API.html#DANE-API" accesskey="p" rel="prev">DANE API</a>, Up: <a href="API-reference.html#API-reference" accesskey="u" rel="up">API reference</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Function-and-Data-Index.html#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>



</body>
</html>