org.logi.crypto.keys
Interface Key

All Superinterfaces:
java.security.Key, PrettyPrintable, java.io.Serializable
All Known Subinterfaces:
BlindingKey, BlindSigningKey, CipherKey, DecryptionKey, EncryptionKey, SigningKey, VerificationKey
All Known Implementing Classes:
org.logi.crypto.keys.K, DHPrivateKey

public interface Key
extends PrettyPrintable, java.security.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 of 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 (but still old) 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.
DHKey yes >=256 yes K-1 / 2*K yes Diffie-Hellman key-exchange and El-Gamal encryption and signatures. 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? (*) RSA can also be used for blind signatures.


Author:
Logi Ragnarsson (logir@logi.org)

Fields inherited from interface java.security.Key
serialVersionUID
 
Method Summary
 java.lang.String getAlgorithm()
          Return the name of the algorithm used by this key.
 Fingerprint getFingerprint()
          Return the key's fingerprint using the default hash function.
 Fingerprint getFingerprint(java.lang.String algorithm)
          Return the key's fingerprint using the specified hash function.
 int getSize()
          Return the "size" of the key.
 int hashCode()
          Return a hash-code based on the keys SHA1 fingerprint.
 boolean matches(Key key)
          Check if a key mathces this.
 Fingerprint matchFingerprint()
          Returns the fingerprint of the matching key in the key-pair.
 Fingerprint matchFingerprint(java.lang.String algorithm)
          Returns the fingerprint of the matching key in the key-pair.
 
Methods inherited from interface org.logi.crypto.io.PrettyPrintable
prettyPrint, prettyPrint
 
Methods inherited from interface java.security.Key
getEncoded, getFormat
 

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 fingerprint using the default hash function.

getFingerprint

public Fingerprint getFingerprint(java.lang.String algorithm)
                           throws InvalidCDSException
Return the key's fingerprint using the specified hash function.
Throws:
InvalidCDSException - if the specified hash function is not available.

matchFingerprint

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

matchFingerprint

public Fingerprint matchFingerprint(java.lang.String algorithm)
                             throws InvalidCDSException
Returns the fingerprint of the matching key in the key-pair.
Throws:
InvalidCDSException - if the specified hash function is not available.

getAlgorithm

public java.lang.String getAlgorithm()
Return the name of the algorithm used by this key.
Specified by:
getAlgorithm in interface java.security.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 (c) 1997-2001 Logi Ragnarsson - Distributed under the GPL