gwenhywfar  5.3.0
cttest2.c
Go to the documentation of this file.
1 /***************************************************************************
2  $RCSfile$
3  -------------------
4  cvs : $Id: main.c 1107 2007-01-07 21:17:05Z martin $
5  begin : Tue May 03 2005
6  copyright : (C) 2005 by Martin Preuss
7  email : martin@libchipcard.de
8 
9  ***************************************************************************
10  * Please see toplevel file COPYING for license details *
11  ***************************************************************************/
12 
13 #ifdef HAVE_CONFIG_H
14 # include <config.h>
15 #endif
16 
17 #include <gwenhywfar/debug.h>
18 #include <gwenhywfar/pathmanager.h>
19 #include <gwenhywfar/cgui.h>
20 
21 #include <gwenhywfar/gwenhywfar.h>
22 #include <gwenhywfar/args.h>
23 #include <gwenhywfar/logger.h>
24 #include <gwenhywfar/db.h>
25 #include <gwenhywfar/misc.h>
26 #include <gwenhywfar/misc2.h>
27 #include <gwenhywfar/inherit.h>
28 #include <gwenhywfar/crypttoken.h>
29 #include <gwenhywfar/ct.h>
30 #include <gwenhywfar/ctplugin.h>
31 #include <gwenhywfar/text.h>
32 #include <gwenhywfar/mdigest.h>
33 
34 #include "src/base/i18n_l.h"
35 
36 #ifdef OS_WIN32
37 # define DIRSEP "\\"
38 #else
39 # define DIRSEP "/"
40 #endif
41 
42 #ifdef HAVE_I18N
43 # include <libintl.h>
44 # include <locale.h>
45 #endif
46 
47 
48 #define GCT_LOGDOMAIN "GCT"
49 
50 //#define DEBUG_GCT_TOOL
51 
52 
53 int signWithOld(GWEN_DB_NODE *dbArgs, int argc, char **argv)
54 {
55  GWEN_DB_NODE *db;
56  const char *ttype;
57  const char *tname;
59  GWEN_PLUGIN *pl;
60  GWEN_CRYPTTOKEN *ct;
61  unsigned int ucid;
62  int rv;
63  const GWEN_ARGS args[]= {
64  {
65  GWEN_ARGS_FLAGS_HAS_ARGUMENT, /* flags */
66  GWEN_ArgsType_Int, /* type */
67  "userContextId", /* name */
68  0, /* minnum */
69  1, /* maxnum */
70  "i", /* short option */
71  "id", /* long option */
72  "User context id (0 for any)",/* short description */
73  "User context id (0 for any)" /* long description */
74  },
75  {
76  GWEN_ARGS_FLAGS_HAS_ARGUMENT, /* flags */
77  GWEN_ArgsType_Char, /* type */
78  "tokenType", /* name */
79  1, /* minnum */
80  1, /* maxnum */
81  "t", /* short option */
82  "ttype", /* long option */
83  "Specify the crypt token type", /* short description */
84  "Specify the crypt token type" /* long description */
85  },
86  {
87  GWEN_ARGS_FLAGS_HAS_ARGUMENT, /* flags */
88  GWEN_ArgsType_Char, /* type */
89  "tokenName", /* name */
90  0, /* minnum */
91  1, /* maxnum */
92  "n", /* short option */
93  "tname", /* long option */
94  "Specify the crypt token name", /* short description */
95  "Specify the crypt token name" /* long description */
96  },
97  {
99  GWEN_ArgsType_Int, /* type */
100  "help", /* name */
101  0, /* minnum */
102  0, /* maxnum */
103  "h", /* short option */
104  "help", /* long option */
105  "Show this help screen", /* short description */
106  "Show this help screen" /* long description */
107  }
108  };
109 
110  db=GWEN_DB_GetGroup(dbArgs, GWEN_DB_FLAGS_DEFAULT, "local");
111  rv=GWEN_Args_Check(argc, argv, 1,
113  args,
114  db);
115  if (rv==GWEN_ARGS_RESULT_ERROR) {
116  fprintf(stderr, "ERROR: Could not parse arguments\n");
117  return 1;
118  }
119  else if (rv==GWEN_ARGS_RESULT_HELP) {
120  GWEN_BUFFER *ubuf;
121 
122  ubuf=GWEN_Buffer_new(0, 1024, 0, 1);
123  if (GWEN_Args_Usage(args, ubuf, GWEN_ArgsOutType_Txt)) {
124  fprintf(stderr, "ERROR: Could not create help string\n");
125  return 1;
126  }
127  fprintf(stderr, "%s\n", GWEN_Buffer_GetStart(ubuf));
128  GWEN_Buffer_free(ubuf);
129  return 0;
130  }
131 
132  ucid=GWEN_DB_GetIntValue(db, "userContextId", 0, 0);
133 
134  ttype=GWEN_DB_GetCharValue(db, "tokenType", 0, 0);
135  assert(ttype);
136 
137  tname=GWEN_DB_GetCharValue(db, "tokenName", 0, 0);
138 
139  /* get crypt token */
140  pm=GWEN_PluginManager_FindPluginManager("crypttoken");
141  if (pm==0) {
142  DBG_ERROR(0, "Plugin manager not found");
143  return 3;
144  }
145 
146  pl=GWEN_PluginManager_GetPlugin(pm, ttype);
147  if (pl==0) {
148  DBG_ERROR(0, "Plugin not found");
149  return 3;
150  }
151  DBG_INFO(0, "Plugin found");
152 
153  ct=GWEN_CryptToken_Plugin_CreateToken(pl, 0, tname);
154  if (ct==0) {
155  DBG_ERROR(0, "Could not create crypt token");
156  return 3;
157  }
158 
159  if (GWEN_DB_GetIntValue(dbArgs, "forcePin", 0, 0))
160  GWEN_CryptToken_AddModes(ct, GWEN_CRYPTTOKEN_MODES_FORCE_PIN_ENTRY);
161 
162  /* open crypt token for use */
163  rv=GWEN_CryptToken_Open(ct, 0);
164  if (rv) {
165  DBG_ERROR(0, "Could not open token");
166  return 3;
167  }
168  else {
169  GWEN_BUFFER *dstBuf;
170  const GWEN_CRYPTTOKEN_CONTEXT *octx;
171  GWEN_CRYPTTOKEN_CONTEXT *ctx;
172  GWEN_CRYPTTOKEN_SIGNINFO *si;
173  uint8_t clearText[96]= {
174  0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
175  0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10,
176  0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18,
177  0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20,
178  0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28,
179  0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30,
180  0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38,
181  0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, 0x40,
182  0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48,
183  0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50,
184  0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58,
185  0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, 0x60
186  };
187 
188  octx=GWEN_CryptToken_GetContextById(ct, 0x01);
189  if (octx==NULL) {
190  DBG_ERROR(0, "Context not found");
191  return 3;
192  }
193 
194  /* prepare context */
195  ctx=GWEN_CryptToken_Context_dup(octx);
196  si=GWEN_CryptToken_Context_GetSignInfo(ctx);
197  GWEN_CryptToken_SignInfo_SetHashAlgo(si, GWEN_CryptToken_HashAlgo_None);
198  GWEN_CryptToken_SignInfo_SetPaddAlgo(si, GWEN_CryptToken_PaddAlgo_None);
199 
200  dstBuf=GWEN_Buffer_new(0, 256, 0, 1);
201  rv=GWEN_CryptToken_Sign(ct, ctx, (const char *)clearText, 96, dstBuf);
202  if (rv) {
203  DBG_ERROR(0, "Could not sign data (%d)", rv);
204  return 3;
205  }
206  fprintf(stderr, "Signature is:\n");
208  GWEN_Buffer_GetUsedBytes(dstBuf),
209  stderr, 2);
210  GWEN_Buffer_free(dstBuf);
211  }
212 
213 
214  /* close crypt token */
215  rv=GWEN_CryptToken_Close(ct);
216  if (rv) {
217  DBG_ERROR(0, "Could not close token");
218  return 3;
219  }
220 
221  return 0;
222 }
223 
224 
225 
226 
227 int signWithNew(GWEN_DB_NODE *dbArgs, int argc, char **argv)
228 {
229  GWEN_DB_NODE *db;
230  const char *ttype;
231  const char *tname;
233  GWEN_PLUGIN *pl;
234  GWEN_CRYPT_TOKEN *ct;
235  unsigned int cid;
236  int rv;
237  const GWEN_ARGS args[]= {
238  {
239  GWEN_ARGS_FLAGS_HAS_ARGUMENT, /* flags */
240  GWEN_ArgsType_Int, /* type */
241  "contextId", /* name */
242  0, /* minnum */
243  1, /* maxnum */
244  "i", /* short option */
245  "id", /* long option */
246  "Context id (0 for any)", /* short description */
247  "Context id (0 for any)" /* long description */
248  },
249  {
250  GWEN_ARGS_FLAGS_HAS_ARGUMENT, /* flags */
251  GWEN_ArgsType_Char, /* type */
252  "tokenType", /* name */
253  1, /* minnum */
254  1, /* maxnum */
255  "t", /* short option */
256  "ttype", /* long option */
257  "Specify the crypt token type", /* short description */
258  "Specify the crypt token type" /* long description */
259  },
260  {
261  GWEN_ARGS_FLAGS_HAS_ARGUMENT, /* flags */
262  GWEN_ArgsType_Char, /* type */
263  "tokenName", /* name */
264  0, /* minnum */
265  1, /* maxnum */
266  "n", /* short option */
267  "tname", /* long option */
268  "Specify the crypt token name", /* short description */
269  "Specify the crypt token name" /* long description */
270  },
271  {
273  GWEN_ArgsType_Int, /* type */
274  "help", /* name */
275  0, /* minnum */
276  0, /* maxnum */
277  "h", /* short option */
278  "help", /* long option */
279  "Show this help screen", /* short description */
280  "Show this help screen" /* long description */
281  }
282  };
283 
284  db=GWEN_DB_GetGroup(dbArgs, GWEN_DB_FLAGS_DEFAULT, "local");
285  rv=GWEN_Args_Check(argc, argv, 1,
287  args,
288  db);
289  if (rv==GWEN_ARGS_RESULT_ERROR) {
290  fprintf(stderr, "ERROR: Could not parse arguments\n");
291  return 1;
292  }
293  else if (rv==GWEN_ARGS_RESULT_HELP) {
294  GWEN_BUFFER *ubuf;
295 
296  ubuf=GWEN_Buffer_new(0, 1024, 0, 1);
297  if (GWEN_Args_Usage(args, ubuf, GWEN_ArgsOutType_Txt)) {
298  fprintf(stderr, "ERROR: Could not create help string\n");
299  return 1;
300  }
301  fprintf(stderr, "%s\n", GWEN_Buffer_GetStart(ubuf));
302  GWEN_Buffer_free(ubuf);
303  return 0;
304  }
305 
306  cid=GWEN_DB_GetIntValue(db, "contextId", 0, 0);
307 
308  ttype=GWEN_DB_GetCharValue(db, "tokenType", 0, 0);
309  assert(ttype);
310 
311  tname=GWEN_DB_GetCharValue(db, "tokenName", 0, 0);
312 
313  /* get crypt token */
315  if (pm==0) {
316  DBG_ERROR(0, "Plugin manager not found");
317  return 3;
318  }
319 
320  pl=GWEN_PluginManager_GetPlugin(pm, ttype);
321  if (pl==0) {
322  DBG_ERROR(0, "Plugin not found");
323  return 3;
324  }
325  DBG_INFO(0, "Plugin found");
326 
328  if (ct==0) {
329  DBG_ERROR(0, "Could not create crypt token");
330  return 3;
331  }
332 
333  if (GWEN_DB_GetIntValue(dbArgs, "forcePin", 0, 0))
335 
336  /* open crypt token for use */
337  rv=GWEN_Crypt_Token_Open(ct, 0, 0);
338  if (rv) {
339  DBG_ERROR(0, "Could not open token");
340  return 3;
341  }
342  else {
343  uint8_t clearText[96]= {
344  0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
345  0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10,
346  0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18,
347  0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20,
348  0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28,
349  0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30,
350  0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38,
351  0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, 0x40,
352  0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48,
353  0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50,
354  0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58,
355  0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, 0x60
356  };
357  uint8_t signature[256];
358  uint32_t signLen;
359  GWEN_CRYPT_PADDALGO *algo;
360 
361  algo=GWEN_Crypt_PaddAlgo_new(GWEN_Crypt_PaddAlgoId_None);
362  signLen=sizeof(signature);
363  rv=GWEN_Crypt_Token_Sign(ct,
364  0x01, /* local sign key */
365  algo,
366  clearText,
367  96,
368  signature,
369  &signLen,
370  NULL,
371  0);
372  if (rv) {
373  DBG_ERROR(0, "Could not sign data (%d)", rv);
374  return 3;
375  }
376 
377  fprintf(stderr, "Signature is:\n");
378  GWEN_Text_DumpString((const char *) signature, signLen, stderr, 2);
379 
380  rv=GWEN_Crypt_Token_Verify(ct, 0x01,
381  algo,
382  clearText,
383  96,
384  signature,
385  signLen,
386  0,
387  0);
388  if (rv) {
389  DBG_ERROR(0, "Could not verify data (%d)", rv);
390  return 3;
391  }
392  fprintf(stderr, "Signature is ok.\n");
393 
394  }
395 
396  /* close crypt token */
397  rv=GWEN_Crypt_Token_Close(ct, 0, 0);
398  if (rv) {
399  DBG_ERROR(0, "Could not close token");
400  return 3;
401  }
402 
403  return 0;
404 }
405 
406 
407 
408 int cryptWithOld(GWEN_DB_NODE *dbArgs, int argc, char **argv)
409 {
410  GWEN_DB_NODE *db;
411  const char *ttype;
412  const char *tname;
414  GWEN_PLUGIN *pl;
415  GWEN_CRYPTTOKEN *ct;
416  unsigned int ucid;
417  int rv;
418  const GWEN_ARGS args[]= {
419  {
420  GWEN_ARGS_FLAGS_HAS_ARGUMENT, /* flags */
421  GWEN_ArgsType_Int, /* type */
422  "userContextId", /* name */
423  0, /* minnum */
424  1, /* maxnum */
425  "i", /* short option */
426  "id", /* long option */
427  "User context id (0 for any)",/* short description */
428  "User context id (0 for any)" /* long description */
429  },
430  {
431  GWEN_ARGS_FLAGS_HAS_ARGUMENT, /* flags */
432  GWEN_ArgsType_Char, /* type */
433  "tokenType", /* name */
434  1, /* minnum */
435  1, /* maxnum */
436  "t", /* short option */
437  "ttype", /* long option */
438  "Specify the crypt token type", /* short description */
439  "Specify the crypt token type" /* long description */
440  },
441  {
442  GWEN_ARGS_FLAGS_HAS_ARGUMENT, /* flags */
443  GWEN_ArgsType_Char, /* type */
444  "tokenName", /* name */
445  0, /* minnum */
446  1, /* maxnum */
447  "n", /* short option */
448  "tname", /* long option */
449  "Specify the crypt token name", /* short description */
450  "Specify the crypt token name" /* long description */
451  },
452  {
454  GWEN_ArgsType_Int, /* type */
455  "help", /* name */
456  0, /* minnum */
457  0, /* maxnum */
458  "h", /* short option */
459  "help", /* long option */
460  "Show this help screen", /* short description */
461  "Show this help screen" /* long description */
462  }
463  };
464 
465  db=GWEN_DB_GetGroup(dbArgs, GWEN_DB_FLAGS_DEFAULT, "local");
466  rv=GWEN_Args_Check(argc, argv, 1,
468  args,
469  db);
470  if (rv==GWEN_ARGS_RESULT_ERROR) {
471  fprintf(stderr, "ERROR: Could not parse arguments\n");
472  return 1;
473  }
474  else if (rv==GWEN_ARGS_RESULT_HELP) {
475  GWEN_BUFFER *ubuf;
476 
477  ubuf=GWEN_Buffer_new(0, 1024, 0, 1);
478  if (GWEN_Args_Usage(args, ubuf, GWEN_ArgsOutType_Txt)) {
479  fprintf(stderr, "ERROR: Could not create help string\n");
480  return 1;
481  }
482  fprintf(stderr, "%s\n", GWEN_Buffer_GetStart(ubuf));
483  GWEN_Buffer_free(ubuf);
484  return 0;
485  }
486 
487  ucid=GWEN_DB_GetIntValue(db, "userContextId", 0, 0);
488 
489  ttype=GWEN_DB_GetCharValue(db, "tokenType", 0, 0);
490  assert(ttype);
491 
492  tname=GWEN_DB_GetCharValue(db, "tokenName", 0, 0);
493 
494  /* get crypt token */
495  pm=GWEN_PluginManager_FindPluginManager("crypttoken");
496  if (pm==0) {
497  DBG_ERROR(0, "Plugin manager not found");
498  return 3;
499  }
500 
501  pl=GWEN_PluginManager_GetPlugin(pm, ttype);
502  if (pl==0) {
503  DBG_ERROR(0, "Plugin not found");
504  return 3;
505  }
506  DBG_INFO(0, "Plugin found");
507 
508  ct=GWEN_CryptToken_Plugin_CreateToken(pl, 0, tname);
509  if (ct==0) {
510  DBG_ERROR(0, "Could not create crypt token");
511  return 3;
512  }
513 
514  if (GWEN_DB_GetIntValue(dbArgs, "forcePin", 0, 0))
515  GWEN_CryptToken_AddModes(ct, GWEN_CRYPTTOKEN_MODES_FORCE_PIN_ENTRY);
516 
517  /* open crypt token for use */
518  rv=GWEN_CryptToken_Open(ct, 0);
519  if (rv) {
520  DBG_ERROR(0, "Could not open token");
521  return 3;
522  }
523  else {
524  GWEN_BUFFER *dstBuf;
525  const GWEN_CRYPTTOKEN_CONTEXT *octx;
526  GWEN_CRYPTTOKEN_CONTEXT *ctx;
527  GWEN_CRYPTTOKEN_CRYPTINFO *ci;
528  //GWEN_CRYPTTOKEN_KEYINFO *ki;
529  uint8_t clearText[96]= {
530  0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
531  0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10,
532  0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18,
533  0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20,
534  0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28,
535  0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30,
536  0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38,
537  0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, 0x40,
538  0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48,
539  0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50,
540  0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58,
541  0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, 0x60
542  };
543 
544  octx=GWEN_CryptToken_GetContextById(ct, 0x01);
545  if (octx==NULL) {
546  DBG_ERROR(0, "Context not found");
547  return 3;
548  }
549 
550  /* prepare context */
551  ctx=GWEN_CryptToken_Context_dup(octx);
552  ci=GWEN_CryptToken_Context_GetCryptInfo(ctx);
553  GWEN_CryptToken_CryptInfo_SetPaddAlgo(ci, GWEN_CryptToken_PaddAlgo_None);
554  //ki=GWEN_CryptToken_Context_GetEncryptKeyInfo(ctx);
555  //GWEN_CryptToken_KeyInfo_SetKeyId(ki, 0x02);
556 
557  dstBuf=GWEN_Buffer_new(0, 256, 0, 1);
558  rv=GWEN_CryptToken_Encrypt(ct, ctx, (const char *)clearText, 96, dstBuf);
559  if (rv) {
560  DBG_ERROR(0, "Could not encrypt data (%d)", rv);
561  return 3;
562  }
563  fprintf(stderr, "Result is:\n");
565  GWEN_Buffer_GetUsedBytes(dstBuf),
566  stderr, 2);
567  GWEN_Buffer_free(dstBuf);
568  }
569 
570 
571  /* close crypt token */
572  rv=GWEN_CryptToken_Close(ct);
573  if (rv) {
574  DBG_ERROR(0, "Could not close token");
575  return 3;
576  }
577 
578  return 0;
579 }
580 
581 
582 
583 int cryptWithNew(GWEN_DB_NODE *dbArgs, int argc, char **argv)
584 {
585  GWEN_DB_NODE *db;
586  const char *ttype;
587  const char *tname;
589  GWEN_PLUGIN *pl;
590  GWEN_CRYPT_TOKEN *ct;
591  unsigned int cid;
592  int rv;
593  const GWEN_ARGS args[]= {
594  {
595  GWEN_ARGS_FLAGS_HAS_ARGUMENT, /* flags */
596  GWEN_ArgsType_Int, /* type */
597  "contextId", /* name */
598  0, /* minnum */
599  1, /* maxnum */
600  "i", /* short option */
601  "id", /* long option */
602  "Context id (0 for any)", /* short description */
603  "Context id (0 for any)" /* long description */
604  },
605  {
606  GWEN_ARGS_FLAGS_HAS_ARGUMENT, /* flags */
607  GWEN_ArgsType_Char, /* type */
608  "tokenType", /* name */
609  1, /* minnum */
610  1, /* maxnum */
611  "t", /* short option */
612  "ttype", /* long option */
613  "Specify the crypt token type", /* short description */
614  "Specify the crypt token type" /* long description */
615  },
616  {
617  GWEN_ARGS_FLAGS_HAS_ARGUMENT, /* flags */
618  GWEN_ArgsType_Char, /* type */
619  "tokenName", /* name */
620  0, /* minnum */
621  1, /* maxnum */
622  "n", /* short option */
623  "tname", /* long option */
624  "Specify the crypt token name", /* short description */
625  "Specify the crypt token name" /* long description */
626  },
627  {
629  GWEN_ArgsType_Int, /* type */
630  "help", /* name */
631  0, /* minnum */
632  0, /* maxnum */
633  "h", /* short option */
634  "help", /* long option */
635  "Show this help screen", /* short description */
636  "Show this help screen" /* long description */
637  }
638  };
639 
640  db=GWEN_DB_GetGroup(dbArgs, GWEN_DB_FLAGS_DEFAULT, "local");
641  rv=GWEN_Args_Check(argc, argv, 1,
643  args,
644  db);
645  if (rv==GWEN_ARGS_RESULT_ERROR) {
646  fprintf(stderr, "ERROR: Could not parse arguments\n");
647  return 1;
648  }
649  else if (rv==GWEN_ARGS_RESULT_HELP) {
650  GWEN_BUFFER *ubuf;
651 
652  ubuf=GWEN_Buffer_new(0, 1024, 0, 1);
653  if (GWEN_Args_Usage(args, ubuf, GWEN_ArgsOutType_Txt)) {
654  fprintf(stderr, "ERROR: Could not create help string\n");
655  return 1;
656  }
657  fprintf(stderr, "%s\n", GWEN_Buffer_GetStart(ubuf));
658  GWEN_Buffer_free(ubuf);
659  return 0;
660  }
661 
662  cid=GWEN_DB_GetIntValue(db, "contextId", 0, 0);
663 
664  ttype=GWEN_DB_GetCharValue(db, "tokenType", 0, 0);
665  assert(ttype);
666 
667  tname=GWEN_DB_GetCharValue(db, "tokenName", 0, 0);
668 
669  /* get crypt token */
671  if (pm==0) {
672  DBG_ERROR(0, "Plugin manager not found");
673  return 3;
674  }
675 
676  pl=GWEN_PluginManager_GetPlugin(pm, ttype);
677  if (pl==0) {
678  DBG_ERROR(0, "Plugin not found");
679  return 3;
680  }
681  DBG_INFO(0, "Plugin found");
682 
684  if (ct==0) {
685  DBG_ERROR(0, "Could not create crypt token");
686  return 3;
687  }
688 
689  if (GWEN_DB_GetIntValue(dbArgs, "forcePin", 0, 0))
691 
692  /* open crypt token for use */
693  rv=GWEN_Crypt_Token_Open(ct, 0, 0);
694  if (rv) {
695  DBG_ERROR(0, "Could not open token");
696  return 3;
697  }
698  else {
699  uint8_t clearText[96]= {
700  0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
701  0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10,
702  0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18,
703  0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20,
704  0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28,
705  0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30,
706  0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38,
707  0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, 0x40,
708  0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48,
709  0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50,
710  0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58,
711  0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, 0x60
712  };
713  uint8_t encrypted[128];
714  uint32_t elen;
715  GWEN_CRYPT_PADDALGO *algo;
716 
717  algo=GWEN_Crypt_PaddAlgo_new(GWEN_Crypt_PaddAlgoId_None);
718  elen=sizeof(encrypted);
720  0x04,
721  algo,
722  clearText,
723  96,
724  encrypted,
725  &elen,
726  0);
727  if (rv) {
728  DBG_ERROR(0, "Could not encipher data (%d)", rv);
729  return 3;
730  }
731 
732  fprintf(stderr, "Encrypted data is:\n");
733  GWEN_Text_DumpString((const char *) encrypted, elen, stderr, 2);
734  }
735 
736  /* close crypt token */
737  rv=GWEN_Crypt_Token_Close(ct, 0, 0);
738  if (rv) {
739  DBG_ERROR(0, "Could not close token");
740  return 3;
741  }
742 
743  return 0;
744 }
745 
746 
747 
748 int cryptWithNew2(GWEN_DB_NODE *dbArgs, int argc, char **argv)
749 {
750  GWEN_DB_NODE *db;
751  const char *ttype;
752  const char *tname;
754  GWEN_PLUGIN *pl;
755  GWEN_CRYPT_TOKEN *ct;
756  unsigned int cid;
757  int rv;
758  const GWEN_ARGS args[]= {
759  {
760  GWEN_ARGS_FLAGS_HAS_ARGUMENT, /* flags */
761  GWEN_ArgsType_Int, /* type */
762  "contextId", /* name */
763  0, /* minnum */
764  1, /* maxnum */
765  "i", /* short option */
766  "id", /* long option */
767  "Context id (0 for any)", /* short description */
768  "Context id (0 for any)" /* long description */
769  },
770  {
771  GWEN_ARGS_FLAGS_HAS_ARGUMENT, /* flags */
772  GWEN_ArgsType_Char, /* type */
773  "tokenType", /* name */
774  1, /* minnum */
775  1, /* maxnum */
776  "t", /* short option */
777  "ttype", /* long option */
778  "Specify the crypt token type", /* short description */
779  "Specify the crypt token type" /* long description */
780  },
781  {
782  GWEN_ARGS_FLAGS_HAS_ARGUMENT, /* flags */
783  GWEN_ArgsType_Char, /* type */
784  "tokenName", /* name */
785  0, /* minnum */
786  1, /* maxnum */
787  "n", /* short option */
788  "tname", /* long option */
789  "Specify the crypt token name", /* short description */
790  "Specify the crypt token name" /* long description */
791  },
792  {
794  GWEN_ArgsType_Int, /* type */
795  "help", /* name */
796  0, /* minnum */
797  0, /* maxnum */
798  "h", /* short option */
799  "help", /* long option */
800  "Show this help screen", /* short description */
801  "Show this help screen" /* long description */
802  }
803  };
804 
805  db=GWEN_DB_GetGroup(dbArgs, GWEN_DB_FLAGS_DEFAULT, "local");
806  rv=GWEN_Args_Check(argc, argv, 1,
808  args,
809  db);
810  if (rv==GWEN_ARGS_RESULT_ERROR) {
811  fprintf(stderr, "ERROR: Could not parse arguments\n");
812  return 1;
813  }
814  else if (rv==GWEN_ARGS_RESULT_HELP) {
815  GWEN_BUFFER *ubuf;
816 
817  ubuf=GWEN_Buffer_new(0, 1024, 0, 1);
818  if (GWEN_Args_Usage(args, ubuf, GWEN_ArgsOutType_Txt)) {
819  fprintf(stderr, "ERROR: Could not create help string\n");
820  return 1;
821  }
822  fprintf(stderr, "%s\n", GWEN_Buffer_GetStart(ubuf));
823  GWEN_Buffer_free(ubuf);
824  return 0;
825  }
826 
827  cid=GWEN_DB_GetIntValue(db, "contextId", 0, 0);
828 
829  ttype=GWEN_DB_GetCharValue(db, "tokenType", 0, 0);
830  assert(ttype);
831 
832  tname=GWEN_DB_GetCharValue(db, "tokenName", 0, 0);
833 
834  /* get crypt token */
836  if (pm==0) {
837  DBG_ERROR(0, "Plugin manager not found");
838  return 3;
839  }
840 
841  pl=GWEN_PluginManager_GetPlugin(pm, ttype);
842  if (pl==0) {
843  DBG_ERROR(0, "Plugin not found");
844  return 3;
845  }
846  DBG_INFO(0, "Plugin found");
847 
849  if (ct==0) {
850  DBG_ERROR(0, "Could not create crypt token");
851  return 3;
852  }
853 
854  if (GWEN_DB_GetIntValue(dbArgs, "forcePin", 0, 0))
856 
857  /* open crypt token for use */
858  rv=GWEN_Crypt_Token_Open(ct, 0, 0);
859  if (rv) {
860  DBG_ERROR(0, "Could not open token");
861  return 3;
862  }
863  else {
864  uint8_t clearText[96]= {
865  0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
866  0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10,
867  0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18,
868  0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20,
869  0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28,
870  0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30,
871  0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38,
872  0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, 0x40,
873  0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48,
874  0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50,
875  0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58,
876  0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, 0x60
877  };
878  uint8_t encrypted[128];
879  uint32_t elen;
880  uint8_t decrypted[128];
881  uint32_t dlen;
882  GWEN_CRYPT_PADDALGO *algo;
883 
884  algo=GWEN_Crypt_PaddAlgo_new(GWEN_Crypt_PaddAlgoId_None);
885  elen=sizeof(encrypted);
887  0x02,
888  algo,
889  clearText,
890  96,
891  encrypted,
892  &elen,
893  0);
894  if (rv) {
895  DBG_ERROR(0, "Could not encipher data (%d)", rv);
896  return 3;
897  }
898 
899  fprintf(stderr, "Encrypted data is:\n");
900  GWEN_Text_DumpString((const char *) encrypted, elen, stderr, 2);
901 
902  dlen=sizeof(decrypted);
904  0x02,
905  algo,
906  encrypted,
907  elen,
908  decrypted,
909  &dlen,
910  0);
911  if (rv) {
912  DBG_ERROR(0, "Could not decipher data (%d)", rv);
913  return 3;
914  }
915 
916  if (memcmp(clearText, decrypted, dlen)) {
917  DBG_ERROR(0, "Deciphered data does not equal clear text(%d)", rv);
918  return 3;
919  }
920  fprintf(stderr, "Deciphered data is ok.\n");
921 
922  }
923 
924  /* close crypt token */
925  rv=GWEN_Crypt_Token_Close(ct, 0, 0);
926  if (rv) {
927  DBG_ERROR(0, "Could not close token");
928  return 3;
929  }
930 
931  return 0;
932 }
933 
934 
935 
936 
937 
938 
939 
940 
941 int main(int argc, char **argv)
942 {
943  GWEN_DB_NODE *db;
944  const char *cmd;
945  int rv;
946  int err;
947  GWEN_GUI *gui;
948  const char *localedir;
949  GWEN_STRINGLIST *slist;
950  const GWEN_ARGS args[]= {
951  {
952  GWEN_ARGS_FLAGS_HAS_ARGUMENT, /* flags */
953  GWEN_ArgsType_Char, /* type */
954  "cfgfile", /* name */
955  0, /* minnum */
956  1, /* maxnum */
957  "C", /* short option */
958  "cfgfile", /* long option */
959  "Specify the configuration file", /* short description */
960  "Specify the configuration file" /* long description */
961  },
962  {
963  0, /* flags */
964  GWEN_ArgsType_Int, /* type */
965  "forcePin", /* name */
966  0, /* minnum */
967  1, /* maxnum */
968  0, /* short option */
969  "forcepin", /* long option */
970  "force pin entry", /* short description */
971  "force pin entry even if the error counter is not zero"
972  },
973  {
975  GWEN_ArgsType_Int, /* type */
976  "help", /* name */
977  0, /* minnum */
978  0, /* maxnum */
979  "h", /* short option */
980  "help", /* long option */
981  "Show this help screen", /* short description */
982  "Show this help screen" /* long description */
983  }
984  };
985 
986  err=GWEN_Init();
987  if (err) {
988  fprintf(stderr, "Could not initialize Gwenhywfar.\n");
989  return 2;
990  }
991 
992  gui=GWEN_Gui_CGui_new();
993  GWEN_Gui_SetGui(gui);
994 
995  slist =
997 
998  assert(GWEN_StringList_Count(slist) > 0);
999  localedir = GWEN_StringList_FirstString(slist);
1000 #ifdef HAVE_I18N
1001  setlocale(LC_ALL, "");
1002  if (bindtextdomain(PACKAGE, localedir)==0)
1003  fprintf(stderr, "Error binding locale\n");
1004 #endif
1005  GWEN_StringList_free(slist);
1006 
1007  GWEN_Logger_Open(GCT_LOGDOMAIN, "gct-tool", 0,
1010 
1011 #ifdef DEBUG_GCT_TOOL
1015 #else
1019 #endif
1020 
1021 #ifdef GCT_IS_EXPERIMENTAL
1022  fprintf(stderr, "\n");
1023  fprintf(stderr, "\n");
1024  fprintf(stderr, "=================== WARNING ===================\n");
1025  fprintf(stderr, "This tool is still EXPERIMENTAL !!!\n");
1026  fprintf(stderr, "Please DON'T USE it with your daily key files !\n");
1027  fprintf(stderr, "===============================================\n");
1028  fprintf(stderr, "\n");
1029  fprintf(stderr, "\n");
1030 #endif
1031 
1032  db=GWEN_DB_Group_new("arguments");
1033  rv=GWEN_Args_Check(argc, argv, 1,
1036  args,
1037  db);
1038  if (rv==GWEN_ARGS_RESULT_ERROR) {
1039  fprintf(stderr, "ERROR: Could not parse arguments main\n");
1040  return -1;
1041  }
1042  else if (rv==GWEN_ARGS_RESULT_HELP) {
1043  GWEN_BUFFER *ubuf;
1044 
1045  ubuf=GWEN_Buffer_new(0, 1024, 0, 1);
1047  I18N("Usage: "));
1048  GWEN_Buffer_AppendString(ubuf, argv[0]);
1050  I18N(" [GLOBAL OPTIONS] COMMAND "
1051  "[LOCAL OPTIONS]\n"));
1053  I18N("\nGlobal Options:\n"));
1054  if (GWEN_Args_Usage(args, ubuf, GWEN_ArgsOutType_Txt)) {
1055  fprintf(stderr, "ERROR: Could not create help string\n");
1056  return 1;
1057  }
1059  I18N("\nCommands:\n\n"));
1061  I18N(" create:\n"
1062  " This command creates a crypt token"
1063  "\n\n"));
1065  I18N(" showuser:\n"
1066  " Display user data stored on the "
1067  "token\n\n"));
1068 
1069  fprintf(stderr, "%s\n", GWEN_Buffer_GetStart(ubuf));
1070  GWEN_Buffer_free(ubuf);
1071  return 0;
1072  }
1073  if (rv) {
1074  argc-=rv-1;
1075  argv+=rv-1;
1076  }
1077 
1078  cmd=GWEN_DB_GetCharValue(db, "params", 0, 0);
1079  if (!cmd) {
1080  fprintf(stderr, "ERROR: Command needed.\n");
1081  return 1;
1082  }
1083 
1084  if (strcasecmp(cmd, "sign1")==0) {
1085  rv=signWithOld(db, argc, argv);
1086  }
1087  else if (strcasecmp(cmd, "sign2")==0) {
1088  rv=signWithNew(db, argc, argv);
1089  }
1090  else if (strcasecmp(cmd, "crypt1")==0) {
1091  rv=cryptWithOld(db, argc, argv);
1092  }
1093  else if (strcasecmp(cmd, "crypt2")==0) {
1094  rv=cryptWithNew(db, argc, argv);
1095  }
1096  else if (strcasecmp(cmd, "crypt3")==0) {
1097  rv=cryptWithNew2(db, argc, argv);
1098  }
1099  else {
1100  fprintf(stderr, "ERROR: Unknown command \"%s\".\n", cmd);
1101  rv=1;
1102  }
1103 
1104  err=GWEN_Fini();
1105  if (err) {
1106  fprintf(stderr,
1107  "WARNING: Could not deinitialize Gwenhywfar.\n");
1108  }
1109 
1110  return rv;
1111 }
1112 
1113 
1114 
1115 
1116 
1117 
1118 
1119 
1120 
#define GWEN_CRYPT_TOKEN_MODE_FORCE_PIN_ENTRY
Definition: ct.h:59
struct GWEN_PLUGIN_MANAGER GWEN_PLUGIN_MANAGER
Definition: plugin.h:40
#define GCT_LOGDOMAIN
Definition: cttest2.c:48
char * GWEN_Buffer_GetStart(const GWEN_BUFFER *bf)
Definition: buffer.c:235
#define I18N(m)
Definition: error.c:42
int signWithOld(GWEN_DB_NODE *dbArgs, int argc, char **argv)
Definition: cttest2.c:53
struct GWEN_DB_NODE GWEN_DB_NODE
Definition: db.h:228
struct GWEN_PLUGIN GWEN_PLUGIN
Definition: plugin.h:39
uint32_t GWEN_Buffer_GetUsedBytes(const GWEN_BUFFER *bf)
Definition: buffer.c:277
void GWEN_Logger_SetLevel(const char *logDomain, GWEN_LOGGER_LEVEL l)
Definition: logger.c:627
int cryptWithNew2(GWEN_DB_NODE *dbArgs, int argc, char **argv)
Definition: cttest2.c:748
void GWEN_Text_DumpString(const char *s, unsigned int l, unsigned int insert)
Definition: text.c:1283
int signWithNew(GWEN_DB_NODE *dbArgs, int argc, char **argv)
Definition: cttest2.c:227
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
GWEN_CRYPT_PADDALGO * GWEN_Crypt_PaddAlgo_new(GWEN_CRYPT_PADDALGOID id)
Definition: paddalgo.c:90
#define NULL
Definition: binreloc.c:300
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_Close(GWEN_CRYPT_TOKEN *ct, int abandon, uint32_t gid)
Definition: ct.c:265
int main(int argc, char **argv)
Definition: cttest2.c:941
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
struct GWEN_CRYPT_PADDALGO GWEN_CRYPT_PADDALGO
Definition: paddalgo.h:21
GWEN_PLUGIN * GWEN_PluginManager_GetPlugin(GWEN_PLUGIN_MANAGER *pm, const char *s)
Definition: plugin.c:529
#define GWEN_LOGDOMAIN
Definition: logger.h:35
GWEN_CRYPT_TOKEN * GWEN_Crypt_Token_Plugin_CreateToken(GWEN_PLUGIN *pl, const char *name)
Definition: ctplugin.c:142
#define GWEN_ARGS_FLAGS_HELP
Definition: src/base/args.h:52
GWEN_BUFFER * GWEN_Buffer_new(char *buffer, uint32_t size, uint32_t used, int take)
Definition: buffer.c:42
GWEN_PLUGIN_MANAGER * GWEN_PluginManager_FindPluginManager(const char *s)
Definition: plugin.c:548
#define GWEN_ARGS_RESULT_HELP
Definition: src/base/args.h:58
#define GWEN_ARGS_RESULT_ERROR
Definition: src/base/args.h:57
void GWEN_StringList_free(GWEN_STRINGLIST *sl)
Definition: stringlist.c:58
#define GWEN_ARGS_MODE_STOP_AT_FREEPARAM
Definition: src/base/args.h:55
int GWEN_Args_Usage(const GWEN_ARGS *args, GWEN_BUFFER *ubuf, GWEN_ARGS_OUTTYPE ot)
struct GWEN_STRINGLISTSTRUCT GWEN_STRINGLIST
Definition: stringlist.h:54
#define GWEN_ARGS_MODE_ALLOW_FREEPARAM
Definition: src/base/args.h:54
const char * GWEN_DB_GetCharValue(GWEN_DB_NODE *n, const char *path, int idx, const char *defVal)
Definition: db.c:969
GWEN_STRINGLIST * GWEN_PathManager_GetPaths(const char *destLib, const char *pathName)
Definition: pathmanager.c:494
GWEN_DB_NODE * GWEN_DB_GetGroup(GWEN_DB_NODE *n, uint32_t flags, const char *path)
Definition: db.c:1379
int cryptWithOld(GWEN_DB_NODE *dbArgs, int argc, char **argv)
Definition: cttest2.c:408
void GWEN_Buffer_free(GWEN_BUFFER *bf)
Definition: buffer.c:89
struct GWEN_BUFFER GWEN_BUFFER
A dynamically resizeable text buffer.
Definition: buffer.h:38
int GWEN_Fini(void)
Definition: gwenhywfar.c:298
struct GWEN_CRYPT_TOKEN GWEN_CRYPT_TOKEN
Definition: ct.h:19
#define GWEN_ARGS_FLAGS_LAST
Definition: src/base/args.h:51
int GWEN_Crypt_Token_Open(GWEN_CRYPT_TOKEN *ct, int admin, uint32_t gid)
Definition: ct.c:222
int GWEN_Logger_Open(const char *logDomain, const char *ident, const char *file, GWEN_LOGGER_LOGTYPE logtype, GWEN_LOGGER_FACILITY facility)
Definition: logger.c:225
unsigned int GWEN_StringList_Count(const GWEN_STRINGLIST *sl)
Definition: stringlist.c:423
#define DBG_ERROR(dbg_logger, format, args...)
Definition: debug.h:97
const char * GWEN_StringList_FirstString(const GWEN_STRINGLIST *l)
Definition: stringlist.c:572
int GWEN_Args_Check(int argc, char **argv, int startAt, uint32_t mode, const GWEN_ARGS *args, GWEN_DB_NODE *db)
Definition: src/base/args.c:45
#define GWEN_PM_LOCALEDIR
Definition: gwenhywfar.h:49
#define DBG_INFO(dbg_logger, format, args...)
Definition: debug.h:178
#define GWEN_PM_LIBNAME
Definition: gwenhywfar.h:42
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
struct GWEN_GUI GWEN_GUI
Definition: gui.h:176
int GWEN_DB_GetIntValue(GWEN_DB_NODE *n, const char *path, int idx, int defVal)
Definition: db.c:1161
GWEN_DB_NODE * GWEN_DB_Group_new(const char *name)
Definition: db.c:171
void GWEN_Gui_SetGui(GWEN_GUI *gui)
Definition: gui.c:156
int GWEN_Init(void)
Definition: gwenhywfar.c:91
GWEN_GUI * GWEN_Gui_CGui_new(void)
Definition: cgui.c:74
int cryptWithNew(GWEN_DB_NODE *dbArgs, int argc, char **argv)
Definition: cttest2.c:583
#define GWEN_ARGS_FLAGS_HAS_ARGUMENT
Definition: src/base/args.h:50
int GWEN_Buffer_AppendString(GWEN_BUFFER *bf, const char *buffer)
Definition: buffer.c:989
#define GWEN_DB_FLAGS_DEFAULT
Definition: db.h:168
void GWEN_Crypt_Token_AddModes(GWEN_CRYPT_TOKEN *ct, uint32_t f)
Definition: ct.c:202