Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

KeePass Password Safe

, 1 Oct 2014 CPOL
KeePass is a free, open-source, light-weight and easy-to-use password safe.
KeePass.zip
KeePass.chm
KeePass.exe
KeePass_Src.zip
Build
Docs
Ext
Icons
Finals
Finals2
plock-blu.ico
plock-dis.ico
plock.ico
plockb.ico
key-blu.png
key-bw.png
key-grn.ico
key-grn.png
plock-blu.ico
plock-blu.png
plock-bw.png
plock-dis.ico
plock-grn.ico
plock-grn.png
plock.ico
plock.png
plockb.png
plockbw-r.png
plockbw.png
Untitled.ico
key-org.ico
keyhole-grn.ico
lockblue.ico
lockgreen.ico
lockred.ico
lockyellow.ico
plockb.ico
plockb2.ico
plockbw.ico
plockg.ico
plocko.ico
plockr.ico
plocky.ico
Icons_Nuvola
KeePass.ini
KeePass.iss
KeePassMsi
KeePassMsi.vdproj
KeePassLibC
KeePassLibCpp
Crypto
SHA2
DataExchange
Details
IO
PasswordGenerator
SDK
Details
SysSpec_Windows
Util
KeePassAPI
KeePassLib.def
res
WinGUI
NewGUI
TaskbarListEx
TaskDialog
VistaMenu
Plugins
res
autotype.bmp
cancel.bmp
clienticex.bmp
clock.bmp
disk.bmp
document.bmp
entry_ed.ico
file.bmp
help_sma.bmp
help_smp.bmp
iconpic.ico
infoicon.bmp
infoiconex.bmp
KeePass.png
key.ico
keyhole.ico
key_smal.bmp
language.bmp
locked.ico
lock_ovr.ico
MostPopularPasswords.bin
mouse_sm.bmp
ok.bmp
optionicex.bmp
options.ico
plugins.ico
PwSafe.ico
randomke.bmp
random_b.bmp
search.ico
tb_about.bmp
tb_adden.bmp
tb_copyp.bmp
tb_copyu.bmp
tb_defau.bmp
tb_delet.bmp
tb_edite.bmp
tb_find.bmp
tb_lock.bmp
tb_new.bmp
tb_open.bmp
tb_save.bmp
tb_save1.bmp
tb_saved.bmp
toolssma.bmp
unlocked.ico
winprops.bmp
world.ico
Util
CmdLine
SprEngine
/*
  Copyright (C) 2008-2014 Dominik Reichl
  All rights reserved.

  Redistribution and use in source and binary forms, with or without
  modification, are permitted provided that the following conditions
  are met:

  * Redistributions of source code must retain the above copyright
    notice, this list of conditions and the following disclaimer.
  * Redistributions in binary form must reproduce the above copyright
    notice, this list of conditions and the following disclaimer in
	the documentation and/or other materials provided with the
	distribution.

  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  POSSIBILITY OF SUCH DAMAGE.
*/

#ifndef ___IKPDATABASE_H___
#define ___IKPDATABASE_H___

#pragma once

#include "../../SysDefEx.h"
#include "IKpUnknown.h"
#include "../../PwStructs.h"

#pragma pack(1)

/// Interface to a database handling object.
/// Use IKpAPI::QueryInstance to retrieve an interface to a singleton
/// object in KeePass handling database operations.
struct KP_DECL_INTERFACE("29A5C55A-7100-4A1E-B74D-986C0E085AB2") IKpDatabase :
	public IKpUnknown
{
public:
	/// Used by KeePass internally, plugins must not call this method.
	STDMETHOD(InitPrimaryInstance)() = 0;

	/// Set the master key for the database (will be used in the database
	/// loading / saving process).
	STDMETHOD_(INT, SetMasterKey)(LPCTSTR lpMasterKey, BOOL bDiskDrive,
		LPCTSTR lpSecondKey) = 0;

	STDMETHOD_(DWORD, GetEntryCount)() = 0; ///< Returns the total number of entries in database.
	STDMETHOD_(DWORD, GetGroupCount)() = 0; ///< Returns the total number of groups in database.

	/// Count entries in a group (identified by its name).
	STDMETHOD_(DWORD, GetEntryCountInGroup)(LPCTSTR lpGroup) = 0;
	/// Count entries in a group (identified by its ID).
	STDMETHOD_(DWORD, GetEntryCountInGroupN)(DWORD dwGroupId) = 0;

	// Access entry information

	/// Get an entry (by index). @kpstaticobject
	STDMETHOD_(PW_ENTRY*, GetEntry)(DWORD dwIndex) = 0;
	/// Get an entry (by specifying an index of a group). @kpstaticobject
	STDMETHOD_(PW_ENTRY*, GetEntryByGroup)(DWORD dwGroupId, DWORD dwIndex) = 0;
	STDMETHOD_(DWORD, GetEntryByGroupN)(DWORD dwGroupId, DWORD dwIndex) = 0;
	/// Get an entry (by its UUID). @kpstaticobject
	STDMETHOD_(PW_ENTRY*, GetEntryByUuid)(const BYTE* pUuid) = 0;
	STDMETHOD_(DWORD, GetEntryByUuidN)(const BYTE* pUuid) = 0; // Returns the index of the item with pUuid
	STDMETHOD_(DWORD, GetEntryPosInGroup)(const PW_ENTRY* pEntry) = 0;
	/// Get the entry that was last modified. @kpstaticobject
	STDMETHOD_(PW_ENTRY*, GetLastEditedEntry)() = 0;

	// Access group information

	/// Get a group (by index). @kpstaticobject
	STDMETHOD_(PW_GROUP*, GetGroup)(DWORD dwIndex) = 0;
	/// Get a group (by ID). @kpstaticobject
	STDMETHOD_(PW_GROUP*, GetGroupById)(DWORD dwGroupId) = 0;
	STDMETHOD_(DWORD, GetGroupByIdN)(DWORD dwGroupId) = 0;
	STDMETHOD_(DWORD, GetGroupId)(LPCTSTR lpGroupName) = 0;
	STDMETHOD_(DWORD, GetGroupIdByIndex)(DWORD dwIndex) = 0;
	STDMETHOD_(DWORD, GetLastChildGroup)(DWORD dwParentIndex) = 0;
	STDMETHOD_(BOOL, GetGroupTree)(DWORD dwGroupId, DWORD* pvIndices) = 0;

	// Add entries and groups
	STDMETHOD_(BOOL, AddGroup)(const PW_GROUP* pTemplate) = 0;
	STDMETHOD_(BOOL, AddEntry)(const PW_ENTRY* pTemplate) = 0;
	STDMETHOD_(BOOL, BackupEntry)(const PW_ENTRY* pe, BOOL* pbGroupCreated) = 0; // pe must be unlocked already

	// Delete entries and groups
	STDMETHOD_(BOOL, DeleteEntry)(DWORD dwIndex) = 0;
	STDMETHOD_(BOOL, DeleteGroupById)(DWORD dwGroupId, BOOL bCreateBackupEntries) = 0;

	STDMETHOD_(BOOL, SetGroup)(DWORD dwIndex, const PW_GROUP* pTemplate) = 0;
	STDMETHOD_(BOOL, SetEntry)(DWORD dwIndex, const PW_ENTRY* pTemplate) = 0;

	/// In-memory protection: encrypt the password of an entry.
	/// @see UnlockEntryPassword
	STDMETHOD(LockEntryPassword)(PW_ENTRY* pEntry) = 0;

	/// In-memory protection: decrypt the password of an entry.
	/// Passwords of all entries are by default encrypted. In order to make them
	/// readable, use this method. After you've finished using the password, immediately
	/// encrypt it again using the LockEntryPassword method.
	/// @see LockEntryPassword
	STDMETHOD(UnlockEntryPassword)(PW_ENTRY* pEntry) = 0;

	STDMETHOD(NewDatabase)() = 0;
	STDMETHOD_(INT, OpenDatabase)(LPCTSTR lpFile, PWDB_REPAIR_INFO* pRepair) = 0;
	STDMETHOD_(INT, SaveDatabase)(LPCTSTR lpFile, BYTE* pWrittenDataHash32) = 0;

	// Move entries and groups
	STDMETHOD(MoveEntry)(DWORD dwGroupId, DWORD dwFrom, DWORD dwTo) = 0;
	STDMETHOD_(BOOL, MoveGroup)(DWORD dwFrom, DWORD dwTo) = 0;
	STDMETHOD_(BOOL, MoveGroupEx)(DWORD dwFromId, DWORD dwToId) = 0;
	STDMETHOD_(BOOL, MoveGroupExDir)(DWORD dwGroupId, INT iDirection) = 0;

	// Sort entry and group lists
	STDMETHOD(SortGroup)(DWORD dwGroupId, DWORD dwSortByField) = 0;
	STDMETHOD(SortGroupList)() = 0;

	// Find an item
	STDMETHOD_(DWORD, Find)(LPCTSTR lpFindString, BOOL bCaseSensitive,
		DWORD dwSearchFlags, DWORD dwStart) = 0;

	// Get and set the algorithm used to encrypt the database
	STDMETHOD_(BOOL, SetEncryptionAlgorithm)(INT nAlgorithm) = 0;
	STDMETHOD_(INT, GetEncryptionAlgorithm)() = 0;

	STDMETHOD_(DWORD, GetKeyEncRounds)() = 0;
	STDMETHOD(SetKeyEncRounds)(DWORD dwRounds) = 0;

	/// Get the last used database header. @kpstaticobject
	STDMETHOD_(const PW_DBHEADER*, GetLastDatabaseHeader)() = 0;

	/// Checks and corrects the group tree (level order, etc).
	STDMETHOD(FixGroupTree)() = 0;

	STDMETHOD(SubstEntryGroupIds)(DWORD dwExistingId, DWORD dwNewId) = 0;

	STDMETHOD(GetRawMasterKey)(BYTE* pStorage) = 0;
	STDMETHOD(SetRawMasterKey)(const BYTE* pNewKey) = 0;

	STDMETHOD(GetPropertyString)(DWORD dwPropertyId, LPTSTR lpBuf, DWORD dwBufMaxChars) = 0;
	STDMETHOD_(BOOL, SetPropertyString)(DWORD dwPropertyId, LPCTSTR lpValue) = 0;

	/// Set a custom key-value pair, plugins can use this method to store
	/// own data in the database.
	STDMETHOD_(BOOL, SetCustomKvp)(LPCTSTR lpKey, LPCTSTR lpValue) = 0;
	/// Get a custom key-value pair, these are typically set by plugins to
	/// store own data in the database. @kpstaticstring
	STDMETHOD_(LPCTSTR, GetCustomKvp)(LPCTSTR lpKey) = 0;

	/// Get the name of the entry backups group. @kpstaticstring
	STDMETHOD_(LPCTSTR, GetBackupGroupName)(BOOL bTranslated) = 0;
};

#pragma pack()

#endif // ___IKPDATABASE_H___

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Dominik Reichl
Software Developer
Germany Germany
Dominik started programming in Omikron Basic, a programming language for the good old Atari ST. After this, there was some short period of QBasic programming on the PC, but soon he began learning C++, which is his favorite language up to now.
 
Today, his programming experience includes C / C++ / [Visual] C++ [MFC], C#/.NET, Java, JavaScript, PHP and HTML and the basics of pure assembler.
 
He is interested in almost everything that has to do with computing, his special interests are security and data compression.
 
You can find his latest freeware, open-source projects and all articles on his homepage: http://www.dominik-reichl.de/

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.150326.1 | Last Updated 1 Oct 2014
Article Copyright 2003 by Dominik Reichl
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid