public class WrappedRawMaterials extends AbstractRawMaterials
Other possibly implementations might use a Key-Derivation Function to derive a unique key per record.
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
CONTENT_KEY_ALGORITHM
The key-name in the Description which contains the algorithm used by the content key.
|
static java.lang.String |
ENVELOPE_KEY
The key-name in the Description which which contains the wrapped content key.
|
static java.lang.String |
KEY_WRAPPING_ALGORITHM
The key-name in the Description which contains the algorithm use to wrap content key.
|
protected java.security.Key |
unwrappingKey |
protected java.security.Key |
wrappingKey |
| Constructor and Description |
|---|
WrappedRawMaterials(java.security.Key wrappingKey,
java.security.Key unwrappingKey,
java.security.KeyPair signingPair) |
WrappedRawMaterials(java.security.Key wrappingKey,
java.security.Key unwrappingKey,
java.security.KeyPair signingPair,
java.util.Map<java.lang.String,java.lang.String> description) |
WrappedRawMaterials(java.security.Key wrappingKey,
java.security.Key unwrappingKey,
javax.crypto.SecretKey macKey) |
WrappedRawMaterials(java.security.Key wrappingKey,
java.security.Key unwrappingKey,
javax.crypto.SecretKey macKey,
java.util.Map<java.lang.String,java.lang.String> description) |
| Modifier and Type | Method and Description |
|---|---|
protected javax.crypto.SecretKey |
generateContentKey(java.lang.String algorithm) |
javax.crypto.SecretKey |
getDecryptionKey() |
javax.crypto.SecretKey |
getEncryptionKey() |
protected javax.crypto.SecretKey |
initEnvelopeKey()
Called by the constructors.
|
protected javax.crypto.SecretKey |
unwrapKey(java.util.Map<java.lang.String,java.lang.String> description,
byte[] encryptedKey,
java.lang.String wrappingAlgorithm) |
byte[] |
wrapKey(javax.crypto.SecretKey key,
java.lang.String wrappingAlg) |
getMaterialDescription, getSigningKey, getVerificationKey, setMaterialDescriptionpublic static final java.lang.String KEY_WRAPPING_ALGORITHM
public static final java.lang.String CONTENT_KEY_ALGORITHM
public static final java.lang.String ENVELOPE_KEY
protected final java.security.Key wrappingKey
protected final java.security.Key unwrappingKey
public WrappedRawMaterials(java.security.Key wrappingKey,
java.security.Key unwrappingKey,
java.security.KeyPair signingPair)
throws java.security.GeneralSecurityException
java.security.GeneralSecurityExceptionpublic WrappedRawMaterials(java.security.Key wrappingKey,
java.security.Key unwrappingKey,
java.security.KeyPair signingPair,
java.util.Map<java.lang.String,java.lang.String> description)
throws java.security.GeneralSecurityException
java.security.GeneralSecurityExceptionpublic WrappedRawMaterials(java.security.Key wrappingKey,
java.security.Key unwrappingKey,
javax.crypto.SecretKey macKey)
throws java.security.GeneralSecurityException
java.security.GeneralSecurityExceptionpublic WrappedRawMaterials(java.security.Key wrappingKey,
java.security.Key unwrappingKey,
javax.crypto.SecretKey macKey,
java.util.Map<java.lang.String,java.lang.String> description)
throws java.security.GeneralSecurityException
java.security.GeneralSecurityExceptionpublic javax.crypto.SecretKey getDecryptionKey()
public javax.crypto.SecretKey getEncryptionKey()
protected javax.crypto.SecretKey initEnvelopeKey()
throws java.security.GeneralSecurityException
ENVELOPE_KEY) it extracts it
and returns it. Otherwise it generates a new key, stores a wrapped version in the Description,
and returns the key to the caller.getDecryptionKey() and getEncryptionKey().java.security.GeneralSecurityExceptionpublic byte[] wrapKey(javax.crypto.SecretKey key,
java.lang.String wrappingAlg)
throws java.security.NoSuchAlgorithmException,
javax.crypto.NoSuchPaddingException,
java.security.InvalidKeyException,
javax.crypto.IllegalBlockSizeException
java.security.NoSuchAlgorithmExceptionjavax.crypto.NoSuchPaddingExceptionjava.security.InvalidKeyExceptionjavax.crypto.IllegalBlockSizeExceptionprotected javax.crypto.SecretKey unwrapKey(java.util.Map<java.lang.String,java.lang.String> description,
byte[] encryptedKey,
java.lang.String wrappingAlgorithm)
throws java.security.NoSuchAlgorithmException,
javax.crypto.NoSuchPaddingException,
java.security.InvalidKeyException
java.security.NoSuchAlgorithmExceptionjavax.crypto.NoSuchPaddingExceptionjava.security.InvalidKeyExceptionprotected javax.crypto.SecretKey generateContentKey(java.lang.String algorithm)
throws java.security.NoSuchAlgorithmException
java.security.NoSuchAlgorithmException