Agent System POND 1.2 (28.2.2002)

FIM.Util.Crypto
Class SealedAndSignedObject

java.lang.Object
  |
  +--FIM.Util.Crypto.SealedAndSignedObject
All Implemented Interfaces:
Serializable

public class SealedAndSignedObject
extends Object
implements Serializable

An object to contain another object which is first signed and afterwards encrypted. The data-object must be serializable.
Based on SignedObject and SealedObject.

Version:
1.0, 1.7.2000
Author:
Michael Sonntag
See Also:
SignedObject, SealedObject, Serialized Form

Field Summary
(package private)  String cryptAlgorithm
          The algorithm used for encryption.
(package private)  Serializable cryptData
          Additional data to tell the recipient e. g. which public key was used for encryption.
(package private)  javax.crypto.SealedObject encrypted
          The object containing the encrypted (and previously signed) data-object.
 
Constructor Summary
SealedAndSignedObject(javax.crypto.Cipher c, String cryptAlgo, Serializable cryptData, Signature s, PrivateKey pk, Certificate[] certs, Serializable content)
          Creates a new encrypted and signed object with a certain data-object.
 
Method Summary
 Certificate[] getCertificates(javax.crypto.Cipher c)
          Retrieve the certificates associated with the signature.
 String getEncryptionAlgorithm()
          Retrieve the algorithm used for encrypting the data.
 Serializable getEncryptionData()
          Retrieve the additional data stored with encrypted object.
 Object getObject(javax.crypto.Cipher c)
          Retrieve the encrypted data-object.
 String getSignAlgorithm(javax.crypto.Cipher c)
          Retrieve the algorithm used for signing the data.
 boolean verify(javax.crypto.Cipher c, KeyStore ks)
          Verifies the signature of the object using a keystore.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

encrypted

javax.crypto.SealedObject encrypted
The object containing the encrypted (and previously signed) data-object.

cryptAlgorithm

String cryptAlgorithm
The algorithm used for encryption.

cryptData

Serializable cryptData
Additional data to tell the recipient e. g. which public key was used for encryption.
Constructor Detail

SealedAndSignedObject

public SealedAndSignedObject(javax.crypto.Cipher c,
                             String cryptAlgo,
                             Serializable cryptData,
                             Signature s,
                             PrivateKey pk,
                             Certificate[] certs,
                             Serializable content)
                      throws SignatureException,
                             InvalidKeyException,
                             IOException,
                             javax.crypto.IllegalBlockSizeException
Creates a new encrypted and signed object with a certain data-object.
Parameters:
c - the ciher to use for encrypting the object
cryptAlgo - the algorithm to be used for encryption
cryptData - the additional data as information for the recipient
s - the signature to use for signing the object
pk - the private key to be used for signing
certs - the certificate chain for the public key to be used for verification of the signature
content - the data-object to be signed and encrypted
Throws:
SignatureException - if an error occured during singing the content
InvalidKeyException - if the key could not be used for signing
IOException - If an error occured during serialization of the data object or the signed content
javax.crypto.IllegalBlockSizeException - if an error occured during encrypting the signed content
Method Detail

getEncryptionAlgorithm

public String getEncryptionAlgorithm()
Retrieve the algorithm used for encrypting the data.
Returns:
the encryption algorithm

getEncryptionData

public Serializable getEncryptionData()
Retrieve the additional data stored with encrypted object. E. g. which public key was used.
Returns:
the additional data

getSignAlgorithm

public String getSignAlgorithm(javax.crypto.Cipher c)
                        throws ClassNotFoundException,
                               IOException,
                               javax.crypto.BadPaddingException,
                               javax.crypto.IllegalBlockSizeException
Retrieve the algorithm used for signing the data. This is only accessible after decryption, so a initialized cipher must be provided.
Parameters:
c - the Cipher for decrypting the data
Returns:
the signature algorithm
Throws:
ClassNotFoundException - if the object could not be decrypted because a class was not found
IOException - IO error decrypting the object
javax.crypto.BadPaddingException - padding error decrypting the object
javax.crypto.IllegalBlockSizeException - block size error decrypting the object

getObject

public Object getObject(javax.crypto.Cipher c)
                 throws ClassNotFoundException,
                        IOException,
                        javax.crypto.BadPaddingException,
                        javax.crypto.IllegalBlockSizeException
Retrieve the encrypted data-object. A initialized cipher must be provided.
Parameters:
c - the Cipher for decrypting the data
Returns:
the stored object
Throws:
ClassNotFoundException - if the object could not be decrypted because a class was not found
IOException - IO error decrypting the object
javax.crypto.BadPaddingException - padding error decrypting the object
javax.crypto.IllegalBlockSizeException - block size error decrypting the object

getCertificates

public Certificate[] getCertificates(javax.crypto.Cipher c)
                              throws ClassNotFoundException,
                                     IOException,
                                     javax.crypto.BadPaddingException,
                                     javax.crypto.IllegalBlockSizeException
Retrieve the certificates associated with the signature. They are only accessible after decryption, so a initialized cipher must be provided.
Parameters:
c - the Cipher for decrypting the data
Returns:
the certificate chain of the signature
Throws:
ClassNotFoundException - if the object could not be decrypted because a class was not found
IOException - IO error decrypting the object
javax.crypto.BadPaddingException - padding error decrypting the object
javax.crypto.IllegalBlockSizeException - block size error decrypting the object

verify

public boolean verify(javax.crypto.Cipher c,
                      KeyStore ks)
               throws ClassNotFoundException,
                      IOException,
                      javax.crypto.BadPaddingException,
                      javax.crypto.IllegalBlockSizeException,
                      InvalidKeyException,
                      SignatureException,
                      NoSuchAlgorithmException
Verifies the signature of the object using a keystore. To get access, it must be decrypted so a initialized cipher must be provided.
Parameters:
c - the cipher used for decrypting the object
ks - the key store used for verification
Throws:
ClassNotFoundException - if the object could not be decrypted because a class was not found
IOException - IO error decrypting the object
javax.crypto.BadPaddingException - padding error decrypting the object
javax.crypto.IllegalBlockSizeException - block size error decrypting the object
SignatureException - if signature verification failed
InvalidKeyException - if the verification key is invalid
NoSuchAlgorithmException - if the algorihtm used for signing is not available

Agent System POND 1.2 (28.2.2002)

Submit a bug

Copyright 2001,2002 Michael Sonntag & Institute for Information Processing and Microprocessor Technology (FIM), Johannes-Kepler-University Linz, Altenbergerstr. 69, A-4040 Linz, Austria.