Class KeyRing

All Implemented Interfaces:

public class KeyRing
extends Crypto
implements KeySource

This implementation of the KeySource interface stores keys in a hash-table. It can be converted to and from a CDS for storage.

A database key-source would be more appropriate for large collections of keys, but hasn't been written yet. An interface to a key-server would be more appropriate for really huge key collections but will have to wait even longer.

The CDS for a KeyRing object is KeyRing(k1,k2,...,kn) with n>=0 and each ki the CDS for a KeyRecord or Key object.

Logi Ragnarsson (
See Also:
Key, KeyRecord

Fields inherited from class org.logi.crypto.Crypto
BIT, cdsPath, EMPTY_ARRAY, FOUR, keySource, NIBBLE, ONE, primeCertainty, random, TWO, ZERO
Constructor Summary
          Create empty key ring.
Method Summary
 KeyRecord byFingerprint(Fingerprint fingerprint)
          Retrieve the key with the given fingerprint.
 void insert(Key k)
          Insert the Key k into the KeyRing.
 void insert(KeyRecord kc)
          Insert the KeyRecord k into the KeyRing.
static KeyRing parseCDS(java.lang.String[] param)
          Used by Crypto.fromString when parsing a CDS.
 java.lang.String toString()
          Return a CDS for this KeyRing.
Methods inherited from class org.logi.crypto.Crypto
binString, binString, ensureArrayLength, ensureArrayLength, equal, equalRelaxed, equalSub, fromHexNibble, fromHexString, fromString, fromString, hexString, hexString, hexString, hexString, hexString, initRandom, initRandom, makeClass, makeInt, makeLong, makeSessionKey, pastSpace, pickBits, pickBits, prettyPrint, prettyPrint, readBlock, readInt, trimArrayLength, trimArrayLength, trimLeadingZeroes, writeBytes, writeBytes, writeInt
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Constructor Detail


public KeyRing()
Create empty key ring.
Method Detail


public static KeyRing parseCDS(java.lang.String[] param)
                        throws InvalidCDSException
Used by Crypto.fromString when parsing a CDS.

A valid CDS can be created by calling the toString() method.

InvalidCDSException - if the CDS is malformed.
See Also:


public java.lang.String toString()
Return a CDS for this KeyRing.
toString in class java.lang.Object


public void insert(Key k)
Insert the Key k into the KeyRing. It will be wrapped in a KeyRecord containing empty strings and no certificates.


public void insert(KeyRecord kc)
Insert the KeyRecord k into the KeyRing.


public KeyRecord byFingerprint(Fingerprint fingerprint)
Retrieve the key with the given fingerprint. If it is not found in the key-source, null is returned. fingerprint must be created with the same algorithm as the the Key object uses, which will be SHA1 for the Key classes included with Crypto.
Specified by:
byFingerprint in interface KeySource

Copyright (c) 1997-2001 Logi Ragnarsson - Distributed under the GPL