Class KeyToolkit
java.lang.Object
org.apache.parquet.crypto.keytools.KeyToolkit
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final longstatic final StringLifetime of cached entities (key encryption keys, local wrapping keys, KMS client objects).static final intstatic final StringLength of data encryption keys (DEKs), randomly generated by parquet key management tools.static final booleanstatic final StringUse double wrapping - where data encryption keys (DEKs) are encrypted with key encryption keys (KEKs), which in turn are encrypted with master keys.static final intstatic final StringLength of key encryption keys (KEKs), randomly generated by parquet key management tools.static final StringAuthorization token that will be passed to KMS.static final booleanstatic final StringStore key material inside Parquet file footers; this mode doesn’t produce additional files.static final StringClass implementing the KmsClient interface.static final booleanstatic final StringIf a KMS URL is set by writers, it will be stored in the key material.static final StringID of the KMS instance that will be used for encryption (if multiple KMS instances are available).static final StringURL of the KMS instance. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic byte[]decryptKeyLocally(String encodedEncryptedKey, byte[] masterKeyBytes, byte[] AAD) Decrypts encrypted key with "masterKey", using AES-GCM and the "AAD"static StringencryptKeyLocally(byte[] keyBytes, byte[] masterKeyBytes, byte[] AAD) Encrypts "key" with "masterKey", using AES-GCM and the "AAD"static voidstatic voidremoveCacheEntriesForToken(String accessToken) Flush any caches that are tied to the (compromised) accessTokenstatic voidrotateMasterKeys(String folderPath, org.apache.hadoop.conf.Configuration hadoopConfig) Key rotation.
-
Field Details
-
KMS_CLIENT_CLASS_PROPERTY_NAME
Class implementing the KmsClient interface. KMS stands for “key management service”.- See Also:
-
KMS_INSTANCE_ID_PROPERTY_NAME
ID of the KMS instance that will be used for encryption (if multiple KMS instances are available).- See Also:
-
KMS_INSTANCE_URL_PROPERTY_NAME
URL of the KMS instance.- See Also:
-
KMS_ENABLE_URL_READ_PROPERTY_NAME
If a KMS URL is set by writers, it will be stored in the key material. However, by default, it will not be provided to readers because the storage is untrusted. Readers that need the URL should set the KMS URL property. If they cannot do so, they can enable retrieving the KMS URL from the stored material by setting this parameter to true. KMS client implementations must validate the URL value and use authentication to prevent key material tampering attacks, which could, for example, send a KMS access token to a malicious URL endpoint.- See Also:
-
KMS_ENABLE_URL_READ_DEFAULT
public static final boolean KMS_ENABLE_URL_READ_DEFAULT- See Also:
-
KEY_ACCESS_TOKEN_PROPERTY_NAME
Authorization token that will be passed to KMS.- See Also:
-
DOUBLE_WRAPPING_PROPERTY_NAME
Use double wrapping - where data encryption keys (DEKs) are encrypted with key encryption keys (KEKs), which in turn are encrypted with master keys. By default, true. If set to false, DEKs are directly encrypted with master keys, KEKs are not used.- See Also:
-
CACHE_LIFETIME_PROPERTY_NAME
Lifetime of cached entities (key encryption keys, local wrapping keys, KMS client objects).- See Also:
-
KEY_MATERIAL_INTERNAL_PROPERTY_NAME
Store key material inside Parquet file footers; this mode doesn’t produce additional files. By default, true. If set to false, key material is stored in separate files in the same folder, which enables key rotation for immutable Parquet files.- See Also:
-
DATA_KEY_LENGTH_PROPERTY_NAME
Length of data encryption keys (DEKs), randomly generated by parquet key management tools. Can be 128, 192 or 256 bits.- See Also:
-
KEK_LENGTH_PROPERTY_NAME
Length of key encryption keys (KEKs), randomly generated by parquet key management tools. Can be 128, 192 or 256 bits.- See Also:
-
DOUBLE_WRAPPING_DEFAULT
public static final boolean DOUBLE_WRAPPING_DEFAULT- See Also:
-
CACHE_LIFETIME_DEFAULT_SECONDS
public static final long CACHE_LIFETIME_DEFAULT_SECONDS- See Also:
-
KEY_MATERIAL_INTERNAL_DEFAULT
public static final boolean KEY_MATERIAL_INTERNAL_DEFAULT- See Also:
-
DATA_KEY_LENGTH_DEFAULT
public static final int DATA_KEY_LENGTH_DEFAULT- See Also:
-
KEK_LENGTH_DEFAULT
public static final int KEK_LENGTH_DEFAULT- See Also:
-
-
Constructor Details
-
KeyToolkit
public KeyToolkit()
-
-
Method Details
-
rotateMasterKeys
public static void rotateMasterKeys(String folderPath, org.apache.hadoop.conf.Configuration hadoopConfig) throws IOException, ParquetCryptoRuntimeException, KeyAccessDeniedException, UnsupportedOperationException Key rotation. In the single wrapping mode, decrypts data keys with old master keys, then encrypts them with new master keys. In the double wrapping mode, decrypts KEKs (key encryption keys) with old master keys, generates new KEKs and encrypts them with new master keys. Works only if key material is not stored internally in file footers. Not supported in local key wrapping mode. Method can be run by multiple threads, but each thread must work on a different folder.- Parameters:
folderPath- parent path of Parquet files, whose keys will be rotatedhadoopConfig- Hadoop configuration- Throws:
IOException- I/O problemsParquetCryptoRuntimeException- General parquet encryption problemsKeyAccessDeniedException- No access to master keysUnsupportedOperationException- Master key rotation not supported in the specific configuration
-
removeCacheEntriesForToken
Flush any caches that are tied to the (compromised) accessToken- Parameters:
accessToken- access token
-
removeCacheEntriesForAllTokens
public static void removeCacheEntriesForAllTokens() -
encryptKeyLocally
Encrypts "key" with "masterKey", using AES-GCM and the "AAD"- Parameters:
keyBytes- the key to encryptmasterKeyBytes- encryption keyAAD- additional authenticated data- Returns:
- base64 encoded encrypted key
-
decryptKeyLocally
public static byte[] decryptKeyLocally(String encodedEncryptedKey, byte[] masterKeyBytes, byte[] AAD) Decrypts encrypted key with "masterKey", using AES-GCM and the "AAD"- Parameters:
encodedEncryptedKey- base64 encoded encrypted keymasterKeyBytes- encryption keyAAD- additional authenticated data- Returns:
- decrypted key
-