summaryrefslogtreecommitdiff
path: root/manual/html_node/PKCS-7-API.html
blob: af0f932a6e263bcc9105459ef10018038717d702 (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
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<!-- This manual is last updated 4 March 2015 for version
3.5.4 of GnuTLS.

Copyright (C) 2001-2015 Free Software Foundation, Inc.\\
Copyright (C) 2001-2015 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 6.1, http://www.gnu.org/software/texinfo/ -->
<head>
<title>GnuTLS 3.5.4: PKCS 7 API</title>

<meta name="description" content="GnuTLS 3.5.4: PKCS 7 API">
<meta name="keywords" content="GnuTLS 3.5.4: PKCS 7 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="OCSP-API.html#OCSP-API" rel="next" title="OCSP API">
<link href="X509-certificate-API.html#X509-certificate-API" rel="prev" title="X509 certificate API">
<style type="text/css">
<!--
a.summary-letter {text-decoration: none}
blockquote.indentedblock {margin-right: 0em}
blockquote.smallindentedblock {margin-right: 0em; font-size: smaller}
blockquote.smallquotation {font-size: smaller}
div.display {margin-left: 3.2em}
div.example {margin-left: 3.2em}
div.lisp {margin-left: 3.2em}
div.smalldisplay {margin-left: 3.2em}
div.smallexample {margin-left: 3.2em}
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.nolinebreak {white-space: nowrap}
span.roman {font-family: initial; 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;
  border-spacing: 7px;
  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">
<a name="PKCS-7-API"></a>
<div class="header">
<p>
Next: <a href="OCSP-API.html#OCSP-API" accesskey="n" rel="next">OCSP API</a>, Previous: <a href="X509-certificate-API.html#X509-certificate-API" accesskey="p" rel="prev">X509 certificate 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="PKCS-7-API-1"></a>
<h3 class="section">E.4 <acronym>PKCS</acronym> 7 API</h3>

<p>The following functions are to be used for PKCS 7 structures handling.
Their prototypes lie in <samp>gnutls/pkcs7.h</samp>.
</p>

<a name="gnutls_005fpkcs7_005fadd_005fattr-1"></a>
<h4 class="subheading">gnutls_pkcs7_add_attr</h4>
<a name="gnutls_005fpkcs7_005fadd_005fattr"></a><dl>
<dt><a name="index-gnutls_005fpkcs7_005fadd_005fattr"></a>Function: <em>int</em> <strong>gnutls_pkcs7_add_attr</strong> <em>(gnutls_pkcs7_attrs_t * <var>list</var>, const char * <var>oid</var>, gnutls_datum_t * <var>data</var>, unsigned <var>flags</var>)</em></dt>
<dd><p><var>list</var>: A list of existing attributes or pointer to <code>NULL</code>  for the first one
</p>
<p><var>oid</var>: the OID of the attribute to be set
</p>
<p><var>data</var>: the raw (DER-encoded) data of the attribute to be set
</p>
<p><var>flags</var>: zero or <code>GNUTLS_PKCS7_ATTR_ENCODE_OCTET_STRING</code> 
</p>
<p>This function will set a PKCS <code>7</code>  attribute in the provided list.
If this function fails, the previous list would be deallocated.
</p>
<p>Note that any attributes set with this function must either be
DER or BER encoded, unless a special flag is present.
</p>
<p><strong>Returns:</strong> On success, the new list head, otherwise <code>NULL</code> .
</p>
<p><strong>Since:</strong> 3.4.2
</p></dd></dl>

<a name="gnutls_005fpkcs7_005fattrs_005fdeinit-1"></a>
<h4 class="subheading">gnutls_pkcs7_attrs_deinit</h4>
<a name="gnutls_005fpkcs7_005fattrs_005fdeinit"></a><dl>
<dt><a name="index-gnutls_005fpkcs7_005fattrs_005fdeinit"></a>Function: <em>void</em> <strong>gnutls_pkcs7_attrs_deinit</strong> <em>(gnutls_pkcs7_attrs_t <var>list</var>)</em></dt>
<dd><p><var>list</var>: A list of existing attributes
</p>
<p>This function will clear a PKCS <code>7</code>  attribute list.
</p>
<p><strong>Since:</strong> 3.4.2
</p></dd></dl>

<a name="gnutls_005fpkcs7_005fdeinit-1"></a>
<h4 class="subheading">gnutls_pkcs7_deinit</h4>
<a name="gnutls_005fpkcs7_005fdeinit"></a><dl>
<dt><a name="index-gnutls_005fpkcs7_005fdeinit"></a>Function: <em>void</em> <strong>gnutls_pkcs7_deinit</strong> <em>(gnutls_pkcs7_t <var>pkcs7</var>)</em></dt>
<dd><p><var>pkcs7</var>: the type to be deinitialized
</p>
<p>This function will deinitialize a PKCS7 type.
</p></dd></dl>

<a name="gnutls_005fpkcs7_005fdelete_005fcrl-1"></a>
<h4 class="subheading">gnutls_pkcs7_delete_crl</h4>
<a name="gnutls_005fpkcs7_005fdelete_005fcrl"></a><dl>
<dt><a name="index-gnutls_005fpkcs7_005fdelete_005fcrl"></a>Function: <em>int</em> <strong>gnutls_pkcs7_delete_crl</strong> <em>(gnutls_pkcs7_t <var>pkcs7</var>, int <var>indx</var>)</em></dt>
<dd><p><var>pkcs7</var>: The pkcs7 type
</p>
<p><var>indx</var>: the index of the crl to delete
</p>
<p>This function will delete a crl from a PKCS7 or RFC2630 crl set.
Index starts from 0. Returns 0 on success.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code>  (0) is returned, otherwise a
negative error value.
</p></dd></dl>

<a name="gnutls_005fpkcs7_005fdelete_005fcrt-1"></a>
<h4 class="subheading">gnutls_pkcs7_delete_crt</h4>
<a name="gnutls_005fpkcs7_005fdelete_005fcrt"></a><dl>
<dt><a name="index-gnutls_005fpkcs7_005fdelete_005fcrt"></a>Function: <em>int</em> <strong>gnutls_pkcs7_delete_crt</strong> <em>(gnutls_pkcs7_t <var>pkcs7</var>, int <var>indx</var>)</em></dt>
<dd><p><var>pkcs7</var>: The pkcs7 type
</p>
<p><var>indx</var>: the index of the certificate to delete
</p>
<p>This function will delete a certificate from a PKCS7 or RFC2630
certificate set.  Index starts from 0. Returns 0 on success.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code>  (0) is returned, otherwise a
negative error value.
</p></dd></dl>

<a name="gnutls_005fpkcs7_005fexport-1"></a>
<h4 class="subheading">gnutls_pkcs7_export</h4>
<a name="gnutls_005fpkcs7_005fexport"></a><dl>
<dt><a name="index-gnutls_005fpkcs7_005fexport"></a>Function: <em>int</em> <strong>gnutls_pkcs7_export</strong> <em>(gnutls_pkcs7_t <var>pkcs7</var>, gnutls_x509_crt_fmt_t <var>format</var>, void * <var>output_data</var>, size_t * <var>output_data_size</var>)</em></dt>
<dd><p><var>pkcs7</var>: The pkcs7 type
</p>
<p><var>format</var>: the format of output params. One of PEM or DER.
</p>
<p><var>output_data</var>: will contain a structure PEM or DER encoded
</p>
<p><var>output_data_size</var>: holds the size of output_data (and will be
replaced by the actual size of parameters)
</p>
<p>This function will export the pkcs7 structure to DER or PEM format.
</p>
<p>If the buffer provided is not long enough to hold the output, then
* <code>output_data_size</code> is updated and <code>GNUTLS_E_SHORT_MEMORY_BUFFER</code> 
will be returned.
</p>
<p>If the structure is PEM encoded, it will have a header
of &quot;BEGIN PKCS7&quot;.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code>  (0) is returned, otherwise a
negative error value.
</p></dd></dl>

<a name="gnutls_005fpkcs7_005fexport2-1"></a>
<h4 class="subheading">gnutls_pkcs7_export2</h4>
<a name="gnutls_005fpkcs7_005fexport2"></a><dl>
<dt><a name="index-gnutls_005fpkcs7_005fexport2"></a>Function: <em>int</em> <strong>gnutls_pkcs7_export2</strong> <em>(gnutls_pkcs7_t <var>pkcs7</var>, gnutls_x509_crt_fmt_t <var>format</var>, gnutls_datum_t * <var>out</var>)</em></dt>
<dd><p><var>pkcs7</var>: The pkcs7 type
</p>
<p><var>format</var>: the format of output params. One of PEM or DER.
</p>
<p><var>out</var>: will contain a structure PEM or DER encoded
</p>
<p>This function will export the pkcs7 structure to DER or PEM format.
</p>
<p>The output buffer is allocated using <code>gnutls_malloc()</code> .
</p>
<p>If the structure is PEM encoded, it will have a header
of &quot;BEGIN PKCS7&quot;.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code>  (0) is returned, otherwise a
negative error value.
</p>
<p><strong>Since:</strong> 3.1.3
</p></dd></dl>

<a name="gnutls_005fpkcs7_005fget_005fattr-1"></a>
<h4 class="subheading">gnutls_pkcs7_get_attr</h4>
<a name="gnutls_005fpkcs7_005fget_005fattr"></a><dl>
<dt><a name="index-gnutls_005fpkcs7_005fget_005fattr"></a>Function: <em>int</em> <strong>gnutls_pkcs7_get_attr</strong> <em>(gnutls_pkcs7_attrs_t <var>list</var>, unsigned <var>idx</var>, char ** <var>oid</var>, gnutls_datum_t * <var>data</var>, unsigned <var>flags</var>)</em></dt>
<dd><p><var>list</var>: A list of existing attributes or <code>NULL</code>  for the first one
</p>
<p><var>idx</var>: the index of the attribute to get
</p>
<p><var>oid</var>: the OID of the attribute (read-only)
</p>
<p><var>data</var>: the raw data of the attribute
</p>
<p><var>flags</var>: zero or <code>GNUTLS_PKCS7_ATTR_ENCODE_OCTET_STRING</code> 
</p>
<p>This function will get a PKCS <code>7</code>  attribute from the provided list.
The OID is a constant string, but data will be allocated and must be
deinitialized by the caller.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code>  (0) is returned, otherwise a
negative error value. <code>GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE</code>  is returned
if there are no data in the current index.
</p>
<p><strong>Since:</strong> 3.4.2
</p></dd></dl>

<a name="gnutls_005fpkcs7_005fget_005fcrl_005fcount-1"></a>
<h4 class="subheading">gnutls_pkcs7_get_crl_count</h4>
<a name="gnutls_005fpkcs7_005fget_005fcrl_005fcount"></a><dl>
<dt><a name="index-gnutls_005fpkcs7_005fget_005fcrl_005fcount"></a>Function: <em>int</em> <strong>gnutls_pkcs7_get_crl_count</strong> <em>(gnutls_pkcs7_t <var>pkcs7</var>)</em></dt>
<dd><p><var>pkcs7</var>: The pkcs7 type
</p>
<p>This function will return the number of certificates in the PKCS7
or RFC2630 crl set.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code>  (0) is returned, otherwise a
negative error value.
</p></dd></dl>

<a name="gnutls_005fpkcs7_005fget_005fcrl_005fraw-1"></a>
<h4 class="subheading">gnutls_pkcs7_get_crl_raw</h4>
<a name="gnutls_005fpkcs7_005fget_005fcrl_005fraw"></a><dl>
<dt><a name="index-gnutls_005fpkcs7_005fget_005fcrl_005fraw"></a>Function: <em>int</em> <strong>gnutls_pkcs7_get_crl_raw</strong> <em>(gnutls_pkcs7_t <var>pkcs7</var>, unsigned <var>indx</var>, void * <var>crl</var>, size_t * <var>crl_size</var>)</em></dt>
<dd><p><var>pkcs7</var>: The pkcs7 type
</p>
<p><var>indx</var>: contains the index of the crl to extract
</p>
<p><var>crl</var>: the contents of the crl will be copied there (may be null)
</p>
<p><var>crl_size</var>: should hold the size of the crl
</p>
<p>This function will return a crl of the PKCS7 or RFC2630 crl set.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code>  (0) is returned, otherwise a
negative error value.  If the provided buffer is not long enough,
then  <code>crl_size</code> is updated and <code>GNUTLS_E_SHORT_MEMORY_BUFFER</code>  is
returned.  After the last crl has been read
<code>GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE</code>  will be returned.
</p></dd></dl>

<a name="gnutls_005fpkcs7_005fget_005fcrl_005fraw2-1"></a>
<h4 class="subheading">gnutls_pkcs7_get_crl_raw2</h4>
<a name="gnutls_005fpkcs7_005fget_005fcrl_005fraw2"></a><dl>
<dt><a name="index-gnutls_005fpkcs7_005fget_005fcrl_005fraw2"></a>Function: <em>int</em> <strong>gnutls_pkcs7_get_crl_raw2</strong> <em>(gnutls_pkcs7_t <var>pkcs7</var>, unsigned <var>indx</var>, gnutls_datum_t * <var>crl</var>)</em></dt>
<dd><p><var>pkcs7</var>: The pkcs7 type
</p>
<p><var>indx</var>: contains the index of the crl to extract
</p>
<p><var>crl</var>: will contain the contents of the CRL in an allocated buffer
</p>
<p>This function will return a DER encoded CRL of the PKCS7 or RFC2630 crl set.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code>  (0) is returned, otherwise a
negative error value.  After the last crl has been read
<code>GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE</code>  will be returned.
</p>
<p><strong>Since:</strong> 3.4.2
</p></dd></dl>

<a name="gnutls_005fpkcs7_005fget_005fcrt_005fcount-1"></a>
<h4 class="subheading">gnutls_pkcs7_get_crt_count</h4>
<a name="gnutls_005fpkcs7_005fget_005fcrt_005fcount"></a><dl>
<dt><a name="index-gnutls_005fpkcs7_005fget_005fcrt_005fcount"></a>Function: <em>int</em> <strong>gnutls_pkcs7_get_crt_count</strong> <em>(gnutls_pkcs7_t <var>pkcs7</var>)</em></dt>
<dd><p><var>pkcs7</var>: should contain a <code>gnutls_pkcs7_t</code>  type
</p>
<p>This function will return the number of certificates in the PKCS7
or RFC2630 certificate set.
</p>
<p><strong>Returns:</strong> On success, a positive number is returned, otherwise a
negative error value.
</p></dd></dl>

<a name="gnutls_005fpkcs7_005fget_005fcrt_005fraw-1"></a>
<h4 class="subheading">gnutls_pkcs7_get_crt_raw</h4>
<a name="gnutls_005fpkcs7_005fget_005fcrt_005fraw"></a><dl>
<dt><a name="index-gnutls_005fpkcs7_005fget_005fcrt_005fraw"></a>Function: <em>int</em> <strong>gnutls_pkcs7_get_crt_raw</strong> <em>(gnutls_pkcs7_t <var>pkcs7</var>, unsigned <var>indx</var>, void * <var>certificate</var>, size_t * <var>certificate_size</var>)</em></dt>
<dd><p><var>pkcs7</var>: should contain a gnutls_pkcs7_t type
</p>
<p><var>indx</var>: contains the index of the certificate to extract
</p>
<p><var>certificate</var>: the contents of the certificate will be copied
there (may be null)
</p>
<p><var>certificate_size</var>: should hold the size of the certificate
</p>
<p>This function will return a certificate of the PKCS7 or RFC2630
certificate set.
</p>
<p>After the last certificate has been read
<code>GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE</code>  will be returned.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code>  (0) is returned, otherwise a
negative error value.  If the provided buffer is not long enough,
then  <code>certificate_size</code> is updated and
<code>GNUTLS_E_SHORT_MEMORY_BUFFER</code>  is returned.
</p></dd></dl>

<a name="gnutls_005fpkcs7_005fget_005fcrt_005fraw2-1"></a>
<h4 class="subheading">gnutls_pkcs7_get_crt_raw2</h4>
<a name="gnutls_005fpkcs7_005fget_005fcrt_005fraw2"></a><dl>
<dt><a name="index-gnutls_005fpkcs7_005fget_005fcrt_005fraw2"></a>Function: <em>int</em> <strong>gnutls_pkcs7_get_crt_raw2</strong> <em>(gnutls_pkcs7_t <var>pkcs7</var>, unsigned <var>indx</var>, gnutls_datum_t * <var>cert</var>)</em></dt>
<dd><p><var>pkcs7</var>: should contain a gnutls_pkcs7_t type
</p>
<p><var>indx</var>: contains the index of the certificate to extract
</p>
<p><var>cert</var>: will hold the contents of the certificate; must be deallocated with <code>gnutls_free()</code> 
</p>
<p>This function will return a certificate of the PKCS7 or RFC2630
certificate set.
</p>
<p>After the last certificate has been read
<code>GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE</code>  will be returned.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code>  (0) is returned, otherwise a
negative error value.  If the provided buffer is not long enough,
then  <code>certificate_size</code> is updated and
<code>GNUTLS_E_SHORT_MEMORY_BUFFER</code>  is returned.
</p>
<p><strong>Since:</strong> 3.4.2
</p></dd></dl>

<a name="gnutls_005fpkcs7_005fget_005fembedded_005fdata-1"></a>
<h4 class="subheading">gnutls_pkcs7_get_embedded_data</h4>
<a name="gnutls_005fpkcs7_005fget_005fembedded_005fdata"></a><dl>
<dt><a name="index-gnutls_005fpkcs7_005fget_005fembedded_005fdata"></a>Function: <em>int</em> <strong>gnutls_pkcs7_get_embedded_data</strong> <em>(gnutls_pkcs7_t <var>pkcs7</var>, unsigned <var>idx</var>, gnutls_datum_t * <var>data</var>)</em></dt>
<dd><p><var>pkcs7</var>: should contain a gnutls_pkcs7_t type
</p>
<p><var>idx</var>: the index of the signature info to get the data from
</p>
<p><var>data</var>: will hold the embedded data in the provided structure
</p>
<p>This function will return the data embedded in the signature of
the PKCS7 structure. If no data are available then
<code>GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE</code>  will be returned.
</p>
<p>Note, that since a PKCS<code>7</code>  structure may contain embedded data
for each attached signature, this function accepts and index which
corresponds to the signature index to get the data from.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code>  (0) is returned, otherwise a
negative error value. 
</p>
<p><strong>Since:</strong> 3.4.8
</p></dd></dl>

<a name="gnutls_005fpkcs7_005fget_005fsignature_005fcount-1"></a>
<h4 class="subheading">gnutls_pkcs7_get_signature_count</h4>
<a name="gnutls_005fpkcs7_005fget_005fsignature_005fcount"></a><dl>
<dt><a name="index-gnutls_005fpkcs7_005fget_005fsignature_005fcount"></a>Function: <em>int</em> <strong>gnutls_pkcs7_get_signature_count</strong> <em>(gnutls_pkcs7_t <var>pkcs7</var>)</em></dt>
<dd><p><var>pkcs7</var>: should contain a <code>gnutls_pkcs7_t</code>  type
</p>
<p>This function will return the number of signatures in the PKCS7
structure.
</p>
<p><strong>Returns:</strong> On success, a positive number is returned, otherwise a
negative error value.
</p>
<p><strong>Since:</strong> 3.4.3
</p></dd></dl>

<a name="gnutls_005fpkcs7_005fget_005fsignature_005finfo-1"></a>
<h4 class="subheading">gnutls_pkcs7_get_signature_info</h4>
<a name="gnutls_005fpkcs7_005fget_005fsignature_005finfo"></a><dl>
<dt><a name="index-gnutls_005fpkcs7_005fget_005fsignature_005finfo"></a>Function: <em>int</em> <strong>gnutls_pkcs7_get_signature_info</strong> <em>(gnutls_pkcs7_t <var>pkcs7</var>, unsigned <var>idx</var>, gnutls_pkcs7_signature_info_st * <var>info</var>)</em></dt>
<dd><p><var>pkcs7</var>: should contain a <code>gnutls_pkcs7_t</code>  type
</p>
<p><var>idx</var>: the index of the signature info to check
</p>
<p><var>info</var>: will contain the output signature
</p>
<p>This function will return information about the signature identified
by idx in the provided PKCS <code>7</code>  structure. The information should be
deinitialized using <code>gnutls_pkcs7_signature_info_deinit()</code> .
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code>  (0) is returned, otherwise a
negative error value.
</p>
<p><strong>Since:</strong> 3.4.2
</p></dd></dl>

<a name="gnutls_005fpkcs7_005fimport-1"></a>
<h4 class="subheading">gnutls_pkcs7_import</h4>
<a name="gnutls_005fpkcs7_005fimport"></a><dl>
<dt><a name="index-gnutls_005fpkcs7_005fimport"></a>Function: <em>int</em> <strong>gnutls_pkcs7_import</strong> <em>(gnutls_pkcs7_t <var>pkcs7</var>, const gnutls_datum_t * <var>data</var>, gnutls_x509_crt_fmt_t <var>format</var>)</em></dt>
<dd><p><var>pkcs7</var>: The data to store the parsed PKCS7.
</p>
<p><var>data</var>: The DER or PEM encoded PKCS7.
</p>
<p><var>format</var>: One of DER or PEM
</p>
<p>This function will convert the given DER or PEM encoded PKCS7 to
the native <code>gnutls_pkcs7_t</code>  format.  The output will be stored in
 <code>pkcs7</code> .
</p>
<p>If the PKCS7 is PEM encoded it should have a header of &quot;PKCS7&quot;.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code>  (0) is returned, otherwise a
negative error value.
</p></dd></dl>

<a name="gnutls_005fpkcs7_005finit-1"></a>
<h4 class="subheading">gnutls_pkcs7_init</h4>
<a name="gnutls_005fpkcs7_005finit"></a><dl>
<dt><a name="index-gnutls_005fpkcs7_005finit"></a>Function: <em>int</em> <strong>gnutls_pkcs7_init</strong> <em>(gnutls_pkcs7_t * <var>pkcs7</var>)</em></dt>
<dd><p><var>pkcs7</var>: A pointer to the type to be initialized
</p>
<p>This function will initialize a PKCS7 structure. PKCS7 structures
usually contain lists of X.509 Certificates and X.509 Certificate
revocation lists.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code>  (0) is returned, otherwise a
negative error value.
</p></dd></dl>

<a name="gnutls_005fpkcs7_005fprint-1"></a>
<h4 class="subheading">gnutls_pkcs7_print</h4>
<a name="gnutls_005fpkcs7_005fprint"></a><dl>
<dt><a name="index-gnutls_005fpkcs7_005fprint"></a>Function: <em>int</em> <strong>gnutls_pkcs7_print</strong> <em>(gnutls_pkcs7_t <var>pkcs7</var>, gnutls_certificate_print_formats_t <var>format</var>, gnutls_datum_t * <var>out</var>)</em></dt>
<dd><p><var>pkcs7</var>: The PKCS7 struct to be printed
</p>
<p><var>format</var>: Indicate the format to use
</p>
<p><var>out</var>: Newly allocated datum with null terminated string.
</p>
<p>This function will pretty print a signed PKCS <code>7</code>  structure, suitable for
display to a human.
</p>
<p>Currently the supported formats are <code>GNUTLS_CRT_PRINT_FULL</code>  and
<code>GNUTLS_CRT_PRINT_COMPACT</code> .
</p>
<p>The output  <code>out</code> needs to be deallocated using <code>gnutls_free()</code> .
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code>  (0) is returned, otherwise a
negative error value.
</p></dd></dl>

<a name="gnutls_005fpkcs7_005fset_005fcrl-1"></a>
<h4 class="subheading">gnutls_pkcs7_set_crl</h4>
<a name="gnutls_005fpkcs7_005fset_005fcrl"></a><dl>
<dt><a name="index-gnutls_005fpkcs7_005fset_005fcrl"></a>Function: <em>int</em> <strong>gnutls_pkcs7_set_crl</strong> <em>(gnutls_pkcs7_t <var>pkcs7</var>, gnutls_x509_crl_t <var>crl</var>)</em></dt>
<dd><p><var>pkcs7</var>: The pkcs7 type
</p>
<p><var>crl</var>: the DER encoded crl to be added
</p>
<p>This function will add a parsed CRL to the PKCS7 or RFC2630 crl
set.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code>  (0) is returned, otherwise a
negative error value.
</p></dd></dl>

<a name="gnutls_005fpkcs7_005fset_005fcrl_005fraw-1"></a>
<h4 class="subheading">gnutls_pkcs7_set_crl_raw</h4>
<a name="gnutls_005fpkcs7_005fset_005fcrl_005fraw"></a><dl>
<dt><a name="index-gnutls_005fpkcs7_005fset_005fcrl_005fraw"></a>Function: <em>int</em> <strong>gnutls_pkcs7_set_crl_raw</strong> <em>(gnutls_pkcs7_t <var>pkcs7</var>, const gnutls_datum_t * <var>crl</var>)</em></dt>
<dd><p><var>pkcs7</var>: The pkcs7 type
</p>
<p><var>crl</var>: the DER encoded crl to be added
</p>
<p>This function will add a crl to the PKCS7 or RFC2630 crl set.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code>  (0) is returned, otherwise a
negative error value.
</p></dd></dl>

<a name="gnutls_005fpkcs7_005fset_005fcrt-1"></a>
<h4 class="subheading">gnutls_pkcs7_set_crt</h4>
<a name="gnutls_005fpkcs7_005fset_005fcrt"></a><dl>
<dt><a name="index-gnutls_005fpkcs7_005fset_005fcrt"></a>Function: <em>int</em> <strong>gnutls_pkcs7_set_crt</strong> <em>(gnutls_pkcs7_t <var>pkcs7</var>, gnutls_x509_crt_t <var>crt</var>)</em></dt>
<dd><p><var>pkcs7</var>: The pkcs7 type
</p>
<p><var>crt</var>: the certificate to be copied.
</p>
<p>This function will add a parsed certificate to the PKCS7 or
RFC2630 certificate set.  This is a wrapper function over
<code>gnutls_pkcs7_set_crt_raw()</code>  .
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code>  (0) is returned, otherwise a
negative error value.
</p></dd></dl>

<a name="gnutls_005fpkcs7_005fset_005fcrt_005fraw-1"></a>
<h4 class="subheading">gnutls_pkcs7_set_crt_raw</h4>
<a name="gnutls_005fpkcs7_005fset_005fcrt_005fraw"></a><dl>
<dt><a name="index-gnutls_005fpkcs7_005fset_005fcrt_005fraw"></a>Function: <em>int</em> <strong>gnutls_pkcs7_set_crt_raw</strong> <em>(gnutls_pkcs7_t <var>pkcs7</var>, const gnutls_datum_t * <var>crt</var>)</em></dt>
<dd><p><var>pkcs7</var>: The pkcs7 type
</p>
<p><var>crt</var>: the DER encoded certificate to be added
</p>
<p>This function will add a certificate to the PKCS7 or RFC2630
certificate set.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code>  (0) is returned, otherwise a
negative error value.
</p></dd></dl>

<a name="gnutls_005fpkcs7_005fsign-1"></a>
<h4 class="subheading">gnutls_pkcs7_sign</h4>
<a name="gnutls_005fpkcs7_005fsign"></a><dl>
<dt><a name="index-gnutls_005fpkcs7_005fsign-1"></a>Function: <em>int</em> <strong>gnutls_pkcs7_sign</strong> <em>(gnutls_pkcs7_t <var>pkcs7</var>, gnutls_x509_crt_t <var>signer</var>, gnutls_privkey_t <var>signer_key</var>, const gnutls_datum_t * <var>data</var>, gnutls_pkcs7_attrs_t <var>signed_attrs</var>, gnutls_pkcs7_attrs_t <var>unsigned_attrs</var>, gnutls_digest_algorithm_t <var>dig</var>, unsigned <var>flags</var>)</em></dt>
<dd><p><var>pkcs7</var>: should contain a <code>gnutls_pkcs7_t</code>  type
</p>
<p><var>signer</var>: the certificate to sign the structure
</p>
<p><var>signer_key</var>: the key to sign the structure
</p>
<p><var>data</var>: The data to be signed or <code>NULL</code>  if the data are already embedded
</p>
<p><var>signed_attrs</var>: Any additional attributes to be included in the signed ones (or <code>NULL</code> )
</p>
<p><var>unsigned_attrs</var>: Any additional attributes to be included in the unsigned ones (or <code>NULL</code> )
</p>
<p><var>dig</var>: The digest algorithm to use for signing
</p>
<p><var>flags</var>: Should be zero or one of <code>GNUTLS_PKCS7</code>  flags
</p>
<p>This function will add a signature in the provided PKCS <code>7</code>  structure
for the provided data. Multiple signatures can be made with different
signers.
</p>
<p>The available flags are:
<code>GNUTLS_PKCS7_EMBED_DATA</code> , <code>GNUTLS_PKCS7_INCLUDE_TIME</code> , <code>GNUTLS_PKCS7_INCLUDE_CERT</code> ,
and <code>GNUTLS_PKCS7_WRITE_SPKI</code> . They are explained in the <code>gnutls_pkcs7_sign_flags</code> 
definition.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code>  (0) is returned, otherwise a
negative error value. 
</p>
<p><strong>Since:</strong> 3.4.2
</p></dd></dl>

<a name="gnutls_005fpkcs7_005fsignature_005finfo_005fdeinit-1"></a>
<h4 class="subheading">gnutls_pkcs7_signature_info_deinit</h4>
<a name="gnutls_005fpkcs7_005fsignature_005finfo_005fdeinit"></a><dl>
<dt><a name="index-gnutls_005fpkcs7_005fsignature_005finfo_005fdeinit"></a>Function: <em>void</em> <strong>gnutls_pkcs7_signature_info_deinit</strong> <em>(gnutls_pkcs7_signature_info_st * <var>info</var>)</em></dt>
<dd><p><var>info</var>: should point to a <code>gnutls_pkcs7_signature_info_st</code>  structure
</p>
<p>This function will deinitialize any allocated value in the
provided <code>gnutls_pkcs7_signature_info_st</code> .
</p>
<p><strong>Since:</strong> 3.4.2
</p></dd></dl>

<a name="gnutls_005fpkcs7_005fverify-1"></a>
<h4 class="subheading">gnutls_pkcs7_verify</h4>
<a name="gnutls_005fpkcs7_005fverify"></a><dl>
<dt><a name="index-gnutls_005fpkcs7_005fverify"></a>Function: <em>int</em> <strong>gnutls_pkcs7_verify</strong> <em>(gnutls_pkcs7_t <var>pkcs7</var>, gnutls_x509_trust_list_t <var>tl</var>, gnutls_typed_vdata_st * <var>vdata</var>, unsigned int <var>vdata_size</var>, unsigned <var>idx</var>, const gnutls_datum_t * <var>data</var>, unsigned <var>flags</var>)</em></dt>
<dd><p><var>pkcs7</var>: should contain a <code>gnutls_pkcs7_t</code>  type
</p>
<p><var>tl</var>: A list of trusted certificates
</p>
<p><var>vdata</var>: an array of typed data
</p>
<p><var>vdata_size</var>: the number of data elements
</p>
<p><var>idx</var>: the index of the signature info to check
</p>
<p><var>data</var>: The data to be verified or <code>NULL</code> 
</p>
<p><var>flags</var>: Zero or an OR list of <code>gnutls_certificate_verify_flags</code> 
</p>
<p>This function will verify the provided data against the signature
present in the SignedData of the PKCS <code>7</code>  structure. If the data
provided are NULL then the data in the encapsulatedContent field
will be used instead.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code>  (0) is returned, otherwise a
negative error value. A verification error results to a
<code>GNUTLS_E_PK_SIG_VERIFY_FAILED</code>  and the lack of encapsulated data
to verify to a <code>GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE</code> .
</p>
<p><strong>Since:</strong> 3.4.2
</p></dd></dl>

<a name="gnutls_005fpkcs7_005fverify_005fdirect-1"></a>
<h4 class="subheading">gnutls_pkcs7_verify_direct</h4>
<a name="gnutls_005fpkcs7_005fverify_005fdirect"></a><dl>
<dt><a name="index-gnutls_005fpkcs7_005fverify_005fdirect"></a>Function: <em>int</em> <strong>gnutls_pkcs7_verify_direct</strong> <em>(gnutls_pkcs7_t <var>pkcs7</var>, gnutls_x509_crt_t <var>signer</var>, unsigned <var>idx</var>, const gnutls_datum_t * <var>data</var>, unsigned <var>flags</var>)</em></dt>
<dd><p><var>pkcs7</var>: should contain a <code>gnutls_pkcs7_t</code>  type
</p>
<p><var>signer</var>: the certificate believed to have signed the structure
</p>
<p><var>idx</var>: the index of the signature info to check
</p>
<p><var>data</var>: The data to be verified or <code>NULL</code> 
</p>
<p><var>flags</var>: Zero or an OR list of <code>gnutls_certificate_verify_flags</code> 
</p>
<p>This function will verify the provided data against the signature
present in the SignedData of the PKCS <code>7</code>  structure. If the data
provided are NULL then the data in the encapsulatedContent field
will be used instead.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code>  (0) is returned, otherwise a
negative error value. A verification error results to a
<code>GNUTLS_E_PK_SIG_VERIFY_FAILED</code>  and the lack of encapsulated data
to verify to a <code>GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE</code> .
</p>
<p><strong>Since:</strong> 3.4.2
</p></dd></dl>


<hr>
<div class="header">
<p>
Next: <a href="OCSP-API.html#OCSP-API" accesskey="n" rel="next">OCSP API</a>, Previous: <a href="X509-certificate-API.html#X509-certificate-API" accesskey="p" rel="prev">X509 certificate 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>