KeePass   KeePass Help Center Home KeePass Home | Package Downloads | Flag Translations | Blocks Plugins | Donate Donate  
Home Help Center Home | People Forums | Award Awards | Link Links | Search Search  







Settings

Key Providers Development


How to develop key provider plugins for KeePass 2.x.

This documentation applies to KeePass 2.x plugins. 2.x plugins are fundamentally different from 1.x plugins. 2.x plugins cannot be loaded by KeePass 1.x.

This article is intended for KeePass plugin developers. If you are looking for ready-to-use key providers, see the Plugins page.


Info  Introduction

For an introduction about what key provider plugins are, see the KeePass 1.x Key Providers page.

A 2.x key provider plugin derives from the KeePassLib.Keys.KeyProvider class and registers itself in the key provider pool by using the Add method of the KeyProviderPool class in the IPluginHost interface that you get in the Initialize function. Don't forget to unregister your plugin using Remove when KeePass calls your plugin's Terminate method.


Info  Sample Source Code

Here's the source code of a very simple key provider plugin for KeePass 2.x. This code is complete and can be compiled as-is.

using System;

using KeePass.Plugins;
using KeePassLib.Keys;

namespace KeyProviderTest
{
	public sealed class KeyProviderTestExt : Plugin
	{
		private IPluginHost m_host = null;
		private SampleKeyProvider m_prov = new SampleKeyProvider();

		public override bool Initialize(IPluginHost host)
		{
			m_host = host;

			m_host.KeyProviderPool.Add(m_prov);
			return true;
		}

		public override void Terminate()
		{
			m_host.KeyProviderPool.Remove(m_prov);
		}
	}

	public sealed class SampleKeyProvider : KeyProvider
	{
		public override string Name
		{
			get { return "Sample Key Provider"; }
		}

		public override byte[] GetKey(KeyProviderQueryContext ctx)
		{
			// Return a sample key. In a real key provider plugin, the key
			// would be retrieved from smart card, USB device, ...
			return new byte[]{ 2, 3, 5, 7, 11, 13 };
		}
	}
}




Valid XHTML 1.0 Transitional Document

Get KeePass

Flattr this


KeePass is OSI Certified Open Source Software
Copyright © 2003-2014
Dominik Reichl, [Legal Contact / Imprint] [Disclaimer] [Acknowledgements] [Donate], Downloads hosted at

Get KeePass Password Safe at
SourceForge.net. Fast, secure and Free Open Source software downloads