30 #include "passwdstore_p.h" 33 #include <gwenhywfar/gui.h> 34 #include <gwenhywfar/db.h> 35 #include <gwenhywfar/directory.h> 36 #include <gwenhywfar/fslock.h> 37 #include <gwenhywfar/mdigest.h> 38 #include <gwenhywfar/text.h> 39 #include <gwenhywfar/debug.h> 40 #include <gwenhywfar/smalltresor.h> 52 sto->fileName=strdup(fname);
53 sto->dbPasswords=
NULL;
63 memset(sto->pw, 0,
sizeof(sto->pw));
64 if (sto->dbPasswords) {
67 sto->dbPasswords=
NULL;
79 memset(sto->pw, 0, GWEN_PASSWDSTORE_PWLEN);
80 if (sto->dbPasswords) {
83 sto->dbPasswords=
NULL;
107 if (s==(ssize_t)-1) {
110 fname, strerror(errno));
130 fname, strerror(errno));
147 s=fwrite(p, 1, l, f);
148 if (s==(ssize_t)-1 || s==0) {
163 static int writeFile(
const char *fname,
const char *p,
int len)
167 f=fopen(fname,
"wb");
184 fname, strerror(errno));
252 if (sto->dbPasswords) {
255 sto->dbPasswords=
NULL;
292 I18N(
"Enter Password"),
293 I18N(
"Please enter the password for the password store.\n" 295 "Please enter the password for the <b>password store</b>.</br>" 315 GWEN_PASSWDSTORE_PW_ITERATIONS,
316 GWEN_PASSWDSTORE_CRYPT_ITERATIONS);
321 memset(sto->pw, 0,
sizeof(sto->pw));
370 DBG_ERROR(0,
"Looking for [%s]", sto->fileName);
385 I18N(
"Create New Password Store"),
387 "You are about to create a new password store.\n" 388 "Passwords you store here will be encrypted with a passphrase\n" 389 "which you must enter now.\n" 392 "Later you will only need to remember the passphrase for the\n" 393 "password store, not all the individuell passwords.\n" 395 "WARNING: Storing your passwords in the password store\n" 396 "can be considered a security risk, especially if the passphrase protecting it\n" 397 "is not strong enough!\n" 399 "You can safely abort this step, in which case your passwords will not be stored.\n" 401 "Please enter the passphrase for the password store to be created or abort.\n" 403 "<p>You are about to create a new <b>password store</b>.</p>" 405 "<p>Passwords you store here will be encrypted with a passphrase " 406 "which you must enter now.</p>" 407 "<p>Later you will only need to remember the passphrase for the " 408 "password store, not all the individuell passwords.<p>" 409 "<p><font color=\"red\">" 410 "<b>Warning:</b> Storing your passwords in the password store " 411 "can be considered a <b>security risk</b>, especially if the passphrase protecting it " 412 "is not strong enough!" 414 "<p><b>You can safely abort this step</b>, in which case your passwords will not be stored.</p>" 416 "<p>Please enter the passphrase for the password store to be created or abort.</p>" 426 I18N(
"Enter Password"),
427 I18N(
"Please enter the password for the password store.\n" 429 "Please enter the password for the <b>password store</b>.</br>" 465 GWEN_PASSWDSTORE_PW_ITERATIONS,
466 GWEN_PASSWDSTORE_CRYPT_ITERATIONS);
533 if (sto->dbPasswords) {
605 if (i>=minLen && i < maxLen) {
606 memmove(buffer, s, i+1);
650 if (sto->dbPasswords==
NULL) {
GWENHYWFAR_API int GWEN_DB_WriteToBuffer(GWEN_DB_NODE *n, GWEN_BUFFER *buf, uint32_t dbflags)
GWENHYWFAR_API void GWEN_FSLock_free(GWEN_FSLOCK *fl)
char * GWEN_Buffer_GetStart(const GWEN_BUFFER *bf)
void GWEN_PasswordStore_free(GWEN_PASSWD_STORE *sto)
static int writeToFile(FILE *f, const char *p, int len)
#define GWEN_DB_FLAGS_OVERWRITE_VARS
void GWEN_MDigest_free(GWEN_MDIGEST *md)
static int readFile(const char *fname, GWEN_BUFFER *dbuf)
struct GWEN_DB_NODE GWEN_DB_NODE
int GWEN_Buffer_AllocRoom(GWEN_BUFFER *bf, uint32_t size)
uint32_t GWEN_Buffer_GetMaxUnsegmentedWrite(GWEN_BUFFER *bf)
void GWEN_DB_Group_free(GWEN_DB_NODE *n)
uint32_t GWEN_Buffer_GetUsedBytes(const GWEN_BUFFER *bf)
static void GWEN_PasswordStore_SafeFreeDb(GWEN_PASSWD_STORE *sto)
#define GWEN_GUI_INPUT_FLAGS_CONFIRM
static int GWEN_PasswordStore_Digest(const uint8_t *t, uint32_t size, GWEN_BUFFER *buf)
#define GWEN_FREE_OBJECT(varname)
int GWEN_Text_EscapeToBufferTolerant(const char *src, GWEN_BUFFER *buf)
GWEN_PASSWD_STORE * GWEN_PasswordStore_new(const char *fname)
static int GWEN_PasswordStore_ReadDecryptFile(GWEN_PASSWD_STORE *sto, GWEN_BUFFER *secbuf)
int GWEN_SmallTresor_Decrypt(const uint8_t *p, uint32_t len, const char *password, GWEN_BUFFER *dst, int passwordIterations, int cryptIterations)
int GWEN_Buffer_AdjustUsedBytes(GWEN_BUFFER *bf)
GWENHYWFAR_API int GWEN_DB_ReadFromString(GWEN_DB_NODE *n, const char *str, int len, uint32_t dbflags)
void GWEN_DB_ModifyBranchFlagsDown(GWEN_DB_NODE *n, uint32_t newflags, uint32_t mask)
uint32_t GWEN_Buffer_GetPos(const GWEN_BUFFER *bf)
int GWEN_MDigest_Update(GWEN_MDIGEST *md, const uint8_t *buf, unsigned int l)
int GWEN_PasswordStore_GetPassword(GWEN_PASSWD_STORE *sto, const char *token, char *buffer, int minLen, int maxLen)
#define GWEN_GUI_INPUT_FLAGS_DIRECT
GWEN_BUFFER * GWEN_Buffer_new(char *buffer, uint32_t size, uint32_t used, int take)
int GWEN_Text_UnescapeToBufferTolerant(const char *src, GWEN_BUFFER *buf)
static int GWEN_PasswordStore__SetPassword(GWEN_PASSWD_STORE *sto, const char *token, const char *secret)
char * GWEN_Buffer_GetPosPointer(const GWEN_BUFFER *bf)
int GWEN_PasswordStore_SetPassword(GWEN_PASSWD_STORE *sto, const char *token, const char *secret)
int GWEN_Buffer_IncrementPos(GWEN_BUFFER *bf, uint32_t i)
uint8_t * GWEN_MDigest_GetDigestPtr(GWEN_MDIGEST *md)
#define GWEN_ERROR_BAD_DATA
int GWEN_MDigest_Begin(GWEN_MDIGEST *md)
GWEN_DB_NODE * GWEN_DB_GetFirstVar(GWEN_DB_NODE *n)
#define GWEN_NEW_OBJECT(typ, varname)
GWENHYWFAR_API GWEN_FSLOCK * GWEN_FSLock_new(const char *fname, GWEN_FSLOCK_TYPE t)
static int GWEN_PasswordStore_CheckDigest(const uint8_t *t, uint32_t size, const uint8_t *h)
GWENHYWFAR_API GWEN_MDIGEST * GWEN_MDigest_Rmd160_new(void)
GWENHYWFAR_API int GWEN_Gui_InputBox(uint32_t flags, const char *title, const char *text, char *buffer, int minLen, int maxLen, uint32_t guiid)
int GWEN_StringList_AppendString(GWEN_STRINGLIST *sl, const char *s, int take, int checkDouble)
#define GWEN_PATH_FLAGS_VARIABLE
#define GWEN_DB_NODE_FLAGS_SAFE
struct GWEN_STRINGLISTSTRUCT GWEN_STRINGLIST
#define GWEN_ERROR_GENERIC
struct GWEN_MDIGEST GWEN_MDIGEST
const char * GWEN_DB_GetCharValue(GWEN_DB_NODE *n, const char *path, int idx, const char *defVal)
const char * GWEN_DB_VariableName(GWEN_DB_NODE *n)
GWENHYWFAR_API GWEN_FSLOCK_RESULT GWEN_FSLock_Lock(GWEN_FSLOCK *fl, int timeout, uint32_t gid)
static int GWEN_PasswordStore_ReadFile(GWEN_PASSWD_STORE *sto)
void GWEN_Buffer_free(GWEN_BUFFER *bf)
int GWEN_DB_DeleteVar(GWEN_DB_NODE *n, const char *path)
struct GWEN_BUFFER GWEN_BUFFER
A dynamically resizeable text buffer.
int GWEN_PasswordStore_GetTokenList(GWEN_PASSWD_STORE *sto, GWEN_STRINGLIST *sl)
int GWEN_Buffer_Crop(GWEN_BUFFER *bf, uint32_t pos, uint32_t l)
int GWEN_MDigest_End(GWEN_MDIGEST *md)
#define DBG_ERROR(dbg_logger, format, args...)
unsigned int GWEN_MDigest_GetDigestSize(GWEN_MDIGEST *md)
struct GWEN_PASSWD_STORE GWEN_PASSWD_STORE
int GWEN_DB_SetCharValue(GWEN_DB_NODE *n, uint32_t flags, const char *path, const char *val)
static int GWEN_PasswordStore_WriteFile(GWEN_PASSWD_STORE *sto)
#define GWEN_ERROR_NOT_FOUND
#define DBG_INFO(dbg_logger, format, args...)
GWEN_DB_NODE * GWEN_DB_GetNextVar(GWEN_DB_NODE *n)
GWENHYWFAR_API int GWEN_Directory_GetPath(const char *path, unsigned int flags)
struct GWEN_FSLOCK GWEN_FSLOCK
int GWEN_Buffer_AppendBytes(GWEN_BUFFER *bf, const char *buffer, uint32_t size)
void GWEN_PasswordStore_ClearStoragePasswd(GWEN_PASSWD_STORE *sto)
GWEN_DB_NODE * GWEN_DB_Group_new(const char *name)
int GWEN_SmallTresor_Encrypt(const uint8_t *src, uint32_t slen, const char *password, GWEN_BUFFER *dst, int passwordIterations, int cryptIterations)
#define GWEN_ERROR_INTERNAL
static int GWEN_PasswordStore__GetPassword(GWEN_PASSWD_STORE *sto, const char *token, char *buffer, int minLen, int maxLen)
GWENHYWFAR_API GWEN_FSLOCK_RESULT GWEN_FSLock_Unlock(GWEN_FSLOCK *fl)
#define GWEN_ERROR_NO_DATA
static int GWEN_PasswordStore_EncryptWriteFile(GWEN_PASSWD_STORE *sto, const uint8_t *sec, uint32_t len)
int GWEN_Buffer_AppendString(GWEN_BUFFER *bf, const char *buffer)
#define GWEN_DB_FLAGS_DEFAULT
void GWEN_Buffer_OverwriteContent(GWEN_BUFFER *bf, int c)
static int writeFile(const char *fname, const char *p, int len)