Contact Us Forum Customers Area

DidiSoft Ltd.

KeyStore

Introduction to the KeyStore concept

The KeyStore object encapsulates a storage that contains public and private OpenPGP keys. Referencing the keys in the key store is done either by their Key ID or by their User ID. The KeyStore object can be considered an implementation of the PKCS 12 standard .

Common operations

1. Creating
2. Opening
3. Saving
4. Auto save and backup

1. Create and open a KeyStore

1.1 KeyStore in a File
The first version of the KeyStore class was stored in a file. The constructor of the class KeyStore was used when we wanted to create a new KeyStore or open an existing one.

// C#
KeyStore ks = new KeyStore(@"c:\my.keystore", "my password");
' VB.NET
Dim ks As New KeyStore("c:\my.keystore", "my password")

As of version 1.7.2 an equivalent static construction method has been added:

// C#
KeyStore ks = KeyStore.OpenFile(@"c:\my.keystore", "my password");
' VB.NET
Dim ks As KeyStore = KeyStore.OpenFile("c:\my.keystore", "my password")

1.2 In-memory KeyStore 
As of version 1.7.2 we can have also an in-memory KeyStore object.

// C#
KeyStore ks = KeyStore.OpenInMemory();
' VB.NET
Dim ks As KeyStore = KeyStore.OpenInMemory()

Saving a KeyStore

The Save() method of the KeyStore class writes back the KeyStore object to its file on the disk. This operation has no effect over a KeyStore created in-memory.

Auto save and backup

By default the AutoSave property is on, and after each operation the modified state of the KeyStore is saved to the disk automatically. The BackupOnSave property is true by default too and on each save a backup file is stored with the previous state before the save operation (only one backup though).