I am trying to back up my Vault keys I am using to encrypt/decrypt my data. The official doc says that in order to read the keys I should execute the following command line:
$ vault read transit/keys/orders
Key Value
--- -----
allow_plaintext_backup false
deletion_allowed false
derived false
exportable false
keys map[1:1604988997 2:1604993553 3:1604993556 4:1604993569]
latest_version 4
min_available_version 0
min_decryption_version 1
min_encryption_version 0
name orders
supports_decryption true
supports_derivation true
supports_encryption true
supports_signing false
type aes256-gcm96
As you can tell I have got 4 "keys". To make sure that these numeric strings are the right keys I decided to conduct the following maneuver : Consider the plain 4111 1111 1111 1111
1- Convert the plain text into base64 and encrypt it with the key n°4 :
$ vault write transit/encrypt/orders plaintext=$(base64 <<< "4111 1111 1111 1111")
Key Value
--- -----
ciphertext vault:v4:F6hjhlJM8xczv8J20zQTRMWn3RflTd6UhcWLD9NOsEt+MQJjy4LlyAY5SY6UyydN
key_version 4
2- Take the cipher text generated above and decrypt it programatically using the key n°4 1604993569 and AES256-GCM96
At this stage if I want to achieve what has been mentioned above using Java Cryptography Extension I find myself blocked because the official doc gives information about :
- Encryption algorithm : AES
- Key size : 256 bits
- Mode : GCM
- GCM Nonce/IV : 96
- GCM tag : not mentioned in the official doc
I have two questions now : What is the GCM tag I should use in this case (could not figure out that from the source code)? Is the numerical string "1604993569" the raw format of the 4th key or is it encoded in some format?