Additional top-level class in compilation unit: extObjectInputStream.
Given any Serializable object, one can create a
SealedObject that encapsulates the original object, in serialized
format (i.e., a "deep copy"), and seals (encrypts) its serialized contents,
using a cryptographic algorithm such as AES, to protect its
confidentiality. The encrypted content can later be decrypted (with
the corresponding algorithm using the correct decryption key) and
de-serialized, yielding the original object.
Note that the Cipher object must be fully initialized with
the correct algorithm, key, padding scheme, etc., before being applied
to a SealedObject.
The original object that was sealed can be recovered in two different ways:
getObject
method that takes a Cipher object.
This method requires a fully initialized Cipher object,
initialized with the
exact same algorithm, key, padding scheme, etc., that were used to seal the
object.
This approach has the advantage that the party who unseals the sealed object does not require knowledge of the decryption key. For example, after one party has initialized the cipher object with the required decryption key, it could hand over the cipher object to another party who then unseals the sealed object.
getObject methods
that take a Key object.
In this approach, the getObject method creates a cipher
object for the appropriate decryption algorithm and initializes it with the
given decryption key and the algorithm parameters (if any) that were stored
in the sealed object.
This approach has the advantage that the party who unseals the object does not need to keep track of the parameters (e.g., an IV) that were used to seal the object.
Cipher
| Modifier and Type | Field and Description |
|---|---|
| protected byte[] | encodedParams
The cryptographic parameters used by the sealing |
| private byte[] | encryptedContent
The serialized object contents in encrypted format. |
| private String | paramsAlg
The algorithm of the parameters used. |
| private final String | sealAlg
The algorithm that was used to seal this object. |
| pack-priv static final long |
| Access | Constructor and Description |
|---|---|
| public | SealedObject(Serializable
the object to be sealed; can be object, Cipher null.the cipher used to seal the object. c)Constructs a |
| protected | SealedObject(SealedObject
a so)SealedObject objectConstructs a |
| Modifier and Type | Method and Description |
|---|---|
| public final String | Returns: the algorithm that was used to seal this object.Returns the algorithm that was used to seal this object. |
| private ObjectInputStream | |
| public final Object | |
| public final Object | |
| public final Object | |
| private void | readObject(ObjectInputStream
the object input stream. s)Restores the state of the |
| private Object |
| encodedParams | back to summary |
|---|---|
| protected byte[] encodedParams The cryptographic parameters used by the sealing
That is, | |
| encryptedContent | back to summary |
|---|---|
| private byte[] encryptedContent The serialized object contents in encrypted format. | |
| paramsAlg | back to summary |
|---|---|
| private String paramsAlg The algorithm of the parameters used. | |
| sealAlg | back to summary |
|---|---|
| private final String sealAlg The algorithm that was used to seal this object. | |
| serialVersionUID | back to summary |
|---|---|
| pack-priv static final long serialVersionUID
| |
| SealedObject | back to summary |
|---|---|
| public SealedObject(Serializable object, Cipher c) throws IOException, IllegalBlockSizeException Constructs a The given object is serialized, and its serialized contents are
encrypted using the given Any algorithm parameters that may be used in the encryption
operation are stored inside the new
| |
| SealedObject | back to summary |
|---|---|
| protected SealedObject(SealedObject so) Constructs a
| |
| getAlgorithm | back to summary |
|---|---|
| public final String getAlgorithm() Returns the algorithm that was used to seal this object.
| |
| getExtObjectInputStream | back to summary |
|---|---|
| private ObjectInputStream getExtObjectInputStream(Cipher c) throws BadPaddingException, IllegalBlockSizeException, IOException | |
| getObject | back to summary |
|---|---|
| public final Object getObject(Key key) throws IOException, ClassNotFoundException, NoSuchAlgorithmException, InvalidKeyException Retrieves the original (encapsulated) object. This method creates a cipher for the algorithm that had been used in
the sealing operation.
If the default provider package provides an implementation of that
algorithm, a The encapsulated object is unsealed and de-serialized, before it is returned.
| |
| getObject | back to summary |
|---|---|
| public final Object getObject(Cipher c) throws IOException, ClassNotFoundException, IllegalBlockSizeException, BadPaddingException Retrieves the original (encapsulated) object. The encapsulated object is unsealed (using the given
| |
| getObject | back to summary |
|---|---|
| public final Object getObject(Key key, String provider) throws IOException, ClassNotFoundException, NoSuchAlgorithmException, NoSuchProviderException, InvalidKeyException Retrieves the original (encapsulated) object. This method creates a cipher for the algorithm that had been used in
the sealing operation, using an implementation of that algorithm from
the given The encapsulated object is unsealed and de-serialized, before it is returned.
| |
| readObject | back to summary |
|---|---|
| private void readObject(ObjectInputStream s) throws IOException, ClassNotFoundException Restores the state of the
| |
| unseal | back to summary |
|---|---|
| private Object unseal(Key key, String provider) throws IOException, ClassNotFoundException, NoSuchAlgorithmException, NoSuchProviderException, InvalidKeyException, IllegalBlockSizeException, BadPaddingException | |