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>
44# define ftruncate chsize
122 if (access(p, F_OK)) {
128 if (access(p, R_OK | W_OK)) {
131 "File exists but I have no writes on it");
138 "File exists, I have all rights but still can't open it");
140 "File exists, I have all rights but "
141 "still can't open it");
145 rv=fread(buffer,
sizeof(buffer), 1, f);
150 "This seems not to be an OpenHBCI keyfile");
157 "This seems not to be an OpenHBCI keyfile "
162 if ((
unsigned char)(buffer[0])==GWEN_CRYPT_TOKEN_OHBCI_TAG_MEDIUM1) {
164 "Old OpenHBCI file detected");
166 "Old OpenHBCI file detected");
169 else if ((
unsigned char)(buffer[0])==GWEN_CRYPT_TOKEN_OHBCI_TAG_MEDIUM2) {
171 "OpenHBCI file (<1.6) detected");
173 "OpenHBCI file (<1.6) detected");
176 else if ((
unsigned char)(buffer[0])==GWEN_CRYPT_TOKEN_OHBCI_TAG_MEDIUM3) {
177 if ((
unsigned char)(buffer[3])==GWEN_CRYPT_TOKEN_OHBCI_TAG_HEADER &&
179 GWEN_CRYPT_TOKEN_OHBCI_NAME,
180 strlen(GWEN_CRYPT_TOKEN_OHBCI_NAME))==0) {
182 "New OpenHBCI file (>=1.6) detected");
184 "New OpenHBCI file (>=1.6) detected");
190 "This seems not to be an OpenHBCI keyfile");
192 "This seems not to be an OpenHBCI keyfile");
204 GWEN_CRYPT_TOKEN_OHBCI *lct;
212 lct->mediumTag=GWEN_CRYPT_TOKEN_OHBCI_TAG_MEDIUM3;
213 lct->vminor=GWEN_CRYPT_TOKEN_OHBCI_VMINOR;
214 lct->cryptoTag=GWEN_CRYPT_TOKEN_OHBCI_TAG_CRYPT_BF;
232 GWEN_CRYPT_TOKEN_OHBCI *lct;
234 lct=(GWEN_CRYPT_TOKEN_OHBCI *) p;
235 memset(lct->password, 0,
sizeof(lct->password));
247 GWEN_CRYPT_TOKEN_OHBCI *lct;
253 if (lct->passWordIsSet==0) {
256 unsigned int pinLength=0;
260 memset(lct->password, 0,
sizeof(lct->password));
271 (
unsigned char *)password,
272 GWEN_CRYPT_TOKEN_OHBCI_PINMINLENGTH,
281 if (strlen(password)<GWEN_CRYPT_TOKEN_OHBCI_PINMINLENGTH) {
283 "Your program returned a shorter PIN than instructed!");
288 if (lct->cryptoTag==GWEN_CRYPT_TOKEN_OHBCI_TAG_CRYPT) {
292 (
unsigned char *)lct->password,
296 "Could not create key data from password (%d)", rv);
300 else if (lct->cryptoTag==GWEN_CRYPT_TOKEN_OHBCI_TAG_CRYPT_OLD) {
304 (
unsigned char *)lct->password,
309 "OpenSSL-style password creation not supported with Libgcrypt!");
317 else if (lct->cryptoTag==GWEN_CRYPT_TOKEN_OHBCI_TAG_CRYPT_BF) {
321 (
unsigned char *)lct->password,
325 "Could not create key data from password (%d)", rv);
329 else if (lct->cryptoTag==GWEN_CRYPT_TOKEN_OHBCI_TAG_CRYPT_TRESOR) {
331 strncpy(lct->password, password,
sizeof(lct->password)-1);
332 lct->password[
sizeof(lct->password)-1]=0;
340 lct->passWordIsSet=1;
353 GWEN_CRYPT_TOKEN_OHBCI *lct;
360 unsigned int pinLength=0;
372 if (lct->cryptoTag==GWEN_CRYPT_TOKEN_OHBCI_TAG_CRYPT) {
374 (
const uint8_t *)lct->password, 24);
376 else if (lct->cryptoTag==GWEN_CRYPT_TOKEN_OHBCI_TAG_CRYPT_OLD) {
378 (
const uint8_t *)lct->password, 16);
380 else if (lct->cryptoTag==GWEN_CRYPT_TOKEN_OHBCI_TAG_CRYPT_BF) {
382 (
const uint8_t *)lct->password, 16);
409 (
unsigned char *)password,
413 memset(password, 0,
sizeof(password));
414 lct->passWordIsSet=0;
429 lct->passWordIsSet=0;
435 (
unsigned char *)password,
439 memset(password, 0,
sizeof(password));
459 (
unsigned char *)password,
463 memset(password, 0,
sizeof(password));
464 lct->passWordIsSet=0;
474 (
unsigned char *)password,
478 memset(password, 0,
sizeof(password));
489 GWEN_CRYPT_TOKEN_OHBCI *lct;
510 GWEN_CRYPT_TOKEN_OHBCI_TRESOR_PWD_ITERATIONS,
511 GWEN_CRYPT_TOKEN_OHBCI_TRESOR_CRYPT_ITERATIONS);
515 if (lct->password[0])
520 (
unsigned char *)lct->password,
521 strlen(lct->password),
524 memset(lct->password, 0,
sizeof(lct->password));
525 lct->passWordIsSet=0;
538 if (lct->password[0])
543 (
unsigned char *)lct->password,
544 strlen(lct->password),
547 memset(lct->password, 0,
sizeof(lct->password));
548 lct->passWordIsSet=0;
553 if (lct->password[0])
558 (
unsigned char *)lct->password,
559 strlen(lct->password),
569 GWEN_CRYPT_TOKEN_OHBCI *lct;
586 rv=read(fd, buffer,
sizeof(buffer));
605 if (c!=GWEN_CRYPT_TOKEN_OHBCI_TAG_MEDIUM1 &&
606 c!=GWEN_CRYPT_TOKEN_OHBCI_TAG_MEDIUM2 &&
607 c!=GWEN_CRYPT_TOKEN_OHBCI_TAG_MEDIUM3) {
635 if (i>GWEN_CRYPT_TOKEN_OHBCI_MAX_PIN_TRY) {
637 "No valid PIN within %d tries, giving up", i);
639 I18N(
"No valid PIN (tried too often), "
645 switch (lct->mediumTag) {
646 case GWEN_CRYPT_TOKEN_OHBCI_TAG_MEDIUM1:
647 lct->cryptoTag=GWEN_CRYPT_TOKEN_OHBCI_TAG_CRYPT_OLD;
650 case GWEN_CRYPT_TOKEN_OHBCI_TAG_MEDIUM2:
651 lct->cryptoTag=GWEN_CRYPT_TOKEN_OHBCI_TAG_CRYPT;
654 case GWEN_CRYPT_TOKEN_OHBCI_TAG_MEDIUM3:
673 I18N(
"Bad PIN, will try again"));
703 const char defaultExpo[3]= {0x01, 0x00, 0x01};
731 sizeof(defaultExpo));
753 p=(
char *)malloc(l+1);
760 case GWEN_CRYPT_TOKEN_OHBCI_TAG_KEY_ISPUBLIC:
764 case GWEN_CRYPT_TOKEN_OHBCI_TAG_KEY_ISCRYPT:
768 case GWEN_CRYPT_TOKEN_OHBCI_TAG_KEY_OWNER:
775 case GWEN_CRYPT_TOKEN_OHBCI_TAG_KEY_VERSION:
783 case GWEN_CRYPT_TOKEN_OHBCI_TAG_KEY_NUMBER:
791 case GWEN_CRYPT_TOKEN_OHBCI_TAG_KEY_MODULUS:
799 case GWEN_CRYPT_TOKEN_OHBCI_TAG_KEY_EXP_OLD:
801 "Ignoring old exponent (%d), keeping default", l);
804 case GWEN_CRYPT_TOKEN_OHBCI_TAG_KEY_EXP:
812 case GWEN_CRYPT_TOKEN_OHBCI_TAG_KEY_N:
820 case GWEN_CRYPT_TOKEN_OHBCI_TAG_KEY_P:
828 case GWEN_CRYPT_TOKEN_OHBCI_TAG_KEY_Q:
836 case GWEN_CRYPT_TOKEN_OHBCI_TAG_KEY_D:
844 case GWEN_CRYPT_TOKEN_OHBCI_TAG_KEY_LEN:
874 GWEN_CRYPT_TOKEN_OHBCI *lct;
880 const char *peerId=0;
881 uint32_t localSignSeq=0;
882 uint32_t remoteSignSeq=0;
892 "File doesn't contain a TLV: Either bad pin or bad file");
899 "File doesn't start with version info or header.");
918 "File doesn't contain a TLV: Either bad pin or bad file");
926 p=(
char *)malloc(l+1);
933 case GWEN_CRYPT_TOKEN_OHBCI_TAG_VERSION_MAJOR:
937 if (i!=GWEN_CRYPT_TOKEN_OHBCI_VMAJOR) {
941 "Basically this file type is supported.\n"
942 "However, the major versions do not match,\n"
943 "so this particular version is not supported");
951 case GWEN_CRYPT_TOKEN_OHBCI_TAG_VERSION_MINOR:
955 if (i>GWEN_CRYPT_TOKEN_OHBCI_VMINOR) {
957 "Keyfile version is higher than mine (%d).\n",
960 "This key file file has been created with a "
961 "newer library version.\n");
967 else if (i<GWEN_CRYPT_TOKEN_OHBCI_VMINOR) {
973 case GWEN_CRYPT_TOKEN_OHBCI_TAG_SEQ:
975 localSignSeq=atoi(p);
980 case GWEN_CRYPT_TOKEN_OHBCI_TAG_USER_ID:
984 case GWEN_CRYPT_TOKEN_OHBCI_TAG_INST_COUNTRY:
988 case GWEN_CRYPT_TOKEN_OHBCI_TAG_INST_CODE:
992 case GWEN_CRYPT_TOKEN_OHBCI_TAG_INST_SYSTEMID:
996 case GWEN_CRYPT_TOKEN_OHBCI_TAG_SERVER_ADDR:
1001 case GWEN_CRYPT_TOKEN_OHBCI_TAG_SERVER_PORT:
1006 case GWEN_CRYPT_TOKEN_OHBCI_TAG_REMOTE_SEQ:
1008 remoteSignSeq=atoi(p);
1011 case GWEN_CRYPT_TOKEN_OHBCI_TAG_USER_PUBSIGNKEY:
1012 case GWEN_CRYPT_TOKEN_OHBCI_TAG_USER_PRIVSIGNKEY:
1016 case GWEN_CRYPT_TOKEN_OHBCI_TAG_USER_PUBCRYPTKEY:
1017 case GWEN_CRYPT_TOKEN_OHBCI_TAG_USER_PRIVCRYPTKEY:
1021 case GWEN_CRYPT_TOKEN_OHBCI_TAG_INST_PUBSIGNKEY:
1025 case GWEN_CRYPT_TOKEN_OHBCI_TAG_INST_PUBCRYPTKEY:
1030 case GWEN_CRYPT_TOKEN_OHBCI_TAG_TEMP_PUBSIGNKEY:
1031 case GWEN_CRYPT_TOKEN_OHBCI_TAG_TEMP_PRIVSIGNKEY:
1035 case GWEN_CRYPT_TOKEN_OHBCI_TAG_TEMP_PUBCRYPTKEY:
1036 case GWEN_CRYPT_TOKEN_OHBCI_TAG_TEMP_PRIVCRYPTKEY:
1038 "Ignoring temporary crypt keys");
1041 case GWEN_CRYPT_TOKEN_OHBCI_TAG_USER_PRIVAUTHKEY:
1045 case GWEN_CRYPT_TOKEN_OHBCI_TAG_INST_PUBAUTHKEY:
1049 case GWEN_CRYPT_TOKEN_OHBCI_TAG_HEADER:
1142 GWEN_Crypt_CryptAlgoId_Rsa, 96);
1222 GWEN_Crypt_CryptAlgoId_Rsa, 96);
1306 GWEN_Crypt_CryptAlgoId_Rsa, 96);
1325 DBG_INFO(0,
"Got Peer Id [%s]", peerId);
1387 GWEN_Crypt_CryptAlgoId_Rsa, 96);
1468 GWEN_Crypt_CryptAlgoId_Rsa, 96);
1549 GWEN_Crypt_CryptAlgoId_Rsa, 96);
1563 "tempLocalSignKey");
1636 GWEN_Crypt_CryptAlgoId_Rsa, 96);
1676 GWEN_CRYPT_TOKEN_OHBCI *lct;
1688 "File doesn't contain a TLV: Either bad pin or bad file");
1709 "File doesn't contain a TLV: Either bad pin or bad file");
1716 p=(
char *)malloc(l+1);
1723 case GWEN_CRYPT_TOKEN_OHBCI_TAG_HEADER:
1724 if (strcasecmp(p, GWEN_CRYPT_TOKEN_OHBCI_NAME)!=0) {
1732 case GWEN_CRYPT_TOKEN_OHBCI_TAG_VERSION_MAJOR:
1734 if (i!=GWEN_CRYPT_TOKEN_OHBCI_VMAJOR) {
1738 "Basically this file type is supported.\n"
1739 "However, the major versions do not match,\n"
1740 "so this particular version is not supported");
1747 case GWEN_CRYPT_TOKEN_OHBCI_TAG_VERSION_MINOR:
1749 if (i>GWEN_CRYPT_TOKEN_OHBCI_VMINOR) {
1751 "Keyfile version is higher than mine (%d).\n",
1754 "This key file file has been created with a "
1755 "newer library version.\n");
1760 else if (i<GWEN_CRYPT_TOKEN_OHBCI_VMINOR) {
1762 "Will update this file upon unmount (%d)", i);
1767 case GWEN_CRYPT_TOKEN_OHBCI_TAG_CRYPT_OLD:
1768 case GWEN_CRYPT_TOKEN_OHBCI_TAG_CRYPT:
1769 case GWEN_CRYPT_TOKEN_OHBCI_TAG_CRYPT_BF: {
1788 case GWEN_CRYPT_TOKEN_OHBCI_TAG_CRYPT_TRESOR: {
1824 unsigned int tagType,
1882 if (tagType==GWEN_CRYPT_TOKEN_OHBCI_TAG_INST_PUBCRYPTKEY) {
1920 pp[1]=(bs>>8) & 0xff;
1929 GWEN_CRYPT_TOKEN_OHBCI *lct;
1944 "Crypt token does not contain a file context");
1950 GWEN_CRYPT_TOKEN_OHBCI_NAME,
1953 if (lct->mediumTag!=GWEN_CRYPT_TOKEN_OHBCI_TAG_MEDIUM3) {
1955 snprintf(numbuf,
sizeof(numbuf),
"%d", GWEN_CRYPT_TOKEN_OHBCI_VMAJOR);
1959 snprintf(numbuf,
sizeof(numbuf),
"%d", GWEN_CRYPT_TOKEN_OHBCI_VMINOR);
1971 GWEN_CRYPT_TOKEN_OHBCI_TAG_USER_PUBSIGNKEY,
1978 GWEN_CRYPT_TOKEN_OHBCI_TAG_USER_PRIVSIGNKEY,
1986 GWEN_CRYPT_TOKEN_OHBCI_TAG_USER_PUBCRYPTKEY,
1993 GWEN_CRYPT_TOKEN_OHBCI_TAG_USER_PRIVCRYPTKEY,
2006 GWEN_CRYPT_TOKEN_OHBCI_TAG_INST_PUBSIGNKEY,
2014 GWEN_CRYPT_TOKEN_OHBCI_TAG_INST_PUBCRYPTKEY,
2020 snprintf(numbuf,
sizeof(numbuf),
"%d", 280);
2039 snprintf(numbuf,
sizeof(numbuf),
"%d",
2056 GWEN_CRYPT_TOKEN_OHBCI_TAG_USER_PRIVAUTHKEY,
2064 GWEN_CRYPT_TOKEN_OHBCI_TAG_INST_PUBAUTHKEY,
2074 GWEN_CRYPT_TOKEN_OHBCI_TAG_TEMP_PUBSIGNKEY,
2081 GWEN_CRYPT_TOKEN_OHBCI_TAG_TEMP_PRIVSIGNKEY,
2094 GWEN_CRYPT_TOKEN_OHBCI *lct;
2112 ((lct->mediumTag!=GWEN_CRYPT_TOKEN_OHBCI_TAG_MEDIUM3) ||
2113 (lct->cryptoTag!=GWEN_CRYPT_TOKEN_OHBCI_TAG_CRYPT_TRESOR))) {
2115 "Updating ancient key file to new one");
2117 I18N(
"Updating ancient key file to new one"));
2118 lct->passWordIsSet=0;
2119 lct->mediumTag=GWEN_CRYPT_TOKEN_OHBCI_TAG_MEDIUM3;
2120 lct->cryptoTag=GWEN_CRYPT_TOKEN_OHBCI_TAG_CRYPT_TRESOR;
2131#ifdef DEBUG_OHBCI_MODULE
2135 f=fopen(
"encoded.medium",
"w+b");
2160 if (lct->cryptoTag==GWEN_CRYPT_TOKEN_OHBCI_TAG_CRYPT_TRESOR) {
2169 GWEN_CRYPT_TOKEN_OHBCI_TRESOR_PWD_ITERATIONS,
2170 GWEN_CRYPT_TOKEN_OHBCI_TRESOR_CRYPT_ITERATIONS);
2183 if (lct->cryptoTag==GWEN_CRYPT_TOKEN_OHBCI_TAG_CRYPT) {
2185 (
const uint8_t *)lct->password, 24);
2187 else if (lct->cryptoTag==GWEN_CRYPT_TOKEN_OHBCI_TAG_CRYPT_OLD) {
2189 (
const uint8_t *)lct->password, 16);
2191 else if (lct->cryptoTag==GWEN_CRYPT_TOKEN_OHBCI_TAG_CRYPT_BF) {
2193 (
const uint8_t *)lct->password, 16);
2240 p[0]=(
unsigned char)(lct->cryptoTag);
2241 p[1]=(
unsigned char)(bs & 0xff);
2242 p[2]=(
unsigned char)((bs>>8) & 0xff);
2245 if (lct->mediumTag==GWEN_CRYPT_TOKEN_OHBCI_TAG_MEDIUM3) {
2255 GWEN_CRYPT_TOKEN_OHBCI_NAME, -1, dbuf);
2256 snprintf(numbuf,
sizeof(numbuf),
"%d", GWEN_CRYPT_TOKEN_OHBCI_VMAJOR);
2260 snprintf(numbuf,
sizeof(numbuf),
"%d", GWEN_CRYPT_TOKEN_OHBCI_VMINOR);
2269 p[0]=(
unsigned char)(lct->mediumTag);
2270 p[1]=(
unsigned char)(bs & 0xff);
2271 p[2]=(
unsigned char)((bs>>8) & 0xff);
2278 if (ftruncate(fd, 0)==-1) {
2280 "ftruncate(%s): %s",
2292 rv=write(fd, p, bs);
2324 GWEN_CRYPT_TOKEN_OHBCI *lct;
2331 lct->passWordIsSet=0;
2332 memset(lct->password, 0,
sizeof(lct->password));
2341 GWEN_CRYPT_TOKEN_OHBCI *lct;
2365 GWEN_Crypt_CryptAlgoId_Rsa,
2381 GWEN_Crypt_CryptAlgoId_Rsa,
2395 GWEN_Crypt_CryptAlgoId_Rsa,
2410 GWEN_Crypt_CryptAlgoId_Rsa,
2424 GWEN_Crypt_CryptAlgoId_Rsa,
2438 GWEN_Crypt_CryptAlgoId_Rsa,
2453 assert(lct->createFn);
2454 rv=lct->createFn(ct, gid);
2467 GWEN_CRYPT_TOKEN_OHBCI *lct;
2474 assert(lct->openFn);
2475 rv=lct->openFn(ct, manage, gid);
2488 GWEN_CRYPT_TOKEN_OHBCI *lct;
2495 assert(lct->closeFn);
2496 rv=lct->closeFn(ct, abandon, gid);
2502 memset(lct->password, 0,
sizeof(lct->password));
2503 lct->passWordIsSet=0;
GWEN_BUFFER * GWEN_Buffer_new(char *buffer, uint32_t size, uint32_t used, int take)
int GWEN_Buffer_InsertBytes(GWEN_BUFFER *bf, const char *buffer, uint32_t size)
int GWEN_Buffer_IncrementPos(GWEN_BUFFER *bf, uint32_t i)
int GWEN_Buffer_AdjustUsedBytes(GWEN_BUFFER *bf)
void GWEN_Buffer_SubMode(GWEN_BUFFER *bf, uint32_t mode)
uint32_t GWEN_Buffer_GetBytesLeft(GWEN_BUFFER *bf)
void GWEN_Buffer_Rewind(GWEN_BUFFER *bf)
int GWEN_Buffer_AppendBytes(GWEN_BUFFER *bf, const char *buffer, uint32_t size)
uint32_t GWEN_Buffer_GetPos(const GWEN_BUFFER *bf)
void GWEN_Buffer_free(GWEN_BUFFER *bf)
uint32_t GWEN_Buffer_GetUsedBytes(const GWEN_BUFFER *bf)
char * GWEN_Buffer_GetStart(const GWEN_BUFFER *bf)
int GWEN_Buffer_ReserveBytes(GWEN_BUFFER *bf, uint32_t res)
int GWEN_Buffer_AppendByte(GWEN_BUFFER *bf, char c)
#define GWEN_BUFFER_MODE_DYNAMIC
@ GWEN_Crypt_CryptMode_Cbc
int GWEN_Crypt_KeyDataFromText(const char *text, unsigned char *buffer, unsigned int bufLength)
@ GWEN_Crypt_PinEncoding_Ascii
@ GWEN_Crypt_PinType_Access
int GWEN_Crypt_Key_Decipher(GWEN_CRYPT_KEY *k, const uint8_t *pInData, uint32_t inLen, uint8_t *pOutData, uint32_t *pOutLen)
void GWEN_Crypt_Key_free(GWEN_CRYPT_KEY *k)
int GWEN_Crypt_Key_GetKeyVersion(const GWEN_CRYPT_KEY *k)
GWEN_CRYPT_CRYPTALGOID GWEN_Crypt_Key_GetCryptAlgoId(const GWEN_CRYPT_KEY *k)
int GWEN_Crypt_Key_GetKeySize(const GWEN_CRYPT_KEY *k)
int GWEN_Crypt_Key_GetKeyNumber(const GWEN_CRYPT_KEY *k)
int GWEN_Crypt_Key_Encipher(GWEN_CRYPT_KEY *k, const uint8_t *pInData, uint32_t inLen, uint8_t *pOutData, uint32_t *pOutLen)
struct GWEN_CRYPT_KEY GWEN_CRYPT_KEY
GWEN_CRYPT_KEY * GWEN_Crypt_KeyRsa_fromDb(GWEN_DB_NODE *db)
int GWEN_Crypt_KeyRsa_toDb(const GWEN_CRYPT_KEY *k, GWEN_DB_NODE *db, int pub)
int GWEN_Crypt_KeyRsa_GetExponent(const GWEN_CRYPT_KEY *k, uint8_t *buffer, uint32_t *pBufLen)
void GWEN_Crypt_KeyRsa_AddFlags(GWEN_CRYPT_KEY *k, uint32_t fl)
int GWEN_Crypt_KeyRsa_GetModulus(const GWEN_CRYPT_KEY *k, uint8_t *buffer, uint32_t *pBufLen)
#define GWEN_CRYPT_KEYRSA_MAX_KEYLENGTH
#define GWEN_CRYPT_KEYRSA_FLAGS_DIRECTSIGN
GWEN_CRYPT_KEY * GWEN_Crypt_KeyDes3K_fromData(GWEN_CRYPT_CRYPTMODE mode, int keySize, const uint8_t *kd, uint32_t kl)
GWEN_CRYPT_KEY * GWEN_Crypt_KeyBlowFish_fromData(GWEN_CRYPT_CRYPTMODE mode, int keySize, const uint8_t *kd, uint32_t kl)
const char * GWEN_Crypt_Token_GetTokenName(const GWEN_CRYPT_TOKEN *ct)
GWEN_CRYPT_TOKEN_CREATE_FN GWEN_Crypt_Token_SetCreateFn(GWEN_CRYPT_TOKEN *ct, GWEN_CRYPT_TOKEN_CREATE_FN f)
uint32_t GWEN_Crypt_Token_GetModes(const GWEN_CRYPT_TOKEN *ct)
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)
GWEN_CRYPT_TOKEN_CLOSE_FN GWEN_Crypt_Token_SetCloseFn(GWEN_CRYPT_TOKEN *ct, GWEN_CRYPT_TOKEN_CLOSE_FN f)
GWEN_CRYPT_TOKEN_OPEN_FN GWEN_Crypt_Token_SetOpenFn(GWEN_CRYPT_TOKEN *ct, GWEN_CRYPT_TOKEN_OPEN_FN f)
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)
GWEN_CRYPT_TOKEN_CHANGEPIN_FN GWEN_Crypt_Token_SetChangePinFn(GWEN_CRYPT_TOKEN *ct, GWEN_CRYPT_TOKEN_CHANGEPIN_FN f)
struct GWEN_CRYPT_TOKEN GWEN_CRYPT_TOKEN
@ GWEN_Crypt_Token_Device_File
#define GWEN_CRYPT_TOKEN_MODE_ALLOW_UPDATE
#define GWEN_CRYPT_TOKEN_MODE_DIRECT_SIGN
void GWEN_Crypt_Token_Context_SetDecipherKeyId(GWEN_CRYPT_TOKEN_CONTEXT *p_struct, uint32_t p_src)
void GWEN_Crypt_Token_Context_free(GWEN_CRYPT_TOKEN_CONTEXT *p_struct)
const char * GWEN_Crypt_Token_Context_GetServiceId(const GWEN_CRYPT_TOKEN_CONTEXT *p_struct)
void GWEN_Crypt_Token_Context_SetSignKeyId(GWEN_CRYPT_TOKEN_CONTEXT *p_struct, uint32_t p_src)
const char * GWEN_Crypt_Token_Context_GetUserId(const GWEN_CRYPT_TOKEN_CONTEXT *p_struct)
void GWEN_Crypt_Token_Context_SetUserId(GWEN_CRYPT_TOKEN_CONTEXT *p_struct, const char *p_src)
void GWEN_Crypt_Token_Context_SetId(GWEN_CRYPT_TOKEN_CONTEXT *p_struct, uint32_t p_src)
const char * GWEN_Crypt_Token_Context_GetSystemId(const GWEN_CRYPT_TOKEN_CONTEXT *p_struct)
int GWEN_Crypt_Token_Context_GetPort(const GWEN_CRYPT_TOKEN_CONTEXT *p_struct)
void GWEN_Crypt_Token_Context_SetSystemId(GWEN_CRYPT_TOKEN_CONTEXT *p_struct, const char *p_src)
void GWEN_Crypt_Token_Context_SetAuthSignKeyId(GWEN_CRYPT_TOKEN_CONTEXT *p_struct, uint32_t p_src)
void GWEN_Crypt_Token_Context_SetAuthVerifyKeyId(GWEN_CRYPT_TOKEN_CONTEXT *p_struct, uint32_t p_src)
void GWEN_Crypt_Token_Context_SetEncipherKeyId(GWEN_CRYPT_TOKEN_CONTEXT *p_struct, uint32_t p_src)
const char * GWEN_Crypt_Token_Context_GetAddress(const GWEN_CRYPT_TOKEN_CONTEXT *p_struct)
void GWEN_Crypt_Token_Context_SetPort(GWEN_CRYPT_TOKEN_CONTEXT *p_struct, int p_src)
void GWEN_Crypt_Token_Context_SetVerifyKeyId(GWEN_CRYPT_TOKEN_CONTEXT *p_struct, uint32_t p_src)
void GWEN_Crypt_Token_Context_SetAddress(GWEN_CRYPT_TOKEN_CONTEXT *p_struct, const char *p_src)
void GWEN_Crypt_Token_Context_SetServiceId(GWEN_CRYPT_TOKEN_CONTEXT *p_struct, const char *p_src)
void GWEN_Crypt_Token_Context_SetPeerId(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)
const char * GWEN_Crypt_Token_Context_GetPeerId(const GWEN_CRYPT_TOKEN_CONTEXT *p_struct)
struct GWEN_CRYPT_TOKEN_CONTEXT GWEN_CRYPT_TOKEN_CONTEXT
GWEN_CRYPT_TOKEN_KEYINFO * GWEN_Crypt_Token_KeyInfo_new(uint32_t kid, GWEN_CRYPT_CRYPTALGOID a, int keySize)
void GWEN_Crypt_Token_KeyInfo_SetKeyDescr(GWEN_CRYPT_TOKEN_KEYINFO *p_struct, const char *p_src)
void GWEN_Crypt_Token_KeyInfo_free(GWEN_CRYPT_TOKEN_KEYINFO *p_struct)
uint32_t GWEN_Crypt_Token_KeyInfo_GetSignCounter(const GWEN_CRYPT_TOKEN_KEYINFO *p_struct)
void GWEN_Crypt_Token_KeyInfo_SetKeyVersion(GWEN_CRYPT_TOKEN_KEYINFO *p_struct, uint32_t p_src)
void GWEN_Crypt_Token_KeyInfo_SetSignCounter(GWEN_CRYPT_TOKEN_KEYINFO *p_struct, uint32_t p_src)
void GWEN_Crypt_Token_KeyInfo_SetExponent(GWEN_CRYPT_TOKEN_KEYINFO *st, const uint8_t *p, uint32_t len)
void GWEN_Crypt_Token_KeyInfo_SetModulus(GWEN_CRYPT_TOKEN_KEYINFO *st, const uint8_t *p, uint32_t len)
void GWEN_Crypt_Token_KeyInfo_SetKeyNumber(GWEN_CRYPT_TOKEN_KEYINFO *p_struct, uint32_t p_src)
void GWEN_Crypt_Token_KeyInfo_AddFlags(GWEN_CRYPT_TOKEN_KEYINFO *p_struct, uint32_t p_src)
#define GWEN_CRYPT_TOKEN_KEYFLAGS_HASEXPONENT
#define GWEN_CRYPT_TOKEN_KEYFLAGS_CANSIGN
#define GWEN_CRYPT_TOKEN_KEYFLAGS_HASMODULUS
#define GWEN_CRYPT_TOKEN_KEYFLAGS_HASACTIONFLAGS
#define GWEN_CRYPT_TOKEN_KEYFLAGS_HASKEYNUMBER
#define GWEN_CRYPT_TOKEN_KEYFLAGS_CANDECIPHER
#define GWEN_CRYPT_TOKEN_KEYFLAGS_CANENCIPHER
#define GWEN_CRYPT_TOKEN_KEYFLAGS_HASKEYVERSION
#define GWEN_CRYPT_TOKEN_KEYFLAGS_CANVERIFY
struct GWEN_CRYPT_TOKEN_KEYINFO GWEN_CRYPT_TOKEN_KEYINFO
#define GWEN_CRYPT_TOKEN_KEYFLAGS_HASSIGNCOUNTER
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)
GWEN_CRYPT_TOKEN_KEYINFO * GWEN_CTF_Context_GetRemoteSignKeyInfo(const GWEN_CRYPT_TOKEN_CONTEXT *ctx)
void GWEN_CTF_Context_SetRemoteSignKey(GWEN_CRYPT_TOKEN_CONTEXT *ctx, GWEN_CRYPT_KEY *k)
GWEN_CRYPT_TOKEN_CONTEXT * GWEN_CTF_Context_new()
GWEN_CRYPT_KEY * GWEN_CTF_Context_GetTempLocalSignKey(const GWEN_CRYPT_TOKEN_CONTEXT *ctx)
void GWEN_CTF_Context_SetLocalCryptKey(GWEN_CRYPT_TOKEN_CONTEXT *ctx, GWEN_CRYPT_KEY *k)
void GWEN_CTF_Context_SetTempLocalSignKey(GWEN_CRYPT_TOKEN_CONTEXT *ctx, GWEN_CRYPT_KEY *k)
void GWEN_CTF_Context_SetLocalSignKeyInfo(GWEN_CRYPT_TOKEN_CONTEXT *ctx, GWEN_CRYPT_TOKEN_KEYINFO *ki)
void GWEN_CTF_Context_SetRemoteSignKeyInfo(GWEN_CRYPT_TOKEN_CONTEXT *ctx, GWEN_CRYPT_TOKEN_KEYINFO *ki)
void GWEN_CTF_Context_SetRemoteCryptKeyInfo(GWEN_CRYPT_TOKEN_CONTEXT *ctx, GWEN_CRYPT_TOKEN_KEYINFO *ki)
void GWEN_CTF_Context_SetRemoteAuthKey(GWEN_CRYPT_TOKEN_CONTEXT *ctx, GWEN_CRYPT_KEY *k)
GWEN_CRYPT_TOKEN_KEYINFO * GWEN_CTF_Context_GetTempLocalSignKeyInfo(const GWEN_CRYPT_TOKEN_CONTEXT *ctx)
GWEN_CRYPT_KEY * GWEN_CTF_Context_GetRemoteAuthKey(const GWEN_CRYPT_TOKEN_CONTEXT *ctx)
GWEN_CRYPT_KEY * GWEN_CTF_Context_GetLocalCryptKey(const GWEN_CRYPT_TOKEN_CONTEXT *ctx)
GWEN_CRYPT_KEY * GWEN_CTF_Context_GetLocalAuthKey(const GWEN_CRYPT_TOKEN_CONTEXT *ctx)
GWEN_CRYPT_KEY * GWEN_CTF_Context_GetRemoteCryptKey(const GWEN_CRYPT_TOKEN_CONTEXT *ctx)
void GWEN_CTF_Context_SetLocalAuthKeyInfo(GWEN_CRYPT_TOKEN_CONTEXT *ctx, GWEN_CRYPT_TOKEN_KEYINFO *ki)
void GWEN_CTF_Context_SetLocalCryptKeyInfo(GWEN_CRYPT_TOKEN_CONTEXT *ctx, GWEN_CRYPT_TOKEN_KEYINFO *ki)
void GWEN_CTF_Context_SetRemoteCryptKey(GWEN_CRYPT_TOKEN_CONTEXT *ctx, GWEN_CRYPT_KEY *k)
GWEN_CRYPT_KEY * GWEN_CTF_Context_GetLocalSignKey(const GWEN_CRYPT_TOKEN_CONTEXT *ctx)
void GWEN_CTF_Context_SetLocalSignKey(GWEN_CRYPT_TOKEN_CONTEXT *ctx, GWEN_CRYPT_KEY *k)
void GWEN_CTF_Context_SetLocalAuthKey(GWEN_CRYPT_TOKEN_CONTEXT *ctx, GWEN_CRYPT_KEY *k)
void GWEN_CTF_Context_SetTempLocalSignKeyInfo(GWEN_CRYPT_TOKEN_CONTEXT *ctx, GWEN_CRYPT_TOKEN_KEYINFO *ki)
void GWEN_CTF_Context_SetRemoteAuthKeyInfo(GWEN_CRYPT_TOKEN_CONTEXT *ctx, GWEN_CRYPT_TOKEN_KEYINFO *ki)
GWEN_CRYPT_TOKEN_FILE_READ_FN GWEN_Crypt_TokenFile_SetReadFn(GWEN_CRYPT_TOKEN *ct, GWEN_CRYPT_TOKEN_FILE_READ_FN f)
GWEN_CRYPT_TOKEN * GWEN_Crypt_TokenFile_new(const char *typeName, const char *tokenName)
GWEN_CRYPT_TOKEN_CONTEXT * GWEN_Crypt_TokenFile_GetContext(GWEN_CRYPT_TOKEN *ct, int idx)
void GWEN_Crypt_TokenFile_AddContext(GWEN_CRYPT_TOKEN *ct, GWEN_CRYPT_TOKEN_CONTEXT *ctx)
GWEN_CRYPT_TOKEN_FILE_WRITE_FN GWEN_Crypt_TokenFile_SetWriteFn(GWEN_CRYPT_TOKEN *ct, GWEN_CRYPT_TOKEN_FILE_WRITE_FN f)
GWEN_PLUGIN * GWEN_Crypt_Token_Plugin_new(GWEN_PLUGIN_MANAGER *mgr, GWEN_CRYPT_TOKEN_DEVICE devType, const char *typeName, const char *fileName)
GWEN_CRYPT_TOKEN_PLUGIN_CHECKTOKEN_FN GWEN_Crypt_Token_Plugin_SetCheckTokenFn(GWEN_PLUGIN *pl, GWEN_CRYPT_TOKEN_PLUGIN_CHECKTOKEN_FN fn)
GWEN_CRYPT_TOKEN_PLUGIN_CREATETOKEN_FN GWEN_Crypt_Token_Plugin_SetCreateTokenFn(GWEN_PLUGIN *pl, GWEN_CRYPT_TOKEN_PLUGIN_CREATETOKEN_FN fn)
const char * GWEN_DB_GetCharValue(GWEN_DB_NODE *n, const char *path, int idx, const char *defVal)
GWEN_DB_NODE * GWEN_DB_Group_new(const char *name)
int GWEN_DB_SetIntValue(GWEN_DB_NODE *n, uint32_t flags, const char *path, int val)
GWEN_DB_NODE * GWEN_DB_GetGroup(GWEN_DB_NODE *n, uint32_t flags, const char *path)
int GWEN_DB_SetCharValue(GWEN_DB_NODE *n, uint32_t flags, const char *path, const char *val)
int GWEN_DB_SetBinValue(GWEN_DB_NODE *n, uint32_t flags, const char *path, const void *val, unsigned int valSize)
const void * GWEN_DB_GetBinValue(GWEN_DB_NODE *n, const char *path, int idx, const void *defVal, unsigned int defValSize, unsigned int *returnValueSize)
void GWEN_DB_Group_free(GWEN_DB_NODE *n)
#define GWEN_DB_FLAGS_DEFAULT
#define GWEN_DB_FLAGS_OVERWRITE_VARS
struct GWEN_DB_NODE GWEN_DB_NODE
#define DBG_INFO_ERR(dbg_logger, dbg_err)
#define DBG_INFO(dbg_logger, format,...)
#define DBG_NOTICE(dbg_logger, format,...)
#define DBG_ERROR(dbg_logger, format,...)
#define DBG_ERROR_ERR(dbg_logger, dbg_err)
#define DBG_WARN(dbg_logger, format,...)
#define GWEN_ERROR_NOT_IMPLEMENTED
#define GWEN_ERROR_BAD_NAME
#define GWEN_ERROR_INVALID
#define GWEN_ERROR_BAD_PIN
#define GWEN_ERROR_GENERIC
#define GWEN_ERROR_USER_ABORTED
#define GWEN_ERROR_NOT_SUPPORTED
#define GWEN_ERROR_ABORTED
struct GWEN_BUFFER GWEN_BUFFER
A dynamically resizeable text buffer.
#define GWEN_GUI_INPUT_FLAGS_RETRY
GWENHYWFAR_API int GWEN_Gui_ProgressLog(uint32_t id, GWEN_LOGGER_LEVEL level, const char *text)
#define GWEN_GUI_INPUT_FLAGS_CONFIRM
GWENHYWFAR_API int GWEN_Gui_KeyDataFromText_OpenSSL(const char *text, unsigned char *buffer, unsigned int bufLength)
#define GWEN_INHERIT_SETDATA(bt, t, element, data, fn)
#define GWEN_INHERIT(bt, t)
#define GWEN_INHERIT_GETDATA(bt, t, element)
@ GWEN_LoggerLevel_Warning
@ GWEN_LoggerLevel_Notice
@ GWEN_LoggerLevel_Critical
#define GWEN_FREE_OBJECT(varname)
#define GWEN_NEW_OBJECT(typ, varname)
int GWEN_Crypt_TokenOHBCI__DecryptTresor(GWEN_CRYPT_TOKEN *ct, GWEN_BUFFER *fbuf, int trynum, uint32_t gid)
void GWEN_Crypt_TokenOHBCI__DecodeKey(GWEN_UNUSED GWEN_CRYPT_TOKEN *ct, GWEN_TAG16 *keyTlv, GWEN_DB_NODE *dbKeys, const char *keyName)
GWEN_PLUGIN * ct_ohbci_factory(GWEN_PLUGIN_MANAGER *pm, const char *modName, const char *fileName)
int GWEN_Crypt_TokenOHBCI_Encode(GWEN_CRYPT_TOKEN *ct, GWEN_BUFFER *dbuf)
int GWENHYWFAR_CB GWEN_Crypt_TokenOHBCI_Open(GWEN_CRYPT_TOKEN *ct, int manage, uint32_t gid)
int GWENHYWFAR_CB GWEN_Crypt_TokenOHBCI_Plugin_CheckToken(GWEN_UNUSED GWEN_PLUGIN *pl, GWEN_BUFFER *name)
int GWEN_Crypt_TokenOHBCI__DecryptFile(GWEN_CRYPT_TOKEN *ct, GWEN_BUFFER *fbuf, int trynum, uint32_t gid)
int GWEN_Crypt_TokenOHBCI__EnsurePassword(GWEN_CRYPT_TOKEN *ct, int trynum, int confirm, uint32_t gid)
int GWENHYWFAR_CB GWEN_Crypt_TokenOHBCI_ChangePin(GWEN_CRYPT_TOKEN *ct, GWEN_UNUSED int admin, GWEN_UNUSED uint32_t gid)
int GWENHYWFAR_CB GWEN_Crypt_TokenOHBCI_Read(GWEN_CRYPT_TOKEN *ct, int fd, uint32_t gid)
int GWENHYWFAR_CB GWEN_Crypt_TokenOHBCI_Write(GWEN_CRYPT_TOKEN *ct, int fd, GWEN_UNUSED int cre, uint32_t gid)
int GWENHYWFAR_CB GWEN_Crypt_TokenOHBCI_Close(GWEN_CRYPT_TOKEN *ct, int abandon, uint32_t gid)
GWEN_CRYPT_TOKEN * GWEN_Crypt_TokenOHBCI_new(GWEN_UNUSED GWEN_PLUGIN_MANAGER *pm, const char *name)
int GWEN_Crypt_TokenOHBCI__DecryptFile16(GWEN_CRYPT_TOKEN *ct, GWEN_BUFFER *dbuf, int tryNum, uint32_t gid)
void GWENHYWFAR_CB GWEN_Crypt_TokenOHBCI_FreeData(GWEN_UNUSED void *bp, void *p)
GWEN_PLUGIN * GWEN_Crypt_TokenOHBCI_Plugin_new(GWEN_PLUGIN_MANAGER *pm, const char *modName, const char *fileName)
GWEN_CRYPT_TOKEN *GWENHYWFAR_CB GWEN_Crypt_TokenOHBCI_Plugin_CreateToken(GWEN_PLUGIN *pl, const char *name)
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)
int GWEN_Crypt_TokenOHBCI__Decode(GWEN_CRYPT_TOKEN *ct, GWEN_BUFFER *dbuf)
int GWENHYWFAR_CB GWEN_Crypt_TokenOHBCI_Create(GWEN_CRYPT_TOKEN *ct, uint32_t gid)
int GWEN_Padd_PaddWithAnsiX9_23(GWEN_BUFFER *src)
int GWEN_Padd_UnpaddWithAnsiX9_23(GWEN_BUFFER *src)
#define GWEN_PATH_FLAGS_NAMEMUSTEXIST
GWEN_PLUGIN_MANAGER * GWEN_Plugin_GetManager(const GWEN_PLUGIN *p)
struct GWEN_PLUGIN_MANAGER GWEN_PLUGIN_MANAGER
struct GWEN_PLUGIN GWEN_PLUGIN
int GWEN_SmallTresor_Encrypt(const uint8_t *src, uint32_t slen, const char *password, GWEN_BUFFER *dst, int passwordIterations, int cryptIterations)
int GWEN_SmallTresor_Decrypt(const uint8_t *p, uint32_t len, const char *password, GWEN_BUFFER *dst, int passwordIterations, int cryptIterations)
void GWEN_Tag16_DirectlyToBuffer(unsigned int tagType, const char *p, int size, GWEN_BUFFER *buf)
GWEN_TAG16 * GWEN_Tag16_fromBuffer(GWEN_BUFFER *mbuf, GWEN_UNUSED int isBerTlv)
unsigned int GWEN_Tag16_GetTagLength(const GWEN_TAG16 *tag)
const void * GWEN_Tag16_GetTagData(const GWEN_TAG16 *tag)
void GWEN_Tag16_free(GWEN_TAG16 *tag)
unsigned int GWEN_Tag16_GetTagType(const GWEN_TAG16 *tag)
struct GWEN_TAG16 GWEN_TAG16