Class AesGcmTotpSecretCipher
java.lang.Object
com.irurueta.authserver.authorization.infrastructure.keys.AesGcmTotpSecretCipher
- All Implemented Interfaces:
TotpSecretCipher
TotpSecretCipher that encrypts TOTP secrets with AES-256 in GCM mode. Its key is derived from the
key-encryption passphrase with a salt of its own (PurposeKeyDerivation, purpose "totp-secret"), so it
never shares the key that protects the signing keys. Each encryption uses a random initialisation vector, which is
stored in front of the cipher text.-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionAesGcmTotpSecretCipher(KeyEncryptionProperties properties, PurposeKeyDerivation derivation) Derives the encryption key. -
Method Summary
-
Field Details
-
PURPOSE
Label of the purpose the key is derived for.- See Also:
-
encryptor
private final org.springframework.security.crypto.encrypt.BytesEncryptor encryptorThe encryptor derived from the passphrase and the salt of this purpose.
-
-
Constructor Details
-
AesGcmTotpSecretCipher
Derives the encryption key.- Parameters:
properties- passphrase of the key-encryption secret.derivation- derives the salt of this purpose from the configured salt.
-
-
Method Details
-
encrypt
public byte[] encrypt(byte[] secret) Description copied from interface:TotpSecretCipherEncrypts a secret.- Specified by:
encryptin interfaceTotpSecretCipher- Parameters:
secret- the clear secret.- Returns:
- the encrypted form, which includes whatever is needed to decrypt it.
-
decrypt
public byte[] decrypt(byte[] encrypted) Description copied from interface:TotpSecretCipherDecrypts a secret.- Specified by:
decryptin interfaceTotpSecretCipher- Parameters:
encrypted- a value produced byTotpSecretCipher.encrypt(byte[]).- Returns:
- the clear secret.
-