All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class semper.statement.StatementFile

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

public class StatementFile
extends Statement
A StatementFile is a datastructure containing reference to a file. The contents of the file and the statement is unprotected, encrypted (symmetric or asymmetric), digitally signed or authenticated using a MAC. It is possible to have several layers of protection by doing more operations. The actual cryptographic operations are done by the crypto manager.

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

Constructor Index

 o StatementFile()
Creates a new, empty StatementFile object.
 o StatementFile(String)
Creates a StatementFile object with a reference to a file.

Method Index

 o copyFrom(StatementFile)
Copy the contents of a StatementFile object to this one.
 o decipher(CryptoKeyInfo)
Decipher the statement.
 o decipher(String, CryptoKeyInfo)
Decipher an encrypted file and the statement.
 o encipher(String, CryptoKeyInfo)
Encipher the file and the statement using a conventional crypto system.
 o generateMAC(CryptoKeyInfo, MACAlgorithm)
Generate a (keyed) MAC value on a file.
 o generateSignature(CryptoKeyInfo, HashingAlgorithm, Certificate)
Sign a file.
 o getPlainText()
Returns the file in the StatementFile object.
 o getPrevious()
If a given StatementFile is obtained by making an operation on a StatementFile (sign, MAC) then this method can be used to retrieve that previous StatementFile.
 o pkDecipher(String, CryptoKeyInfo)
Decipher a pkEnciphered file and the statement object.
 o pkEncipher(String, CryptoKeyInfo, ConventionalAlgorithm, KeyPadding)
Encipher a file and the statement object under a random, conventional key using encipher(), and include this key enciphered under a public key.
 o printContents()
Temporary function printing the file name and securityVal of a Statement.
 o setPlainFile(String)
Sets the file in the StatementFile.
 o statementFromBytes(byte[])
Convert byte array into a StatementFile object.
 o statementToBytes()
"Helper" method to linearize the statement into an array of bytes.
 o verifyMAC(CryptoKeyInfo)
Verify a (keyed) MAC value on a file.
 o verifySignature(CryptoKeyInfo)
Verify the signature in a signed file.

Constructors

 o StatementFile
 public StatementFile()
Creates a new, empty StatementFile object. 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 StatementFile
 public StatementFile(String newFileName)
Creates a StatementFile object with a reference to a file.

Parameters:
newFileName - the file name.

Methods

 o getPlainText
 public Object getPlainText()
Returns the file in the StatementFile object.

Returns:
the file to which the StatementFile object refers to.
Overrides:
getPlainText in class Statement
 o setPlainFile
 public void setPlainFile(String filename)
Sets the file in the StatementFile.

Parameters:
the - file name to which the StatementFile will refer to.
 o getPrevious
 public Statement getPrevious() throws StatementManException
If a given StatementFile is obtained by making an operation on a StatementFile (sign, MAC) then this method can be used to retrieve that previous StatementFile. if a StatementFile has not been operated on or the last operation was encryption, then it is not possible to go back.

Returns:
the StatementFile from which the current was obtained
Throws: StatementManException
if it is not possible to retrieve the last StatementFile
Overrides:
getPrevious in class Statement
 o encipher
 public void encipher(String destFileName,
                      CryptoKeyInfo newKeyInfo) throws StatementManException
Encipher the file and the statement using a conventional crypto system. Encrypt the file that the Statement refers to. Linearise 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:
destFileName - identifies the name of the destination file that will store the encrypted information
newKeyInfo - identifies the key under which to encipher
Throws: StatementManException
if the statement could not be enciphered
See Also:
decipher, encipher, CryptoConstants
 o decipher
 public void decipher(String destFileName,
                      CryptoKeyInfo convKeyInfo) throws StatementManException
Decipher an encrypted file and the 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:
destFileName - identifies the name of the destination file that will store the decrypted information
The - key needed for decryption (if null the key information from the Statement is used)
Throws: StatementManException
if the statement could not be deciphered
See Also:
encipher, decipher
 o decipher
 public void decipher(CryptoKeyInfo convKeyInfo) throws StatementManException
Decipher the 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 file. Hashes the file using the hash algorithm given as input parameter. The hash algorithm used is added to the file's hash value and the result is signed. A signature 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 file. This method DOES NOT alter the Statement. To obtain the Statement, 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 file. Generate a MAC value on the file. The MAC algorithm used is added and the MAC value of the result is stored in securityVal.

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 file. 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(String destFileName,
                        CryptoKeyInfo newKeyInfo,
                        ConventionalAlgorithm convAlg,
                        KeyPadding keyEncryption) throws StatementManException
Encipher a file and the statement object under a random, conventional key using encipher(), and include this key enciphered under a public key.

Parameters:
destFileName - identifies the name of the destination file that will store the encrypted information
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
See Also:
encipher, pkDecipher
 o pkDecipher
 public void pkDecipher(String destFileName,
                        CryptoKeyInfo secretKey) throws StatementManException
Decipher a pkEnciphered file and the 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:
destFileName - identifies the name of the destination file that will store the decrypted information
newKeyInfo - is the key to be used for decryption
Throws: StatementManException
if the statement could not be deciphered
See Also:
pkEncipher, decipher
 o statementToBytes
 public byte[] statementToBytes() throws StatementManException
"Helper" method to linearize the statement into an array of bytes.

Returns:
byte array containing the linearized statement.
Throws: StatementManException
if the statement could not be linearised.
 o statementFromBytes
 public void statementFromBytes(byte _byteArray[]) throws StatementManException
Convert byte array into a StatementFile object.

Throws: StatementManException
if conversion fails.
 o copyFrom
 public void copyFrom(StatementFile src)
Copy the contents of a StatementFile object to this one.

Throws: StatementManException
if conversion fails.
 o printContents
 public void printContents()
Temporary function printing the file name 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