Class semper.crypto.CryptoKeyInfo
All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class semper.crypto.CryptoKeyInfo

java.lang.Object
   |
   +----semper.crypto.CryptoKeyInfo

public class CryptoKeyInfo
extends Object
implements CryptoConstants, Streamable
CryptoKeyInfo implements a datastructure containing all keys used internally in SEMPER. Thus external modules do not need to use this structure unless they want to use the key inside SEMPER as well. See the overview for more details on this. A CryptoKeyInfo object contains the following information on a key: For some asymmetric keys part of the key is common to many key pairs. This is, for example, the case in ElGamal like systems (such as DSS), where the same prime and generator can be used by everyone. In order to avoid storing such a common part of the key several times a CryptoKeyInfo object may contain a pointer to the common part of the key.

Finally the object may contain a capability needed for access control to the key. This is not implemented yet, though.

Version:
$Revision: 1.26 $ $Date: 1997/04/11 15:20:17 $
Author:
Jesper Drud Nielsen ([email protected]), Torben Pryds Pedersen ([email protected])
See Also:
Statement

Constructor Index

 o CryptoKeyInfo()
Creates a new, empty key information object.
 o CryptoKeyInfo(AccessName, byte[], CryptoKeyInfo, int, Capability)
Creates a new key information object with variables initialised by the parameters.
 o CryptoKeyInfo(CryptoKeyInfo)
Creates a new object based on the values of a given one.

Method Index

 o clearKeyId()
Deletes the key identifier from the object.
 o decryptKeyVal(CryptoKeyInfo)
This service decrypts the key value under the key given.
 o encryptKeyVal(CryptoKeyInfo)
This service encrypts the key value under the key given.
 o equals(CryptoKeyInfo)
Compares the CryptoKeyInfo with another CryptoKeyInfo.
 o getAlg()
Find the algorithm for which this key can be used.
 o getCap()
 o getCommonKey()
Returns the value of the common key of the object.
 o getCommonKeyInfo()
Returns the common key CryptoKeyInfo of the object.
 o getKeyId()
Returns the key identifier in the object.
 o getKeyVal(boolean, CryptoKeyInfo)
Returns the key value stored in the object.
 o getLength()
Returns the block length for the conventional key.
 o myStreamSize()
Finds the expected number of bytes needed to externalize the object to s.
 o printContents()
 o readObject(StreamInputInterface)
Initialise a CryptoKeyInfo with values read from an io stream (SourceStream)
 o setAlg(int)
Sets the algorithm identifier of the object
 o setCap(Capability)
Sets the capability of the object if allowed by the present capability.
 o setCommonKeyInfo(CryptoKeyInfo)
Sets the common key of the object.
 o setKeyId(AccessName)
Defines the key identifier in the object.
 o setKeyVal(byte[])
Sets the actual key value of the object.
 o storeKeyVal(Date, boolean, CryptoKeyInfo)
Store and protect a key.
 o writeObject(StreamOutputInterface)
Writes the state of the object to an io stream (TargetStream).

Constructors

 o CryptoKeyInfo
  public CryptoKeyInfo()
Creates a new, empty key information object.
 o CryptoKeyInfo
  public CryptoKeyInfo(CryptoKeyInfo oldKeyInfo)
Creates a new object based on the values of a given one.
Parameters:
oldKeyInfo - is used to a new CryptokeyInfo object.
 o CryptoKeyInfo
  public CryptoKeyInfo(AccessName newKeyId,
                       byte newKeyVal[],
                       CryptoKeyInfo newCommon,
                       int newAlgId,
                       Capability newCapability)
Creates a new key information object with variables initialised by the parameters. The supplied key value must not be encrypted.
Parameters:
newKeyID - is the identity of the key
newKeyVal - is the actual key value
newCommon - is the common part of the new key (see above)
identifies - the algorithm for which the key can be used
newCapability - is the capability for protecting the key
Returns:
the new key information object

Methods

 o getKeyVal
  public byte[] getKeyVal(boolean decryptedKey,
                          CryptoKeyInfo masterKey) throws CryptoManException
Returns the key value stored in the object. If necessary the archive is used to retrieve it. This function will decrypt the key if it is encrypted en decryption is explicitly requested. If a user wants to the entire CryptokeyInfo object it can be retrieved immediately from the archive withou this function (given the key identifier).
Parameters:
decryptedKey - if true the key will be decrypted (only if it is encrypted)
masterKey - is the key under which the key should be decrypted (if null the masterKey of CryptoMan will be used).
Returns:
an array of bytes containing the actual key
Throws: CryptoManException
if the capability is locked or problems with archive occur
See Also:
storeKeyVal
 o getCommonKey
  public byte[] getCommonKey() throws CryptoManException
Returns the value of the common key of the object. If necessary the archive is used to retrieve it. No master key is needed as the common key is not protected.
Returns:
key value of the common key
Throws: CryptoManException
if the common key value could not be retrieved
 o getCommonKeyInfo
  public CryptoKeyInfo getCommonKeyInfo()
Returns the common key CryptoKeyInfo of the object. See the overview for more details on this.
Returns:
the common key object
 o setCommonKeyInfo
  public void setCommonKeyInfo(CryptoKeyInfo newComKeyInfo)
Sets the common key of the object. See the overview for more details on this.
Parameters:
newComKeyInfo - is the new common key of the object
Returns:
void
 o setCap
  public void setCap(Capability newCapability) throws CryptoManException
Sets the capability of the object if allowed by the present capability.
Parameters:
newCapabiity - is the new capability of the object
Returns:
void
Throws: CryptoManException
if the old capability could not be unlocked
 o getAlg
  public int getAlg()
Find the algorithm for which this key can be used.
Returns:
the algorithm identifier corresponding to the key information object
 o setAlg
  public void setAlg(int newAlgId)
Sets the algorithm identifier of the object
Parameters:
newAlgId - is the new algorithm identifier.
 o getCap
  public Capability getCap()
Returns:
the capability identifier corresponding to the key information object
 o clearKeyId
  public void clearKeyId()
Deletes the key identifier from the object. Since the key identifier is a local handle, this may be useful if the KeyInfo object is part of Statement which is communicatd to another enntity.
 o setKeyId
  public void setKeyId(AccessName newKeyId)
Defines the key identifier in the object. This may be useful if a Statement is received from nother party and the recipient want to store it. The key identifier should never be changed for an already stored key! Be careful using this function, as the Statement Manager for the moment expects the default names.
Parameters:
newKeyId - is the new value of the key identifier
 o getKeyId
  public AccessName getKeyId()
Returns the key identifier in the object.
Returns:
the key identifier
 o encryptKeyVal
  public boolean encryptKeyVal(CryptoKeyInfo masterKey) throws CryptoManException
This service encrypts the key value under the key given. If a null key is given the master key of the CryptoMan is used. If the key value is already encrypted nothing is done and the method returns false.
Parameters:
masterKey - is the key encryption key (if null masterKey of CryptoMan will be used)
Returns:
false if the key was already encrypted. True otherwise.
Throws: CryptoManException
if problems with archive or encryption
See Also:
getKeyVal
 o decryptKeyVal
  public int decryptKeyVal(CryptoKeyInfo masterKey) throws CryptoManException
This service decrypts the key value under the key given. If a null key is given the master key of the CryptoMan is used. The service returns true if the correct key was obtained (based on redundance in the encrypted key). encrypted nothing is done an the method returns false.
Parameters:
masterKey - is the key encryption key (if null masterKey of CryptoMan will be used)
Returns:
false if the redundancy check failed. True otherwise.
Throws: CryptoManException
if problems with archive or encryption
See Also:
getKeyVal
 o storeKeyVal
  public void storeKeyVal(Date expDate,
                          boolean encryptKey,
                          CryptoKeyInfo masterKey) throws CryptoManException
Store and protect a key. If an expiration date is given as parameter the key value is stored in archive before being deleted. If requested the key is encrypted before being stored. Note that this method works on the given object - not a copy. The key is stored using the keyId as access name. Currently an exception is raised if the key had been stored previously.
Parameters:
expDate - tells for how long the key must be stored in archive
encryptKey - tells if the key should be encrypted before storage, if not, it will be done by the Archive.
masterKey - is the key encryption key (if null masterKey of CryptoMan will be used)
Throws: CryptoManException
if problems with archive or encryption
See Also:
getKeyVal
 o setKeyVal
  public void setKeyVal(byte newKeyVal[]) throws CryptoManException
Sets the actual key value of the object. Can be used to clear the key value of a CryptoKeyInfo object. It is assumed that the key is in clear
Parameters:
newKeyVal - is the new key value to be associated with this object
Returns:
void
Throws: CryptoManException
if the capability could not be unlocked
 o getLength
  public int getLength() throws CryptoManException
Returns the block length for the conventional key.
Returns:
the block length
Throws: CryptoManException
if the key does not designate a supported conventional algorithm
 o writeObject
  public void writeObject(StreamOutputInterface s) throws StreamIOException
Writes the state of the object to an io stream (TargetStream). Caveat: The actual key value is also written if not explcicitly cleared previously.
Parameters:
s - is the stream the object is written to
Returns:
void
Throws: StreamIOException
if the object could not be serialised
See Also:
readObject
 o readObject
  public void readObject(StreamInputInterface s) throws StreamIOException
Initialise a CryptoKeyInfo with values read from an io stream (SourceStream)
Parameters:
s - is the stream the value is read from
Returns:
void
Throws: StreamIOException
if the object could not be externalised
See Also:
writeObject
 o myStreamSize
  public int myStreamSize() throws StreamIOException
Finds the expected number of bytes needed to externalize the object to s.
Parameters:
s - is the stream the key information is written to
Returns:
number of bytes required
Throws: StreamIOException
if the size could not be computed
See Also:
writeObject
 o equals
  public boolean equals(CryptoKeyInfo key)
Compares the CryptoKeyInfo with another CryptoKeyInfo. the current implementation just verifies if the two object have the same key identifier (as this should be unique).
Parameters:
key - is the CryptoKeyInfo with which to compare
Returns:
true iff keyId's match false otherwise.
 o printContents
  public void printContents()

All Packages  Class Hierarchy  This Package  Previous  Next  Index