public class JceMasterKey extends MasterKey<JceMasterKey>
MasterKey
backed by one (or more) JCE Key
s. Instances of this should
only be acquired using getInstance(SecretKey, String, String, String)
or getInstance(PublicKey, PrivateKey, String, String, String)
.Modifier | Constructor and Description |
---|---|
protected |
JceMasterKey(String providerName,
String keyId,
JceKeyCipher jceKeyCipher) |
Modifier and Type | Method and Description |
---|---|
DataKey<JceMasterKey> |
decryptDataKey(CryptoAlgorithm algorithm,
Collection<? extends EncryptedDataKey> encryptedDataKeys,
Map<String,String> encryptionContext)
Iterates through
encryptedDataKeys and returns the first one which can be successfully
decrypted. |
DataKey<JceMasterKey> |
encryptDataKey(CryptoAlgorithm algorithm,
Map<String,String> encryptionContext,
DataKey<?> dataKey)
Returns a new copy of the provided
dataKey which is protected by this MasterKey
for use with algorithm and associated with the provided encryptionContext . |
DataKey<JceMasterKey> |
generateDataKey(CryptoAlgorithm algorithm,
Map<String,String> encryptionContext)
|
static JceMasterKey |
getInstance(PublicKey wrappingKey,
PrivateKey unwrappingKey,
String provider,
String keyId,
String wrappingAlgorithm)
Returns a
JceMasterKey backed by the asymmetric key pair unwrappingKey and
wrappingKey using wrappingAlgorithm . |
static JceMasterKey |
getInstance(SecretKey key,
String provider,
String keyId,
String wrappingAlgorithm)
Returns a
JceMasterKey backed by the symmetric key key using wrappingAlgorithm . |
String |
getKeyId() |
String |
getProviderId() |
canProvide, equals, getDefaultProviderId, getMasterKey, getMasterKeysForEncryption, hashCode, toString
buildCannotDecryptDksException, buildCannotDecryptDksException, buildCannotDecryptDksException, getMasterKey
protected JceMasterKey(String providerName, String keyId, JceKeyCipher jceKeyCipher)
public static JceMasterKey getInstance(SecretKey key, String provider, String keyId, String wrappingAlgorithm)
JceMasterKey
backed by the symmetric key key
using wrappingAlgorithm
. Currently "AES/GCM/NoPadding
" is the only supported value for
symmetric wrappingAlgorithm
s.key
- key used to wrap/unwrap (encrypt/decrypt) DataKey
sprovider
- keyId
- wrappingAlgorithm
- public static JceMasterKey getInstance(PublicKey wrappingKey, PrivateKey unwrappingKey, String provider, String keyId, String wrappingAlgorithm)
JceMasterKey
backed by the asymmetric key pair unwrappingKey
and
wrappingKey
using wrappingAlgorithm
. Currently only RSA algorithms are
supported for asymmetric wrappingAlgorithm
s. If unwrappingKey
is null
then the returned JceMasterKey
can only be used for encryption.public String getProviderId()
getProviderId
in class MasterKey<JceMasterKey>
public String getKeyId()
getKeyId
in class MasterKey<JceMasterKey>
public DataKey<JceMasterKey> generateDataKey(CryptoAlgorithm algorithm, Map<String,String> encryptionContext)
MasterKey
DataKey
which is protected by this MasterKey
for use with
algorithm
and associated with the provided encryptionContext
.generateDataKey
in class MasterKey<JceMasterKey>
public DataKey<JceMasterKey> encryptDataKey(CryptoAlgorithm algorithm, Map<String,String> encryptionContext, DataKey<?> dataKey)
MasterKey
dataKey
which is protected by this MasterKey
for use with algorithm
and associated with the provided encryptionContext
.encryptDataKey
in class MasterKey<JceMasterKey>
public DataKey<JceMasterKey> decryptDataKey(CryptoAlgorithm algorithm, Collection<? extends EncryptedDataKey> encryptedDataKeys, Map<String,String> encryptionContext) throws UnsupportedProviderException, AwsCryptoException
MasterKeyProvider
encryptedDataKeys
and returns the first one which can be successfully
decrypted.decryptDataKey
in class MasterKeyProvider<JceMasterKey>
null
UnsupportedProviderException
- if the encryptedDataKey
is associated with an
unsupported providerCannotUnwrapDataKeyException
- if the encryptedDataKey
cannot be decryptedAwsCryptoException
Copyright © 2023. All rights reserved.