17 #include <gwenhywfar/debug.h> 18 #include <gwenhywfar/pathmanager.h> 19 #include <gwenhywfar/cgui.h> 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/ct.h> 29 #include <gwenhywfar/ctplugin.h> 30 #include <gwenhywfar/text.h> 31 #include <gwenhywfar/mdigest.h> 47 #define GCT_LOGDOMAIN "GCT" 72 "Context id (0 for any)",
73 "Context id (0 for any)" 83 "Specify the crypt token type",
84 "Specify the crypt token type" 94 "Specify the crypt token name",
95 "Specify the crypt token name" 105 "Show this help screen",
106 "Show this help screen" 116 fprintf(stderr,
"ERROR: Could not parse arguments\n");
124 fprintf(stderr,
"ERROR: Could not create help string\n");
142 DBG_ERROR(0,
"Plugin manager not found");
155 DBG_ERROR(0,
"Could not create crypt token");
169 uint8_t clearText[20]= {
170 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
171 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10,
172 0x11, 0x12, 0x13, 0x14
174 uint8_t signature[256];
179 signLen=
sizeof(signature);
190 DBG_ERROR(0,
"Could not sign data (%d)", rv);
194 fprintf(stderr,
"Signature is:\n");
206 DBG_ERROR(0,
"Could not verify data (%d)", rv);
209 fprintf(stderr,
"Signature is ok.\n");
244 "Context id (0 for any)",
245 "Context id (0 for any)" 255 "Specify the crypt token type",
256 "Specify the crypt token type" 266 "Specify the crypt token name",
267 "Specify the crypt token name" 277 "Show this help screen",
278 "Show this help screen" 288 fprintf(stderr,
"ERROR: Could not parse arguments\n");
296 fprintf(stderr,
"ERROR: Could not create help string\n");
314 DBG_ERROR(0,
"Plugin manager not found");
327 DBG_ERROR(0,
"Could not create crypt token");
341 uint8_t clearText[16]= {
342 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
343 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10
345 uint8_t encrypted[128];
347 uint8_t decrypted[128];
352 elen=
sizeof(encrypted);
362 DBG_ERROR(0,
"Could not encipher data (%d)", rv);
366 fprintf(stderr,
"Encrypted data is:\n");
369 dlen=
sizeof(decrypted);
379 DBG_ERROR(0,
"Could not decipher data (%d)", rv);
383 if (memcmp(clearText, decrypted, dlen)) {
384 DBG_ERROR(0,
"Deciphered data does not equal clear text(%d)", rv);
387 fprintf(stderr,
"Deciphered data is ok.\n");
408 int main(
int argc,
char **argv)
425 "Specify the configuration file",
426 "Specify the configuration file" 437 "force pin entry even if the error counter is not zero" 447 "Show this help screen",
448 "Show this help screen" 454 fprintf(stderr,
"Could not initialize Gwenhywfar.\n");
468 setlocale(LC_ALL,
"");
469 if (bindtextdomain(PACKAGE, localedir)==0)
470 fprintf(stderr,
"Error binding locale\n");
479 #ifdef DEBUG_GCT_TOOL 489 #ifdef GCT_IS_EXPERIMENTAL 490 fprintf(stderr,
"\n");
491 fprintf(stderr,
"\n");
492 fprintf(stderr,
"=================== WARNING ===================\n");
493 fprintf(stderr,
"This tool is still EXPERIMENTAL !!!\n");
494 fprintf(stderr,
"Please DON'T USE it with your daily key files !\n");
495 fprintf(stderr,
"===============================================\n");
496 fprintf(stderr,
"\n");
497 fprintf(stderr,
"\n");
507 fprintf(stderr,
"ERROR: Could not parse arguments main\n");
518 I18N(
" [GLOBAL OPTIONS] COMMAND " 519 "[LOCAL OPTIONS]\n"));
521 I18N(
"\nGlobal Options:\n"));
523 fprintf(stderr,
"ERROR: Could not create help string\n");
527 I18N(
"\nCommands:\n\n"));
530 " This command creates a crypt token" 534 " Display user data stored on the " 548 fprintf(stderr,
"ERROR: Command needed.\n");
552 if (strcasecmp(cmd,
"sign")==0) {
555 else if (strcasecmp(cmd,
"crypt")==0) {
559 fprintf(stderr,
"ERROR: Unknown command \"%s\".\n", cmd);
566 "WARNING: Could not deinitialize Gwenhywfar.\n");
#define GWEN_CRYPT_TOKEN_MODE_FORCE_PIN_ENTRY
struct GWEN_PLUGIN_MANAGER GWEN_PLUGIN_MANAGER
char * GWEN_Buffer_GetStart(const GWEN_BUFFER *bf)
struct GWEN_DB_NODE GWEN_DB_NODE
struct GWEN_PLUGIN GWEN_PLUGIN
void GWEN_Logger_SetLevel(const char *logDomain, GWEN_LOGGER_LEVEL l)
void GWEN_Text_DumpString(const char *s, unsigned int l, unsigned int insert)
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)
GWEN_CRYPT_PADDALGO * GWEN_Crypt_PaddAlgo_new(GWEN_CRYPT_PADDALGOID id)
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)
int GWEN_Crypt_Token_Close(GWEN_CRYPT_TOKEN *ct, int abandon, uint32_t gid)
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)
struct GWEN_CRYPT_PADDALGO GWEN_CRYPT_PADDALGO
GWEN_PLUGIN * GWEN_PluginManager_GetPlugin(GWEN_PLUGIN_MANAGER *pm, const char *s)
GWEN_CRYPT_TOKEN * GWEN_Crypt_Token_Plugin_CreateToken(GWEN_PLUGIN *pl, const char *name)
#define GWEN_ARGS_FLAGS_HELP
GWEN_BUFFER * GWEN_Buffer_new(char *buffer, uint32_t size, uint32_t used, int take)
GWEN_PLUGIN_MANAGER * GWEN_PluginManager_FindPluginManager(const char *s)
#define GWEN_ARGS_RESULT_HELP
int main(int argc, char **argv)
#define GWEN_ARGS_RESULT_ERROR
void GWEN_StringList_free(GWEN_STRINGLIST *sl)
int cryptWithNew(GWEN_DB_NODE *dbArgs, int argc, char **argv)
int signWithNew(GWEN_DB_NODE *dbArgs, int argc, char **argv)
#define GWEN_ARGS_MODE_STOP_AT_FREEPARAM
int GWEN_Args_Usage(const GWEN_ARGS *args, GWEN_BUFFER *ubuf, GWEN_ARGS_OUTTYPE ot)
struct GWEN_STRINGLISTSTRUCT GWEN_STRINGLIST
#define GWEN_ARGS_MODE_ALLOW_FREEPARAM
const char * GWEN_DB_GetCharValue(GWEN_DB_NODE *n, const char *path, int idx, const char *defVal)
GWEN_STRINGLIST * GWEN_PathManager_GetPaths(const char *destLib, const char *pathName)
GWEN_DB_NODE * GWEN_DB_GetGroup(GWEN_DB_NODE *n, uint32_t flags, const char *path)
void GWEN_Buffer_free(GWEN_BUFFER *bf)
struct GWEN_BUFFER GWEN_BUFFER
A dynamically resizeable text buffer.
struct GWEN_CRYPT_TOKEN GWEN_CRYPT_TOKEN
#define GWEN_ARGS_FLAGS_LAST
int GWEN_Crypt_Token_Open(GWEN_CRYPT_TOKEN *ct, int admin, uint32_t gid)
int GWEN_Logger_Open(const char *logDomain, const char *ident, const char *file, GWEN_LOGGER_LOGTYPE logtype, GWEN_LOGGER_FACILITY facility)
unsigned int GWEN_StringList_Count(const GWEN_STRINGLIST *sl)
#define DBG_ERROR(dbg_logger, format, args...)
const char * GWEN_StringList_FirstString(const GWEN_STRINGLIST *l)
int GWEN_Args_Check(int argc, char **argv, int startAt, uint32_t mode, const GWEN_ARGS *args, GWEN_DB_NODE *db)
#define GWEN_PM_LOCALEDIR
#define DBG_INFO(dbg_logger, format, args...)
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)
int GWEN_DB_GetIntValue(GWEN_DB_NODE *n, const char *path, int idx, int defVal)
GWEN_DB_NODE * GWEN_DB_Group_new(const char *name)
void GWEN_Gui_SetGui(GWEN_GUI *gui)
GWEN_GUI * GWEN_Gui_CGui_new(void)
#define GWEN_ARGS_FLAGS_HAS_ARGUMENT
int GWEN_Buffer_AppendString(GWEN_BUFFER *bf, const char *buffer)
#define GWEN_DB_FLAGS_DEFAULT
void GWEN_Crypt_Token_AddModes(GWEN_CRYPT_TOKEN *ct, uint32_t f)