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) {
163static 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) {
GWEN_BUFFER * GWEN_Buffer_new(char *buffer, uint32_t size, uint32_t used, int take)
int GWEN_Buffer_IncrementPos(GWEN_BUFFER *bf, uint32_t i)
uint32_t GWEN_Buffer_GetMaxUnsegmentedWrite(GWEN_BUFFER *bf)
int GWEN_Buffer_AdjustUsedBytes(GWEN_BUFFER *bf)
char * GWEN_Buffer_GetPosPointer(const GWEN_BUFFER *bf)
void GWEN_Buffer_OverwriteContent(GWEN_BUFFER *bf, int c)
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)
int GWEN_Buffer_AppendString(GWEN_BUFFER *bf, const char *buffer)
uint32_t GWEN_Buffer_GetUsedBytes(const GWEN_BUFFER *bf)
char * GWEN_Buffer_GetStart(const GWEN_BUFFER *bf)
int GWEN_Buffer_AllocRoom(GWEN_BUFFER *bf, uint32_t size)
int GWEN_Buffer_Crop(GWEN_BUFFER *bf, uint32_t pos, uint32_t l)
const char * GWEN_DB_GetCharValue(GWEN_DB_NODE *n, const char *path, int idx, const char *defVal)
int GWEN_DB_DeleteVar(GWEN_DB_NODE *n, const char *path)
GWEN_DB_NODE * GWEN_DB_GetNextVar(GWEN_DB_NODE *n)
GWEN_DB_NODE * GWEN_DB_Group_new(const char *name)
GWEN_DB_NODE * GWEN_DB_GetFirstVar(GWEN_DB_NODE *n)
int GWEN_DB_SetCharValue(GWEN_DB_NODE *n, uint32_t flags, const char *path, const char *val)
const char * GWEN_DB_VariableName(GWEN_DB_NODE *n)
void GWEN_DB_ModifyBranchFlagsDown(GWEN_DB_NODE *n, uint32_t newflags, uint32_t mask)
void GWEN_DB_Group_free(GWEN_DB_NODE *n)
GWENHYWFAR_API int GWEN_DB_ReadFromString(GWEN_DB_NODE *n, const char *str, int len, uint32_t dbflags)
GWENHYWFAR_API int GWEN_DB_WriteToBuffer(GWEN_DB_NODE *n, GWEN_BUFFER *buf, uint32_t dbflags)
#define GWEN_DB_FLAGS_DEFAULT
#define GWEN_DB_FLAGS_OVERWRITE_VARS
#define GWEN_DB_NODE_FLAGS_SAFE
struct GWEN_DB_NODE GWEN_DB_NODE
#define DBG_INFO(dbg_logger, format,...)
#define DBG_ERROR(dbg_logger, format,...)
GWENHYWFAR_API int GWEN_Directory_GetPath(const char *path, unsigned int flags)
#define GWEN_ERROR_INTERNAL
#define GWEN_ERROR_BAD_DATA
#define GWEN_ERROR_GENERIC
#define GWEN_ERROR_NOT_FOUND
#define GWEN_ERROR_NO_DATA
GWENHYWFAR_API void GWEN_FSLock_free(GWEN_FSLOCK *fl)
struct GWEN_FSLOCK GWEN_FSLOCK
GWENHYWFAR_API GWEN_FSLOCK * GWEN_FSLock_new(const char *fname, GWEN_FSLOCK_TYPE t)
GWENHYWFAR_API GWEN_FSLOCK_RESULT GWEN_FSLock_Lock(GWEN_FSLOCK *fl, int timeout, uint32_t gid)
GWENHYWFAR_API GWEN_FSLOCK_RESULT GWEN_FSLock_Unlock(GWEN_FSLOCK *fl)
struct GWEN_BUFFER GWEN_BUFFER
A dynamically resizeable text buffer.
GWENHYWFAR_API int GWEN_Gui_InputBox(uint32_t flags, const char *title, const char *text, char *buffer, int minLen, int maxLen, uint32_t guiid)
#define GWEN_GUI_INPUT_FLAGS_DIRECT
#define GWEN_GUI_INPUT_FLAGS_CONFIRM
int GWEN_MDigest_Begin(GWEN_MDIGEST *md)
int GWEN_MDigest_End(GWEN_MDIGEST *md)
unsigned int GWEN_MDigest_GetDigestSize(GWEN_MDIGEST *md)
uint8_t * GWEN_MDigest_GetDigestPtr(GWEN_MDIGEST *md)
void GWEN_MDigest_free(GWEN_MDIGEST *md)
int GWEN_MDigest_Update(GWEN_MDIGEST *md, const uint8_t *buf, unsigned int l)
GWENHYWFAR_API GWEN_MDIGEST * GWEN_MDigest_Rmd160_new(void)
struct GWEN_MDIGEST GWEN_MDIGEST
#define GWEN_FREE_OBJECT(varname)
#define GWEN_NEW_OBJECT(typ, varname)
int GWEN_PasswordStore_GetPassword(GWEN_PASSWD_STORE *sto, const char *token, char *buffer, int minLen, int maxLen)
static int GWEN_PasswordStore__GetPassword(GWEN_PASSWD_STORE *sto, const char *token, char *buffer, int minLen, int maxLen)
static int readFile(const char *fname, GWEN_BUFFER *dbuf)
GWEN_PASSWD_STORE * GWEN_PasswordStore_new(const char *fname)
static int GWEN_PasswordStore_CheckDigest(const uint8_t *t, uint32_t size, const uint8_t *h)
void GWEN_PasswordStore_ClearStoragePasswd(GWEN_PASSWD_STORE *sto)
int GWEN_PasswordStore_GetTokenList(GWEN_PASSWD_STORE *sto, GWEN_STRINGLIST *sl)
static int GWEN_PasswordStore__SetPassword(GWEN_PASSWD_STORE *sto, const char *token, const char *secret)
static int GWEN_PasswordStore_EncryptWriteFile(GWEN_PASSWD_STORE *sto, const uint8_t *sec, uint32_t len)
static int writeToFile(FILE *f, const char *p, int len)
void GWEN_PasswordStore_free(GWEN_PASSWD_STORE *sto)
static int GWEN_PasswordStore_ReadDecryptFile(GWEN_PASSWD_STORE *sto, GWEN_BUFFER *secbuf)
static void GWEN_PasswordStore_SafeFreeDb(GWEN_PASSWD_STORE *sto)
int GWEN_PasswordStore_SetPassword(GWEN_PASSWD_STORE *sto, const char *token, const char *secret)
static int GWEN_PasswordStore_WriteFile(GWEN_PASSWD_STORE *sto)
static int writeFile(const char *fname, const char *p, int len)
static int GWEN_PasswordStore_Digest(const uint8_t *t, uint32_t size, GWEN_BUFFER *buf)
static int GWEN_PasswordStore_ReadFile(GWEN_PASSWD_STORE *sto)
struct GWEN_PASSWD_STORE GWEN_PASSWD_STORE
#define GWEN_PATH_FLAGS_VARIABLE
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)
int GWEN_StringList_AppendString(GWEN_STRINGLIST *sl, const char *s, int take, int checkDouble)
struct GWEN_STRINGLISTSTRUCT GWEN_STRINGLIST
int GWEN_Text_EscapeToBufferTolerant(const char *src, GWEN_BUFFER *buf)
int GWEN_Text_UnescapeToBufferTolerant(const char *src, GWEN_BUFFER *buf)