pwmanager.h
来自「一款密码保险箱源码」· C头文件 代码 · 共 556 行 · 第 1/2 页
H
556 行
/*
KeePass Password Safe - The Open-Source Password Manager
Copyright (C) 2003-2007 Dominik Reichl <dominik.reichl@t-online.de>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef ___KEEPASS_PASSWORD_MANAGER_H___
#define ___KEEPASS_PASSWORD_MANAGER_H___
#include "SysDefEx.h"
#include <string>
#include <vector>
#include "Util/NewRandom.h"
#include "Crypto/Rijndael.h"
// General product information
#define PWM_PRODUCT_NAME _T("KeePass Password Safe")
#define PWM_PRODUCT_NAME_SHORT _T("KeePass")
// When making a Windows build, don't forget to update the verinfo resource
#ifndef _UNICODE
#define PWM_VERSION_STR _T("1.09")
#else
#define PWM_VERSION_STR _T("1.09 Unicode")
#endif
#define PWM_VERSION_DW 0x01000901
// Database file signature bytes
#define PWM_DBSIG_1 0x9AA2D903
#define PWM_DBSIG_2 0xB54BFB65
#define PWM_DBVER_DW 0x00030002
#define PWM_HOMEPAGE _T("http://keepass.info/")
#define PWM_URL_TRL _T("http://keepass.info/translations.html")
#define PWM_URL_PLUGINS _T("http://keepass.info/plugins.html")
#define PWM_URL_VERSION _T("http://keepass.info/update/version1.txt")
#define PWM_URL_DONATE _T("http://keepass.info/donate.html")
#define PWM_EXENAME _T("KeePass")
#define PWM_README_FILE _T("KeePass.chm")
#define PWM_LICENSE_FILE _T("License.txt")
#define PWM_HELP_AUTOTYPE _T("help/base/autotype.html")
#define PWM_HELP_URLS _T("help/base/autourl.html")
#define PWM_HELP_CREDITS _T("help/base/credits.html")
#define PWM_HELP_SECURITY _T("help/base/security.html")
#define PWM_HELP_PLUGINS _T("help/v1/plugins.html")
#define PWM_HELP_KEYS _T("help/base/keys.html")
#define PWM_HELP_TANS _T("help/base/tans.html")
#define PWM_HELP_PWGEN _T("help/base/pwgenerator.html")
#define PWM_HELP_CSV _T("help/base/importexport.html#csv")
#define PWMKEY_LANG _T("KeeLanguage")
#define PWMKEY_CLIPSECS _T("KeeClipboardSeconds")
#define PWMKEY_NEWLINE _T("KeeNewLine")
#define PWMKEY_LASTDIR _T("KeeLastDir")
#define PWMKEY_OPENLASTB _T("KeeAutoOpen")
#define PWMKEY_LASTDB _T("KeeLastDb")
#define PWMKEY_AUTOSAVEB _T("KeeAutoSave")
#define PWMKEY_IMGBTNS _T("KeeImgButtons")
#define PWMKEY_ENTRYGRID _T("KeeEntryGrid")
#define PWMKEY_ALWAYSTOP _T("KeeAlwaysOnTop")
#define PWMKEY_SHOWTITLE _T("KeeShowTitle")
#define PWMKEY_SHOWUSER _T("KeeShowUser")
#define PWMKEY_SHOWURL _T("KeeShowURL")
#define PWMKEY_SHOWPASS _T("KeeShowPassword")
#define PWMKEY_SHOWNOTES _T("KeeShowNotes")
#define PWMKEY_SHOWATTACH _T("KeeShowAttach")
#define PWMKEY_HIDESTARS _T("KeeHideStars")
#define PWMKEY_HIDEUSERS _T("KeeHideUserStars")
#define PWMKEY_LISTFONT _T("KeeListFont")
#define PWMKEY_WINDOWPX _T("KeeWindowPX")
#define PWMKEY_WINDOWPY _T("KeeWindowPY")
#define PWMKEY_WINDOWDX _T("KeeWindowDX")
#define PWMKEY_WINDOWDY _T("KeeWindowDY")
#define PWMKEY_COLWIDTH0 _T("KeeColumnWidth0")
#define PWMKEY_COLWIDTH1 _T("KeeColumnWidth1")
#define PWMKEY_COLWIDTH2 _T("KeeColumnWidth2")
#define PWMKEY_COLWIDTH3 _T("KeeColumnWidth3")
#define PWMKEY_COLWIDTH4 _T("KeeColumnWidth4")
#define PWMKEY_COLWIDTH5 _T("KeeColumnWidth5")
#define PWMKEY_COLWIDTH6 _T("KeeColumnWidth6")
#define PWMKEY_COLWIDTH7 _T("KeeColumnWidth7")
#define PWMKEY_COLWIDTH8 _T("KeeColumnWidth8")
#define PWMKEY_COLWIDTH9 _T("KeeColumnWidth9")
#define PWMKEY_COLWIDTH10 _T("KeeColumnWidth10")
#define PWMKEY_SPLITTERX _T("KeeSplitterX")
#define PWMKEY_SPLITTERY _T("KeeSplitterY")
#define PWMKEY_ENTRYVIEW _T("KeeEntryView")
#define PWMKEY_LOCKMIN _T("KeeLockOnMinimize")
#define PWMKEY_MINTRAY _T("KeeMinimizeToTray")
#define PWMKEY_CLOSEMIN _T("KeeCloseMinimizes")
#define PWMKEY_LOCKTIMER _T("KeeLockAfterTime")
#define PWMKEY_ROWCOLOR _T("KeeRowColor")
#define PWMKEY_SHOWCREATION _T("KeeShowCreation")
#define PWMKEY_SHOWLASTMOD _T("KeeShowLastMod")
#define PWMKEY_SHOWLASTACCESS _T("KeeShowLastAccess")
#define PWMKEY_SHOWEXPIRE _T("KeeShowExpire")
#define PWMKEY_SHOWUUID _T("KeeShowUUID")
#define PWMKEY_SHOWTOOLBAR _T("KeeShowToolBar")
#define PWMKEY_COLAUTOSIZE _T("KeeColAutoSize")
// #define PWMKEY_PWGEN_OPTIONS _T("KeePwGenOptions")
// #define PWMKEY_PWGEN_CHARS _T("KeePwGenChars")
// #define PWMKEY_PWGEN_NUMCHARS _T("KeePwGenNumChars")
#define PWMKEY_DISABLEUNSAFE _T("KeeDisableUnsafe")
#define PWMKEY_REMEMBERLAST _T("KeeRememberLast")
#define PWMKEY_HEADERORDER _T("KeeHeaderItemOrder")
#define PWMKEY_USEPUTTYFORURLS _T("KeeUsePutty")
#define PWMKEY_SAVEONLATMOD _T("KeeSaveOnLATMod")
#define PWMKEY_WINSTATE_MAX _T("KeeWindowMaximized")
#define PWMKEY_AUTOSORT _T("KeeAutoSortPwList")
#define PWMKEY_AUTOTYPEHOTKEY _T("KeeAutoTypeHotKey")
#define PWMKEY_CLIPBOARDMETHOD _T("KeeClipboardMethod")
#define PWMKEY_STARTMINIMIZED _T("KeeStartMinimized")
#define PWMKEY_AUTOSHOWEXPIRED _T("KeeShowExpiredAtOpen")
#define PWMKEY_AUTOSHOWEXPIREDS _T("KeeShowSoonExpiredAtOpen")
#define PWMKEY_BACKUPENTRIES _T("KeeBackupEntries")
#define PWMKEY_SINGLEINSTANCE _T("KeeSingleInstance")
#define PWMKEY_SECUREEDITS _T("KeeSecureEditControls")
#define PWMKEY_SINGLECLICKTRAY _T("KeeSingleClickTrayIcon")
#define PWMKEY_DEFAULTEXPIRE _T("KeeDefaultExpire")
#define PWMKEY_AUTOPWGEN _T("KeeAutoPwGen")
#define PWMKEY_QUICKFINDINCBK _T("KeeQuickFindIncBackup")
#define PWMKEY_AUTOTYPEMETHOD _T("KeeAutoTypeMethod")
#define PWMKEY_DELETEBKONSAVE _T("KeeDeleteBackupsOnSave")
#define PWMKEY_SHOWFULLPATH _T("KeeShowFullPath")
#define PWMKEY_DISABLEAUTOTYPE _T("KeeDisableAutoType")
#define PWMKEY_COPYURLS _T("KeeCopyURLs")
#define PWMKEY_EXITINSTEADLOCK _T("KeeExitInsteadOfLockAT")
#define PWMKEY_URLOVERRIDE _T("KeeURLOverride")
#define PWMKEY_SIMPLETANVIEW _T("KeeSimpleTANView")
#define PWMKEY_SHOWTANINDICES _T("KeeShowTANIndices")
#define PWMKEY_ALLOWSAVEIFMODIFIEDONLY _T("KeeAllowSaveIfModifiedOnly")
#define PWMKEY_CHECKFORUPDATE _T("KeeCheckForUpdate")
#define PWMKEY_LOCKONWINLOCK _T("KeeLockOnWinLock")
#define PWMKEY_ENABLEREMOTECTRL _T("KeeEnableRemoteCtrl")
#define PWMKEY_DEFAULTATSEQ _T("KeeDefaultAutoTypeSequence")
#define PWMKEY_USELOCALTIMEFMT _T("KeeUseLocalTimeFormat")
#define PWMKEY_TANCHARS _T("KeeTANCharacters")
#define PWMKEY_HTMURLMETHOD _T("KeeHTMURLMethod")
#define PWMKEY_GENPROFILE _T("KeeGenProfile")
#define PWMKEY_GENPROFILEAUTO _T("KeeGenProfileAuto")
#define PWMKEY_GENPROFILELASTPR _T("KeeGenProfileLast")
#define PWMKEY_PREFERUSER _T("KeePreferUserConfiguration")
#define PWM_NUM_INITIAL_ENTRIES 256
#define PWM_NUM_INITIAL_GROUPS 32
#define PWM_PASSWORD_STRING _T("********")
#define PWM_KEYMETHOD_OR FALSE
#define PWM_KEYMETHOD_AND TRUE
#define PWS_SEARCHGROUP TRL("Search Results")
#define PWS_BACKUPGROUP_SRC _T("Backup")
#define PWS_BACKUPGROUP TRL("Backup")
#define PWS_DEFAULT_KEY_FILENAME _T("pwsafe.key")
#define PWV_SOONTOEXPIRE_DAYS 7
#define PWS_TAN_ENTRY TRL("<TAN>")
#define PWM_FLAG_SHA2 1
#define PWM_FLAG_RIJNDAEL 2
#define PWM_FLAG_ARCFOUR 4
#define PWM_FLAG_TWOFISH 8
#define PWM_SESSION_KEY_SIZE 12
#define PWM_STD_KEYENCROUNDS 6000
#define PWM_STD_ICON_GROUP 48
#define PWM_STD_ICON_GROUP_OPEN 49
#define PWM_STD_ICON_GROUP_EMAIL 50
#define PWM_STD_ICON_GROUP_PKG 25
// Field flags (for example in Find function)
#define PWMF_TITLE 1
#define PWMF_USER 2
#define PWMF_URL 4
#define PWMF_PASSWORD 8
#define PWMF_ADDITIONAL 16
#define PWMF_GROUPNAME 32
#define PWMF_CREATION 64
#define PWMF_LASTMOD 128
#define PWMF_LASTACCESS 256
#define PWMF_EXPIRE 512
#define PWMF_UUID 1024
#define PWGF_EXPANDED 1
#define ALGO_AES 0
#define ALGO_TWOFISH 1
// Error codes
#define PWE_UNKNOWN 0
#define PWE_SUCCESS 1
#define PWE_INVALID_PARAM 2
#define PWE_NO_MEM 3
#define PWE_INVALID_KEY 4
#define PWE_NOFILEACCESS_READ 5
#define PWE_NOFILEACCESS_WRITE 6
#define PWE_FILEERROR_READ 7
#define PWE_FILEERROR_WRITE 8
#define PWE_INVALID_RANDOMSOURCE 9
#define PWE_INVALID_FILESTRUCTURE 10
#define PWE_CRYPT_ERROR 11
#define PWE_INVALID_FILESIZE 12
#define PWE_INVALID_FILESIGNATURE 13
#define PWE_INVALID_FILEHEADER 14
#define PWE_NOFILEACCESS_READ_KEY 15
// Format Flags
#define PWFF_NO_INTRO 1
// Password Meta Streams
#define PMS_ID_BINDESC _T("bin-stream")
#define PMS_ID_TITLE _T("Meta-Info")
#define PMS_ID_USER _T("SYSTEM")
#define PMS_ID_URL _T("$")
#define PMS_STREAM_SIMPLESTATE _T("Simple UI State")
#define PMS_STREAM_KPXICON2 _T("KPX_CUSTOM_ICONS_2")
#ifdef VPA_MODIFY
#error VPA_MODIFY must not be defined already.
#else
#define VPA_MODIFY
#endif
#pragma pack(1)
typedef struct _PW_TIME
{
USHORT shYear; // Year, 2004 means 2004
BYTE btMonth; // Month, ranges from 1 = Jan to 12 = Dec
BYTE btDay; // Day, the first day is 1
BYTE btHour; // Hour, begins with hour 0, max value is 23
BYTE btMinute; // Minutes, begins at 0, max value is 59
BYTE btSecond; // Seconds, begins at 0, max value is 59
#ifdef VPF_ALIGN
BYTE btDummy;
#endif
} PW_TIME, *PPW_TIME;
typedef struct _PW_DBHEADER // The database header
{
DWORD dwSignature1; // = PWM_DBSIG_1
DWORD dwSignature2; // = PWM_DBSIG_2
DWORD dwFlags;
DWORD dwVersion;
BYTE aMasterSeed[16]; // Seed that gets hashed with the userkey to form the final key
UINT8 aEncryptionIV[16]; // IV used for content encryption
DWORD dwGroups; // Number of groups in the database
DWORD dwEntries; // Number of entries in the database
BYTE aContentsHash[32]; // SHA-256 hash of the database, used for integrity check
BYTE aMasterSeed2[32]; // Used for the dwKeyEncRounds AES transformations
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?