next up previous contents
Next: Distributing a plugin Up: Creating Encryption Plugins Previous: Changing default encryption plugin   Contents

Coding a plugin

Creating an encryption plugin if you are knowledgable about Java and Cryptology is not a difficult task. Plugins must implement the interface CryptoPlugin and it's three methods

	String encrypt (String password, String toEncrypt) throws CryptoException
	String decrypt (String password, String toDecrypt) throws CryptoException
	String getVersion ()
The encrypt and decrypt methods accept a password and text. Using the password as a key (either directally or as a password to unlock a private key for example) they encrypt/decrypt the text and return the result. The most basic plugin would simply have the statement return toEncrypt; which would not perform any encryption but is a valid plugin.

If an error occures that the user needs to be informed about then a CryptoException can be thrown. This will cause the loading of the user file to fail, and present the user with the reason (using the getMessage() method of the CryptoException.

The getVersion() method plays a significent role in the plugin behaviour.

Before the plugin is used, the version is checked against the stored version in the user file. If the version numbers don't match a warning is given to the user that it may not work. Ideally, encryptions plugins should be backward compatable. The version number is not arbitrary. It is in the format <int>.<int> where the first int is the ``major'' version number, and the second is the ``minor'' version number.

A plugin MUST be able to interpret all files encrypted with ALL past plugins with the same major version number (ie. for an example plugin XPlugin, XPlugin 1.2 should be able to read files made with XPlugin 1.1 and 1.0). A plugin MAY interpret files encrypted with past plugins with differing version numbers. A warning message is displayed to the user stating that the decryption operation may not work if either the major version numbers don't match, or the encryption plugin used to decrypt has a minor version number less than that which was used to encrypt it.

Due to this, it is advised not to change the major version number and not to make backward incompatible changes. If significant changes need to be made, then creating a new plugin with a different name is recommended so that they can both be installed at once. Forward-compatible plugins (eg. where an earlier version of a plugin can decrypt the output of a later plugin) are not explicitly supported, if this is the case then it may not be necessary to change the version numbers at all.


next up previous contents
Next: Distributing a plugin Up: Creating Encryption Plugins Previous: Changing default encryption plugin   Contents
William Denniss 2003-12-04