Kettle is used more and more in enterprises where the standard obfuscation of credentials is not sufficient enough. There are requirements to use strong encryption methods and even to store internal data encrypted (covered in PDI-6168 and PDI-6170). The above use cases inspired me to create some simple transformations to test and play around with encryption.
The transformations and some test data are attached to the Kettle Exchange page Security Considerations and Encryption with Kettle.
Let’s start with creating a key by the cryptographyCreateSecretKey transformation:
The generateKey step uses the User Defined Java Class step and implements sample code for AES, the Advanced Encryption Standard is a symmetric-key encryption standard, see also http://java.sun.com/developer/technicalArticles/Security/AES/AES_v1.html. The key serialization to file is a little trick to obfuscate the key. Other methods can be included instead of the clear text file output.
Now that we have the key file, we can encrypt our secret data:
With the transformation cryptographyEncrypt:
We keep it simple and assume the key is available in each row (accomplished by the Join Key).
The encrypted result looks like this:
Let’s decrypt it with the transformation cryptographyDecrypt:
The result is correct but only when the key file is the same and the encrypted data was not modified. You can test it yourself and see what error messages come up or the resulting files look like when the key file or data was modified.
Instead of storing the decrypted data to a file there are a lof of other options, e.g.:
- use the decrypted data as credentials in subsequent steps or transformations
- put the decrypted data into variables visible in a limited scope (e.g. parent job) and use them as credentials for databases, repository etc. (see PDI-6168)
- and many more options
We may consider:
- Symmetric-key algorithm vs. asymmetric key algorithms (public-key cryptography)
- Diffie-Hellman key exchange is a specific method of exchanging keys.
- Ensure integrity e.g. by hash-codes
- Key file handling could be optimized in different ways.
- Please keep in mind that unencrypted data is in RAM (see PDI-6170 for a circumvention to prevent heap dumps)
- Beneath the binary or indexed storage type, an encrypted storage type may be possible in Kettle core.
In the end: Don’t lose your key!
Update since Kettle 4.2: There are two steps in the experimental section: Secret key generator, Symmetric Cryptography that cover this use case.