summaryrefslogtreecommitdiff
path: root/manual/html_node/PKCS-11-API.html
blob: 1e5111ec8e96ab269bf96d147d0bed0a6ad00349 (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
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
<!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.3 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.3: PKCS 11 API</title>

<meta name="description" content="GnuTLS 3.5.3: PKCS 11 API">
<meta name="keywords" content="GnuTLS 3.5.3: PKCS 11 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="TPM-API.html#TPM-API" rel="next" title="TPM API">
<link href="PKCS-12-API.html#PKCS-12-API" rel="prev" title="PKCS 12 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-11-API"></a>
<div class="header">
<p>
Next: <a href="TPM-API.html#TPM-API" accesskey="n" rel="next">TPM API</a>, Previous: <a href="PKCS-12-API.html#PKCS-12-API" accesskey="p" rel="prev">PKCS 12 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="Hardware-token-via-PKCS-11-API"></a>
<h3 class="section">E.8 Hardware token via PKCS 11 API</h3>

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

<a name="gnutls_005fpkcs11_005fadd_005fprovider-1"></a>
<h4 class="subheading">gnutls_pkcs11_add_provider</h4>
<a name="gnutls_005fpkcs11_005fadd_005fprovider"></a><dl>
<dt><a name="index-gnutls_005fpkcs11_005fadd_005fprovider-1"></a>Function: <em>int</em> <strong>gnutls_pkcs11_add_provider</strong> <em>(const char * <var>name</var>, const char * <var>params</var>)</em></dt>
<dd><p><var>name</var>: The filename of the module
</p>
<p><var>params</var>: should be NULL or a known string (see description)
</p>
<p>This function will load and add a PKCS 11 module to the module
list used in gnutls. After this function is called the module will
be used for PKCS 11 operations.
</p>
<p>When loading a module to be used for certificate verification,
use the string &rsquo;trusted&rsquo; as  <code>params</code> .
</p>
<p>Note that this function is not thread safe.
</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> 2.12.0
</p></dd></dl>

<a name="gnutls_005fpkcs11_005fcopy_005fattached_005fextension-1"></a>
<h4 class="subheading">gnutls_pkcs11_copy_attached_extension</h4>
<a name="gnutls_005fpkcs11_005fcopy_005fattached_005fextension"></a><dl>
<dt><a name="index-gnutls_005fpkcs11_005fcopy_005fattached_005fextension"></a>Function: <em>int</em> <strong>gnutls_pkcs11_copy_attached_extension</strong> <em>(const char * <var>token_url</var>, gnutls_x509_crt_t <var>crt</var>, gnutls_datum_t * <var>data</var>, const char * <var>label</var>, unsigned int <var>flags</var>)</em></dt>
<dd><p><var>token_url</var>: A PKCS <code>11</code>  URL specifying a token
</p>
<p><var>crt</var>: An X.509 certificate object
</p>
<p><var>data</var>: the attached extension
</p>
<p><var>label</var>: A name to be used for the attached extension (may be <code>NULL</code> )
</p>
<p><var>flags</var>: One of GNUTLS_PKCS11_OBJ_FLAG_*
</p>
<p>This function will copy an the attached extension in  <code>data</code> for
the certificate provided in  <code>crt</code> in the PKCS <code>11</code>  token specified
by the URL (typically a trust module). The extension must be in
RFC5280 Extension format.
</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.3.8
</p></dd></dl>

<a name="gnutls_005fpkcs11_005fcopy_005fpubkey-1"></a>
<h4 class="subheading">gnutls_pkcs11_copy_pubkey</h4>
<a name="gnutls_005fpkcs11_005fcopy_005fpubkey"></a><dl>
<dt><a name="index-gnutls_005fpkcs11_005fcopy_005fpubkey"></a>Function: <em>int</em> <strong>gnutls_pkcs11_copy_pubkey</strong> <em>(const char * <var>token_url</var>, gnutls_pubkey_t <var>pubkey</var>, const char * <var>label</var>, const gnutls_datum_t * <var>cid</var>, unsigned int <var>key_usage</var>, unsigned int <var>flags</var>)</em></dt>
<dd><p><var>token_url</var>: A PKCS <code>11</code>  URL specifying a token
</p>
<p><var>pubkey</var>: The public key to copy
</p>
<p><var>label</var>: The name to be used for the stored data
</p>
<p><var>cid</var>: The CKA_ID to set for the object -if NULL, the ID will be derived from the public key
</p>
<p><var>key_usage</var>: One of GNUTLS_KEY_*
</p>
<p><var>flags</var>: One of GNUTLS_PKCS11_OBJ_FLAG_*
</p>
<p>This function will copy a public key object into a PKCS <code>11</code>  token specified by
a URL. Valid flags to mark the key: <code>GNUTLS_PKCS11_OBJ_FLAG_MARK_TRUSTED</code> ,
<code>GNUTLS_PKCS11_OBJ_FLAG_MARK_SENSITIVE</code> , <code>GNUTLS_PKCS11_OBJ_FLAG_MARK_PRIVATE</code> ,
<code>GNUTLS_PKCS11_OBJ_FLAG_MARK_CA</code> , <code>GNUTLS_PKCS11_OBJ_FLAG_MARK_ALWAYS_AUTH</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.6
</p></dd></dl>

<a name="gnutls_005fpkcs11_005fcopy_005fsecret_005fkey-1"></a>
<h4 class="subheading">gnutls_pkcs11_copy_secret_key</h4>
<a name="gnutls_005fpkcs11_005fcopy_005fsecret_005fkey"></a><dl>
<dt><a name="index-gnutls_005fpkcs11_005fcopy_005fsecret_005fkey"></a>Function: <em>int</em> <strong>gnutls_pkcs11_copy_secret_key</strong> <em>(const char * <var>token_url</var>, gnutls_datum_t * <var>key</var>, const char * <var>label</var>, unsigned int <var>key_usage</var>, unsigned int <var>flags</var>)</em></dt>
<dd><p><var>token_url</var>: A PKCS <code>11</code>  URL specifying a token
</p>
<p><var>key</var>: The raw key
</p>
<p><var>label</var>: A name to be used for the stored data
</p>
<p><var>key_usage</var>: One of GNUTLS_KEY_*
</p>
<p><var>flags</var>: One of GNUTLS_PKCS11_OBJ_FLAG_*
</p>
<p>This function will copy a raw secret (symmetric) key into a PKCS <code>11</code>  
token specified by a URL. The key can be marked as sensitive or not.
</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> 2.12.0
</p></dd></dl>

<a name="gnutls_005fpkcs11_005fcopy_005fx509_005fcrt-1"></a>
<h4 class="subheading">gnutls_pkcs11_copy_x509_crt</h4>
<a name="gnutls_005fpkcs11_005fcopy_005fx509_005fcrt"></a><dl>
<dt><a name="index-gnutls_005fpkcs11_005fcopy_005fx509_005fcrt"></a>Function: <em>int</em> <strong>gnutls_pkcs11_copy_x509_crt</strong> <em>(const char * <var>token_url</var>, gnutls_x509_crt_t <var>crt</var>, const char * <var>label</var>, unsigned int <var>flags</var>)</em></dt>
<dd><p><var>token_url</var>: A PKCS <code>11</code>  URL specifying a token
</p>
<p><var>crt</var>: A certificate
</p>
<p><var>label</var>: A name to be used for the stored data
</p>
<p><var>flags</var>: One of GNUTLS_PKCS11_OBJ_FLAG_*
</p>
<p>This function will copy a certificate into a PKCS <code>11</code>  token specified by
a URL. The certificate can be marked as trusted or not.
</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> 2.12.0
</p></dd></dl>

<a name="gnutls_005fpkcs11_005fcopy_005fx509_005fcrt2-1"></a>
<h4 class="subheading">gnutls_pkcs11_copy_x509_crt2</h4>
<a name="gnutls_005fpkcs11_005fcopy_005fx509_005fcrt2"></a><dl>
<dt><a name="index-gnutls_005fpkcs11_005fcopy_005fx509_005fcrt2-1"></a>Function: <em>int</em> <strong>gnutls_pkcs11_copy_x509_crt2</strong> <em>(const char * <var>token_url</var>, gnutls_x509_crt_t <var>crt</var>, const char * <var>label</var>, const gnutls_datum_t * <var>cid</var>, unsigned int <var>flags</var>)</em></dt>
<dd><p><var>token_url</var>: A PKCS <code>11</code>  URL specifying a token
</p>
<p><var>crt</var>: The certificate to copy
</p>
<p><var>label</var>: The name to be used for the stored data
</p>
<p><var>cid</var>: The CKA_ID to set for the object -if NULL, the ID will be derived from the public key
</p>
<p><var>flags</var>: One of GNUTLS_PKCS11_OBJ_FLAG_*
</p>
<p>This function will copy a certificate into a PKCS <code>11</code>  token specified by
a URL. Valid flags to mark the certificate: <code>GNUTLS_PKCS11_OBJ_FLAG_MARK_TRUSTED</code> ,
<code>GNUTLS_PKCS11_OBJ_FLAG_MARK_SENSITIVE</code> , <code>GNUTLS_PKCS11_OBJ_FLAG_MARK_PRIVATE</code> ,
<code>GNUTLS_PKCS11_OBJ_FLAG_MARK_CA</code> , <code>GNUTLS_PKCS11_OBJ_FLAG_MARK_ALWAYS_AUTH</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.0
</p></dd></dl>

<a name="gnutls_005fpkcs11_005fcopy_005fx509_005fprivkey-1"></a>
<h4 class="subheading">gnutls_pkcs11_copy_x509_privkey</h4>
<a name="gnutls_005fpkcs11_005fcopy_005fx509_005fprivkey"></a><dl>
<dt><a name="index-gnutls_005fpkcs11_005fcopy_005fx509_005fprivkey"></a>Function: <em>int</em> <strong>gnutls_pkcs11_copy_x509_privkey</strong> <em>(const char * <var>token_url</var>, gnutls_x509_privkey_t <var>key</var>, const char * <var>label</var>, unsigned int <var>key_usage</var>, unsigned int <var>flags</var>)</em></dt>
<dd><p><var>token_url</var>: A PKCS <code>11</code>  URL specifying a token
</p>
<p><var>key</var>: A private key
</p>
<p><var>label</var>: A name to be used for the stored data
</p>
<p><var>key_usage</var>: One of GNUTLS_KEY_*
</p>
<p><var>flags</var>: One of GNUTLS_PKCS11_OBJ_* flags
</p>
<p>This function will copy a private key into a PKCS <code>11</code>  token specified by
a URL. It is highly recommended flags to contain <code>GNUTLS_PKCS11_OBJ_FLAG_MARK_SENSITIVE</code> 
unless there is a strong reason not to.
</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> 2.12.0
</p></dd></dl>

<a name="gnutls_005fpkcs11_005fcopy_005fx509_005fprivkey2-1"></a>
<h4 class="subheading">gnutls_pkcs11_copy_x509_privkey2</h4>
<a name="gnutls_005fpkcs11_005fcopy_005fx509_005fprivkey2"></a><dl>
<dt><a name="index-gnutls_005fpkcs11_005fcopy_005fx509_005fprivkey2-1"></a>Function: <em>int</em> <strong>gnutls_pkcs11_copy_x509_privkey2</strong> <em>(const char * <var>token_url</var>, gnutls_x509_privkey_t <var>key</var>, const char * <var>label</var>, const gnutls_datum_t * <var>cid</var>, unsigned int <var>key_usage</var>, unsigned int <var>flags</var>)</em></dt>
<dd><p><var>token_url</var>: A PKCS <code>11</code>  URL specifying a token
</p>
<p><var>key</var>: A private key
</p>
<p><var>label</var>: A name to be used for the stored data
</p>
<p><var>cid</var>: The CKA_ID to set for the object -if NULL, the ID will be derived from the public key
</p>
<p><var>key_usage</var>: One of GNUTLS_KEY_*
</p>
<p><var>flags</var>: One of GNUTLS_PKCS11_OBJ_* flags
</p>
<p>This function will copy a private key into a PKCS <code>11</code>  token specified by
a URL. It is highly recommended flags to contain <code>GNUTLS_PKCS11_OBJ_FLAG_MARK_SENSITIVE</code> 
unless there is a strong reason not to.
</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.0
</p></dd></dl>

<a name="gnutls_005fpkcs11_005fcrt_005fis_005fknown-1"></a>
<h4 class="subheading">gnutls_pkcs11_crt_is_known</h4>
<a name="gnutls_005fpkcs11_005fcrt_005fis_005fknown"></a><dl>
<dt><a name="index-gnutls_005fpkcs11_005fcrt_005fis_005fknown"></a>Function: <em>unsigned</em> <strong>gnutls_pkcs11_crt_is_known</strong> <em>(const char * <var>url</var>, gnutls_x509_crt_t <var>cert</var>, unsigned int <var>flags</var>)</em></dt>
<dd><p><var>url</var>: A PKCS 11 url identifying a token
</p>
<p><var>cert</var>: is the certificate to find issuer for
</p>
<p><var>flags</var>: Use zero or flags from <code>GNUTLS_PKCS11_OBJ_FLAG</code> .
</p>
<p>This function will check whether the provided certificate is stored
in the specified token. This is useful in combination with 
<code>GNUTLS_PKCS11_OBJ_FLAG_RETRIEVE_TRUSTED</code>  or
<code>GNUTLS_PKCS11_OBJ_FLAG_RETRIEVE_DISTRUSTED</code> ,
to check whether a CA is present or a certificate is blacklisted in
a trust PKCS <code>11</code>  module.
</p>
<p>This function can be used with a  <code>url</code> of &quot;pkcs11:&quot;, and in that case all modules
will be searched. To restrict the modules to the marked as trusted in p11-kit
use the <code>GNUTLS_PKCS11_OBJ_FLAG_PRESENT_IN_TRUSTED_MODULE</code>  flag.
</p>
<p>Note that the flag <code>GNUTLS_PKCS11_OBJ_FLAG_RETRIEVE_DISTRUSTED</code>  is
specific to p11-kit trust modules.
</p>
<p><strong>Returns:</strong> If the certificate exists non-zero is returned, otherwise zero.
</p>
<p><strong>Since:</strong> 3.3.0
</p></dd></dl>

<a name="gnutls_005fpkcs11_005fdeinit-1"></a>
<h4 class="subheading">gnutls_pkcs11_deinit</h4>
<a name="gnutls_005fpkcs11_005fdeinit"></a><dl>
<dt><a name="index-gnutls_005fpkcs11_005fdeinit"></a>Function: <em>void</em> <strong>gnutls_pkcs11_deinit</strong> <em>( <var>void</var>)</em></dt>
<dd>
<p>This function will deinitialize the PKCS 11 subsystem in gnutls.
This function is only needed if you need to deinitialize the
subsystem without calling <code>gnutls_global_deinit()</code> .
</p>
<p><strong>Since:</strong> 2.12.0
</p></dd></dl>

<a name="gnutls_005fpkcs11_005fdelete_005furl-1"></a>
<h4 class="subheading">gnutls_pkcs11_delete_url</h4>
<a name="gnutls_005fpkcs11_005fdelete_005furl"></a><dl>
<dt><a name="index-gnutls_005fpkcs11_005fdelete_005furl-1"></a>Function: <em>int</em> <strong>gnutls_pkcs11_delete_url</strong> <em>(const char * <var>object_url</var>, unsigned int <var>flags</var>)</em></dt>
<dd><p><var>object_url</var>: The URL of the object to delete.
</p>
<p><var>flags</var>: One of GNUTLS_PKCS11_OBJ_* flags
</p>
<p>This function will delete objects matching the given URL.
Note that not all tokens support the delete operation.
</p>
<p><strong>Returns:</strong> On success, the number of objects deleted is returned, otherwise a
negative error value.
</p>
<p><strong>Since:</strong> 2.12.0
</p></dd></dl>

<a name="gnutls_005fpkcs11_005fget_005fpin_005ffunction-1"></a>
<h4 class="subheading">gnutls_pkcs11_get_pin_function</h4>
<a name="gnutls_005fpkcs11_005fget_005fpin_005ffunction"></a><dl>
<dt><a name="index-gnutls_005fpkcs11_005fget_005fpin_005ffunction"></a>Function: <em>gnutls_pin_callback_t</em> <strong>gnutls_pkcs11_get_pin_function</strong> <em>(void ** <var>userdata</var>)</em></dt>
<dd><p><var>userdata</var>: data to be supplied to callback
</p>
<p>This function will return the callback function set using
<code>gnutls_pkcs11_set_pin_function()</code> .
</p>
<p><strong>Returns:</strong> The function set or NULL otherwise.
</p>
<p><strong>Since:</strong> 3.1.0
</p></dd></dl>

<a name="gnutls_005fpkcs11_005fget_005fraw_005fissuer-1"></a>
<h4 class="subheading">gnutls_pkcs11_get_raw_issuer</h4>
<a name="gnutls_005fpkcs11_005fget_005fraw_005fissuer"></a><dl>
<dt><a name="index-gnutls_005fpkcs11_005fget_005fraw_005fissuer"></a>Function: <em>int</em> <strong>gnutls_pkcs11_get_raw_issuer</strong> <em>(const char * <var>url</var>, gnutls_x509_crt_t <var>cert</var>, gnutls_datum_t * <var>issuer</var>, gnutls_x509_crt_fmt_t <var>fmt</var>, unsigned int <var>flags</var>)</em></dt>
<dd><p><var>url</var>: A PKCS 11 url identifying a token
</p>
<p><var>cert</var>: is the certificate to find issuer for
</p>
<p><var>issuer</var>: Will hold the issuer if any in an allocated buffer.
</p>
<p><var>fmt</var>: The format of the exported issuer.
</p>
<p><var>flags</var>: Use zero or flags from <code>GNUTLS_PKCS11_OBJ_FLAG</code> .
</p>
<p>This function will return the issuer of a given certificate, if it
is stored in the token. By default only marked as trusted issuers
are retuned. If any issuer should be returned specify
<code>GNUTLS_PKCS11_OBJ_FLAG_RETRIEVE_ANY</code>  in  <code>flags</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.2.7
</p></dd></dl>

<a name="gnutls_005fpkcs11_005fget_005fraw_005fissuer_005fby_005fdn-1"></a>
<h4 class="subheading">gnutls_pkcs11_get_raw_issuer_by_dn</h4>
<a name="gnutls_005fpkcs11_005fget_005fraw_005fissuer_005fby_005fdn"></a><dl>
<dt><a name="index-gnutls_005fpkcs11_005fget_005fraw_005fissuer_005fby_005fdn"></a>Function: <em>int</em> <strong>gnutls_pkcs11_get_raw_issuer_by_dn</strong> <em>(const char * <var>url</var>, const gnutls_datum_t * <var>dn</var>, gnutls_datum_t * <var>issuer</var>, gnutls_x509_crt_fmt_t <var>fmt</var>, unsigned int <var>flags</var>)</em></dt>
<dd><p><var>url</var>: A PKCS 11 url identifying a token
</p>
<p><var>dn</var>: is the DN to search for
</p>
<p><var>issuer</var>: Will hold the issuer if any in an allocated buffer.
</p>
<p><var>fmt</var>: The format of the exported issuer.
</p>
<p><var>flags</var>: Use zero or flags from <code>GNUTLS_PKCS11_OBJ_FLAG</code> .
</p>
<p>This function will return the certificate with the given DN, if it
is stored in the token. By default only marked as trusted issuers
are retuned. If any issuer should be returned specify
<code>GNUTLS_PKCS11_OBJ_FLAG_RETRIEVE_ANY</code>  in  <code>flags</code> .
</p>
<p>The name of the function includes issuer because it can
be used to discover issuers of certificates.
</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.0
</p></dd></dl>

<a name="gnutls_005fpkcs11_005fget_005fraw_005fissuer_005fby_005fsubject_005fkey_005fid-1"></a>
<h4 class="subheading">gnutls_pkcs11_get_raw_issuer_by_subject_key_id</h4>
<a name="gnutls_005fpkcs11_005fget_005fraw_005fissuer_005fby_005fsubject_005fkey_005fid"></a><dl>
<dt><a name="index-gnutls_005fpkcs11_005fget_005fraw_005fissuer_005fby_005fsubject_005fkey_005fid"></a>Function: <em>int</em> <strong>gnutls_pkcs11_get_raw_issuer_by_subject_key_id</strong> <em>(const char * <var>url</var>, const gnutls_datum_t * <var>dn</var>, const gnutls_datum_t * <var>spki</var>, gnutls_datum_t * <var>issuer</var>, gnutls_x509_crt_fmt_t <var>fmt</var>, unsigned int <var>flags</var>)</em></dt>
<dd><p><var>url</var>: A PKCS 11 url identifying a token
</p>
<p><var>dn</var>: is the DN to search for (may be <code>NULL</code> )
</p>
<p><var>spki</var>: is the subject key ID to search for
</p>
<p><var>issuer</var>: Will hold the issuer if any in an allocated buffer.
</p>
<p><var>fmt</var>: The format of the exported issuer.
</p>
<p><var>flags</var>: Use zero or flags from <code>GNUTLS_PKCS11_OBJ_FLAG</code> .
</p>
<p>This function will return the certificate with the given DN and  <code>spki</code> , if it
is stored in the token. By default only marked as trusted issuers
are retuned. If any issuer should be returned specify
<code>GNUTLS_PKCS11_OBJ_FLAG_RETRIEVE_ANY</code>  in  <code>flags</code> .
</p>
<p>The name of the function includes issuer because it can
be used to discover issuers of certificates.
</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_005fpkcs11_005finit-1"></a>
<h4 class="subheading">gnutls_pkcs11_init</h4>
<a name="gnutls_005fpkcs11_005finit"></a><dl>
<dt><a name="index-gnutls_005fpkcs11_005finit-1"></a>Function: <em>int</em> <strong>gnutls_pkcs11_init</strong> <em>(unsigned int <var>flags</var>, const char * <var>deprecated_config_file</var>)</em></dt>
<dd><p><var>flags</var>: An ORed sequence of <code>GNUTLS_PKCS11_FLAG_</code> *
</p>
<p><var>deprecated_config_file</var>: either NULL or the location of a deprecated
configuration file
</p>
<p>This function will initialize the PKCS 11 subsystem in gnutls. It will
read configuration files if <code>GNUTLS_PKCS11_FLAG_AUTO</code>  is used or allow
you to independently load PKCS 11 modules using <code>gnutls_pkcs11_add_provider()</code> 
if <code>GNUTLS_PKCS11_FLAG_MANUAL</code>  is specified.
</p>
<p>You don&rsquo;t need to call this function since GnuTLS 3.3.0 because it is being called
during the first request PKCS 11 operation. That call will assume the <code>GNUTLS_PKCS11_FLAG_AUTO</code> 
flag. If another flags are required then it must be called independently
prior to any PKCS 11 operation.
</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> 2.12.0
</p></dd></dl>

<a name="gnutls_005fpkcs11_005fobj_005fdeinit-1"></a>
<h4 class="subheading">gnutls_pkcs11_obj_deinit</h4>
<a name="gnutls_005fpkcs11_005fobj_005fdeinit"></a><dl>
<dt><a name="index-gnutls_005fpkcs11_005fobj_005fdeinit"></a>Function: <em>void</em> <strong>gnutls_pkcs11_obj_deinit</strong> <em>(gnutls_pkcs11_obj_t <var>obj</var>)</em></dt>
<dd><p><var>obj</var>: The type to be deinitialized
</p>
<p>This function will deinitialize a certificate structure.
</p>
<p><strong>Since:</strong> 2.12.0
</p></dd></dl>

<a name="gnutls_005fpkcs11_005fobj_005fexport-1"></a>
<h4 class="subheading">gnutls_pkcs11_obj_export</h4>
<a name="gnutls_005fpkcs11_005fobj_005fexport"></a><dl>
<dt><a name="index-gnutls_005fpkcs11_005fobj_005fexport"></a>Function: <em>int</em> <strong>gnutls_pkcs11_obj_export</strong> <em>(gnutls_pkcs11_obj_t <var>obj</var>, void * <var>output_data</var>, size_t * <var>output_data_size</var>)</em></dt>
<dd><p><var>obj</var>: Holds the object
</p>
<p><var>output_data</var>: will contain the object data
</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 PKCS11 object data.  It is normal for
data to be inaccesible and in that case <code>GNUTLS_E_INVALID_REQUEST</code> 
will be returned.
</p>
<p>If the buffer provided is not long enough to hold the output, then
*output_data_size is updated and GNUTLS_E_SHORT_MEMORY_BUFFER will
be returned.
</p>
<p><strong>Returns:</strong> In case of failure a negative error code will be
returned, and <code>GNUTLS_E_SUCCESS</code>  (0) on success.
</p>
<p><strong>Since:</strong> 2.12.0
</p></dd></dl>

<a name="gnutls_005fpkcs11_005fobj_005fexport2-1"></a>
<h4 class="subheading">gnutls_pkcs11_obj_export2</h4>
<a name="gnutls_005fpkcs11_005fobj_005fexport2"></a><dl>
<dt><a name="index-gnutls_005fpkcs11_005fobj_005fexport2"></a>Function: <em>int</em> <strong>gnutls_pkcs11_obj_export2</strong> <em>(gnutls_pkcs11_obj_t <var>obj</var>, gnutls_datum_t * <var>out</var>)</em></dt>
<dd><p><var>obj</var>: Holds the object
</p>
<p><var>out</var>: will contain the object data
</p>
<p>This function will export the PKCS11 object data.  It is normal for
data to be inaccesible and in that case <code>GNUTLS_E_INVALID_REQUEST</code> 
will be returned.
</p>
<p>The output buffer is allocated using <code>gnutls_malloc()</code> .
</p>
<p><strong>Returns:</strong> In case of failure a negative error code will be
returned, and <code>GNUTLS_E_SUCCESS</code>  (0) on success.
</p>
<p><strong>Since:</strong> 3.1.3
</p></dd></dl>

<a name="gnutls_005fpkcs11_005fobj_005fexport3-1"></a>
<h4 class="subheading">gnutls_pkcs11_obj_export3</h4>
<a name="gnutls_005fpkcs11_005fobj_005fexport3"></a><dl>
<dt><a name="index-gnutls_005fpkcs11_005fobj_005fexport3"></a>Function: <em>int</em> <strong>gnutls_pkcs11_obj_export3</strong> <em>(gnutls_pkcs11_obj_t <var>obj</var>, gnutls_x509_crt_fmt_t <var>fmt</var>, gnutls_datum_t * <var>out</var>)</em></dt>
<dd><p><var>obj</var>: Holds the object
</p>
<p><var>fmt</var>: The format of the exported data
</p>
<p><var>out</var>: will contain the object data
</p>
<p>This function will export the PKCS11 object data.  It is normal for
data to be inaccesible and in that case <code>GNUTLS_E_INVALID_REQUEST</code> 
will be returned.
</p>
<p>The output buffer is allocated using <code>gnutls_malloc()</code> .
</p>
<p><strong>Returns:</strong> In case of failure a negative error code will be
returned, and <code>GNUTLS_E_SUCCESS</code>  (0) on success.
</p>
<p><strong>Since:</strong> 3.2.7
</p></dd></dl>

<a name="gnutls_005fpkcs11_005fobj_005fexport_005furl-1"></a>
<h4 class="subheading">gnutls_pkcs11_obj_export_url</h4>
<a name="gnutls_005fpkcs11_005fobj_005fexport_005furl"></a><dl>
<dt><a name="index-gnutls_005fpkcs11_005fobj_005fexport_005furl"></a>Function: <em>int</em> <strong>gnutls_pkcs11_obj_export_url</strong> <em>(gnutls_pkcs11_obj_t <var>obj</var>, gnutls_pkcs11_url_type_t <var>detailed</var>, char ** <var>url</var>)</em></dt>
<dd><p><var>obj</var>: Holds the PKCS 11 certificate
</p>
<p><var>detailed</var>: non zero if a detailed URL is required
</p>
<p><var>url</var>: will contain an allocated url
</p>
<p>This function will export a URL identifying the given object.
</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> 2.12.0
</p></dd></dl>

<a name="gnutls_005fpkcs11_005fobj_005fflags_005fget_005fstr-1"></a>
<h4 class="subheading">gnutls_pkcs11_obj_flags_get_str</h4>
<a name="gnutls_005fpkcs11_005fobj_005fflags_005fget_005fstr"></a><dl>
<dt><a name="index-gnutls_005fpkcs11_005fobj_005fflags_005fget_005fstr"></a>Function: <em>char *</em> <strong>gnutls_pkcs11_obj_flags_get_str</strong> <em>(unsigned int <var>flags</var>)</em></dt>
<dd><p><var>flags</var>: holds the flags
</p>
<p>This function given an or-sequence of <code>GNUTLS_PKCS11_OBJ_FLAG_MARK</code> ,
will return an allocated string with its description. The string
needs to be deallocated using <code>gnutls_free()</code> .
</p>
<p><strong>Returns:</strong> If flags is zero <code>NULL</code>  is returned, otherwise an allocated string.
</p>
<p><strong>Since:</strong> 3.3.7
</p></dd></dl>

<a name="gnutls_005fpkcs11_005fobj_005fget_005fexts-1"></a>
<h4 class="subheading">gnutls_pkcs11_obj_get_exts</h4>
<a name="gnutls_005fpkcs11_005fobj_005fget_005fexts"></a><dl>
<dt><a name="index-gnutls_005fpkcs11_005fobj_005fget_005fexts"></a>Function: <em>int</em> <strong>gnutls_pkcs11_obj_get_exts</strong> <em>(gnutls_pkcs11_obj_t <var>obj</var>, gnutls_x509_ext_st ** <var>exts</var>, unsigned int * <var>exts_size</var>, unsigned int <var>flags</var>)</em></dt>
<dd><p><var>obj</var>: should contain a <code>gnutls_pkcs11_obj_t</code>  type
</p>
<p><var>exts</var>: a pointer to a <code>gnutls_x509_ext_st</code>  pointer
</p>
<p><var>exts_size</var>: will be updated with the number of  <code>exts</code> 
</p>
<p><var>flags</var>: Or sequence of <code>GNUTLS_PKCS11_OBJ_</code> * flags 
</p>
<p>This function will return information about attached extensions
that associate to the provided object (which should be a certificate).
The extensions are the attached p11-kit trust module extensions.
</p>
<p>Each element of  <code>exts</code> must be deinitialized using <code>gnutls_x509_ext_deinit()</code> 
while  <code>exts</code> should be deallocated using <code>gnutls_free()</code> .
</p>
<p><strong>Returns:</strong> <code>GNUTLS_E_SUCCESS</code>  (0) on success or a negative error code on error.
</p>
<p><strong>Since:</strong> 3.3.8
</p></dd></dl>

<a name="gnutls_005fpkcs11_005fobj_005fget_005fflags-1"></a>
<h4 class="subheading">gnutls_pkcs11_obj_get_flags</h4>
<a name="gnutls_005fpkcs11_005fobj_005fget_005fflags"></a><dl>
<dt><a name="index-gnutls_005fpkcs11_005fobj_005fget_005fflags"></a>Function: <em>int</em> <strong>gnutls_pkcs11_obj_get_flags</strong> <em>(gnutls_pkcs11_obj_t <var>obj</var>, unsigned int * <var>oflags</var>)</em></dt>
<dd><p><var>obj</var>: The pkcs11 object
</p>
<p><var>oflags</var>: Will hold the output flags
</p>
<p>This function will return the flags of the object.
The  <code>oflags</code> will be flags from <code>gnutls_pkcs11_obj_flags</code> . That is,
the <code>GNUTLS_PKCS11_OBJ_FLAG_MARK_</code> * flags.
</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.3.7
</p></dd></dl>

<a name="gnutls_005fpkcs11_005fobj_005fget_005finfo-1"></a>
<h4 class="subheading">gnutls_pkcs11_obj_get_info</h4>
<a name="gnutls_005fpkcs11_005fobj_005fget_005finfo"></a><dl>
<dt><a name="index-gnutls_005fpkcs11_005fobj_005fget_005finfo-1"></a>Function: <em>int</em> <strong>gnutls_pkcs11_obj_get_info</strong> <em>(gnutls_pkcs11_obj_t <var>obj</var>, gnutls_pkcs11_obj_info_t <var>itype</var>, void * <var>output</var>, size_t * <var>output_size</var>)</em></dt>
<dd><p><var>obj</var>: should contain a <code>gnutls_pkcs11_obj_t</code>  type
</p>
<p><var>itype</var>: Denotes the type of information requested
</p>
<p><var>output</var>: where output will be stored
</p>
<p><var>output_size</var>: contains the maximum size of the output and will be overwritten with actual
</p>
<p>This function will return information about the PKCS11 certificate
such as the label, id as well as token information where the key is
stored. When output is text it returns null terminated string
although  <code>output_size</code> contains the size of the actual data only.
</p>
<p><strong>Returns:</strong> <code>GNUTLS_E_SUCCESS</code>  (0) on success or a negative error code on error.
</p>
<p><strong>Since:</strong> 2.12.0
</p></dd></dl>

<a name="gnutls_005fpkcs11_005fobj_005fget_005ftype-1"></a>
<h4 class="subheading">gnutls_pkcs11_obj_get_type</h4>
<a name="gnutls_005fpkcs11_005fobj_005fget_005ftype"></a><dl>
<dt><a name="index-gnutls_005fpkcs11_005fobj_005fget_005ftype"></a>Function: <em>gnutls_pkcs11_obj_type_t</em> <strong>gnutls_pkcs11_obj_get_type</strong> <em>(gnutls_pkcs11_obj_t <var>obj</var>)</em></dt>
<dd><p><var>obj</var>: Holds the PKCS 11 object
</p>
<p>This function will return the type of the object being
stored in the structure.
</p>
<p><strong>Returns:</strong> The type of the object
</p>
<p><strong>Since:</strong> 2.12.0
</p></dd></dl>

<a name="gnutls_005fpkcs11_005fobj_005fimport_005furl-1"></a>
<h4 class="subheading">gnutls_pkcs11_obj_import_url</h4>
<a name="gnutls_005fpkcs11_005fobj_005fimport_005furl"></a><dl>
<dt><a name="index-gnutls_005fpkcs11_005fobj_005fimport_005furl"></a>Function: <em>int</em> <strong>gnutls_pkcs11_obj_import_url</strong> <em>(gnutls_pkcs11_obj_t <var>obj</var>, const char * <var>url</var>, unsigned int <var>flags</var>)</em></dt>
<dd><p><var>obj</var>: The structure to store the object
</p>
<p><var>url</var>: a PKCS 11 url identifying the key
</p>
<p><var>flags</var>: Or sequence of GNUTLS_PKCS11_OBJ_* flags
</p>
<p>This function will &quot;import&quot; a PKCS 11 URL identifying an object (e.g. certificate)
to the <code>gnutls_pkcs11_obj_t</code>  type. This does not involve any
parsing (such as X.509 or OpenPGP) since the <code>gnutls_pkcs11_obj_t</code>  is
format agnostic. Only data are transferred.
</p>
<p>If the flag <code>GNUTLS_PKCS11_OBJ_FLAG_OVERWRITE_TRUSTMOD_EXT</code>  is specified
any certificate read, will have its extensions overwritten by any
stapled extensions in the trust module.
</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> 2.12.0
</p></dd></dl>

<a name="gnutls_005fpkcs11_005fobj_005finit-1"></a>
<h4 class="subheading">gnutls_pkcs11_obj_init</h4>
<a name="gnutls_005fpkcs11_005fobj_005finit"></a><dl>
<dt><a name="index-gnutls_005fpkcs11_005fobj_005finit"></a>Function: <em>int</em> <strong>gnutls_pkcs11_obj_init</strong> <em>(gnutls_pkcs11_obj_t * <var>obj</var>)</em></dt>
<dd><p><var>obj</var>: A pointer to the type to be initialized
</p>
<p>This function will initialize a pkcs11 certificate structure.
</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> 2.12.0
</p></dd></dl>

<a name="gnutls_005fpkcs11_005fobj_005flist_005fimport_005furl3-1"></a>
<h4 class="subheading">gnutls_pkcs11_obj_list_import_url3</h4>
<a name="gnutls_005fpkcs11_005fobj_005flist_005fimport_005furl3"></a><dl>
<dt><a name="index-gnutls_005fpkcs11_005fobj_005flist_005fimport_005furl3"></a>Function: <em>int</em> <strong>gnutls_pkcs11_obj_list_import_url3</strong> <em>(gnutls_pkcs11_obj_t * <var>p_list</var>, unsigned int * <var>n_list</var>, const char * <var>url</var>, unsigned int <var>flags</var>)</em></dt>
<dd><p><var>p_list</var>: An uninitialized object list (may be <code>NULL</code> )
</p>
<p><var>n_list</var>: Initially should hold the maximum size of the list. Will contain the actual size.
</p>
<p><var>url</var>: A PKCS 11 url identifying a set of objects
</p>
<p><var>flags</var>: Or sequence of GNUTLS_PKCS11_OBJ_* flags
</p>
<p>This function will initialize and set values to an object list
by using all objects identified by a PKCS 11 URL.
</p>
<p>This function will enumerate all the objects specified by the PKCS<code>11</code>  URL
provided. It expects an already allocated  <code>p_list</code> which has * <code>n_list</code> elements,
and that value will be updated to the actual number of present objects. The
 <code>p_list</code> objects will be initialized and set by this function.
To obtain a list of all available objects use a  <code>url</code> of &rsquo;pkcs11:&rsquo;.
</p>
<p>All returned objects must be deinitialized using <code>gnutls_pkcs11_obj_deinit()</code> .
</p>
<p>The supported in this function  <code>flags</code> are <code>GNUTLS_PKCS11_OBJ_FLAG_LOGIN</code> ,
<code>GNUTLS_PKCS11_OBJ_FLAG_LOGIN_SO</code> , <code>GNUTLS_PKCS11_OBJ_FLAG_PRESENT_IN_TRUSTED_MODULE</code> ,
<code>GNUTLS_PKCS11_OBJ_FLAG_CRT</code> , <code>GNUTLS_PKCS11_OBJ_FLAG_PUBKEY</code> , <code>GNUTLS_PKCS11_OBJ_FLAG_PRIVKEY</code> ,
<code>GNUTLS_PKCS11_OBJ_FLAG_WITH_PRIVKEY</code> , <code>GNUTLS_PKCS11_OBJ_FLAG_MARK_CA</code> ,
<code>GNUTLS_PKCS11_OBJ_FLAG_MARK_TRUSTED</code> , and since 3.5.1 the <code>GNUTLS_PKCS11_OBJ_FLAG_OVERWRITE_TRUSTMOD_EXT</code> .
</p>
<p>On versions of GnuTLS prior to 3.4.0 the equivalent function was
<code>gnutls_pkcs11_obj_list_import_url()</code> . That is also available on this version
as a macro which maps to this function.
</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.0
</p></dd></dl>

<a name="gnutls_005fpkcs11_005fobj_005flist_005fimport_005furl4-1"></a>
<h4 class="subheading">gnutls_pkcs11_obj_list_import_url4</h4>
<a name="gnutls_005fpkcs11_005fobj_005flist_005fimport_005furl4"></a><dl>
<dt><a name="index-gnutls_005fpkcs11_005fobj_005flist_005fimport_005furl4"></a>Function: <em>int</em> <strong>gnutls_pkcs11_obj_list_import_url4</strong> <em>(gnutls_pkcs11_obj_t ** <var>p_list</var>, unsigned int * <var>n_list</var>, const char * <var>url</var>, unsigned int <var>flags</var>)</em></dt>
<dd><p><var>p_list</var>: An uninitialized object list (may be NULL)
</p>
<p><var>n_list</var>: It will contain the size of the list.
</p>
<p><var>url</var>: A PKCS 11 url identifying a set of objects
</p>
<p><var>flags</var>: Or sequence of GNUTLS_PKCS11_OBJ_* flags
</p>
<p>This function will enumerate all the objects specified by the PKCS<code>11</code>  URL
provided. It will initialize and set values to the object pointer list ( <code>p_list</code> )
provided. To obtain a list of all available objects use a  <code>url</code> of &rsquo;pkcs11:&rsquo;.
</p>
<p>All returned objects must be deinitialized using <code>gnutls_pkcs11_obj_deinit()</code> ,
and  <code>p_list</code> must be deinitialized using <code>gnutls_free()</code> .
</p>
<p>The supported in this function  <code>flags</code> are <code>GNUTLS_PKCS11_OBJ_FLAG_LOGIN</code> ,
<code>GNUTLS_PKCS11_OBJ_FLAG_LOGIN_SO</code> , <code>GNUTLS_PKCS11_OBJ_FLAG_PRESENT_IN_TRUSTED_MODULE</code> ,
<code>GNUTLS_PKCS11_OBJ_FLAG_CRT</code> , <code>GNUTLS_PKCS11_OBJ_FLAG_PUBKEY</code> , <code>GNUTLS_PKCS11_OBJ_FLAG_PRIVKEY</code> ,
<code>GNUTLS_PKCS11_OBJ_FLAG_WITH_PRIVKEY</code> , <code>GNUTLS_PKCS11_OBJ_FLAG_MARK_CA</code> ,
<code>GNUTLS_PKCS11_OBJ_FLAG_MARK_TRUSTED</code> , and since 3.5.1 the <code>GNUTLS_PKCS11_OBJ_FLAG_OVERWRITE_TRUSTMOD_EXT</code> .
</p>
<p>On versions of GnuTLS prior to 3.4.0 the equivalent function was
<code>gnutls_pkcs11_obj_list_import_url2()</code> . That is also available on this version
as a macro which maps to this function.
</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.0
</p></dd></dl>

<a name="gnutls_005fpkcs11_005fobj_005fset_005finfo-1"></a>
<h4 class="subheading">gnutls_pkcs11_obj_set_info</h4>
<a name="gnutls_005fpkcs11_005fobj_005fset_005finfo"></a><dl>
<dt><a name="index-gnutls_005fpkcs11_005fobj_005fset_005finfo"></a>Function: <em>int</em> <strong>gnutls_pkcs11_obj_set_info</strong> <em>(gnutls_pkcs11_obj_t <var>obj</var>, gnutls_pkcs11_obj_info_t <var>itype</var>, const void * <var>data</var>, size_t <var>data_size</var>, unsigned <var>flags</var>)</em></dt>
<dd><p><var>obj</var>: should contain a <code>gnutls_pkcs11_obj_t</code>  type
</p>
<p><var>itype</var>: Denotes the type of information to be set
</p>
<p><var>data</var>: the data to set
</p>
<p><var>data_size</var>: the size of data
</p>
<p><var>flags</var>: Or sequence of GNUTLS_PKCS11_OBJ_* flags
</p>
<p>This function will set attributes on the provided object.
Available options for  <code>itype</code> are <code>GNUTLS_PKCS11_OBJ_LABEL</code> ,
<code>GNUTLS_PKCS11_OBJ_ID_HEX</code> , and <code>GNUTLS_PKCS11_OBJ_ID</code> .
</p>
<p><strong>Returns:</strong> <code>GNUTLS_E_SUCCESS</code>  (0) on success or a negative error code on error.
</p>
<p><strong>Since:</strong> 3.4.0
</p></dd></dl>

<a name="gnutls_005fpkcs11_005fobj_005fset_005fpin_005ffunction-1"></a>
<h4 class="subheading">gnutls_pkcs11_obj_set_pin_function</h4>
<a name="gnutls_005fpkcs11_005fobj_005fset_005fpin_005ffunction"></a><dl>
<dt><a name="index-gnutls_005fpkcs11_005fobj_005fset_005fpin_005ffunction"></a>Function: <em>void</em> <strong>gnutls_pkcs11_obj_set_pin_function</strong> <em>(gnutls_pkcs11_obj_t <var>obj</var>, gnutls_pin_callback_t <var>fn</var>, void * <var>userdata</var>)</em></dt>
<dd><p><var>obj</var>: The object structure
</p>
<p><var>fn</var>: the callback
</p>
<p><var>userdata</var>: data associated with the callback
</p>
<p>This function will set a callback function to be used when
required to access the object. This function overrides the global
set using <code>gnutls_pkcs11_set_pin_function()</code> .
</p>
<p><strong>Since:</strong> 3.1.0
</p></dd></dl>

<a name="gnutls_005fpkcs11_005fprivkey_005fcpy-1"></a>
<h4 class="subheading">gnutls_pkcs11_privkey_cpy</h4>
<a name="gnutls_005fpkcs11_005fprivkey_005fcpy"></a><dl>
<dt><a name="index-gnutls_005fpkcs11_005fprivkey_005fcpy"></a>Function: <em>int</em> <strong>gnutls_pkcs11_privkey_cpy</strong> <em>(gnutls_pkcs11_privkey_t <var>dst</var>, gnutls_pkcs11_privkey_t <var>src</var>)</em></dt>
<dd><p><var>dst</var>: The destination key, which should be initialized.
</p>
<p><var>src</var>: The source key
</p>
<p>This function will copy a private key from source to destination
key. Destination has to be initialized.
</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.0
</p></dd></dl>

<a name="gnutls_005fpkcs11_005fprivkey_005fdeinit-1"></a>
<h4 class="subheading">gnutls_pkcs11_privkey_deinit</h4>
<a name="gnutls_005fpkcs11_005fprivkey_005fdeinit"></a><dl>
<dt><a name="index-gnutls_005fpkcs11_005fprivkey_005fdeinit"></a>Function: <em>void</em> <strong>gnutls_pkcs11_privkey_deinit</strong> <em>(gnutls_pkcs11_privkey_t <var>key</var>)</em></dt>
<dd><p><var>key</var>: the key to be deinitialized
</p>
<p>This function will deinitialize a private key structure.
</p></dd></dl>

<a name="gnutls_005fpkcs11_005fprivkey_005fexport_005fpubkey-1"></a>
<h4 class="subheading">gnutls_pkcs11_privkey_export_pubkey</h4>
<a name="gnutls_005fpkcs11_005fprivkey_005fexport_005fpubkey"></a><dl>
<dt><a name="index-gnutls_005fpkcs11_005fprivkey_005fexport_005fpubkey"></a>Function: <em>int</em> <strong>gnutls_pkcs11_privkey_export_pubkey</strong> <em>(gnutls_pkcs11_privkey_t <var>pkey</var>, gnutls_x509_crt_fmt_t <var>fmt</var>, gnutls_datum_t * <var>data</var>, unsigned int <var>flags</var>)</em></dt>
<dd><p><var>pkey</var>: The private key
</p>
<p><var>fmt</var>: the format of output params. PEM or DER.
</p>
<p><var>data</var>: will hold the public key
</p>
<p><var>flags</var>: should be zero
</p>
<p>This function will extract the public key (modulus and public
exponent) from the private key specified by the  <code>url</code> private key.
This public key will be stored in  <code>pubkey</code> in the format specified
by  <code>fmt</code> .  <code>pubkey</code> should be deinitialized 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>
<p><strong>Since:</strong> 3.3.7
</p></dd></dl>

<a name="gnutls_005fpkcs11_005fprivkey_005fexport_005furl-1"></a>
<h4 class="subheading">gnutls_pkcs11_privkey_export_url</h4>
<a name="gnutls_005fpkcs11_005fprivkey_005fexport_005furl"></a><dl>
<dt><a name="index-gnutls_005fpkcs11_005fprivkey_005fexport_005furl"></a>Function: <em>int</em> <strong>gnutls_pkcs11_privkey_export_url</strong> <em>(gnutls_pkcs11_privkey_t <var>key</var>, gnutls_pkcs11_url_type_t <var>detailed</var>, char ** <var>url</var>)</em></dt>
<dd><p><var>key</var>: Holds the PKCS 11 key
</p>
<p><var>detailed</var>: non zero if a detailed URL is required
</p>
<p><var>url</var>: will contain an allocated url
</p>
<p>This function will export a URL identifying the given key.
</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_005fpkcs11_005fprivkey_005fgenerate-1"></a>
<h4 class="subheading">gnutls_pkcs11_privkey_generate</h4>
<a name="gnutls_005fpkcs11_005fprivkey_005fgenerate"></a><dl>
<dt><a name="index-gnutls_005fpkcs11_005fprivkey_005fgenerate"></a>Function: <em>int</em> <strong>gnutls_pkcs11_privkey_generate</strong> <em>(const char * <var>url</var>, gnutls_pk_algorithm_t <var>pk</var>, unsigned int <var>bits</var>, const char * <var>label</var>, unsigned int <var>flags</var>)</em></dt>
<dd><p><var>url</var>: a token URL
</p>
<p><var>pk</var>: the public key algorithm
</p>
<p><var>bits</var>: the security bits
</p>
<p><var>label</var>: a label
</p>
<p><var>flags</var>: should be zero
</p>
<p>This function will generate a private key in the specified
by the  <code>url</code> token. The private key will be generate within
the token and will not be exportable.
</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.0
</p></dd></dl>

<a name="gnutls_005fpkcs11_005fprivkey_005fgenerate2-1"></a>
<h4 class="subheading">gnutls_pkcs11_privkey_generate2</h4>
<a name="gnutls_005fpkcs11_005fprivkey_005fgenerate2"></a><dl>
<dt><a name="index-gnutls_005fpkcs11_005fprivkey_005fgenerate2"></a>Function: <em>int</em> <strong>gnutls_pkcs11_privkey_generate2</strong> <em>(const char * <var>url</var>, gnutls_pk_algorithm_t <var>pk</var>, unsigned int <var>bits</var>, const char * <var>label</var>, gnutls_x509_crt_fmt_t <var>fmt</var>, gnutls_datum_t * <var>pubkey</var>, unsigned int <var>flags</var>)</em></dt>
<dd><p><var>url</var>: a token URL
</p>
<p><var>pk</var>: the public key algorithm
</p>
<p><var>bits</var>: the security bits
</p>
<p><var>label</var>: a label
</p>
<p><var>fmt</var>: the format of output params. PEM or DER
</p>
<p><var>pubkey</var>: will hold the public key (may be <code>NULL</code> )
</p>
<p><var>flags</var>: zero or an OR&rsquo;ed sequence of <code>GNUTLS_PKCS11_OBJ_FLAGs</code> 
</p>
<p>This function will generate a private key in the specified
by the  <code>url</code> token. The private key will be generate within
the token and will not be exportable. This function will
store the DER-encoded public key in the SubjectPublicKeyInfo format 
in  <code>pubkey</code> . The  <code>pubkey</code> should be deinitialized using <code>gnutls_free()</code> .
</p>
<p>Note that when generating an elliptic curve key, the curve
can be substituted in the place of the bits parameter using the
<code>GNUTLS_CURVE_TO_BITS()</code>  macro.
</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.5
</p></dd></dl>

<a name="gnutls_005fpkcs11_005fprivkey_005fgenerate3-1"></a>
<h4 class="subheading">gnutls_pkcs11_privkey_generate3</h4>
<a name="gnutls_005fpkcs11_005fprivkey_005fgenerate3"></a><dl>
<dt><a name="index-gnutls_005fpkcs11_005fprivkey_005fgenerate3"></a>Function: <em>int</em> <strong>gnutls_pkcs11_privkey_generate3</strong> <em>(const char * <var>url</var>, gnutls_pk_algorithm_t <var>pk</var>, unsigned int <var>bits</var>, const char * <var>label</var>, const gnutls_datum_t * <var>cid</var>, gnutls_x509_crt_fmt_t <var>fmt</var>, gnutls_datum_t * <var>pubkey</var>, unsigned int <var>key_usage</var>, unsigned int <var>flags</var>)</em></dt>
<dd><p><var>url</var>: a token URL
</p>
<p><var>pk</var>: the public key algorithm
</p>
<p><var>bits</var>: the security bits
</p>
<p><var>label</var>: a label
</p>
<p><var>cid</var>: The CKA_ID to use for the new object
</p>
<p><var>fmt</var>: the format of output params. PEM or DER
</p>
<p><var>pubkey</var>: will hold the public key (may be <code>NULL</code> )
</p>
<p><var>key_usage</var>: One of GNUTLS_KEY_*
</p>
<p><var>flags</var>: zero or an OR&rsquo;ed sequence of <code>GNUTLS_PKCS11_OBJ_FLAGs</code> 
</p>
<p>This function will generate a private key in the specified
by the  <code>url</code> token. The private key will be generate within
the token and will not be exportable. This function will
store the DER-encoded public key in the SubjectPublicKeyInfo format 
in  <code>pubkey</code> . The  <code>pubkey</code> should be deinitialized using <code>gnutls_free()</code> .
</p>
<p>Note that when generating an elliptic curve key, the curve
can be substituted in the place of the bits parameter using the
<code>GNUTLS_CURVE_TO_BITS()</code>  macro.
</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.0
</p></dd></dl>

<a name="gnutls_005fpkcs11_005fprivkey_005fget_005finfo-1"></a>
<h4 class="subheading">gnutls_pkcs11_privkey_get_info</h4>
<a name="gnutls_005fpkcs11_005fprivkey_005fget_005finfo"></a><dl>
<dt><a name="index-gnutls_005fpkcs11_005fprivkey_005fget_005finfo"></a>Function: <em>int</em> <strong>gnutls_pkcs11_privkey_get_info</strong> <em>(gnutls_pkcs11_privkey_t <var>pkey</var>, gnutls_pkcs11_obj_info_t <var>itype</var>, void * <var>output</var>, size_t * <var>output_size</var>)</em></dt>
<dd><p><var>pkey</var>: should contain a <code>gnutls_pkcs11_privkey_t</code>  type
</p>
<p><var>itype</var>: Denotes the type of information requested
</p>
<p><var>output</var>: where output will be stored
</p>
<p><var>output_size</var>: contains the maximum size of the output and will be overwritten with actual
</p>
<p>This function will return information about the PKCS 11 private key such
as the label, id as well as token information where the key is stored. When
output is text it returns null terminated string although <code>output_size</code>  contains
the size of the actual data only.
</p>
<p><strong>Returns:</strong> <code>GNUTLS_E_SUCCESS</code>  (0) on success or a negative error code on error.
</p></dd></dl>

<a name="gnutls_005fpkcs11_005fprivkey_005fget_005fpk_005falgorithm-1"></a>
<h4 class="subheading">gnutls_pkcs11_privkey_get_pk_algorithm</h4>
<a name="gnutls_005fpkcs11_005fprivkey_005fget_005fpk_005falgorithm"></a><dl>
<dt><a name="index-gnutls_005fpkcs11_005fprivkey_005fget_005fpk_005falgorithm"></a>Function: <em>int</em> <strong>gnutls_pkcs11_privkey_get_pk_algorithm</strong> <em>(gnutls_pkcs11_privkey_t <var>key</var>, unsigned int * <var>bits</var>)</em></dt>
<dd><p><var>key</var>: should contain a <code>gnutls_pkcs11_privkey_t</code>  type
</p>
<p><var>bits</var>: if bits is non null it will hold the size of the parameters&rsquo; in bits
</p>
<p>This function will return the public key algorithm of a private
key.
</p>
<p><strong>Returns:</strong> a member of the <code>gnutls_pk_algorithm_t</code>  enumeration on
success, or a negative error code on error.
</p></dd></dl>

<a name="gnutls_005fpkcs11_005fprivkey_005fimport_005furl-1"></a>
<h4 class="subheading">gnutls_pkcs11_privkey_import_url</h4>
<a name="gnutls_005fpkcs11_005fprivkey_005fimport_005furl"></a><dl>
<dt><a name="index-gnutls_005fpkcs11_005fprivkey_005fimport_005furl"></a>Function: <em>int</em> <strong>gnutls_pkcs11_privkey_import_url</strong> <em>(gnutls_pkcs11_privkey_t <var>pkey</var>, const char * <var>url</var>, unsigned int <var>flags</var>)</em></dt>
<dd><p><var>pkey</var>: The private key
</p>
<p><var>url</var>: a PKCS 11 url identifying the key
</p>
<p><var>flags</var>: Or sequence of GNUTLS_PKCS11_OBJ_* flags
</p>
<p>This function will &quot;import&quot; a PKCS 11 URL identifying a private
key to the <code>gnutls_pkcs11_privkey_t</code>  type. In reality since
in most cases keys cannot be exported, the private key structure
is being associated with the available operations on the token.
</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_005fpkcs11_005fprivkey_005finit-1"></a>
<h4 class="subheading">gnutls_pkcs11_privkey_init</h4>
<a name="gnutls_005fpkcs11_005fprivkey_005finit"></a><dl>
<dt><a name="index-gnutls_005fpkcs11_005fprivkey_005finit"></a>Function: <em>int</em> <strong>gnutls_pkcs11_privkey_init</strong> <em>(gnutls_pkcs11_privkey_t * <var>key</var>)</em></dt>
<dd><p><var>key</var>: A pointer to the type to be initialized
</p>
<p>This function will initialize an private key structure.
</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_005fpkcs11_005fprivkey_005fset_005fpin_005ffunction-1"></a>
<h4 class="subheading">gnutls_pkcs11_privkey_set_pin_function</h4>
<a name="gnutls_005fpkcs11_005fprivkey_005fset_005fpin_005ffunction"></a><dl>
<dt><a name="index-gnutls_005fpkcs11_005fprivkey_005fset_005fpin_005ffunction"></a>Function: <em>void</em> <strong>gnutls_pkcs11_privkey_set_pin_function</strong> <em>(gnutls_pkcs11_privkey_t <var>key</var>, gnutls_pin_callback_t <var>fn</var>, void * <var>userdata</var>)</em></dt>
<dd><p><var>key</var>: The private key
</p>
<p><var>fn</var>: the callback
</p>
<p><var>userdata</var>: data associated with the callback
</p>
<p>This function will set a callback function to be used when
required to access the object. This function overrides the global
set using <code>gnutls_pkcs11_set_pin_function()</code> .
</p>
<p><strong>Since:</strong> 3.1.0
</p></dd></dl>

<a name="gnutls_005fpkcs11_005fprivkey_005fstatus-1"></a>
<h4 class="subheading">gnutls_pkcs11_privkey_status</h4>
<a name="gnutls_005fpkcs11_005fprivkey_005fstatus"></a><dl>
<dt><a name="index-gnutls_005fpkcs11_005fprivkey_005fstatus"></a>Function: <em>unsigned</em> <strong>gnutls_pkcs11_privkey_status</strong> <em>(gnutls_pkcs11_privkey_t <var>key</var>)</em></dt>
<dd><p><var>key</var>: Holds the key
</p>
<p>Checks the status of the private key token.
</p>
<p><strong>Returns:</strong> this function will return non-zero if the token 
holding the private key is still available (inserted), and zero otherwise.
</p>
<p><strong>Since:</strong> 3.1.9
</p></dd></dl>

<a name="gnutls_005fpkcs11_005freinit-1"></a>
<h4 class="subheading">gnutls_pkcs11_reinit</h4>
<a name="gnutls_005fpkcs11_005freinit"></a><dl>
<dt><a name="index-gnutls_005fpkcs11_005freinit"></a>Function: <em>int</em> <strong>gnutls_pkcs11_reinit</strong> <em>( <var>void</var>)</em></dt>
<dd>
<p>This function will reinitialize the PKCS 11 subsystem in gnutls. 
This is required by PKCS 11 when an application uses <code>fork()</code> . The
reinitialization function must be called on the child.
</p>
<p>Note that since GnuTLS 3.3.0, the reinitialization of the PKCS <code>11</code> 
subsystem occurs automatically after fork.
</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.0
</p></dd></dl>

<a name="gnutls_005fpkcs11_005fset_005fpin_005ffunction-1"></a>
<h4 class="subheading">gnutls_pkcs11_set_pin_function</h4>
<a name="gnutls_005fpkcs11_005fset_005fpin_005ffunction"></a><dl>
<dt><a name="index-gnutls_005fpkcs11_005fset_005fpin_005ffunction"></a>Function: <em>void</em> <strong>gnutls_pkcs11_set_pin_function</strong> <em>(gnutls_pin_callback_t <var>fn</var>, void * <var>userdata</var>)</em></dt>
<dd><p><var>fn</var>: The PIN callback, a <code>gnutls_pin_callback_t()</code>  function.
</p>
<p><var>userdata</var>: data to be supplied to callback
</p>
<p>This function will set a callback function to be used when a PIN is
required for PKCS 11 operations.  See
<code>gnutls_pin_callback_t()</code>  on how the callback should behave.
</p>
<p><strong>Since:</strong> 2.12.0
</p></dd></dl>

<a name="gnutls_005fpkcs11_005fset_005ftoken_005ffunction-1"></a>
<h4 class="subheading">gnutls_pkcs11_set_token_function</h4>
<a name="gnutls_005fpkcs11_005fset_005ftoken_005ffunction"></a><dl>
<dt><a name="index-gnutls_005fpkcs11_005fset_005ftoken_005ffunction"></a>Function: <em>void</em> <strong>gnutls_pkcs11_set_token_function</strong> <em>(gnutls_pkcs11_token_callback_t <var>fn</var>, void * <var>userdata</var>)</em></dt>
<dd><p><var>fn</var>: The token callback
</p>
<p><var>userdata</var>: data to be supplied to callback
</p>
<p>This function will set a callback function to be used when a token
needs to be inserted to continue PKCS 11 operations.
</p>
<p><strong>Since:</strong> 2.12.0
</p></dd></dl>

<a name="gnutls_005fpkcs11_005ftoken_005fget_005fflags-1"></a>
<h4 class="subheading">gnutls_pkcs11_token_get_flags</h4>
<a name="gnutls_005fpkcs11_005ftoken_005fget_005fflags"></a><dl>
<dt><a name="index-gnutls_005fpkcs11_005ftoken_005fget_005fflags"></a>Function: <em>int</em> <strong>gnutls_pkcs11_token_get_flags</strong> <em>(const char * <var>url</var>, unsigned int * <var>flags</var>)</em></dt>
<dd><p><var>url</var>: should contain a PKCS 11 URL
</p>
<p><var>flags</var>: The output flags (GNUTLS_PKCS11_TOKEN_*)
</p>
<p>This function will return information about the PKCS 11 token flags.
</p>
<p>The supported flags are: <code>GNUTLS_PKCS11_TOKEN_HW</code>  and <code>GNUTLS_PKCS11_TOKEN_TRUSTED</code> .
</p>
<p><strong>Returns:</strong> <code>GNUTLS_E_SUCCESS</code>  (0) on success or a negative error code on error.
</p>
<p><strong>Since:</strong> 2.12.0
</p></dd></dl>

<a name="gnutls_005fpkcs11_005ftoken_005fget_005finfo-1"></a>
<h4 class="subheading">gnutls_pkcs11_token_get_info</h4>
<a name="gnutls_005fpkcs11_005ftoken_005fget_005finfo"></a><dl>
<dt><a name="index-gnutls_005fpkcs11_005ftoken_005fget_005finfo"></a>Function: <em>int</em> <strong>gnutls_pkcs11_token_get_info</strong> <em>(const char * <var>url</var>, gnutls_pkcs11_token_info_t <var>ttype</var>, void * <var>output</var>, size_t * <var>output_size</var>)</em></dt>
<dd><p><var>url</var>: should contain a PKCS 11 URL
</p>
<p><var>ttype</var>: Denotes the type of information requested
</p>
<p><var>output</var>: where output will be stored
</p>
<p><var>output_size</var>: contains the maximum size of the output and will be overwritten with actual
</p>
<p>This function will return information about the PKCS 11 token such
as the label, id, etc.
</p>
<p><strong>Returns:</strong> <code>GNUTLS_E_SUCCESS</code>  (0) on success or a negative error code
on error.
</p>
<p><strong>Since:</strong> 2.12.0
</p></dd></dl>

<a name="gnutls_005fpkcs11_005ftoken_005fget_005fmechanism-1"></a>
<h4 class="subheading">gnutls_pkcs11_token_get_mechanism</h4>
<a name="gnutls_005fpkcs11_005ftoken_005fget_005fmechanism"></a><dl>
<dt><a name="index-gnutls_005fpkcs11_005ftoken_005fget_005fmechanism"></a>Function: <em>int</em> <strong>gnutls_pkcs11_token_get_mechanism</strong> <em>(const char * <var>url</var>, unsigned int <var>idx</var>, unsigned long * <var>mechanism</var>)</em></dt>
<dd><p><var>url</var>: should contain a PKCS 11 URL
</p>
<p><var>idx</var>: The index of the mechanism
</p>
<p><var>mechanism</var>: The PKCS <code>11</code>  mechanism ID
</p>
<p>This function will return the names of the supported mechanisms
by the token. It should be called with an increasing index until
it return GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE.
</p>
<p><strong>Returns:</strong> <code>GNUTLS_E_SUCCESS</code>  (0) on success or a negative error code on error.
</p>
<p><strong>Since:</strong> 2.12.0
</p></dd></dl>

<a name="gnutls_005fpkcs11_005ftoken_005fget_005frandom-1"></a>
<h4 class="subheading">gnutls_pkcs11_token_get_random</h4>
<a name="gnutls_005fpkcs11_005ftoken_005fget_005frandom"></a><dl>
<dt><a name="index-gnutls_005fpkcs11_005ftoken_005fget_005frandom"></a>Function: <em>int</em> <strong>gnutls_pkcs11_token_get_random</strong> <em>(const char * <var>token_url</var>, void * <var>rnddata</var>, size_t <var>len</var>)</em></dt>
<dd><p><var>token_url</var>: A PKCS <code>11</code>  URL specifying a token
</p>
<p><var>rnddata</var>: A pointer to the memory area to be filled with random data
</p>
<p><var>len</var>: The number of bytes of randomness to request
</p>
<p>This function will get random data from the given token.
It will store rnddata and fill the memory pointed to by rnddata with
len random bytes from the token.
</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_005fpkcs11_005ftoken_005fget_005furl-1"></a>
<h4 class="subheading">gnutls_pkcs11_token_get_url</h4>
<a name="gnutls_005fpkcs11_005ftoken_005fget_005furl"></a><dl>
<dt><a name="index-gnutls_005fpkcs11_005ftoken_005fget_005furl"></a>Function: <em>int</em> <strong>gnutls_pkcs11_token_get_url</strong> <em>(unsigned int <var>seq</var>, gnutls_pkcs11_url_type_t <var>detailed</var>, char ** <var>url</var>)</em></dt>
<dd><p><var>seq</var>: sequence number starting from 0
</p>
<p><var>detailed</var>: non zero if a detailed URL is required
</p>
<p><var>url</var>: will contain an allocated url
</p>
<p>This function will return the URL for each token available
in system. The url has to be released using <code>gnutls_free()</code> 
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code>  (0) is returned,
<code>GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE</code>  if the sequence number
exceeds the available tokens, otherwise a negative error value.
</p>
<p><strong>Since:</strong> 2.12.0
</p></dd></dl>

<a name="gnutls_005fpkcs11_005ftoken_005finit-1"></a>
<h4 class="subheading">gnutls_pkcs11_token_init</h4>
<a name="gnutls_005fpkcs11_005ftoken_005finit"></a><dl>
<dt><a name="index-gnutls_005fpkcs11_005ftoken_005finit"></a>Function: <em>int</em> <strong>gnutls_pkcs11_token_init</strong> <em>(const char * <var>token_url</var>, const char * <var>so_pin</var>, const char * <var>label</var>)</em></dt>
<dd><p><var>token_url</var>: A PKCS <code>11</code>  URL specifying a token
</p>
<p><var>so_pin</var>: Security Officer&rsquo;s PIN
</p>
<p><var>label</var>: A name to be used for the token
</p>
<p>This function will initialize (format) a token. If the token is
at a factory defaults state the security officer&rsquo;s PIN given will be
set to be the default. Otherwise it should match the officer&rsquo;s PIN.
</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_005fpkcs11_005ftoken_005fset_005fpin-1"></a>
<h4 class="subheading">gnutls_pkcs11_token_set_pin</h4>
<a name="gnutls_005fpkcs11_005ftoken_005fset_005fpin"></a><dl>
<dt><a name="index-gnutls_005fpkcs11_005ftoken_005fset_005fpin"></a>Function: <em>int</em> <strong>gnutls_pkcs11_token_set_pin</strong> <em>(const char * <var>token_url</var>, const char * <var>oldpin</var>, const char * <var>newpin</var>, unsigned int <var>flags</var>)</em></dt>
<dd><p><var>token_url</var>: A PKCS <code>11</code>  URL specifying a token
</p>
<p><var>oldpin</var>: old user&rsquo;s PIN
</p>
<p><var>newpin</var>: new user&rsquo;s PIN
</p>
<p><var>flags</var>: one of <code>gnutls_pin_flag_t</code> .
</p>
<p>This function will modify or set a user&rsquo;s PIN for the given token. 
If it is called to set a user pin for first time the oldpin must
be NULL.
</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_005fpkcs11_005ftype_005fget_005fname-1"></a>
<h4 class="subheading">gnutls_pkcs11_type_get_name</h4>
<a name="gnutls_005fpkcs11_005ftype_005fget_005fname"></a><dl>
<dt><a name="index-gnutls_005fpkcs11_005ftype_005fget_005fname"></a>Function: <em>const char *</em> <strong>gnutls_pkcs11_type_get_name</strong> <em>(gnutls_pkcs11_obj_type_t <var>type</var>)</em></dt>
<dd><p><var>type</var>: Holds the PKCS 11 object type, a <code>gnutls_pkcs11_obj_type_t</code> .
</p>
<p>This function will return a human readable description of the
PKCS11 object type  <code>obj</code> .  It will return &quot;Unknown&quot; for unknown
types.
</p>
<p><strong>Returns:</strong> human readable string labeling the PKCS11 object type
 <code>type</code> .
</p>
<p><strong>Since:</strong> 2.12.0
</p></dd></dl>

<a name="gnutls_005fx509_005fcrt_005fimport_005fpkcs11-1"></a>
<h4 class="subheading">gnutls_x509_crt_import_pkcs11</h4>
<a name="gnutls_005fx509_005fcrt_005fimport_005fpkcs11"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrt_005fimport_005fpkcs11"></a>Function: <em>int</em> <strong>gnutls_x509_crt_import_pkcs11</strong> <em>(gnutls_x509_crt_t <var>crt</var>, gnutls_pkcs11_obj_t <var>pkcs11_crt</var>)</em></dt>
<dd><p><var>crt</var>: A certificate of type <code>gnutls_x509_crt_t</code> 
</p>
<p><var>pkcs11_crt</var>: A PKCS 11 object that contains a certificate
</p>
<p>This function will import a PKCS 11 certificate to a <code>gnutls_x509_crt_t</code> 
structure.
</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> 2.12.0
</p></dd></dl>

<a name="gnutls_005fx509_005fcrt_005flist_005fimport_005fpkcs11-1"></a>
<h4 class="subheading">gnutls_x509_crt_list_import_pkcs11</h4>
<a name="gnutls_005fx509_005fcrt_005flist_005fimport_005fpkcs11"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrt_005flist_005fimport_005fpkcs11"></a>Function: <em>int</em> <strong>gnutls_x509_crt_list_import_pkcs11</strong> <em>(gnutls_x509_crt_t * <var>certs</var>, unsigned int <var>cert_max</var>, gnutls_pkcs11_obj_t * const <var>objs</var>, unsigned int <var>flags</var>)</em></dt>
<dd><p><var>certs</var>: A list of certificates of type <code>gnutls_x509_crt_t</code> 
</p>
<p><var>cert_max</var>: The maximum size of the list
</p>
<p><var>objs</var>: A list of PKCS 11 objects
</p>
<p><var>flags</var>: 0 for now
</p>
<p>This function will import a PKCS 11 certificate list to a list of 
<code>gnutls_x509_crt_t</code>  type. These must not be initialized.
</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> 2.12.0
</p></dd></dl>


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