Class KeyProviderCryptoExtension
- All Implemented Interfaces:
Closeable,AutoCloseable
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceCryptoExtension is a type of Extension that exposes methods to generate EncryptedKeys and to decrypt the same.static classAn encrypted encryption key (EEK) and related information.Nested classes/interfaces inherited from class org.apache.hadoop.crypto.key.KeyProviderExtension
KeyProviderExtension.ExtensionNested classes/interfaces inherited from class org.apache.hadoop.crypto.key.KeyProvider
KeyProvider.KeyVersion, KeyProvider.Metadata, KeyProvider.Options -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringDesignates an encrypted encryption key, or EEK.static final StringDesignates a decrypted encrypted encryption key, that is, an encryption key (EK).Fields inherited from class org.apache.hadoop.crypto.key.KeyProvider
DEFAULT_BITLENGTH, DEFAULT_BITLENGTH_NAME, DEFAULT_CIPHER, DEFAULT_CIPHER_NAME, JCEKS_KEY_SERIAL_FILTER, JCEKS_KEY_SERIALFILTER_DEFAULT -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedKeyProviderCryptoExtension(KeyProvider keyProvider, KeyProviderCryptoExtension.CryptoExtension extension) This constructor is to be used by sub classes that provide delegating/proxying functionality to theKeyProviderCryptoExtension -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Can be used by implementing classes to close any resources that require closingstatic KeyProviderCryptoExtensioncreateKeyProviderCryptoExtension(KeyProvider keyProvider) Creates aKeyProviderCryptoExtensionusing a givenKeyProvider.Decrypts an encrypted byte[] key material using the given a key version name and initialization vector.voidCallsKeyProviderCryptoExtension.CryptoExtension.drain(String)for the given key name on the underlyingKeyProviderCryptoExtension.CryptoExtension.generateEncryptedKey(String encryptionKeyName) Generates a key material and encrypts it using the given key version name and initialization vector.Re-encrypts an encrypted key version, using its initialization vector and key material, but with the latest key version name of its key name in the key provider.voidBatched version ofreencryptEncryptedKey(EncryptedKeyVersion).voidwarmUpEncryptedKeys(String... keyNames) Notifies the Underlying CryptoExtension implementation to warm up any implementation specific caches for the specified KeyVersionsMethods inherited from class org.apache.hadoop.crypto.key.KeyProviderExtension
createKey, createKey, deleteKey, flush, getCurrentKey, getExtension, getKeyProvider, getKeys, getKeysMetadata, getKeyVersion, getKeyVersions, getMetadata, invalidateCache, isTransient, rollNewVersion, rollNewVersion, toStringMethods inherited from class org.apache.hadoop.crypto.key.KeyProvider
buildVersionName, findProvider, generateKey, getBaseName, getConf, needsPassword, noPasswordError, noPasswordWarning, options
-
Field Details
-
EEK
Designates an encrypted encryption key, or EEK.- See Also:
-
EK
Designates a decrypted encrypted encryption key, that is, an encryption key (EK).- See Also:
-
-
Constructor Details
-
KeyProviderCryptoExtension
protected KeyProviderCryptoExtension(KeyProvider keyProvider, KeyProviderCryptoExtension.CryptoExtension extension) This constructor is to be used by sub classes that provide delegating/proxying functionality to theKeyProviderCryptoExtension- Parameters:
keyProvider- key provider.extension- crypto extension.
-
-
Method Details
-
warmUpEncryptedKeys
Notifies the Underlying CryptoExtension implementation to warm up any implementation specific caches for the specified KeyVersions- Parameters:
keyNames- Arrays of key Names- Throws:
IOException- raised on errors performing I/O.
-
generateEncryptedKey
public KeyProviderCryptoExtension.EncryptedKeyVersion generateEncryptedKey(String encryptionKeyName) throws IOException, GeneralSecurityException Generates a key material and encrypts it using the given key version name and initialization vector. The generated key material is of the same length as theKeyVersionmaterial and is encrypted using the same cipher.NOTE: The generated key is not stored by the
KeyProvider- Parameters:
encryptionKeyName- The latest KeyVersion of this key's material will be encrypted.- Returns:
- EncryptedKeyVersion with the generated key material, the version name is 'EEK' (for Encrypted Encryption Key)
- Throws:
IOException- thrown if the key material could not be generatedGeneralSecurityException- thrown if the key material could not be encrypted because of a cryptographic issue.
-
decryptEncryptedKey
public KeyProvider.KeyVersion decryptEncryptedKey(KeyProviderCryptoExtension.EncryptedKeyVersion encryptedKey) throws IOException, GeneralSecurityException Decrypts an encrypted byte[] key material using the given a key version name and initialization vector.- Parameters:
encryptedKey- contains keyVersionName and IV to decrypt the encrypted key material- Returns:
- a KeyVersion with the decrypted key material, the version name is 'EK' (For Encryption Key)
- Throws:
IOException- thrown if the key material could not be decryptedGeneralSecurityException- thrown if the key material could not be decrypted because of a cryptographic issue.
-
reencryptEncryptedKey
public KeyProviderCryptoExtension.EncryptedKeyVersion reencryptEncryptedKey(KeyProviderCryptoExtension.EncryptedKeyVersion ekv) throws IOException, GeneralSecurityException Re-encrypts an encrypted key version, using its initialization vector and key material, but with the latest key version name of its key name in the key provider.If the latest key version name in the provider is the same as the one encrypted the passed-in encrypted key version, the same encrypted key version is returned.
NOTE: The generated key is not stored by the
KeyProvider- Parameters:
ekv- The EncryptedKeyVersion containing keyVersionName and IV.- Returns:
- The re-encrypted EncryptedKeyVersion.
- Throws:
IOException- If the key material could not be re-encryptedGeneralSecurityException- If the key material could not be re-encrypted because of a cryptographic issue.
-
drain
CallsKeyProviderCryptoExtension.CryptoExtension.drain(String)for the given key name on the underlyingKeyProviderCryptoExtension.CryptoExtension.- Parameters:
keyName- key name.
-
reencryptEncryptedKeys
public void reencryptEncryptedKeys(List<KeyProviderCryptoExtension.EncryptedKeyVersion> ekvs) throws IOException, GeneralSecurityException Batched version ofreencryptEncryptedKey(EncryptedKeyVersion).For each encrypted key version, re-encrypts an encrypted key version, using its initialization vector and key material, but with the latest key version name of its key name. If the latest key version name in the provider is the same as the one encrypted the passed-in encrypted key version, the same encrypted key version is returned.
NOTE: The generated key is not stored by the
KeyProvider- Parameters:
ekvs- List containing the EncryptedKeyVersion's- Throws:
IOException- If any EncryptedKeyVersion could not be re-encryptedGeneralSecurityException- If any EncryptedKeyVersion could not be re-encrypted because of a cryptographic issue.
-
createKeyProviderCryptoExtension
Creates aKeyProviderCryptoExtensionusing a givenKeyProvider.If the given
KeyProviderimplements theKeyProviderCryptoExtension.CryptoExtensioninterface theKeyProvideritself will provide the extension functionality. If the givenKeyProviderimplements theKeyProviderExtensioninterface and the KeyProvider being extended by theKeyProviderimplements theKeyProviderCryptoExtension.CryptoExtensioninterface, the KeyProvider being extended will provide the extension functionality. Otherwise, a default extension implementation will be used.- Parameters:
keyProvider-KeyProviderto use to create theKeyProviderCryptoExtensionextension.- Returns:
- a
KeyProviderCryptoExtensioninstance using the givenKeyProvider.
-
close
Description copied from class:KeyProviderCan be used by implementing classes to close any resources that require closing- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classKeyProvider- Throws:
IOException
-