All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class semper.statement.StatementMemory

java.lang.Object
   |
   +----semper.statement.Statement
           |
           +----semper.statement.StatementMemory

public class StatementMemory
extends Statement
A StatementMemory is a datastrucutre containing information which must be protected. The contents of a statement is unprotected, encrypted (symmetric or asymmetric), digitally signed or authenticated using a MAC. It is possible to have several layers or protection by doing more operations. The actual cryptographic operations are done by the crypto manager. A Statement may contain various information such as identification of originator and recipient, a time stamp (currently made using java.util.Date).

Version:
$Revision: 1.9 $ $Date: 1998/07/17 09:13:01 $
Author:
Jesper Drud Nielsen (drud@cryptomathic.dk), Thomas Sepstrup Nielsen (tsn@cryptomathic.dk), Torben Pryds Pedersen (tpp@cryptomathic.dk)
See Also:
CryptoMan, Statement

Variable Index

 o message

Constructor Index

 o StatementMemory()
Creates a new, empty StatementMemory object.
 o StatementMemory(byte[])
Creates a new Statement object containing message.
 o StatementMemory(byte[], String, String)
Creates a new Statement object containing message, senderID and RecipientId. Deprecated.

Method Index

 o copyFrom(StatementMemory)
 o decipher(CryptoKeyInfo)
Decipher an encrypted statement.
 o encipher(CryptoKeyInfo)
Encipher a statement using a conventional crypto system.
 o generateMAC(CryptoKeyInfo, MACAlgorithm)
Generate a (keyed) MAC value on a statement object.
 o generateSignature(CryptoKeyInfo, HashingAlgorithm, Certificate)
Sign a statement.
 o getPlainText()
Returns the message using which this Statement was initiated.
 o getPrevious()
If a given Statement is obtained by making an operation on a Statement (sign, MAC) then this method can be used to retrieve that previous Statement.
 o pkDecipher(CryptoKeyInfo)
Decipher a pkEnciphered statement object.
 o pkEncipher(CryptoKeyInfo, ConventionalAlgorithm, KeyPadding)
Encipher a statement object under a random, conventional key using encipher(), and include this key enciphered under a public key.
 o printContents()
Temporary function printing the message and securityVal of a Statement.
 o printMessage()
Temporary function printing the message.
 o statementFromBytes(byte[])
 o statementToBytes()
 o verifyMAC(CryptoKeyInfo)
Verify a (keyed) MAC value on a statement object.
 o verifySignature(CryptoKeyInfo)
Verify the signature in a signed statement..

Variables

 o message
 protected byte message[]

Constructors

 o StatementMemory
 public StatementMemory()
Creates a new, empty StatementMemory object. A new StatementMemory object is created. All of its attributes are empty, except that its message_type attribute indicates that the Statement is empty. This method is intended to for use by the recipient of a linearized statement, who will make an empty statement and initialise its contents from a stream.

 o StatementMemory
 public StatementMemory(byte newMessage[])
Creates a new Statement object containing message.

Parameters:
newMessage - The plaintext message to insert in the Statement
 o StatementMemory
 public StatementMemory(byte newMessage[],
                        String newSenderId,
                        String newRecipientId)
Note: StatementMemory() is deprecated. Sender and Recepient no longer meaningful in class. Instead you should use constructor without these parameters.

Creates a new Statement object containing message, senderID and RecipientId. A new Statement object containing a given plaintext and having a sender identification and recipient identification.

Parameters:
newMessage - The plaintext message to insert in the Statement
newSenderId - The sender identification
newRecipientId - The recipient identification

Methods

 o getPlainText
 public Object getPlainText() throws StatementManException
Returns the message using which this Statement was initiated. If the message has been encrypted at some point an exception is thrown. This method is overridden in subclasses to return an object of a class with whcih the Statement was created. If the Statement has been signed/MACed several times this method will retrieve the original message.

Returns:
the array of bytes contained in the plaintext
Throws: StatementManException
if the statement is not a plaintext or the message is not an array of bytes.
Overrides:
getPlainText in class Statement
 o getPrevious
 public Statement getPrevious() throws StatementManException
If a given Statement is obtained by making an operation on a Statement (sign, MAC) then this method can be used to retrieve that previous Statement. if a Statement has not been operated on or the last operation was encryption, then it is not possible to go back.

Returns:
the StatementMemory from which the current was obtained
Throws: StatementManException
if it is not possible to retrieve the last Statement
Overrides:
getPrevious in class Statement
 o encipher
 public void encipher(CryptoKeyInfo newKeyInfo) throws StatementManException
Encipher a statement using a conventional crypto system. Linearises the statement and encrypts it under the key in or designated by newKeyInfo. During this process the Statement is changed in that the message and (if present) the date, sender identification and recipient identification are removed. Instead the Statement contains the ciphertext.

Parameters:
newKeyInfo - identifies the key under which to encipher
Throws: StatementManException
if the statement could not be enciphered
Overrides:
encipher in class Statement
See Also:
decipher, encipher, CryptoConstants
 o decipher
 public void decipher(CryptoKeyInfo convKeyInfo) throws StatementManException
Decipher an encrypted statement. If a decipher key is provided in convKeyInfo, it is used to decipher. Otherwise, a decipher key is derived from the statement objects keyInfo attribute. The ciphertext in the statement is deciphered, and the resulting string is delinearized into the statement.

Parameters:
The - key needed for decryption (if null the key information from the Statement is used)
Throws: StatementManException
if the statement could not be deciphered
Overrides:
decipher in class Statement
See Also:
encipher, decipher
 o generateSignature
 public void generateSignature(CryptoKeyInfo newKeyInfo,
                               HashingAlgorithm hashAlg,
                               Certificate newCertificate) throws StatementManException
Sign a statement. Linearises the Statement and hashes it using the hash algorithm given as input parameter. A signature on the hash value is generated using the key in newKeyInfo. Afterwards the statement contains the linearised statement (before hashing), identification of the key (a certificate on the public key if supplied as input) used to sign and the signature .

Parameters:
newKeyInfo - the secret signature key
hashAlg - designates the hashing algorithm to be used (if a DSA signature is used SHS-1 will be used, overwriting ths parameter)
newCertificate - is the certificate to be added to the statement.
Throws: StatementManException
if signature generation failed
Overrides:
generateSignature in class Statement
See Also:
verifySignature
 o verifySignature
 public boolean verifySignature(CryptoKeyInfo trustedPublicKey) throws StatementManException
Verify the signature in a signed statement.. This method DOES NOT alter the Statement. To obtain the Statemen, which was originally signed, use getPrevious().

Parameters:
trustedPublicKey - is used to verify the signature. If no key is supplied the public key in the certificate is used.
Returns:
true if the signture is valid with respect to the given key.
Throws: StatementManException
if something went wrong during the verification
Overrides:
verifySignature in class Statement
See Also:
generateSignature, getPrevious
 o generateMAC
 public void generateMAC(CryptoKeyInfo newKeyInfo,
                         MACAlgorithm MACalg) throws StatementManException
Generate a (keyed) MAC value on a statement object. Linearize the statement into the message attribute. Generate a MAC value and write it in securityVal. Information about the used key is stored in the resulting Statement.

Parameters:
newKeyInfo - the key to use during the MAC operation
MACalg - describes the MAC algorithm to be used
Throws: StatementManException
if the MAC value could not be generated
Overrides:
generateMAC in class Statement
See Also:
verifyMAC, generateMAC
 o verifyMAC
 public boolean verifyMAC(CryptoKeyInfo newKeyInfo) throws StatementManException
Verify a (keyed) MAC value on a statement object. Retrieve the MAC key using the keyInfo attribute and verify the MAC using this key. The statement is NOT CHANGED during verification. To get the Statement which was originally authenticated, use getPrevious().

Parameters:
newKeyInfo - the key to verify MAC with
Returns:
true if the MAC value is correct with respect to the key.
Throws: StatementManException
if the MAC could not be verified
Overrides:
verifyMAC in class Statement
See Also:
generateMAC, getPrevious
 o pkEncipher
 public void pkEncipher(CryptoKeyInfo newKeyInfo,
                        ConventionalAlgorithm convAlg,
                        KeyPadding keyEncryption) throws StatementManException
Encipher a statement object under a random, conventional key using encipher(), and include this key enciphered under a public key.

Parameters:
newKeyInfo - is the public key to be used for encryption
convAlg - the conventional algorithm to be used (0 indicates no conventional encryption)
keyEncryption - describes the way the conventional key is encrypted
Throws: StatementManException
if the encryption fails
Overrides:
pkEncipher in class Statement
See Also:
encipher, pkDecipher
 o pkDecipher
 public void pkDecipher(CryptoKeyInfo secretKey) throws StatementManException
Decipher a pkEnciphered statement object. The enciphered conventinal key is deciphered using the secret key supplied secret (asymmetric) key. The resulting conventional key is used to decipher the statement using decipher.

Parameters:
newKeyInfo - is the key to be used for decryption
Throws: StatementManException
if the statement could not be deciphered
Overrides:
pkDecipher in class Statement
See Also:
pkEncipher, decipher
 o statementToBytes
 protected byte[] statementToBytes() throws StatementManException
 o statementFromBytes
 protected void statementFromBytes(byte _byteArray[]) throws StatementManException
 o copyFrom
 public void copyFrom(StatementMemory src)
 o printMessage
 protected void printMessage()
Temporary function printing the message. should be Overridden in subclases.

 o printContents
 public void printContents()
Temporary function printing the message and securityVal of a Statement. This function is only supplied for testing.

Overrides:
printContents in class Statement

All Packages  Class Hierarchy  This Package  Previous  Next  Index