mail.node.crypt
Class OtherCryptEngine

java.lang.Object
  extended by mail.node.crypt.CryptEngine
      extended by mail.node.crypt.OtherCryptEngine

public class OtherCryptEngine
extends CryptEngine

Author:
Arne Müller

Field Summary
(package private)  ID id
           
(package private)  java.security.PublicKey pubkey
           
 
Constructor Summary
OtherCryptEngine(ID id)
           
OtherCryptEngine(java.lang.String publicKey)
          Creates a CryptEngine that is initialised with a public key.
 
Method Summary
 boolean checkSignature(org.w3c.dom.Element data)
          decodes the signature with the public key and then checks it
 void decrypt(org.w3c.dom.Element data)
          decrypt data with the private key The document that contains the Element will be modified!
 void encrypt(org.w3c.dom.Element data)
          encrypt data with the public key The document that contains the Element will be modified!
private static javax.crypto.SecretKey generateDataEncryptionKey()
          Get a key to be used for encrypting the element.
 ID getID()
          computes the ID of the user with the public Key returned by CryptEngine.getPublicKey()
 byte[] getPublicKey()
           
 java.lang.String getPublicKeyString()
           
 void sign(org.w3c.dom.Element data)
          sign data with the private key The document that contains the Element will be modified!
 
Methods inherited from class mail.node.crypt.CryptEngine
fromHex, getID, toHex
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

pubkey

java.security.PublicKey pubkey

id

ID id
Constructor Detail

OtherCryptEngine

public OtherCryptEngine(java.lang.String publicKey)
                 throws CryptCreationException
Creates a CryptEngine that is initialised with a public key. The String specifying the public Key must be of the form
ALGORITHM:FORMAT:HEXDATA

Parameters:
publicKey -
Throws:
CryptCreationException

OtherCryptEngine

public OtherCryptEngine(ID id)
Method Detail

getID

public ID getID()
Description copied from class: CryptEngine
computes the ID of the user with the public Key returned by CryptEngine.getPublicKey()

Overrides:
getID in class CryptEngine
Returns:
the ID
See Also:
#getID(PublicKey)

decrypt

public void decrypt(org.w3c.dom.Element data)
             throws EncryptionException
Description copied from class: CryptEngine
decrypt data with the private key The document that contains the Element will be modified! Data will change!

Specified by:
decrypt in class CryptEngine
Parameters:
data - to be decrypted
Throws:
EncryptionException

generateDataEncryptionKey

private static javax.crypto.SecretKey generateDataEncryptionKey()
                                                         throws java.lang.Exception
Get a key to be used for encrypting the element. Here we are generating an AES key.

Throws:
java.lang.Exception

encrypt

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

Specified by:
encrypt in class CryptEngine
Parameters:
data - to be encrypted
Throws:
EncryptionException

getPublicKey

public byte[] getPublicKey()
Specified by:
getPublicKey in class CryptEngine

getPublicKeyString

public java.lang.String getPublicKeyString()
Specified by:
getPublicKeyString in class CryptEngine

checkSignature

public boolean checkSignature(org.w3c.dom.Element data)
                       throws EncryptionException
Description copied from class: CryptEngine
decodes the signature with the public key and then checks it

Specified by:
checkSignature in class CryptEngine
Parameters:
data - to check
Returns:
true, if signature is ok
Throws:
EncryptionException

sign

public void sign(org.w3c.dom.Element data)
          throws EncryptionException
Description copied from class: CryptEngine
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.

Specified by:
sign in class CryptEngine
Parameters:
data - to be signed
Throws:
EncryptionException