org.avis.security
Class Key

java.lang.Object
  extended by org.avis.security.Key

public final class Key
extends Object

A key value used to secure notifications. A key is simply an immutable block of bytes.

Elvin defines two types of key, private (or raw) keys, and public (or prime) keys. A public key is a one-way hash (e.g. using SHA-1) of a private key. A private key may be any random data, or simply a password. A private key is defined to match a public key if the corresponding hash of its data matches the public key's data, e.g. if sha1 (privateKey.data) == publicKey.data.

Note that this is not a public key system in the RSA sense but that, like RSA, public keys can be shared in the open without loss of security.

This class precomputes a hash code for the key data to accelerate equals () and hashCode ().

Author:
Matthew Phillips

Field Summary
 byte[] data
          The key's data block.
 
Constructor Summary
Key(byte[] data)
          Create a key from a block of data.
Key(String password)
          Create a key from a password by using the password's UTF-8 representation as the data block.
 
Method Summary
 boolean equals(Key key)
           
 boolean equals(Object object)
           
 int hashCode()
           
 Key publicKeyFor(KeyScheme scheme)
          Shortcut to generate the public (prime) key for a given scheme.
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

data

public final byte[] data
The key's data block.

Constructor Detail

Key

public Key(String password)
Create a key from a password by using the password's UTF-8 representation as the data block.


Key

public Key(byte[] data)
Create a key from a block of data.

Method Detail

publicKeyFor

public Key publicKeyFor(KeyScheme scheme)
Shortcut to generate the public (prime) key for a given scheme.

See Also:
KeyScheme.publicKeyFor(Key)

equals

public boolean equals(Object object)
Overrides:
equals in class Object

equals

public boolean equals(Key key)

hashCode

public int hashCode()
Overrides:
hashCode in class Object


Copyright © 2008 Matthew Phillips. All Rights Reserved.