is.logi.crypto.keys
Interface Key

All Known Subinterfaces:
CipherKey, SignatureKey
All Known Implementing Classes:
K, ElGamalKey, DHKey

public abstract interface Key

This interface is implemented by cryptographic keys of any type. Any actual functionality of the keys is defined in the interfaces derived from Key.

Classes implementing Key should be "read-only" in the same sense as the String class and not implement any methods to change the state of the object.


Overview over Key classes:

Class P-K Key Size Cipher Block Size Signature Notes
CaesarKey no 1 yes 1 no Very weak. Only included as an example.
DESKey no 56 yes 8 no Old US Government standard. Can be broken with exchaustive search.
TriDESKey no 168 yes 8 no Newer US Government standard. Applies DES three times. Slow.
BlowfishKey no <=448 yes 8 no Fast. Free for all use.
RSAKey yes >=256 yes K-1 / K yes Most widely used public-key algorithm. Patented in the USA and Canada.
ElGamalKey yes >=256 yes K-1 / 2*K yes Unpatented, free for all use.
DHKey yes >=256 no n/a no Only used for key-exchange. Patent expired.

Class: The name of the class implementing an algorithm. It will be based on the name of the algorithm.

P-K: Is this a public-key algorithm?

Key Size: The size of the key in bits. In some cases variable.

Cipher: Can this algorithm be used for encryption?

Block Size: The size of the blocks of data which is encrypted at one time with this algorithm. If the resulting ciphertext block is not the same size, its size is also given, separated by a slash. The size may be based on the size of the key, which is denoted by K. All sizes are given in bytes. Thus "K-1 / 2*K" means that the input block size is one byte less than the size of the key, while the output size is twice the size of the key.

Signature: Can this algorithm be used to sign data?


Author:
Logi Ragnarsson (logir@hi.is)
See Also:
CipherKey, SignatureKey

Method Summary
 java.lang.String getAlgorithm()
          Return the name of the algorithm used by this key.
 Fingerprint getFingerprint()
          Return the key's SHA1 fingerprint.
 int getSize()
          Return the "size" of the key.
 int hashCode()
          Return a hash-code based on the keys SHA1 fingerprint.
 boolean isPrivate()
          Returns true iff this is a private key.
 boolean matches(Key key)
          Check if a key mathces this.
 Fingerprint matchFingerprint()
          Returns the fingerprint of the matching key in the key-pair.
 

Method Detail

getSize

public int getSize()
Return the "size" of the key. This is a (fairly inaccurate) measure of how difficult it is to break and is heavily dependant on the algorithm used.

getFingerprint

public Fingerprint getFingerprint()
Return the key's SHA1 fingerprint.

matchFingerprint

public Fingerprint matchFingerprint()
Returns the fingerprint of the matching key in the key-pair.

getAlgorithm

public java.lang.String getAlgorithm()
Return the name of the algorithm used by this key.

isPrivate

public boolean isPrivate()
Returns true iff this is a private key.

hashCode

public int hashCode()
Return a hash-code based on the keys SHA1 fingerprint.
Overrides:
hashCode in class java.lang.Object

matches

public boolean matches(Key key)
Check if a key mathces this. This is true if this and key are a matched pair of public/private keys or the same symmetric key.


Copyright 1997-1999 Logi Ragnarsson