gwenhywfar 5.12.0
ct.c
Go to the documentation of this file.
1/***************************************************************************
2 begin : Wed Mar 16 2005
3 copyright : (C) 2005-2010 by Martin Preuss
4 email : martin@libchipcard.de
5
6 ***************************************************************************
7 * Please see toplevel file COPYING for license details *
8 ***************************************************************************/
9
10#ifdef HAVE_CONFIG_H
11# include <config.h>
12#endif
13
14#define DISABLE_DEBUGLOG
15
16
17#include "ct_p.h"
18#include "i18n_l.h"
19#include <gwenhywfar/misc.h>
20#include <gwenhywfar/debug.h>
21#include <gwenhywfar/gui.h>
22
23
24
28
29
30
31
32
34 const char *typeName,
35 const char *tokenName)
36{
38
39 assert(typeName);
40
42 ct->refCount=1;
45
46 ct->device=dev;
47 ct->typeName=strdup(typeName);
48 if (tokenName)
49 ct->tokenName=strdup(tokenName);
50
51 return ct;
52}
53
54
55
57{
58 if (ct) {
59 assert(ct->refCount);
60 if (ct->refCount==1) {
63 free(ct->tokenName);
64 free(ct->typeName);
65 ct->refCount=0;
67 }
68 else {
69 ct->refCount--;
70 }
71 }
72}
73
74
75
77{
78 assert(ct);
79 assert(ct->refCount);
80
81 return ct->device;
82}
83
84
85
87{
88 assert(ct);
89 assert(ct->refCount);
90
91 return ct->typeName;
92}
93
94
95
97{
98 assert(ct);
99 assert(ct->refCount);
100
101 return ct->tokenName;
102}
103
104
105
107{
108 assert(ct);
109 assert(ct->refCount);
110
111 assert(s);
112
113 free(ct->tokenName);
114 ct->tokenName=strdup(s);
115}
116
117
118
120{
121 assert(ct);
122 assert(ct->refCount);
123
124 return ct->friendlyName;
125}
126
127
128
130{
131 assert(ct);
132 assert(ct->refCount);
133
134 assert(s);
135
136 free(ct->friendlyName);
137 ct->friendlyName=strdup(s);
138}
139
140
141
143{
144 assert(ct);
145 assert(ct->refCount);
146
147 return ct->flags;
148}
149
150
151
153{
154 assert(ct);
155 assert(ct->refCount);
156
157 ct->flags=f;
158}
159
160
161
163{
164 assert(ct);
165 assert(ct->refCount);
166
167 ct->flags|=f;
168}
169
170
171
173{
174 assert(ct);
175 assert(ct->refCount);
176
177 ct->flags&=~f;
178}
179
180
181
183{
184 assert(ct);
185 assert(ct->refCount);
186
187 return ct->modes;
188}
189
190
191
193{
194 assert(ct);
195 assert(ct->refCount);
196
197 ct->modes=f;
198}
199
200
201
203{
204 assert(ct);
205 assert(ct->refCount);
206
207 ct->modes|=f;
208}
209
210
211
213{
214 assert(ct);
215 assert(ct->refCount);
216
217 ct->modes&=~f;
218}
219
220
221
222int GWEN_Crypt_Token_Open(GWEN_CRYPT_TOKEN *ct, int admin, uint32_t gid)
223{
224 int rv;
225
226 assert(ct);
227 assert(ct->refCount);
228
229 if (ct->openCount) {
230 ct->openCount++;
231 return 0;
232 }
233
234 if (ct->openFn)
235 rv=ct->openFn(ct, admin, gid);
236 else
238
239 if (rv==0)
240 ct->openCount++;
241 return rv;
242}
243
244
245
247{
248 int rv;
249
250 assert(ct);
251 assert(ct->refCount);
252
253 if (ct->createFn)
254 rv=ct->createFn(ct, gid);
255 else
257
258 if (rv==0)
259 ct->openCount++;
260 return rv;
261}
262
263
264
265int GWEN_Crypt_Token_Close(GWEN_CRYPT_TOKEN *ct, int abandon, uint32_t gid)
266{
267 assert(ct);
268 assert(ct->refCount);
269
270 if (ct->openCount>1 && !abandon) {
271 ct->openCount--;
272 return 0;
273 }
274
275 if (ct->closeFn) {
276 int rv;
277
278 rv=ct->closeFn(ct, abandon, gid);
279 if (abandon)
280 ct->openCount=0;
281 else if (rv==0)
282 ct->openCount--;
283 return rv;
284 }
285 else
287}
288
289
290
292{
293 assert(ct);
294 assert(ct->refCount);
295
296 return (ct->openCount!=0);
297}
298
299
300
302 uint32_t *pIdList,
303 uint32_t *pCount,
304 uint32_t gid)
305{
306 assert(ct);
307 assert(ct->refCount);
308
309 if (ct->openCount<1)
310 return GWEN_ERROR_NOT_OPEN;
311
312 if (ct->getKeyIdListFn)
313 return ct->getKeyIdListFn(ct, pIdList, pCount, gid);
314 else
316}
317
318
319
321 uint32_t id,
322 uint32_t flags,
323 uint32_t gid)
324{
325 assert(ct);
326 assert(ct->refCount);
327
328 if (ct->openCount<1) {
329 DBG_INFO(GWEN_LOGDOMAIN, "Token not open");
330 return NULL;
331 }
332
333 if (ct->getKeyInfoFn)
334 return ct->getKeyInfoFn(ct, id, flags, gid);
335 else
336 return NULL;
337}
338
339
340
342 uint32_t id,
343 const GWEN_CRYPT_TOKEN_KEYINFO *ki,
344 uint32_t gid)
345{
346 assert(ct);
347 assert(ct->refCount);
348
349 if (ct->openCount<1)
350 return GWEN_ERROR_NOT_OPEN;
351
352 if (ct->setKeyInfoFn)
353 return ct->setKeyInfoFn(ct, id, ki, gid);
354 else
356}
357
358
359
361 uint32_t *pIdList,
362 uint32_t *pCount,
363 uint32_t gid)
364{
365 assert(ct);
366 assert(ct->refCount);
367
368 if (ct->openCount<1)
369 return GWEN_ERROR_NOT_OPEN;
370
371 if (ct->getContextIdListFn)
372 return ct->getContextIdListFn(ct, pIdList, pCount, gid);
373 else
375}
376
377
378
380 uint32_t id,
381 uint32_t gid)
382{
383 assert(ct);
384 assert(ct->refCount);
385
386 if (ct->openCount<1) {
387 DBG_INFO(GWEN_LOGDOMAIN, "Token not open");
388 return NULL;
389 }
390
391 if (ct->getContextFn)
392 return ct->getContextFn(ct, id, gid);
393 else
394 return NULL;
395}
396
397
398
400 uint32_t id,
401 const GWEN_CRYPT_TOKEN_CONTEXT *ctx,
402 uint32_t gid)
403{
404 assert(ct);
405 assert(ct->refCount);
406
407 if (ct->openCount<1)
408 return GWEN_ERROR_NOT_OPEN;
409
410 if (ct->setContextFn)
411 return ct->setContextFn(ct, id, ctx, gid);
412 else
414}
415
416
417
419 uint32_t keyId,
421 const uint8_t *pInData,
422 uint32_t inLen,
423 uint8_t *pSignatureData,
424 uint32_t *pSignatureLen,
425 uint32_t *pSeqCounter,
426 uint32_t gid)
427{
428 assert(ct);
429 assert(ct->refCount);
430
431 if (ct->openCount<1)
432 return GWEN_ERROR_NOT_OPEN;
433
434 if (ct->signFn)
435 return ct->signFn(ct, keyId, a, pInData, inLen, pSignatureData, pSignatureLen,
436 pSeqCounter, gid);
437 else
439}
440
441
442
444 uint32_t keyId,
446 const uint8_t *pInData,
447 uint32_t inLen,
448 const uint8_t *pSignatureData,
449 uint32_t signatureLen,
450 uint32_t seqCounter,
451 uint32_t gid)
452{
453 assert(ct);
454 assert(ct->refCount);
455
456 if (ct->openCount<1)
457 return GWEN_ERROR_NOT_OPEN;
458
459 if (ct->verifyFn)
460 return ct->verifyFn(ct, keyId, a, pInData, inLen, pSignatureData, signatureLen,
461 seqCounter, gid);
462 else
464}
465
466
467
469 uint32_t keyId,
471 const uint8_t *pInData,
472 uint32_t inLen,
473 uint8_t *pOutData,
474 uint32_t *pOutLen,
475 uint32_t gid)
476{
477 assert(ct);
478 assert(ct->refCount);
479
480 if (ct->openCount<1)
481 return GWEN_ERROR_NOT_OPEN;
482
483 if (ct->encipherFn)
484 return ct->encipherFn(ct, keyId, a, pInData, inLen, pOutData, pOutLen, gid);
485 else
487}
488
489
490
492 uint32_t keyId,
494 const uint8_t *pInData,
495 uint32_t inLen,
496 uint8_t *pOutData,
497 uint32_t *pOutLen,
498 uint32_t gid)
499{
500 assert(ct);
501 assert(ct->refCount);
502
503 if (ct->openCount<1)
504 return GWEN_ERROR_NOT_OPEN;
505
506 if (ct->decipherFn)
507 return ct->decipherFn(ct, keyId, a, pInData, inLen, pOutData, pOutLen, gid);
508 else
510}
511
512
513
514
516 uint32_t keyId,
517 const GWEN_CRYPT_CRYPTALGO *a,
518 uint32_t gid)
519{
520 assert(ct);
521 assert(ct->refCount);
522
523 if (ct->openCount<1)
524 return GWEN_ERROR_NOT_OPEN;
525
526 if (ct->generateKeyFn)
527 return ct->generateKeyFn(ct, keyId, a, gid);
528 else
530}
531
532
533
534int GWEN_Crypt_Token_ChangePin(GWEN_CRYPT_TOKEN *ct, int admin, uint32_t gid)
535{
536 assert(ct);
537 assert(ct->refCount);
538
539 if (ct->openCount<1)
540 return GWEN_ERROR_NOT_OPEN;
541
542 if (ct->changePinFn)
543 return ct->changePinFn(ct, admin, gid);
544 else
546}
547
548
549
550int GWEN_Crypt_Token_ActivateKey(GWEN_CRYPT_TOKEN *ct, uint32_t id, uint32_t gid)
551{
552 assert(ct);
553 assert(ct->refCount);
554
555 if (ct->openCount<1)
556 return GWEN_ERROR_NOT_OPEN;
557
558 if (ct->activateKeyFn)
559 return ct->activateKeyFn(ct, id, gid);
560 else
562}
563
564
565
566
567
568
571{
573
574 assert(ct);
575 assert(ct->refCount);
576 of=ct->openFn;
577 ct->openFn=f;
578
579 return of;
580}
581
582
583
586{
588
589 assert(ct);
590 assert(ct->refCount);
591 of=ct->createFn;
592 ct->createFn=f;
593
594 return of;
595
596}
597
598
599
602{
604
605 assert(ct);
606 assert(ct->refCount);
607 of=ct->closeFn;
608 ct->closeFn=f;
609
610 return of;
611}
612
613
614
617{
619
620 assert(ct);
621 assert(ct->refCount);
622 of=ct->getKeyIdListFn;
623 ct->getKeyIdListFn=f;
624
625 return of;
626}
627
628
629
632{
634
635 assert(ct);
636 assert(ct->refCount);
637 of=ct->getKeyInfoFn;
638 ct->getKeyInfoFn=f;
639
640 return of;
641}
642
643
644
647{
649
650 assert(ct);
651 assert(ct->refCount);
652 of=ct->setKeyInfoFn;
653 ct->setKeyInfoFn=f;
654
655 return of;
656}
657
658
659
662{
664
665 assert(ct);
666 assert(ct->refCount);
667 of=ct->getContextIdListFn;
668 ct->getContextIdListFn=f;
669
670 return of;
671}
672
673
674
677{
679
680 assert(ct);
681 assert(ct->refCount);
682 of=ct->getContextFn;
683 ct->getContextFn=f;
684
685 return of;
686}
687
688
689
692{
694
695 assert(ct);
696 assert(ct->refCount);
697 of=ct->setContextFn;
698 ct->setContextFn=f;
699
700 return of;
701}
702
703
704
707{
709
710 assert(ct);
711 assert(ct->refCount);
712 of=ct->signFn;
713 ct->signFn=f;
714
715 return of;
716}
717
718
719
722{
724
725 assert(ct);
726 assert(ct->refCount);
727 of=ct->verifyFn;
728 ct->verifyFn=f;
729
730 return of;
731}
732
733
734
737{
739
740 assert(ct);
741 assert(ct->refCount);
742 of=ct->encipherFn;
743 ct->encipherFn=f;
744
745 return of;
746}
747
748
749
752{
754
755 assert(ct);
756 assert(ct->refCount);
757 of=ct->decipherFn;
758 ct->decipherFn=f;
759
760 return of;
761}
762
763
764
767{
769
770 assert(ct);
771 assert(ct->refCount);
772 of=ct->generateKeyFn;
773 ct->generateKeyFn=f;
774
775 return of;
776}
777
778
779
782{
784
785 assert(ct);
786 assert(ct->refCount);
787 of=ct->changePinFn;
788 ct->changePinFn=f;
789
790 return of;
791}
792
793
794
797{
799
800 assert(ct);
801 assert(ct->refCount);
802 of=ct->activateKeyFn;
803 ct->activateKeyFn=f;
804
805 return of;
806}
807
808
809
810
811
814 GWEN_BUFFER *nbuf)
815{
816 const char *tname;
817 const char *dname;
818
820 assert(tname);
822 if (!dname) {
823 DBG_ERROR(GWEN_LOGDOMAIN, "Token has no name");
824 return GWEN_ERROR_INVALID;
825 }
826
827 GWEN_Buffer_AppendString(nbuf, "PASSWORD_");
828 GWEN_Buffer_AppendString(nbuf, tname);
829 GWEN_Buffer_AppendString(nbuf, "_");
830 GWEN_Buffer_AppendString(nbuf, dname);
832 GWEN_Buffer_AppendString(nbuf, ":MANAGE");
833
834 return 0;
835}
836
837
838
842 uint32_t flags,
843 unsigned char *pwbuffer,
844 unsigned int minLength,
845 unsigned int maxLength,
846 unsigned int *pinLength,
847 uint32_t gid)
848{
849 int rv;
850 const char *dname;
851 const char *mode;
852 const char *numeric_warning = "";
853 char buffer[512];
854 GWEN_BUFFER *nameBuffer;
855
856 assert(ct);
857 assert(ct->refCount);
858
860 if (!dname || !*dname)
862
864 mode=I18N("access password");
865 else if (pt==GWEN_Crypt_PinType_Manage)
866 mode=I18N("manager password");
867 else
868 mode=I18N("password");
869
870 buffer[0]=0;
871 buffer[sizeof(buffer)-1]=0;
872 if (flags & GWEN_GUI_INPUT_FLAGS_NUMERIC) {
873 numeric_warning = I18N("\nYou must only enter numbers, not letters.");
874 }
875
876 if (flags & GWEN_GUI_INPUT_FLAGS_CONFIRM) {
877 snprintf(buffer, sizeof(buffer)-1,
878 I18N("Please enter a new %s for \n"
879 "%s\n"
880 "The password must be at least %d characters long.%s"
881 "<html>"
882 "Please enter a new %s for <i>%s</i>. "
883 "The password must be at least %d characters long.%s"
884 "</html>"),
885 mode,
886 dname,
887 minLength,
888 numeric_warning,
889 mode,
890 dname,
891 minLength,
892 numeric_warning);
893 }
894 else {
895 snprintf(buffer, sizeof(buffer)-1,
896 I18N("Please enter the %s for \n"
897 "%s\n"
898 "%s<html>"
899 "Please enter the %s for <i>%s</i>.%s"
900 "</html>"),
901 mode,
902 dname,
903 numeric_warning,
904 mode,
905 dname,
906 numeric_warning);
907 }
908
909 nameBuffer=GWEN_Buffer_new(0, 256, 0, 1);
910 GWEN_Crypt_Token__CreatePasswordName(ct, pt, nameBuffer);
911 rv=GWEN_Gui_GetPassword(flags,
912 GWEN_Buffer_GetStart(nameBuffer),
913 I18N("Enter Password"),
914 buffer,
915 (char *)pwbuffer,
916 minLength,
917 maxLength,
919 gid);
920 GWEN_Buffer_free(nameBuffer);
921 if (rv) {
922 DBG_INFO(GWEN_LOGDOMAIN, "here (%d)", rv);
923 return rv;
924 }
925
926 *pinLength=strlen((char *)pwbuffer);
927
930 pe,
931 pwbuffer,
932 maxLength,
933 pinLength);
934 if (rv) {
935 DBG_INFO(GWEN_LOGDOMAIN, "here (%d)", rv);
936 return rv;
937 }
938 }
939
940 return 0;
941}
942
943
944
948 GWEN_UNUSED uint32_t flags,
949 const unsigned char *buffer,
950 unsigned int pinLength,
951 int isOk,
952 uint32_t gid)
953{
954 GWEN_BUFFER *nameBuffer;
955 int rv;
956 unsigned char ibuffer[256];
957
958 assert(ct);
959 assert(ct->refCount);
960
962 if (pinLength>=sizeof(ibuffer)) {
963 DBG_ERROR(GWEN_LOGDOMAIN, "Pin too long");
965 }
966 memset(ibuffer, 0, sizeof(ibuffer));
967 memmove(ibuffer, buffer, pinLength);
970 ibuffer,
971 sizeof(ibuffer)-1,
972 &pinLength);
973 if (rv) {
974 DBG_INFO(GWEN_LOGDOMAIN, "here (%d)", rv);
975 return rv;
976 }
977 buffer=ibuffer;
978 }
979
980 nameBuffer=GWEN_Buffer_new(0, 256, 0, 1);
981 GWEN_Crypt_Token__CreatePasswordName(ct, pt, nameBuffer);
983 (const char *)buffer,
986 memset(ibuffer, 0, sizeof(ibuffer));
987 GWEN_Buffer_free(nameBuffer);
988 return rv;
989
990}
991
992
993
996 uint32_t gid)
997{
998 int rv;
999
1000 rv=GWEN_Gui_ProgressLog(gid, GWEN_LoggerLevel_Warning, I18N("Waiting for pin entry on card reader..."));
1001 if (rv<0)
1002 return 0;
1003 return 0xffffffff;
1004}
1005
1006
1007
1010 GWEN_UNUSED int ok,
1011 uint32_t gid)
1012{
1013 return GWEN_Gui_ProgressLog(gid, GWEN_LoggerLevel_Warning, I18N("Pin entry on card reader finished."));
1014}
1015
1016
1017
1019{
1020 int rv;
1021 char buffer[512];
1022 const char *dname;
1023
1024 assert(ct);
1025 assert(ct->refCount);
1026
1027 buffer[0]=0;
1028 buffer[sizeof(buffer)-1]=0;
1029
1031 if (!dname || !*dname)
1033
1035 snprintf(buffer, sizeof(buffer)-1,
1036 I18N("Please insert the security disc\nfor %s"
1037 "<html>"
1038 "Please insert the security disc for <i>%s</i>"
1039 "</html>"), dname, dname);
1040 else
1041 snprintf(buffer, sizeof(buffer)-1,
1042 I18N("Please insert the chip card\nfor %s"
1043 "<html>"
1044 "Please insert the chip card for <i>%s</i>"
1045 "</html>"), dname, dname);
1046
1050 I18N("Insert Medium"),
1051 buffer,
1052 I18N("OK"), I18N("Abort"), 0, gid);
1053 if (rv==2) {
1054 DBG_ERROR(GWEN_LOGDOMAIN, "User aborted");
1056 I18N("Aborted by user."));
1058 }
1059 else if (rv!=1) {
1063 I18N("Error"),
1064 I18N("An internal error occurred."),
1065 I18N("Dismiss"), 0, 0, gid);
1066 return -1;
1067 }
1068
1069 return 0;
1070}
1071
1072
1073
1075{
1076 int rv;
1077 char buffer[512];
1078 const char *dname;
1079
1080 assert(ct);
1081 assert(ct->refCount);
1082
1083 buffer[0]=0;
1084 buffer[sizeof(buffer)-1]=0;
1085
1087 if (!dname || !*dname)
1089
1091 snprintf(buffer, sizeof(buffer)-1,
1092 I18N("Please insert the correct security disc\nfor %s"
1093 "<html>"
1094 "Please insert the correct security disc for <i>%s</i>"
1095 "</html>"), dname, dname);
1096 else {
1097 if (dname && *dname) {
1098 snprintf(buffer, sizeof(buffer)-1,
1099 I18N("The wrong chipcard has been inserted.\n"
1100 "Please insert the chipcard with the number\n"
1101 " %s\n"
1102 "into the card reader.\n"
1103 "<html>"
1104 "<p>The wrong card has been inserted.</p>"
1105 "<p>Please insert the chipcard with the number"
1106 "<b>%s</b> into the card reader.</p>"
1107 "</html>"),
1108 dname,
1109 dname);
1110 }
1111 else
1112 snprintf(buffer, sizeof(buffer)-1,
1113 I18N("Please insert the correct chipcard\nfor %s"
1114 "<html>"
1115 "Please insert the correct chipcard for <i>%s</i>"
1116 "</html>"), dname, dname);
1117 }
1118
1122 I18N("Insert Medium"),
1123 buffer,
1124 I18N("OK"), I18N("Abort"), 0, gid);
1125 if (rv==2) {
1126 DBG_ERROR(GWEN_LOGDOMAIN, "User aborted");
1128 I18N("Aborted by user."));
1130 }
1131 else if (rv!=1) {
1135 I18N("Error"),
1136 I18N("An internal error occurred."),
1137 I18N("Dismiss"), 0, 0, gid);
1138 return -1;
1139 }
1140
1141 return 0;
1142}
1143
1144
1145
1147{
1148 assert(s);
1149 if (strcasecmp(s, "none")==0)
1151 else if (strcasecmp(s, "file")==0)
1153 else if (strcasecmp(s, "card")==0)
1155 else if (strcasecmp(s, "any")==0)
1158}
1159
1160
1161
1163{
1164 switch (d) {
1166 return "none";
1168 return "file";
1170 return "card";
1172 return "any";
1173 default:
1174 return "unknown";
1175 }
1176}
1177
1178
1179
1180
1181
1182
#define NULL
Definition binreloc.c:300
GWEN_BUFFER * GWEN_Buffer_new(char *buffer, uint32_t size, uint32_t used, int take)
Definition buffer.c:42
void GWEN_Buffer_free(GWEN_BUFFER *bf)
Definition buffer.c:89
int GWEN_Buffer_AppendString(GWEN_BUFFER *bf, const char *buffer)
Definition buffer.c:992
char * GWEN_Buffer_GetStart(const GWEN_BUFFER *bf)
Definition buffer.c:235
struct GWEN_CRYPT_CRYPTALGO GWEN_CRYPT_CRYPTALGO
Definition cryptalgo.h:20
int GWEN_Crypt_TransformPin(GWEN_CRYPT_PINENCODING peSrc, GWEN_CRYPT_PINENCODING peDst, unsigned char *buffer, unsigned int bufLength, unsigned int *pinLength)
Definition cryptdefs.c:411
GWEN_CRYPT_PINENCODING
Definition cryptdefs.h:39
@ GWEN_Crypt_PinEncoding_Ascii
Definition cryptdefs.h:44
GWEN_CRYPT_PINTYPE
Definition cryptdefs.h:26
@ GWEN_Crypt_PinType_Access
Definition cryptdefs.h:29
@ GWEN_Crypt_PinType_Manage
Definition cryptdefs.h:30
void GWEN_Crypt_Token_AddFlags(GWEN_CRYPT_TOKEN *ct, uint32_t f)
Definition ct.c:162
const char * GWEN_Crypt_Token_GetTypeName(const GWEN_CRYPT_TOKEN *ct)
Definition ct.c:86
void GWEN_Crypt_Token_free(GWEN_CRYPT_TOKEN *ct)
Definition ct.c:56
GWEN_CRYPT_TOKEN_DEVICE GWEN_Crypt_Token_Device_fromString(const char *s)
Definition ct.c:1146
int GWEN_Crypt_Token_IsOpen(const GWEN_CRYPT_TOKEN *ct)
Definition ct.c:291
const char * GWEN_Crypt_Token_Device_toString(GWEN_CRYPT_TOKEN_DEVICE d)
Definition ct.c:1162
int GWEN_Crypt_Token_Sign(GWEN_CRYPT_TOKEN *ct, uint32_t keyId, GWEN_CRYPT_PADDALGO *a, const uint8_t *pInData, uint32_t inLen, uint8_t *pSignatureData, uint32_t *pSignatureLen, uint32_t *pSeqCounter, uint32_t gid)
Definition ct.c:418
int GWEN_Crypt_Token_Create(GWEN_CRYPT_TOKEN *ct, uint32_t gid)
Definition ct.c:246
const char * GWEN_Crypt_Token_GetTokenName(const GWEN_CRYPT_TOKEN *ct)
Definition ct.c:96
int GWEN_Crypt_Token_SetKeyInfo(GWEN_CRYPT_TOKEN *ct, uint32_t id, const GWEN_CRYPT_TOKEN_KEYINFO *ki, uint32_t gid)
Definition ct.c:341
GWEN_CRYPT_TOKEN_VERIFY_FN GWEN_Crypt_Token_SetVerifyFn(GWEN_CRYPT_TOKEN *ct, GWEN_CRYPT_TOKEN_VERIFY_FN f)
Definition ct.c:720
int GWEN_Crypt_Token_GenerateKey(GWEN_CRYPT_TOKEN *ct, uint32_t keyId, const GWEN_CRYPT_CRYPTALGO *a, uint32_t gid)
Definition ct.c:515
GWEN_CRYPT_TOKEN_SETCONTEXT_FN GWEN_Crypt_Token_SetSetContextFn(GWEN_CRYPT_TOKEN *ct, GWEN_CRYPT_TOKEN_SETCONTEXT_FN f)
Definition ct.c:690
uint32_t GWEN_Crypt_Token_GetFlags(const GWEN_CRYPT_TOKEN *ct)
Definition ct.c:142
GWEN_CRYPT_TOKEN_CREATE_FN GWEN_Crypt_Token_SetCreateFn(GWEN_CRYPT_TOKEN *ct, GWEN_CRYPT_TOKEN_CREATE_FN f)
Definition ct.c:584
GWEN_CRYPT_TOKEN_SETKEYINFO_FN GWEN_Crypt_Token_SetSetKeyInfoFn(GWEN_CRYPT_TOKEN *ct, GWEN_CRYPT_TOKEN_SETKEYINFO_FN f)
Definition ct.c:645
const GWEN_CRYPT_TOKEN_KEYINFO * GWEN_Crypt_Token_GetKeyInfo(GWEN_CRYPT_TOKEN *ct, uint32_t id, uint32_t flags, uint32_t gid)
Definition ct.c:320
const GWEN_CRYPT_TOKEN_CONTEXT * GWEN_Crypt_Token_GetContext(GWEN_CRYPT_TOKEN *ct, uint32_t id, uint32_t gid)
Definition ct.c:379
int GWEN_Crypt_Token_GetKeyIdList(GWEN_CRYPT_TOKEN *ct, uint32_t *pIdList, uint32_t *pCount, uint32_t gid)
Definition ct.c:301
GWEN_CRYPT_TOKEN_GETKEYIDLIST_FN GWEN_Crypt_Token_SetGetKeyIdListFn(GWEN_CRYPT_TOKEN *ct, GWEN_CRYPT_TOKEN_GETKEYIDLIST_FN f)
Definition ct.c:615
GWEN_CRYPT_TOKEN_DEVICE GWEN_Crypt_Token_GetDevice(const GWEN_CRYPT_TOKEN *ct)
Definition ct.c:76
const char * GWEN_Crypt_Token_GetFriendlyName(const GWEN_CRYPT_TOKEN *ct)
Definition ct.c:119
uint32_t GWEN_Crypt_Token_GetModes(const GWEN_CRYPT_TOKEN *ct)
Definition ct.c:182
int GWEN_Crypt_Token_SetPinStatus(GWEN_CRYPT_TOKEN *ct, GWEN_CRYPT_PINTYPE pt, GWEN_CRYPT_PINENCODING pe, GWEN_UNUSED uint32_t flags, const unsigned char *buffer, unsigned int pinLength, int isOk, uint32_t gid)
Definition ct.c:945
int GWEN_Crypt_Token_InsertCorrectToken(GWEN_CRYPT_TOKEN *ct, uint32_t gid)
Definition ct.c:1074
void GWEN_Crypt_Token_SetFlags(GWEN_CRYPT_TOKEN *ct, uint32_t f)
Definition ct.c:152
int GWEN_Crypt_Token_Open(GWEN_CRYPT_TOKEN *ct, int admin, uint32_t gid)
Definition ct.c:222
int GWEN_Crypt_Token_Verify(GWEN_CRYPT_TOKEN *ct, uint32_t keyId, GWEN_CRYPT_PADDALGO *a, const uint8_t *pInData, uint32_t inLen, const uint8_t *pSignatureData, uint32_t signatureLen, uint32_t seqCounter, uint32_t gid)
Definition ct.c:443
GWEN_CRYPT_TOKEN_DECIPHER_FN GWEN_Crypt_Token_SetDecipherFn(GWEN_CRYPT_TOKEN *ct, GWEN_CRYPT_TOKEN_DECIPHER_FN f)
Definition ct.c:750
int GWEN_Crypt_Token_SetContext(GWEN_CRYPT_TOKEN *ct, uint32_t id, const GWEN_CRYPT_TOKEN_CONTEXT *ctx, uint32_t gid)
Definition ct.c:399
GWEN_CRYPT_TOKEN_GETCONTEXT_FN GWEN_Crypt_Token_SetGetContextFn(GWEN_CRYPT_TOKEN *ct, GWEN_CRYPT_TOKEN_GETCONTEXT_FN f)
Definition ct.c:675
int GWEN_Crypt_Token_Close(GWEN_CRYPT_TOKEN *ct, int abandon, uint32_t gid)
Definition ct.c:265
int GWEN_Crypt_Token_ActivateKey(GWEN_CRYPT_TOKEN *ct, uint32_t id, uint32_t gid)
Definition ct.c:550
int GWEN_Crypt_Token_Encipher(GWEN_CRYPT_TOKEN *ct, uint32_t keyId, GWEN_CRYPT_PADDALGO *a, const uint8_t *pInData, uint32_t inLen, uint8_t *pOutData, uint32_t *pOutLen, uint32_t gid)
Definition ct.c:468
int GWEN_Crypt_Token_ChangePin(GWEN_CRYPT_TOKEN *ct, int admin, uint32_t gid)
Definition ct.c:534
GWEN_CRYPT_TOKEN_GENERATEKEY_FN GWEN_Crypt_Token_SetGenerateKeyFn(GWEN_CRYPT_TOKEN *ct, GWEN_CRYPT_TOKEN_GENERATEKEY_FN f)
Definition ct.c:765
GWEN_CRYPT_TOKEN_ACTIVATEKEY_FN GWEN_Crypt_Token_SetActivateKeyFn(GWEN_CRYPT_TOKEN *ct, GWEN_CRYPT_TOKEN_ACTIVATEKEY_FN f)
Definition ct.c:795
GWEN_CRYPT_TOKEN_ENCIPHER_FN GWEN_Crypt_Token_SetEncipherFn(GWEN_CRYPT_TOKEN *ct, GWEN_CRYPT_TOKEN_ENCIPHER_FN f)
Definition ct.c:735
int GWEN_Crypt_Token_Decipher(GWEN_CRYPT_TOKEN *ct, uint32_t keyId, GWEN_CRYPT_PADDALGO *a, const uint8_t *pInData, uint32_t inLen, uint8_t *pOutData, uint32_t *pOutLen, uint32_t gid)
Definition ct.c:491
void GWEN_Crypt_Token_SubFlags(GWEN_CRYPT_TOKEN *ct, uint32_t f)
Definition ct.c:172
int GWEN_Crypt_Token_InsertToken(GWEN_CRYPT_TOKEN *ct, uint32_t gid)
Definition ct.c:1018
int GWEN_Crypt_Token_EndEnterPin(GWEN_UNUSED GWEN_CRYPT_TOKEN *ct, GWEN_UNUSED GWEN_CRYPT_PINTYPE pt, GWEN_UNUSED int ok, uint32_t gid)
Definition ct.c:1008
GWEN_CRYPT_TOKEN * GWEN_Crypt_Token_new(GWEN_CRYPT_TOKEN_DEVICE dev, const char *typeName, const char *tokenName)
Definition ct.c:33
int GWEN_Crypt_Token__CreatePasswordName(GWEN_CRYPT_TOKEN *ct, GWEN_CRYPT_PINTYPE pt, GWEN_BUFFER *nbuf)
Definition ct.c:812
GWEN_CRYPT_TOKEN_CLOSE_FN GWEN_Crypt_Token_SetCloseFn(GWEN_CRYPT_TOKEN *ct, GWEN_CRYPT_TOKEN_CLOSE_FN f)
Definition ct.c:600
GWEN_CRYPT_TOKEN_OPEN_FN GWEN_Crypt_Token_SetOpenFn(GWEN_CRYPT_TOKEN *ct, GWEN_CRYPT_TOKEN_OPEN_FN f)
Definition ct.c:569
GWEN_CRYPT_TOKEN_GETCONTEXTIDLIST_FN GWEN_Crypt_Token_SetGetContextIdListFn(GWEN_CRYPT_TOKEN *ct, GWEN_CRYPT_TOKEN_GETCONTEXTIDLIST_FN f)
Definition ct.c:660
uint32_t GWEN_Crypt_Token_BeginEnterPin(GWEN_UNUSED GWEN_CRYPT_TOKEN *ct, GWEN_UNUSED GWEN_CRYPT_PINTYPE pt, uint32_t gid)
Definition ct.c:994
GWEN_CRYPT_TOKEN_SIGN_FN GWEN_Crypt_Token_SetSignFn(GWEN_CRYPT_TOKEN *ct, GWEN_CRYPT_TOKEN_SIGN_FN f)
Definition ct.c:705
void GWEN_Crypt_Token_SubModes(GWEN_CRYPT_TOKEN *ct, uint32_t f)
Definition ct.c:212
int GWEN_Crypt_Token_GetPin(GWEN_CRYPT_TOKEN *ct, GWEN_CRYPT_PINTYPE pt, GWEN_CRYPT_PINENCODING pe, uint32_t flags, unsigned char *pwbuffer, unsigned int minLength, unsigned int maxLength, unsigned int *pinLength, uint32_t gid)
Definition ct.c:839
void GWEN_Crypt_Token_SetFriendlyName(GWEN_CRYPT_TOKEN *ct, const char *s)
Definition ct.c:129
void GWEN_Crypt_Token_AddModes(GWEN_CRYPT_TOKEN *ct, uint32_t f)
Definition ct.c:202
void GWEN_Crypt_Token_SetModes(GWEN_CRYPT_TOKEN *ct, uint32_t f)
Definition ct.c:192
int GWEN_Crypt_Token_GetContextIdList(GWEN_CRYPT_TOKEN *ct, uint32_t *pIdList, uint32_t *pCount, uint32_t gid)
Definition ct.c:360
GWEN_CRYPT_TOKEN_CHANGEPIN_FN GWEN_Crypt_Token_SetChangePinFn(GWEN_CRYPT_TOKEN *ct, GWEN_CRYPT_TOKEN_CHANGEPIN_FN f)
Definition ct.c:780
GWEN_CRYPT_TOKEN_GETKEYINFO_FN GWEN_Crypt_Token_SetGetKeyInfoFn(GWEN_CRYPT_TOKEN *ct, GWEN_CRYPT_TOKEN_GETKEYINFO_FN f)
Definition ct.c:630
void GWEN_Crypt_Token_SetTokenName(GWEN_CRYPT_TOKEN *ct, const char *s)
Definition ct.c:106
struct GWEN_CRYPT_TOKEN GWEN_CRYPT_TOKEN
Definition ct.h:19
GWEN_CRYPT_TOKEN_DEVICE
Definition ct.h:35
@ GWEN_Crypt_Token_Device_Any
Definition ct.h:40
@ GWEN_Crypt_Token_Device_Unknown
Definition ct.h:36
@ GWEN_Crypt_Token_Device_File
Definition ct.h:38
@ GWEN_Crypt_Token_Device_Card
Definition ct.h:39
@ GWEN_Crypt_Token_Device_None
Definition ct.h:37
int GWENHYWFAR_CB(* GWEN_CRYPT_TOKEN_OPEN_FN)(GWEN_CRYPT_TOKEN *ct, int admin, uint32_t gid)
Definition ct_be.h:31
int GWENHYWFAR_CB(* GWEN_CRYPT_TOKEN_DECIPHER_FN)(GWEN_CRYPT_TOKEN *ct, uint32_t keyId, GWEN_CRYPT_PADDALGO *a, const uint8_t *pInData, uint32_t inLen, uint8_t *pOutData, uint32_t *pOutLen, uint32_t gid)
Definition ct_be.h:92
const GWEN_CRYPT_TOKEN_KEYINFO *GWENHYWFAR_CB(* GWEN_CRYPT_TOKEN_GETKEYINFO_FN)(GWEN_CRYPT_TOKEN *ct, uint32_t id, uint32_t flags, uint32_t gid)
Definition ct_be.h:39
int GWENHYWFAR_CB(* GWEN_CRYPT_TOKEN_GETKEYIDLIST_FN)(GWEN_CRYPT_TOKEN *ct, uint32_t *pIdList, uint32_t *pCount, uint32_t gid)
Definition ct_be.h:35
int GWENHYWFAR_CB(* GWEN_CRYPT_TOKEN_VERIFY_FN)(GWEN_CRYPT_TOKEN *ct, uint32_t keyId, GWEN_CRYPT_PADDALGO *a, const uint8_t *pInData, uint32_t inLen, const uint8_t *pSignatureData, uint32_t signatureLen, uint32_t seqCounter, uint32_t gid)
Definition ct_be.h:73
int GWENHYWFAR_CB(* GWEN_CRYPT_TOKEN_SETKEYINFO_FN)(GWEN_CRYPT_TOKEN *ct, uint32_t id, const GWEN_CRYPT_TOKEN_KEYINFO *ki, uint32_t gid)
Definition ct_be.h:44
int GWENHYWFAR_CB(* GWEN_CRYPT_TOKEN_GETCONTEXTIDLIST_FN)(GWEN_CRYPT_TOKEN *ct, uint32_t *pIdList, uint32_t *pCount, uint32_t gid)
Definition ct_be.h:49
int GWENHYWFAR_CB(* GWEN_CRYPT_TOKEN_SIGN_FN)(GWEN_CRYPT_TOKEN *ct, uint32_t keyId, GWEN_CRYPT_PADDALGO *a, const uint8_t *pInData, uint32_t inLen, uint8_t *pSignatureData, uint32_t *pSignatureLen, uint32_t *pSeqCounter, uint32_t gid)
Definition ct_be.h:63
int GWENHYWFAR_CB(* GWEN_CRYPT_TOKEN_CLOSE_FN)(GWEN_CRYPT_TOKEN *ct, int abandon, uint32_t gid)
Definition ct_be.h:33
int GWENHYWFAR_CB(* GWEN_CRYPT_TOKEN_CHANGEPIN_FN)(GWEN_CRYPT_TOKEN *ct, int admin, uint32_t gid)
Definition ct_be.h:107
const GWEN_CRYPT_TOKEN_CONTEXT *GWENHYWFAR_CB(* GWEN_CRYPT_TOKEN_GETCONTEXT_FN)(GWEN_CRYPT_TOKEN *ct, uint32_t id, uint32_t gid)
Definition ct_be.h:53
int GWENHYWFAR_CB(* GWEN_CRYPT_TOKEN_SETCONTEXT_FN)(GWEN_CRYPT_TOKEN *ct, uint32_t id, const GWEN_CRYPT_TOKEN_CONTEXT *ctx, uint32_t gid)
Definition ct_be.h:57
int GWENHYWFAR_CB(* GWEN_CRYPT_TOKEN_GENERATEKEY_FN)(GWEN_CRYPT_TOKEN *ct, uint32_t keyId, const GWEN_CRYPT_CRYPTALGO *a, uint32_t gid)
Definition ct_be.h:102
int GWENHYWFAR_CB(* GWEN_CRYPT_TOKEN_ACTIVATEKEY_FN)(GWEN_CRYPT_TOKEN *ct, uint32_t id, uint32_t gid)
Definition ct_be.h:109
int GWENHYWFAR_CB(* GWEN_CRYPT_TOKEN_ENCIPHER_FN)(GWEN_CRYPT_TOKEN *ct, uint32_t keyId, GWEN_CRYPT_PADDALGO *a, const uint8_t *pInData, uint32_t inLen, uint8_t *pOutData, uint32_t *pOutLen, uint32_t gid)
Definition ct_be.h:83
int GWENHYWFAR_CB(* GWEN_CRYPT_TOKEN_CREATE_FN)(GWEN_CRYPT_TOKEN *ct, uint32_t gid)
Definition ct_be.h:32
struct GWEN_CRYPT_TOKEN_CONTEXT GWEN_CRYPT_TOKEN_CONTEXT
Definition ct_context.h:221
struct GWEN_CRYPT_TOKEN_KEYINFO GWEN_CRYPT_TOKEN_KEYINFO
Definition ct_keyinfo.h:127
#define DBG_INFO(dbg_logger, format,...)
Definition debug.h:181
#define DBG_ERROR(dbg_logger, format,...)
Definition debug.h:97
#define I18N(m)
Definition error.c:42
#define GWEN_ERROR_NOT_IMPLEMENTED
Definition error.h:108
#define GWEN_ERROR_NOT_OPEN
Definition error.h:70
#define GWEN_ERROR_INVALID
Definition error.h:67
#define GWEN_ERROR_BUFFER_OVERFLOW
Definition error.h:79
#define GWEN_ERROR_USER_ABORTED
Definition error.h:65
struct GWEN_BUFFER GWEN_BUFFER
A dynamically resizeable text buffer.
Definition buffer.h:38
#define GWEN_GUI_MSG_FLAGS_TYPE_WARN
Definition gui.h:287
@ GWEN_Gui_PasswordMethod_Text
Definition gui.h:166
#define GWEN_GUI_MSG_FLAGS_SEVERITY_NORMAL
Definition gui.h:331
GWENHYWFAR_API int GWEN_Gui_MessageBox(uint32_t flags, const char *title, const char *text, const char *b1, const char *b2, const char *b3, uint32_t guiid)
#define GWEN_GUI_INPUT_FLAGS_NUMERIC
Definition gui.h:215
#define GWEN_GUI_MSG_FLAGS_CONFIRM_B1
Definition gui.h:299
GWENHYWFAR_API int GWEN_Gui_GetPassword(uint32_t flags, const char *token, const char *title, const char *text, char *buffer, int minLen, int maxLen, GWEN_GUI_PASSWORD_METHOD methodId, GWEN_DB_NODE *methodParams, uint32_t guiid)
Definition gui_passwd.c:346
#define GWEN_GUI_MSG_FLAGS_TYPE_ERROR
Definition gui.h:293
#define GWEN_GUI_MSG_FLAGS_SEVERITY_DANGEROUS
Definition gui.h:337
GWENHYWFAR_API int GWEN_Gui_ProgressLog(uint32_t id, GWEN_LOGGER_LEVEL level, const char *text)
GWENHYWFAR_API int GWEN_Gui_SetPasswordStatus(const char *token, const char *pin, GWEN_GUI_PASSWORD_STATUS status, uint32_t guiid)
Definition gui_passwd.c:371
@ GWEN_Gui_PasswordStatus_Bad
Definition gui.h:387
@ GWEN_Gui_PasswordStatus_Ok
Definition gui.h:389
#define GWEN_GUI_INPUT_FLAGS_CONFIRM
Definition gui.h:211
#define GWEN_UNUSED
#define GWEN_INHERIT_FUNCTIONS(t)
Definition inherit.h:163
#define GWEN_INHERIT_INIT(t, element)
Definition inherit.h:223
#define GWEN_INHERIT_FINI(t, element)
Definition inherit.h:238
#define GWEN_LIST_FINI(t, element)
Definition list1.h:475
#define GWEN_LIST_FUNCTIONS(t, pr)
Definition list1.h:367
#define GWEN_LIST_INIT(t, element)
Definition list1.h:466
#define GWEN_LIST2_FUNCTIONS(t, pr)
Definition list2.h:99
#define GWEN_LOGDOMAIN
Definition logger.h:35
@ GWEN_LoggerLevel_Warning
Definition logger.h:69
@ GWEN_LoggerLevel_Notice
Definition logger.h:70
#define GWEN_FREE_OBJECT(varname)
Definition memory.h:61
#define GWEN_NEW_OBJECT(typ, varname)
Definition memory.h:55
struct GWEN_CRYPT_PADDALGO GWEN_CRYPT_PADDALGO
Definition paddalgo.h:21