Class semper.statement.Statement
All Packages Class Hierarchy This Package Previous Next Index
Class semper.statement.Statement
java.lang.Object
|
+----semper.statement.Statement
- public class Statement
- extends Object
- implements StatementConstants, Streamable, CryptoConstants
A Statement 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.32 $ $Date: 1997/04/17 10:55:22 $
- Author:
- Jesper Drud Nielsen ([email protected]), Torben Pryds Pedersen ([email protected])
- See Also:
- CryptoMan
-
Statement()
- Creates a new, empty Statement object.
-
Statement(byte[], String, String)
- Creates a new Statement object containing message, senderID and RecipientId.
-
Statement(Streamable, String, String)
- Creates a new Statement object containing message, senderID and RecipientId.
-
Statement(String, String, String)
- Creates a new Statement object containing message, senderID and RecipientId.
-
decipher(CryptoKeyInfo)
- Decipher an encrypted statement.
-
encipher(CryptoKeyInfo)
- Encipher a statement using a conventional crypto system.
-
generateMAC(CryptoKeyInfo, Date, int)
- Generate a (keyed) MAC value on a statement object.
-
generateSignature(CryptoKeyInfo, int, Certificate)
- Sign a statement.
-
getAlg()
- Returns the cryptographic algorithm used in the Statement.
-
getDate()
- Get the date.
-
getPlainStreamable()
- Returns the message in the Statement as a Streamable provided the Statement is a plaintext
and it was constructed using a Streamable.
-
getPlainString()
- Returns the message in the Statement as a String provided the Statement was constructed using
a String, which is either in plain, has been signed or a MAC value has been appended.
-
getPlaintext()
- Returns the message in the Statement provided it is a plaintext.
-
getRecipient()
- Get the information �contained in the Statement about the recipient.
-
getSender()
- Get the information �contained in the Statement about the sender.
-
myStreamSize()
- Returns the size of the Statement object when externalized.
-
pkDecipher(CryptoKeyInfo)
- Decipher a pkEnciphered statement object.
-
pkEncipher(CryptoKeyInfo, int, int)
- Encipher a statement object under a random, conventional key using encipher,
and include this key enciphered under a public key.
-
printContents()
- Temporary function printing the message and securityVal of a Statement.
-
readObject(StreamInputInterface)
- Internalizes a Statement object.
-
setDate(Date)
- Set the date.
-
setRecipient(String)
- Inserts identification of the recipient in Statement.
-
setSender(String)
- Inserts identification of the sender in Statement.
-
verifyMAC(Date, Date, CryptoKeyInfo)
- Verify a (keyed) MAC value on a statement object.
-
verifySignature(Date, Date, CryptoKeyInfo)
- Verify the signature in a signed statement.
-
writeObject(StreamOutputInterface)
- Externalizes a Statement object.
Statement
public Statement()
- Creates a new, empty Statement object.
A new Statement 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 reipient of a
linearized statement, who will make an empty statement and initialise
its contents from a stream.
Statement
public Statement(byte newMessage[],
String newSenderId,
String newRecipientId)
- 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
Statement
public Statement(String newMessage,
String newSenderId,
String newRecipientId)
- 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. The message is stored
as an array of bytes.
- Parameters:
- newMessage - The plaintext message as a String to insert in the Statement
- newSenderId - The sender identification
- newRecipientId - The recipient identification
Statement
public Statement(Streamable newMessage,
String newSenderId,
String newRecipientId) throws StatementManException
- 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. The message is stored
as an array of bytes.
- Parameters:
- newMessage - The plaintext message as a Streamable object to insert in the Statement
- newSenderId - The sender identification
- newRecipientId - The recipient identification
- Throws: StatementManException
- if the new message could not be serialised
getPlaintext
public byte[] getPlaintext() throws StatementManException
- Returns the message in the Statement provided it is a plaintext. This method only makes
sense if the Statement is constructed using anarray of bytes, since otherwise the
result of this operation returns an array of bytes which depends on the actual implementation.
- Returns:
- the array of butes contained in the plaintext
- Throws: StatementManException
- if the statement is not a plaintext or the message is not
an array of bytes.
getPlainString
public String getPlainString() throws StatementManException
- Returns the message in the Statement as a String provided the Statement was constructed using
a String, which is either in plain, has been signed or a MAC value has been appended.
- Returns:
- A String corresponding to the message in the statement
- Throws: StatementManException
- if the statement is encrypted or does not contain a String message
getPlainStreamable
public Streamable getPlainStreamable() throws StatementManException
- Returns the message in the Statement as a Streamable provided the Statement is a plaintext
and it was constructed using a Streamable.
- Returns:
- A Streamable corresponding to the message in the statement
- Throws: StatementManException
- if the statement is not a plaintext
or the Statement was not initially constructed with a Streamable
encipher
public int 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
- Returns:
- 0 on succes
- Throws: StatementManException
- if the statement could not be enciphered
- See Also:
- decipher, CryptoConstants
decipher
public int 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 (in the securityVal attribute) 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)
- Returns:
- 0 on success
- Throws: StatementManException
- if the statement could not be deciphered
- See Also:
- encipher
generateSignature
public void generateSignature(CryptoKeyInfo newKeyInfo,
int hashAlg,
Certificate newCertificate) throws StatementManException
- Sign a statement.
Writes a timestamp in the Statement, linearises it and hashes it using the ahsh function
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, the signature and possible originator and
recipient information if this was in the Statement initially.
- 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.
- Returns:
- 0 on success, otherwise an erro code
- Throws: StatementManException
- if signature generation failed
- See Also:
- verifySignature
verifySignature
public int verifySignature(Date timewindowstart,
Date timewindowend,
CryptoKeyInfo trustedPublicKey) throws StatementManException
- Verify the signature in a signed statement.
Verifies the signature in securityVal against the message. After verification,
the contents of message is delinearized into the statement. Thus this method
changes the Statement!
- Parameters:
- timewindowstart - the earliest signature date to accept
- timewindowend - the lates signature date to accept
- trustedPublicKey - is used to verify the signature. If no key is
supplied the public key in the certificate is used.
- Returns:
- RC_OK if the signature is valid, RC_INVALIDCERTIFICATE if the
an invalid certificate (!= null) is in the Statement, RC_INVSTATEMENTOP if
the Statement is not signed, RC_NOPUBLICKEY if no public key is available
(neither in certificate nor a trusted public key) and RC_SIGNATURENOTBORN
and RC_SIGNATURETOOOLD if the signature is too old or too new, respectively.
- Throws: StatementManException
- if something went wrong during the verification
- See Also:
- generateSignature
generateMAC
public int generateMAC(CryptoKeyInfo newKeyInfo,
Date newdate,
int 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
- newdate - is a timestamp of the operation
- MACalg - describes the MAC algorithm to be used
- Returns:
- 0 on success
- Throws: StatementManException
- if the MAC value could not be generated
- See Also:
- verifyMAC
verifyMAC
public int verifyMAC(Date timewindowstart,
Date timewindowend,
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 on which the MAC was generated is delinearized into the statement.
- Returns:
- 0 on success
- Throws: StatementManException
- if the MAC could not be verified
- See Also:
- generateMAC
pkEncipher
public int pkEncipher(CryptoKeyInfo newKeyInfo,
int convAlg,
int 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
- Returns:
- 0
- Throws: StatementManException
- if the encryption fails
- See Also:
- encipher, pkDecipher
pkDecipher
public int 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
- Returns:
- returncode (0 for success)
- Throws: StatementManException
- if the statement could not be deciphered
- See Also:
- pkEncipher, decipher
setDate
public void setDate(Date newDate)
- Set the date.
This function can be used to put a timestamp in a statement.
- Parameters:
- newDate - is the Date to be set in a Statement
getDate
public Date getDate()
- Get the date.
- Returns:
- time stamp in the statement (null if there is no time stamp)
getAlg
public int getAlg()
- Returns the cryptographic algorithm used in the Statement.
In case more operations have been done the last one is returned.
- Returns:
- an integer describing the algorithm used to protect the statement
(if the statement is not protected 0 is returned)
setSender
public void setSender(String sender)
- Inserts identification of the sender in Statement. A null string clears all
information about the sender.
- Parameters:
- sender - identifies the sender
- See Also:
- getSender
getSender
public String getSender()
- Get the information �contained in the Statement about the sender.
A null string means that the
statement contains no information about the sender.
- Returns:
- the sender identification
- See Also:
- setSender
setRecipient
public void setRecipient(String recipient)
- Inserts identification of the recipient in Statement. A null string clears all
information about the recipient.
- Parameters:
- the - recipient identification
- See Also:
- getRecipient
getRecipient
public String getRecipient()
- Get the information �contained in the Statement about the recipient.
A null string means that the statement contains no information about the recipient.
- Returns:
- the recipient identification
- See Also:
- setRecipient
writeObject
public void writeObject(StreamOutputInterface s) throws StreamIOException
- Externalizes a Statement object. By calling this method a Statement will
be written to the IO stream.
- Returns:
- no return value
- Throws: StreamIOException
- if linearisation fails
readObject
public void readObject(StreamInputInterface s) throws StreamIOException
- Internalizes a Statement object. By calling this method a Statement will
be read from the IO stream.
- Returns:
- no return value
- Throws: IOException
- If the input data is corrupt.
myStreamSize
public int myStreamSize() throws StreamIOException
- Returns the size of the Statement object when externalized.
- Returns:
- Size of externalized object
- Throws: IOException
- if the correct sixe could not be computed.
printContents
public void printContents()
- Temporary function printing the message and securityVal of a Statement. This function
is only supplied for testing.
All Packages Class Hierarchy This Package Previous Next Index