21 #include <gwenhywfar/debug.h>
22 #include <gwenhywfar/misc.h>
23 #include <gwenhywfar/padd.h>
24 #include <gwenhywfar/gui.h>
25 #include <gwenhywfar/ctfile_be.h>
26 #include <gwenhywfar/ctplugin_be.h>
27 #include <gwenhywfar/ctf_context_be.h>
28 #include <gwenhywfar/text.h>
29 #include <gwenhywfar/cryptkeysym.h>
30 #include <gwenhywfar/cryptkeyrsa.h>
31 #include <gwenhywfar/smalltresor.h>
37 #include <sys/types.h>
44 # define ftruncate chsize
55 const
char *fileName) {
68 const char *fileName) {
120 if (access(p, F_OK)) {
126 if (access(p, R_OK | W_OK)) {
129 "File exists but I have no writes on it");
136 "File exists, I have all rights but still can't open it");
138 "File exists, I have all rights but "
139 "still can't open it");
143 rv=fread(buffer,
sizeof(buffer), 1, f);
148 "This seems not to be an OpenHBCI keyfile");
155 "This seems not to be an OpenHBCI keyfile "
160 if ((
unsigned char)(buffer[0])==GWEN_CRYPT_TOKEN_OHBCI_TAG_MEDIUM1) {
162 "Old OpenHBCI file detected");
164 "Old OpenHBCI file detected");
167 else if ((
unsigned char)(buffer[0])==GWEN_CRYPT_TOKEN_OHBCI_TAG_MEDIUM2) {
169 "OpenHBCI file (<1.6) detected");
171 "OpenHBCI file (<1.6) detected");
174 else if ((
unsigned char)(buffer[0])==GWEN_CRYPT_TOKEN_OHBCI_TAG_MEDIUM3) {
175 if ((
unsigned char)(buffer[3])==GWEN_CRYPT_TOKEN_OHBCI_TAG_HEADER &&
177 GWEN_CRYPT_TOKEN_OHBCI_NAME,
178 strlen(GWEN_CRYPT_TOKEN_OHBCI_NAME))==0) {
180 "New OpenHBCI file (>=1.6) detected");
182 "New OpenHBCI file (>=1.6) detected");
188 "This seems not to be an OpenHBCI keyfile");
190 "This seems not to be an OpenHBCI keyfile");
201 GWEN_CRYPT_TOKEN_OHBCI *lct;
209 lct->mediumTag=GWEN_CRYPT_TOKEN_OHBCI_TAG_MEDIUM3;
210 lct->vminor=GWEN_CRYPT_TOKEN_OHBCI_VMINOR;
211 lct->cryptoTag=GWEN_CRYPT_TOKEN_OHBCI_TAG_CRYPT_BF;
228 GWEN_CRYPT_TOKEN_OHBCI *lct;
230 lct=(GWEN_CRYPT_TOKEN_OHBCI*) p;
231 memset(lct->password, 0,
sizeof(lct->password));
242 GWEN_CRYPT_TOKEN_OHBCI *lct;
248 if (lct->passWordIsSet==0) {
251 unsigned int pinLength=0;
255 memset(lct->password, 0,
sizeof(lct->password));
266 (
unsigned char*)password,
267 GWEN_CRYPT_TOKEN_OHBCI_PINMINLENGTH,
276 if (strlen(password)<GWEN_CRYPT_TOKEN_OHBCI_PINMINLENGTH) {
278 "Your program returned a shorter PIN than instructed!");
283 if (lct->cryptoTag==GWEN_CRYPT_TOKEN_OHBCI_TAG_CRYPT) {
287 (
unsigned char*)lct->password,
291 "Could not create key data from password (%d)", rv);
295 else if (lct->cryptoTag==GWEN_CRYPT_TOKEN_OHBCI_TAG_CRYPT_OLD) {
299 (
unsigned char*)lct->password,
304 "OpenSSL-style password creation not supported with Libgcrypt!");
312 else if (lct->cryptoTag==GWEN_CRYPT_TOKEN_OHBCI_TAG_CRYPT_BF) {
316 (
unsigned char*)lct->password,
320 "Could not create key data from password (%d)", rv);
324 else if (lct->cryptoTag==GWEN_CRYPT_TOKEN_OHBCI_TAG_CRYPT_TRESOR) {
326 strncpy(lct->password, password,
sizeof(lct->password)-1);
327 lct->password[
sizeof(lct->password)-1]=0;
335 lct->passWordIsSet=1;
347 GWEN_CRYPT_TOKEN_OHBCI *lct;
354 unsigned int pinLength=0;
366 if (lct->cryptoTag==GWEN_CRYPT_TOKEN_OHBCI_TAG_CRYPT) {
368 (
const uint8_t*)lct->password, 24);
370 else if (lct->cryptoTag==GWEN_CRYPT_TOKEN_OHBCI_TAG_CRYPT_OLD) {
372 (
const uint8_t*)lct->password, 16);
374 else if (lct->cryptoTag==GWEN_CRYPT_TOKEN_OHBCI_TAG_CRYPT_BF) {
376 (
const uint8_t*)lct->password, 16);
403 (
unsigned char*)password,
407 memset(password, 0,
sizeof(password));
408 lct->passWordIsSet=0;
423 lct->passWordIsSet=0;
429 (
unsigned char*)password,
433 memset(password, 0,
sizeof(password));
453 (
unsigned char*)password,
457 memset(password, 0,
sizeof(password));
458 lct->passWordIsSet=0;
468 (
unsigned char*)password,
472 memset(password, 0,
sizeof(password));
482 GWEN_CRYPT_TOKEN_OHBCI *lct;
503 GWEN_CRYPT_TOKEN_OHBCI_TRESOR_PWD_ITERATIONS,
504 GWEN_CRYPT_TOKEN_OHBCI_TRESOR_CRYPT_ITERATIONS);
508 if (lct->password[0])
513 (
unsigned char*)lct->password,
514 strlen(lct->password),
517 memset(lct->password, 0,
sizeof(lct->password));
518 lct->passWordIsSet=0;
531 if (lct->password[0])
536 (
unsigned char*)lct->password,
537 strlen(lct->password),
540 memset(lct->password, 0,
sizeof(lct->password));
541 lct->passWordIsSet=0;
546 if (lct->password[0])
551 (
unsigned char*)lct->password,
552 strlen(lct->password),
562 GWEN_CRYPT_TOKEN_OHBCI *lct;
579 rv=read(fd, buffer,
sizeof(buffer));
598 if (c!=GWEN_CRYPT_TOKEN_OHBCI_TAG_MEDIUM1 &&
599 c!=GWEN_CRYPT_TOKEN_OHBCI_TAG_MEDIUM2 &&
600 c!=GWEN_CRYPT_TOKEN_OHBCI_TAG_MEDIUM3) {
628 if (i>GWEN_CRYPT_TOKEN_OHBCI_MAX_PIN_TRY) {
630 "No valid PIN within %d tries, giving up", i);
632 I18N(
"No valid PIN (tried too often), "
638 switch(lct->mediumTag) {
639 case GWEN_CRYPT_TOKEN_OHBCI_TAG_MEDIUM1:
640 lct->cryptoTag=GWEN_CRYPT_TOKEN_OHBCI_TAG_CRYPT_OLD;
643 case GWEN_CRYPT_TOKEN_OHBCI_TAG_MEDIUM2:
644 lct->cryptoTag=GWEN_CRYPT_TOKEN_OHBCI_TAG_CRYPT;
647 case GWEN_CRYPT_TOKEN_OHBCI_TAG_MEDIUM3:
666 I18N(
"Bad PIN, will try again"));
689 const char *keyName) {
695 const char defaultExpo[3]={0x01, 0x00, 0x01};
723 sizeof(defaultExpo));
745 p=(
char*)malloc(l+1);
752 case GWEN_CRYPT_TOKEN_OHBCI_TAG_KEY_ISPUBLIC:
756 case GWEN_CRYPT_TOKEN_OHBCI_TAG_KEY_ISCRYPT:
760 case GWEN_CRYPT_TOKEN_OHBCI_TAG_KEY_OWNER:
767 case GWEN_CRYPT_TOKEN_OHBCI_TAG_KEY_VERSION:
775 case GWEN_CRYPT_TOKEN_OHBCI_TAG_KEY_NUMBER:
783 case GWEN_CRYPT_TOKEN_OHBCI_TAG_KEY_MODULUS:
791 case GWEN_CRYPT_TOKEN_OHBCI_TAG_KEY_EXP_OLD:
793 "Ignoring old exponent (%d), keeping default", l);
796 case GWEN_CRYPT_TOKEN_OHBCI_TAG_KEY_EXP:
804 case GWEN_CRYPT_TOKEN_OHBCI_TAG_KEY_N:
812 case GWEN_CRYPT_TOKEN_OHBCI_TAG_KEY_P:
820 case GWEN_CRYPT_TOKEN_OHBCI_TAG_KEY_Q:
828 case GWEN_CRYPT_TOKEN_OHBCI_TAG_KEY_D:
836 case GWEN_CRYPT_TOKEN_OHBCI_TAG_KEY_LEN:
865 GWEN_CRYPT_TOKEN_OHBCI *lct;
871 const char *peerId=0;
872 uint32_t localSignSeq=0;
873 uint32_t remoteSignSeq=0;
883 "File doesn't contain a TLV: Either bad pin or bad file");
890 "File doesn't start with version info or header.");
909 "File doesn't contain a TLV: Either bad pin or bad file");
917 p=(
char*)malloc(l+1);
924 case GWEN_CRYPT_TOKEN_OHBCI_TAG_VERSION_MAJOR:
928 if (i!=GWEN_CRYPT_TOKEN_OHBCI_VMAJOR) {
932 "Basically this file type is supported.\n"
933 "However, the major versions do not match,\n"
934 "so this particular version is not supported");
942 case GWEN_CRYPT_TOKEN_OHBCI_TAG_VERSION_MINOR:
946 if (i>GWEN_CRYPT_TOKEN_OHBCI_VMINOR) {
948 "Keyfile version is higher than mine (%d).\n",
951 "This key file file has been created with a "
952 "newer library version.\n");
958 else if (i<GWEN_CRYPT_TOKEN_OHBCI_VMINOR) {
964 case GWEN_CRYPT_TOKEN_OHBCI_TAG_SEQ:
966 localSignSeq=atoi(p);
971 case GWEN_CRYPT_TOKEN_OHBCI_TAG_USER_ID:
975 case GWEN_CRYPT_TOKEN_OHBCI_TAG_INST_COUNTRY:
979 case GWEN_CRYPT_TOKEN_OHBCI_TAG_INST_CODE:
983 case GWEN_CRYPT_TOKEN_OHBCI_TAG_INST_SYSTEMID:
987 case GWEN_CRYPT_TOKEN_OHBCI_TAG_SERVER_ADDR:
992 case GWEN_CRYPT_TOKEN_OHBCI_TAG_SERVER_PORT:
997 case GWEN_CRYPT_TOKEN_OHBCI_TAG_REMOTE_SEQ:
999 remoteSignSeq=atoi(p);
1002 case GWEN_CRYPT_TOKEN_OHBCI_TAG_USER_PUBSIGNKEY:
1003 case GWEN_CRYPT_TOKEN_OHBCI_TAG_USER_PRIVSIGNKEY:
1007 case GWEN_CRYPT_TOKEN_OHBCI_TAG_USER_PUBCRYPTKEY:
1008 case GWEN_CRYPT_TOKEN_OHBCI_TAG_USER_PRIVCRYPTKEY:
1012 case GWEN_CRYPT_TOKEN_OHBCI_TAG_INST_PUBSIGNKEY:
1016 case GWEN_CRYPT_TOKEN_OHBCI_TAG_INST_PUBCRYPTKEY:
1021 case GWEN_CRYPT_TOKEN_OHBCI_TAG_TEMP_PUBSIGNKEY:
1022 case GWEN_CRYPT_TOKEN_OHBCI_TAG_TEMP_PRIVSIGNKEY:
1026 case GWEN_CRYPT_TOKEN_OHBCI_TAG_TEMP_PUBCRYPTKEY:
1027 case GWEN_CRYPT_TOKEN_OHBCI_TAG_TEMP_PRIVCRYPTKEY:
1029 "Ignoring temporary crypt keys");
1032 case GWEN_CRYPT_TOKEN_OHBCI_TAG_USER_PRIVAUTHKEY:
1036 case GWEN_CRYPT_TOKEN_OHBCI_TAG_INST_PUBAUTHKEY:
1040 case GWEN_CRYPT_TOKEN_OHBCI_TAG_HEADER:
1133 GWEN_Crypt_CryptAlgoId_Rsa, 96);
1213 GWEN_Crypt_CryptAlgoId_Rsa, 96);
1297 GWEN_Crypt_CryptAlgoId_Rsa, 96);
1316 DBG_INFO(0,
"Got Peer Id [%s]", peerId);
1378 GWEN_Crypt_CryptAlgoId_Rsa, 96);
1459 GWEN_Crypt_CryptAlgoId_Rsa, 96);
1540 GWEN_Crypt_CryptAlgoId_Rsa, 96);
1554 "tempLocalSignKey");
1627 GWEN_Crypt_CryptAlgoId_Rsa, 96);
1666 GWEN_CRYPT_TOKEN_OHBCI *lct;
1678 "File doesn't contain a TLV: Either bad pin or bad file");
1699 "File doesn't contain a TLV: Either bad pin or bad file");
1706 p=(
char*)malloc(l+1);
1713 case GWEN_CRYPT_TOKEN_OHBCI_TAG_HEADER:
1714 if (strcasecmp(p, GWEN_CRYPT_TOKEN_OHBCI_NAME)!=0) {
1722 case GWEN_CRYPT_TOKEN_OHBCI_TAG_VERSION_MAJOR:
1724 if (i!=GWEN_CRYPT_TOKEN_OHBCI_VMAJOR) {
1728 "Basically this file type is supported.\n"
1729 "However, the major versions do not match,\n"
1730 "so this particular version is not supported");
1737 case GWEN_CRYPT_TOKEN_OHBCI_TAG_VERSION_MINOR:
1739 if (i>GWEN_CRYPT_TOKEN_OHBCI_VMINOR) {
1741 "Keyfile version is higher than mine (%d).\n",
1744 "This key file file has been created with a "
1745 "newer library version.\n");
1750 else if (i<GWEN_CRYPT_TOKEN_OHBCI_VMINOR) {
1752 "Will update this file upon unmount (%d)", i);
1757 case GWEN_CRYPT_TOKEN_OHBCI_TAG_CRYPT_OLD:
1758 case GWEN_CRYPT_TOKEN_OHBCI_TAG_CRYPT:
1759 case GWEN_CRYPT_TOKEN_OHBCI_TAG_CRYPT_BF:
1779 case GWEN_CRYPT_TOKEN_OHBCI_TAG_CRYPT_TRESOR:
1816 unsigned int tagType,
1873 if (tagType==GWEN_CRYPT_TOKEN_OHBCI_TAG_INST_PUBCRYPTKEY) {
1911 pp[1]=(bs>>8) & 0xff;
1919 GWEN_CRYPT_TOKEN_OHBCI *lct;
1934 "Crypt token does not contain a file context");
1940 GWEN_CRYPT_TOKEN_OHBCI_NAME,
1943 if (lct->mediumTag!=GWEN_CRYPT_TOKEN_OHBCI_TAG_MEDIUM3) {
1945 snprintf(numbuf,
sizeof(numbuf),
"%d", GWEN_CRYPT_TOKEN_OHBCI_VMAJOR);
1949 snprintf(numbuf,
sizeof(numbuf),
"%d", GWEN_CRYPT_TOKEN_OHBCI_VMINOR);
1961 GWEN_CRYPT_TOKEN_OHBCI_TAG_USER_PUBSIGNKEY,
1968 GWEN_CRYPT_TOKEN_OHBCI_TAG_USER_PRIVSIGNKEY,
1976 GWEN_CRYPT_TOKEN_OHBCI_TAG_USER_PUBCRYPTKEY,
1983 GWEN_CRYPT_TOKEN_OHBCI_TAG_USER_PRIVCRYPTKEY,
1996 GWEN_CRYPT_TOKEN_OHBCI_TAG_INST_PUBSIGNKEY,
2004 GWEN_CRYPT_TOKEN_OHBCI_TAG_INST_PUBCRYPTKEY,
2010 snprintf(numbuf,
sizeof(numbuf),
"%d", 280);
2029 snprintf(numbuf,
sizeof(numbuf),
"%d",
2046 GWEN_CRYPT_TOKEN_OHBCI_TAG_USER_PRIVAUTHKEY,
2054 GWEN_CRYPT_TOKEN_OHBCI_TAG_INST_PUBAUTHKEY,
2064 GWEN_CRYPT_TOKEN_OHBCI_TAG_TEMP_PUBSIGNKEY,
2071 GWEN_CRYPT_TOKEN_OHBCI_TAG_TEMP_PRIVSIGNKEY,
2084 GWEN_CRYPT_TOKEN_OHBCI *lct;
2102 ((lct->mediumTag!=GWEN_CRYPT_TOKEN_OHBCI_TAG_MEDIUM3) ||
2103 (lct->cryptoTag!=GWEN_CRYPT_TOKEN_OHBCI_TAG_CRYPT_TRESOR))) {
2105 "Updating ancient key file to new one");
2107 I18N(
"Updating ancient key file to new one"));
2108 lct->passWordIsSet=0;
2109 lct->mediumTag=GWEN_CRYPT_TOKEN_OHBCI_TAG_MEDIUM3;
2110 lct->cryptoTag=GWEN_CRYPT_TOKEN_OHBCI_TAG_CRYPT_TRESOR;
2121 #ifdef DEBUG_OHBCI_MODULE
2125 f=fopen(
"encoded.medium",
"w+b");
2150 if (lct->cryptoTag==GWEN_CRYPT_TOKEN_OHBCI_TAG_CRYPT_TRESOR) {
2159 GWEN_CRYPT_TOKEN_OHBCI_TRESOR_PWD_ITERATIONS,
2160 GWEN_CRYPT_TOKEN_OHBCI_TRESOR_CRYPT_ITERATIONS);
2173 if (lct->cryptoTag==GWEN_CRYPT_TOKEN_OHBCI_TAG_CRYPT) {
2175 (
const uint8_t*)lct->password, 24);
2177 else if (lct->cryptoTag==GWEN_CRYPT_TOKEN_OHBCI_TAG_CRYPT_OLD) {
2179 (
const uint8_t*)lct->password, 16);
2181 else if (lct->cryptoTag==GWEN_CRYPT_TOKEN_OHBCI_TAG_CRYPT_BF) {
2183 (
const uint8_t*)lct->password, 16);
2230 p[0]=(
unsigned char)(lct->cryptoTag);
2231 p[1]=(
unsigned char)(bs & 0xff);
2232 p[2]=(
unsigned char)((bs>>8) & 0xff);
2235 if (lct->mediumTag==GWEN_CRYPT_TOKEN_OHBCI_TAG_MEDIUM3) {
2245 GWEN_CRYPT_TOKEN_OHBCI_NAME, -1, dbuf);
2246 snprintf(numbuf,
sizeof(numbuf),
"%d", GWEN_CRYPT_TOKEN_OHBCI_VMAJOR);
2250 snprintf(numbuf,
sizeof(numbuf),
"%d", GWEN_CRYPT_TOKEN_OHBCI_VMINOR);
2259 p[0]=(
unsigned char)(lct->mediumTag);
2260 p[1]=(
unsigned char)(bs & 0xff);
2261 p[2]=(
unsigned char)((bs>>8) & 0xff);
2268 if (ftruncate(fd, 0)==-1) {
2270 "ftruncate(%s): %s",
2282 rv=write(fd, p, bs);
2314 GWEN_CRYPT_TOKEN_OHBCI *lct;
2321 lct->passWordIsSet=0;
2322 memset(lct->password, 0,
sizeof(lct->password));
2331 GWEN_CRYPT_TOKEN_OHBCI *lct;
2355 GWEN_Crypt_CryptAlgoId_Rsa,
2371 GWEN_Crypt_CryptAlgoId_Rsa,
2385 GWEN_Crypt_CryptAlgoId_Rsa,
2400 GWEN_Crypt_CryptAlgoId_Rsa,
2414 GWEN_Crypt_CryptAlgoId_Rsa,
2428 GWEN_Crypt_CryptAlgoId_Rsa,
2443 assert(lct->createFn);
2444 rv=lct->createFn(ct, gid);
2457 GWEN_CRYPT_TOKEN_OHBCI *lct;
2464 assert(lct->openFn);
2465 rv=lct->openFn(ct, manage, gid);
2478 GWEN_CRYPT_TOKEN_OHBCI *lct;
2485 assert(lct->closeFn);
2486 rv=lct->closeFn(ct, abandon, gid);
2492 memset(lct->password, 0,
sizeof(lct->password));
2493 lct->passWordIsSet=0;
void GWEN_Crypt_Token_Context_SetVerifyKeyId(GWEN_CRYPT_TOKEN_CONTEXT *p_struct, uint32_t p_src)
GWEN_CRYPT_KEY * GWEN_CTF_Context_GetRemoteSignKey(const GWEN_CRYPT_TOKEN_CONTEXT *ctx)
GWEN_CRYPT_TOKEN_KEYINFO * GWEN_CTF_Context_GetLocalSignKeyInfo(const GWEN_CRYPT_TOKEN_CONTEXT *ctx)
const char * GWEN_Crypt_Token_Context_GetServiceId(const GWEN_CRYPT_TOKEN_CONTEXT *p_struct)
uint32_t GWEN_Buffer_GetBytesLeft(GWEN_BUFFER *bf)
GWEN_TAG16 * GWEN_Tag16_fromBuffer(GWEN_BUFFER *mbuf, int isBerTlv)
void GWEN_Crypt_TokenFile_AddContext(GWEN_CRYPT_TOKEN *ct, GWEN_CRYPT_TOKEN_CONTEXT *ctx)
void GWEN_Crypt_Token_Context_SetServiceId(GWEN_CRYPT_TOKEN_CONTEXT *p_struct, const char *p_src)
void GWEN_CTF_Context_SetLocalSignKeyInfo(GWEN_CRYPT_TOKEN_CONTEXT *ctx, GWEN_CRYPT_TOKEN_KEYINFO *ki)
int GWEN_Gui_ProgressLog(uint32_t id, GWEN_LOGGER_LEVEL level, const char *text)
struct GWEN_PLUGIN_MANAGER GWEN_PLUGIN_MANAGER
char * GWEN_Buffer_GetStart(const GWEN_BUFFER *bf)
GWEN_CRYPT_TOKEN * GWEN_Crypt_TokenFile_new(const char *typeName, const char *tokenName)
#define GWEN_DB_FLAGS_OVERWRITE_VARS
GWEN_CRYPT_KEY * GWEN_CTF_Context_GetLocalSignKey(const GWEN_CRYPT_TOKEN_CONTEXT *ctx)
struct GWEN_DB_NODE GWEN_DB_NODE
struct GWEN_PLUGIN GWEN_PLUGIN
GWEN_CRYPT_TOKEN_PLUGIN_CHECKTOKEN_FN GWEN_Crypt_Token_Plugin_SetCheckTokenFn(GWEN_PLUGIN *pl, GWEN_CRYPT_TOKEN_PLUGIN_CHECKTOKEN_FN fn)
void GWEN_DB_Group_free(GWEN_DB_NODE *n)
void GWEN_Crypt_Token_KeyInfo_free(GWEN_CRYPT_TOKEN_KEYINFO *p_struct)
#define GWEN_ERROR_INVALID
void GWEN_CTF_Context_SetLocalCryptKey(GWEN_CRYPT_TOKEN_CONTEXT *ctx, GWEN_CRYPT_KEY *k)
GWEN_CRYPT_KEY * GWEN_CTF_Context_GetLocalAuthKey(const GWEN_CRYPT_TOKEN_CONTEXT *ctx)
uint32_t GWEN_Crypt_Token_GetModes(const GWEN_CRYPT_TOKEN *ct)
uint32_t GWEN_Buffer_GetUsedBytes(const GWEN_BUFFER *bf)
int GWEN_Crypt_Key_GetKeySize(const GWEN_CRYPT_KEY *k)
void GWEN_CTF_Context_SetLocalAuthKey(GWEN_CRYPT_TOKEN_CONTEXT *ctx, GWEN_CRYPT_KEY *k)
#define GWEN_GUI_INPUT_FLAGS_CONFIRM
void GWEN_CTF_Context_SetRemoteSignKey(GWEN_CRYPT_TOKEN_CONTEXT *ctx, GWEN_CRYPT_KEY *k)
int GWEN_Crypt_TokenOHBCI__EncodeKey(const GWEN_CRYPT_KEY *key, GWEN_CRYPT_TOKEN_CONTEXT *fct, unsigned int tagType, int wantPublic, int isCrypt, GWEN_BUFFER *dbuf)
const char * GWEN_Crypt_Token_Context_GetUserId(const GWEN_CRYPT_TOKEN_CONTEXT *p_struct)
#define DBG_NOTICE(dbg_logger, format, args...)
#define GWEN_CRYPT_TOKEN_KEYFLAGS_HASMODULUS
void GWEN_Crypt_Key_free(GWEN_CRYPT_KEY *k)
void GWEN_CTF_Context_SetLocalSignKey(GWEN_CRYPT_TOKEN_CONTEXT *ctx, GWEN_CRYPT_KEY *k)
#define GWEN_FREE_OBJECT(varname)
const char * GWEN_Crypt_Token_Context_GetAddress(const GWEN_CRYPT_TOKEN_CONTEXT *p_struct)
void GWEN_Crypt_Token_Context_SetEncipherKeyId(GWEN_CRYPT_TOKEN_CONTEXT *p_struct, uint32_t p_src)
void GWEN_Crypt_Token_Context_SetSystemId(GWEN_CRYPT_TOKEN_CONTEXT *p_struct, const char *p_src)
GWEN_CRYPT_TOKEN_CONTEXT * GWEN_CTF_Context_new()
void GWEN_Crypt_Token_KeyInfo_SetModulus(GWEN_CRYPT_TOKEN_KEYINFO *st, const uint8_t *p, uint32_t len)
int GWENHYWFAR_CB GWEN_Crypt_TokenOHBCI_Close(GWEN_CRYPT_TOKEN *ct, int abandon, uint32_t gid)
int GWEN_Crypt_Token_Context_GetPort(const GWEN_CRYPT_TOKEN_CONTEXT *p_struct)
GWEN_CRYPT_KEY * GWEN_CTF_Context_GetLocalCryptKey(const GWEN_CRYPT_TOKEN_CONTEXT *ctx)
int GWENHYWFAR_CB GWEN_Crypt_TokenOHBCI_Create(GWEN_CRYPT_TOKEN *ct, uint32_t gid)
#define GWEN_ERROR_BAD_PIN
void GWEN_CTF_Context_SetRemoteCryptKeyInfo(GWEN_CRYPT_TOKEN_CONTEXT *ctx, GWEN_CRYPT_TOKEN_KEYINFO *ki)
int GWEN_SmallTresor_Decrypt(const uint8_t *p, uint32_t len, const char *password, GWEN_BUFFER *dst, int passwordIterations, int cryptIterations)
int GWEN_Crypt_TokenOHBCI__Decode(GWEN_CRYPT_TOKEN *ct, GWEN_BUFFER *dbuf)
void GWEN_Crypt_Token_Context_SetAuthSignKeyId(GWEN_CRYPT_TOKEN_CONTEXT *p_struct, uint32_t p_src)
int GWEN_Buffer_AdjustUsedBytes(GWEN_BUFFER *bf)
#define DBG_WARN(dbg_logger, format, args...)
GWEN_CRYPT_KEY * GWEN_Crypt_KeyDes3K_fromData(GWEN_CRYPT_CRYPTMODE mode, int keySize, const uint8_t *kd, uint32_t kl)
const char * GWEN_Crypt_Token_Context_GetSystemId(const GWEN_CRYPT_TOKEN_CONTEXT *p_struct)
int GWENHYWFAR_CB GWEN_Crypt_TokenOHBCI_ChangePin(GWEN_CRYPT_TOKEN *ct, int admin, uint32_t gid)
#define DBG_ERROR_ERR(dbg_logger, dbg_err)
int GWEN_Crypt_Key_Encipher(GWEN_CRYPT_KEY *k, const uint8_t *pInData, uint32_t inLen, uint8_t *pOutData, uint32_t *pOutLen)
GWEN_CRYPT_CRYPTALGOID GWEN_Crypt_Key_GetCryptAlgoId(const GWEN_CRYPT_KEY *k)
uint32_t GWEN_Buffer_GetPos(const GWEN_BUFFER *bf)
struct GWEN_TAG16 GWEN_TAG16
int GWEN_Crypt_Key_GetKeyNumber(const GWEN_CRYPT_KEY *k)
void GWEN_Crypt_Token_Context_free(GWEN_CRYPT_TOKEN_CONTEXT *p_struct)
uint32_t GWEN_Crypt_Token_KeyInfo_GetSignCounter(const GWEN_CRYPT_TOKEN_KEYINFO *p_struct)
GWEN_CRYPT_TOKEN_CONTEXT * GWEN_Crypt_TokenFile_GetContext(GWEN_CRYPT_TOKEN *ct, int idx)
void GWEN_CTF_Context_SetRemoteCryptKey(GWEN_CRYPT_TOKEN_CONTEXT *ctx, GWEN_CRYPT_KEY *k)
void GWEN_CTF_Context_SetRemoteAuthKeyInfo(GWEN_CRYPT_TOKEN_CONTEXT *ctx, GWEN_CRYPT_TOKEN_KEYINFO *ki)
int GWEN_Buffer_ReserveBytes(GWEN_BUFFER *bf, uint32_t res)
#define GWEN_CRYPT_TOKEN_KEYFLAGS_CANSIGN
int GWEN_Crypt_TokenOHBCI__DecryptFile16(GWEN_CRYPT_TOKEN *ct, GWEN_BUFFER *dbuf, int tryNum, uint32_t gid)
GWEN_BUFFER * GWEN_Buffer_new(char *buffer, uint32_t size, uint32_t used, int take)
#define GWEN_CRYPT_TOKEN_KEYFLAGS_HASSIGNCOUNTER
GWEN_CRYPT_KEY * GWEN_CTF_Context_GetRemoteCryptKey(const GWEN_CRYPT_TOKEN_CONTEXT *ctx)
void GWEN_Tag16_DirectlyToBuffer(unsigned int tagType, const char *p, int size, GWEN_BUFFER *buf)
GWEN_CRYPT_TOKEN_CHANGEPIN_FN GWEN_Crypt_Token_SetChangePinFn(GWEN_CRYPT_TOKEN *ct, GWEN_CRYPT_TOKEN_CHANGEPIN_FN f)
int GWENHYWFAR_CB GWEN_Crypt_TokenOHBCI_Open(GWEN_CRYPT_TOKEN *ct, int manage, uint32_t gid)
int GWEN_Buffer_IncrementPos(GWEN_BUFFER *bf, uint32_t i)
void GWEN_Crypt_KeyRsa_AddFlags(GWEN_CRYPT_KEY *k, uint32_t fl)
GWEN_CRYPT_TOKEN *GWENHYWFAR_CB GWEN_Crypt_TokenOHBCI_Plugin_CreateToken(GWEN_PLUGIN *pl, const char *name)
GWEN_CRYPT_TOKEN * GWEN_Crypt_TokenOHBCI_new(GWEN_PLUGIN_MANAGER *pm, const char *name)
GWEN_CRYPT_TOKEN_KEYINFO * GWEN_CTF_Context_GetTempLocalSignKeyInfo(const GWEN_CRYPT_TOKEN_CONTEXT *ctx)
void GWEN_Crypt_Token_Context_SetSignKeyId(GWEN_CRYPT_TOKEN_CONTEXT *p_struct, uint32_t p_src)
void GWEN_Crypt_TokenOHBCI__DecodeKey(GWEN_CRYPT_TOKEN *ct, GWEN_TAG16 *keyTlv, GWEN_DB_NODE *dbKeys, const char *keyName)
const void * GWEN_Tag16_GetTagData(const GWEN_TAG16 *tlv)
int GWEN_DB_SetBinValue(GWEN_DB_NODE *n, uint32_t flags, const char *path, const void *val, unsigned int valSize)
#define GWEN_CRYPT_TOKEN_KEYFLAGS_CANDECIPHER
#define GWEN_NEW_OBJECT(typ, varname)
GWEN_CRYPT_KEY * GWEN_Crypt_KeyRsa_fromDb(GWEN_DB_NODE *db)
void GWEN_Buffer_SubMode(GWEN_BUFFER *bf, uint32_t mode)
#define GWEN_ERROR_ABORTED
GWEN_PLUGIN * GWEN_Crypt_Token_Plugin_new(GWEN_PLUGIN_MANAGER *mgr, GWEN_CRYPT_TOKEN_DEVICE devType, const char *typeName, const char *fileName)
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)
void GWEN_Crypt_Token_KeyInfo_SetKeyVersion(GWEN_CRYPT_TOKEN_KEYINFO *p_struct, uint32_t p_src)
const void * GWEN_DB_GetBinValue(GWEN_DB_NODE *n, const char *path, int idx, const void *defVal, unsigned int defValSize, unsigned int *returnValueSize)
int GWEN_Padd_PaddWithAnsiX9_23(GWEN_BUFFER *src)
#define GWEN_ERROR_GENERIC
void GWEN_CTF_Context_SetRemoteSignKeyInfo(GWEN_CRYPT_TOKEN_CONTEXT *ctx, GWEN_CRYPT_TOKEN_KEYINFO *ki)
int GWEN_Crypt_TokenOHBCI_Encode(GWEN_CRYPT_TOKEN *ct, GWEN_BUFFER *dbuf)
#define GWEN_BUFFER_MODE_DYNAMIC
int GWEN_Crypt_TokenOHBCI__DecryptTresor(GWEN_CRYPT_TOKEN *ct, GWEN_BUFFER *fbuf, int trynum, uint32_t gid)
void GWEN_CTF_Context_SetRemoteAuthKey(GWEN_CRYPT_TOKEN_CONTEXT *ctx, GWEN_CRYPT_KEY *k)
#define GWEN_CRYPT_TOKEN_KEYFLAGS_CANVERIFY
int GWEN_Buffer_AppendByte(GWEN_BUFFER *bf, char c)
const char * GWEN_DB_GetCharValue(GWEN_DB_NODE *n, const char *path, int idx, const char *defVal)
GWEN_CRYPT_TOKEN_FILE_WRITE_FN GWEN_Crypt_TokenFile_SetWriteFn(GWEN_CRYPT_TOKEN *ct, GWEN_CRYPT_TOKEN_FILE_WRITE_FN f)
struct GWEN_CRYPT_KEY GWEN_CRYPT_KEY
void GWENHYWFAR_CB GWEN_Crypt_TokenOHBCI_FreeData(void *bp, void *p)
GWEN_DB_NODE * GWEN_DB_GetGroup(GWEN_DB_NODE *n, uint32_t flags, const char *path)
#define GWEN_ERROR_BAD_NAME
void GWEN_Buffer_free(GWEN_BUFFER *bf)
#define GWEN_CRYPT_TOKEN_KEYFLAGS_HASEXPONENT
struct GWEN_BUFFER GWEN_BUFFER
A dynamically resizeable text buffer.
const char * GWEN_Crypt_Token_Context_GetPeerId(const GWEN_CRYPT_TOKEN_CONTEXT *p_struct)
struct GWEN_CRYPT_TOKEN GWEN_CRYPT_TOKEN
#define GWEN_CRYPT_TOKEN_KEYFLAGS_HASACTIONFLAGS
#define GWEN_CRYPT_TOKEN_KEYFLAGS_HASKEYVERSION
struct GWEN_CRYPT_TOKEN_KEYINFO GWEN_CRYPT_TOKEN_KEYINFO
int GWEN_Gui_KeyDataFromText_OpenSSL(const char *text, unsigned char *buffer, unsigned int bufLength)
GWEN_CRYPT_KEY * GWEN_CTF_Context_GetTempLocalSignKey(const GWEN_CRYPT_TOKEN_CONTEXT *ctx)
void GWEN_CTF_Context_SetTempLocalSignKey(GWEN_CRYPT_TOKEN_CONTEXT *ctx, GWEN_CRYPT_KEY *k)
GWEN_CRYPT_TOKEN_OPEN_FN GWEN_Crypt_Token_SetOpenFn(GWEN_CRYPT_TOKEN *ct, GWEN_CRYPT_TOKEN_OPEN_FN f)
int GWEN_Crypt_KeyDataFromText(const char *text, unsigned char *buffer, unsigned int bufLength)
#define GWEN_CRYPT_KEYRSA_FLAGS_DIRECTSIGN
unsigned int GWEN_Tag16_GetTagLength(const GWEN_TAG16 *tlv)
struct GWEN_CRYPT_TOKEN_CONTEXT GWEN_CRYPT_TOKEN_CONTEXT
#define GWEN_CRYPT_TOKEN_KEYFLAGS_CANENCIPHER
void GWEN_CTF_Context_SetLocalCryptKeyInfo(GWEN_CRYPT_TOKEN_CONTEXT *ctx, GWEN_CRYPT_TOKEN_KEYINFO *ki)
unsigned int GWEN_Tag16_GetTagType(const GWEN_TAG16 *tlv)
#define GWEN_CRYPT_TOKEN_KEYFLAGS_HASKEYNUMBER
#define DBG_ERROR(dbg_logger, format, args...)
GWEN_CRYPT_TOKEN_CREATE_FN GWEN_Crypt_Token_SetCreateFn(GWEN_CRYPT_TOKEN *ct, GWEN_CRYPT_TOKEN_CREATE_FN f)
#define DBG_INFO_ERR(dbg_logger, dbg_err)
void GWEN_Crypt_Token_Context_SetAddress(GWEN_CRYPT_TOKEN_CONTEXT *p_struct, const char *p_src)
#define GWEN_ERROR_NOT_SUPPORTED
int GWEN_DB_SetCharValue(GWEN_DB_NODE *n, uint32_t flags, const char *path, const char *val)
const char * GWEN_Crypt_Token_GetTokenName(const GWEN_CRYPT_TOKEN *ct)
#define GWEN_GUI_INPUT_FLAGS_RETRY
void GWEN_Crypt_Token_KeyInfo_SetExponent(GWEN_CRYPT_TOKEN_KEYINFO *st, const uint8_t *p, uint32_t len)
GWEN_PLUGIN * ct_ohbci_factory(GWEN_PLUGIN_MANAGER *pm, const char *modName, const char *fileName)
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)
void GWEN_Crypt_Token_Context_SetUserId(GWEN_CRYPT_TOKEN_CONTEXT *p_struct, const char *p_src)
void GWEN_Crypt_Token_Context_SetTempSignKeyId(GWEN_CRYPT_TOKEN_CONTEXT *p_struct, uint32_t p_src)
void GWEN_CTF_Context_SetTempLocalSignKeyInfo(GWEN_CRYPT_TOKEN_CONTEXT *ctx, GWEN_CRYPT_TOKEN_KEYINFO *ki)
#define DBG_INFO(dbg_logger, format, args...)
GWEN_CRYPT_KEY * GWEN_Crypt_KeyBlowFish_fromData(GWEN_CRYPT_CRYPTMODE mode, int keySize, const uint8_t *kd, uint32_t kl)
GWEN_CRYPT_TOKEN_KEYINFO * GWEN_CTF_Context_GetRemoteSignKeyInfo(const GWEN_CRYPT_TOKEN_CONTEXT *ctx)
int GWEN_Crypt_Key_GetKeyVersion(const GWEN_CRYPT_KEY *k)
int GWEN_Crypt_TokenOHBCI__DecryptFile(GWEN_CRYPT_TOKEN *ct, GWEN_BUFFER *fbuf, int trynum, uint32_t gid)
GWEN_CRYPT_KEY * GWEN_CTF_Context_GetRemoteAuthKey(const GWEN_CRYPT_TOKEN_CONTEXT *ctx)
void GWEN_Crypt_Token_KeyInfo_SetKeyNumber(GWEN_CRYPT_TOKEN_KEYINFO *p_struct, uint32_t p_src)
int GWEN_Crypt_TokenOHBCI__EnsurePassword(GWEN_CRYPT_TOKEN *ct, int trynum, int confirm, uint32_t gid)
GWEN_CRYPT_TOKEN_KEYINFO * GWEN_Crypt_Token_KeyInfo_new(uint32_t kid, GWEN_CRYPT_CRYPTALGOID a, int keySize)
int GWEN_Crypt_Key_Decipher(GWEN_CRYPT_KEY *k, const uint8_t *pInData, uint32_t inLen, uint8_t *pOutData, uint32_t *pOutLen)
int GWENHYWFAR_CB GWEN_Crypt_TokenOHBCI_Plugin_CheckToken(GWEN_PLUGIN *pl, GWEN_BUFFER *name)
void GWEN_Crypt_Token_KeyInfo_SetSignCounter(GWEN_CRYPT_TOKEN_KEYINFO *p_struct, uint32_t p_src)
int GWEN_Buffer_AppendBytes(GWEN_BUFFER *bf, const char *buffer, uint32_t size)
GWEN_CRYPT_TOKEN_CLOSE_FN GWEN_Crypt_Token_SetCloseFn(GWEN_CRYPT_TOKEN *ct, GWEN_CRYPT_TOKEN_CLOSE_FN f)
GWEN_PLUGIN * GWEN_Crypt_TokenOHBCI_Plugin_new(GWEN_PLUGIN_MANAGER *pm, const char *modName, const char *fileName)
GWEN_DB_NODE * GWEN_DB_Group_new(const char *name)
void GWEN_Crypt_Token_Context_SetDecipherKeyId(GWEN_CRYPT_TOKEN_CONTEXT *p_struct, uint32_t p_src)
void GWEN_Buffer_Rewind(GWEN_BUFFER *bf)
int GWEN_SmallTresor_Encrypt(const uint8_t *src, uint32_t slen, const char *password, GWEN_BUFFER *dst, int passwordIterations, int cryptIterations)
#define GWEN_INHERIT(bt, t)
GWEN_PLUGIN_MANAGER * GWEN_Plugin_GetManager(const GWEN_PLUGIN *p)
int GWEN_DB_SetIntValue(GWEN_DB_NODE *n, uint32_t flags, const char *path, int val)
int GWENHYWFAR_CB GWEN_Crypt_TokenOHBCI_Read(GWEN_CRYPT_TOKEN *ct, int fd, uint32_t gid)
GWEN_CRYPT_TOKEN_PLUGIN_CREATETOKEN_FN GWEN_Crypt_Token_Plugin_SetCreateTokenFn(GWEN_PLUGIN *pl, GWEN_CRYPT_TOKEN_PLUGIN_CREATETOKEN_FN fn)
#define GWEN_ERROR_USER_ABORTED
int GWEN_Buffer_InsertBytes(GWEN_BUFFER *bf, const char *buffer, uint32_t size)
void GWEN_Crypt_Token_Context_SetId(GWEN_CRYPT_TOKEN_CONTEXT *p_struct, uint32_t p_src)
#define GWEN_INHERIT_SETDATA(bt, t, element, data, fn)
#define GWEN_CRYPT_TOKEN_MODE_ALLOW_UPDATE
#define GWEN_CRYPT_KEYRSA_MAX_KEYLENGTH
void GWEN_Crypt_Token_KeyInfo_SetKeyDescr(GWEN_CRYPT_TOKEN_KEYINFO *p_struct, const char *p_src)
void GWEN_Crypt_Token_Context_SetPeerId(GWEN_CRYPT_TOKEN_CONTEXT *p_struct, const char *p_src)
int GWEN_Crypt_KeyRsa_GetExponent(const GWEN_CRYPT_KEY *k, uint8_t *buffer, uint32_t *pBufLen)
void GWEN_Tag16_free(GWEN_TAG16 *tlv)
#define GWEN_PATH_FLAGS_NAMEMUSTEXIST
int GWEN_Crypt_KeyRsa_toDb(const GWEN_CRYPT_KEY *k, GWEN_DB_NODE *db, int pub)
GWEN_CRYPT_TOKEN_FILE_READ_FN GWEN_Crypt_TokenFile_SetReadFn(GWEN_CRYPT_TOKEN *ct, GWEN_CRYPT_TOKEN_FILE_READ_FN f)
void GWEN_Crypt_Token_KeyInfo_AddFlags(GWEN_CRYPT_TOKEN_KEYINFO *p_struct, uint32_t p_src)
int GWEN_Crypt_KeyRsa_GetModulus(const GWEN_CRYPT_KEY *k, uint8_t *buffer, uint32_t *pBufLen)
#define GWEN_DB_FLAGS_DEFAULT
int GWEN_Padd_UnpaddWithAnsiX9_23(GWEN_BUFFER *src)
#define GWEN_INHERIT_GETDATA(bt, t, element)
void GWEN_CTF_Context_SetLocalAuthKeyInfo(GWEN_CRYPT_TOKEN_CONTEXT *ctx, GWEN_CRYPT_TOKEN_KEYINFO *ki)
void GWEN_Crypt_Token_Context_SetAuthVerifyKeyId(GWEN_CRYPT_TOKEN_CONTEXT *p_struct, uint32_t p_src)
int GWENHYWFAR_CB GWEN_Crypt_TokenOHBCI_Write(GWEN_CRYPT_TOKEN *ct, int fd, int cre, uint32_t gid)
void GWEN_Crypt_Token_Context_SetPort(GWEN_CRYPT_TOKEN_CONTEXT *p_struct, int p_src)
#define GWEN_CRYPT_TOKEN_MODE_DIRECT_SIGN
#define GWEN_ERROR_NOT_IMPLEMENTED