mail.node.crypt
Class CryptEngine

java.lang.Object
  extended by mail.node.crypt.CryptEngine
Direct Known Subclasses:
MyCryptEngine, OtherCryptEngine

public abstract class CryptEngine
extends java.lang.Object

Author:
Arne Müller

Constructor Summary
CryptEngine()
           
 
Method Summary
abstract  boolean checkSignature(org.w3c.dom.Element signature)
          decodes the signature with the public key and then checks it
abstract  void decrypt(org.w3c.dom.Element data)
          decrypt data with the private key The document that contains the Element will be modified!
abstract  void encrypt(org.w3c.dom.Element data)
          encrypt data with the public key The document that contains the Element will be modified!
static byte[] fromHex(java.lang.String s)
           
private static int fromHexChar(char c)
           
 ID getID()
          computes the ID of the user with the public Key returned by getPublicKey()
static ID getID(byte[] key)
          computes an ID out of an Public key.
abstract  byte[] getPublicKey()
           
abstract  java.lang.String getPublicKeyString()
           
abstract  void sign(org.w3c.dom.Element data)
          sign data with the private key The document that contains the Element will be modified!
static java.lang.String toHex(byte[] arr)
           
private static char toHexChar(int b)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CryptEngine

public CryptEngine()
Method Detail

encrypt

public abstract void encrypt(org.w3c.dom.Element data)
                      throws EncryptionException
encrypt data with the public key The document that contains the Element will be modified! Data will change! It won't be available afterwards

Parameters:
data - to be encrypted
Throws:
EncryptionException

sign

public abstract void sign(org.w3c.dom.Element data)
                   throws EncryptionException
sign data with the private key The document that contains the Element will be modified! Data will be extended, but it will keep being a valid element.

Parameters:
data - to be signed
Throws:
EncryptionException

checkSignature

public abstract boolean checkSignature(org.w3c.dom.Element signature)
                                throws EncryptionException
decodes the signature with the public key and then checks it

Parameters:
signature - to check
Returns:
true, if signature is ok
Throws:
EncryptionException

decrypt

public abstract void decrypt(org.w3c.dom.Element data)
                      throws EncryptionException
decrypt data with the private key The document that contains the Element will be modified! Data will change!

Parameters:
data - to be decrypted
Throws:
EncryptionException

getPublicKey

public abstract byte[] getPublicKey()

getPublicKeyString

public abstract java.lang.String getPublicKeyString()

getID

public ID getID()
computes the ID of the user with the public Key returned by getPublicKey()

Returns:
the ID
See Also:
#getID(PublicKey)

getID

public static final ID getID(byte[] key)
computes an ID out of an Public key. A simple hash function is used. This is needed, so all ID's have the same length

Parameters:
k - the public Key to compute the ID of
Returns:

toHexChar

private static char toHexChar(int b)

fromHexChar

private static int fromHexChar(char c)

toHex

public static java.lang.String toHex(byte[] arr)

fromHex

public static byte[] fromHex(java.lang.String s)