Package io.helidon.config.encryption
Class EncryptionUtil
- java.lang.Object
-
- io.helidon.config.encryption.EncryptionUtil
-
public final class EncryptionUtil extends Object
Encryption utilities for secrets protection.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static StringdecryptRsa(PrivateKey key, String encryptedBase64)Decrypt using RSA with OAEP.static StringdecryptRsaLegacy(Key key, String encryptedBase64)Decrypt using RSA (private or public key).static StringencryptAes(char[] masterPassword, String secret)Encrypt using AES with GCM method, key is derived from password with random salt.static StringencryptRsa(PublicKey key, String secret)Encrypt secret using RSA with OAEP.
-
-
-
Method Detail
-
decryptRsa
public static String decryptRsa(PrivateKey key, String encryptedBase64) throws ConfigEncryptionException
Decrypt using RSA with OAEP. Expects message encrypted with the public key.- Parameters:
key- private key used to decryptencryptedBase64- base64 encoded encrypted secret- Returns:
- Secret value
- Throws:
ConfigEncryptionException- If any problem with decryption occurs
-
decryptRsaLegacy
public static String decryptRsaLegacy(Key key, String encryptedBase64) throws ConfigEncryptionException
Decrypt using RSA (private or public key). Expects message encrypted with the other key.- Parameters:
key- private or public key to use to decryptencryptedBase64- base64 encoded encrypted secret- Returns:
- Secret value
- Throws:
ConfigEncryptionException- If any problem with decryption occurs
-
encryptRsa
public static String encryptRsa(PublicKey key, String secret) throws ConfigEncryptionException
Encrypt secret using RSA with OAEP.- Parameters:
key- public key used to encryptsecret- secret to encrypt- Returns:
- base64 encoded encrypted bytes
- Throws:
ConfigEncryptionException- If any problem with encryption occurs
-
encryptAes
public static String encryptAes(char[] masterPassword, String secret) throws ConfigEncryptionException
Encrypt using AES with GCM method, key is derived from password with random salt.- Parameters:
masterPassword- master passwordsecret- secret to encrypt- Returns:
- Encrypted value base64 encoded
- Throws:
ConfigEncryptionException- If any problem with encryption occurs
-
-