Package org.forgerock.secrets.gcpkms
Class GoogleKmsAesCipher
java.lang.Object
javax.crypto.CipherSpi
org.forgerock.secrets.gcpkms.GoogleKmsAesCipher
A Cipher implementation using Google KMS symmetric encryption/decryption. This is a variant of AES-GCM, but uses
a proprietary Google-specific padding scheme so is not directly compatible with standard AES/GCM/NoPadding. This
cipher implementation is therefore advertised using the name
AES/GCM/GoogleKmsPadding
and cannot be used
for JWT encryption or other standard modes. It is mainly useful for encrypting and decrypting data locally.-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected byte[]
engineDoFinal
(byte[] input, int inputOffset, int inputLen) protected int
engineDoFinal
(byte[] input, int inputOffset, int inputLen, byte[] output, int outputOffset) protected int
protected byte[]
protected int
engineGetKeySize
(Key key) protected int
engineGetOutputSize
(int inputLen) protected AlgorithmParameters
protected void
engineInit
(int opmode, Key key, AlgorithmParameters params, SecureRandom random) protected void
engineInit
(int opmode, Key key, SecureRandom random) protected void
engineInit
(int opmode, Key key, AlgorithmParameterSpec params, SecureRandom random) protected void
engineSetMode
(String mode) protected void
engineSetPadding
(String padding) protected Key
engineUnwrap
(byte[] wrappedKey, String wrappedKeyAlgorithm, int wrappedKeyType) protected byte[]
engineUpdate
(byte[] input, int inputOffset, int inputLen) protected int
engineUpdate
(byte[] input, int inputOffset, int inputLen, byte[] output, int outputOffset) protected void
engineUpdateAAD
(byte[] src, int offset, int len) protected void
protected byte[]
engineWrap
(Key keyToWrap) Methods inherited from class javax.crypto.CipherSpi
engineDoFinal, engineUpdate
-
Constructor Details
-
GoogleKmsAesCipher
public GoogleKmsAesCipher()
-
-
Method Details
-
engineWrap
- Overrides:
engineWrap
in classCipherSpi
- Throws:
InvalidKeyException
-
engineUnwrap
protected Key engineUnwrap(byte[] wrappedKey, String wrappedKeyAlgorithm, int wrappedKeyType) throws InvalidKeyException, NoSuchAlgorithmException - Overrides:
engineUnwrap
in classCipherSpi
- Throws:
InvalidKeyException
NoSuchAlgorithmException
-
engineGetKeySize
- Overrides:
engineGetKeySize
in classCipherSpi
- Throws:
InvalidKeyException
-
engineSetMode
- Specified by:
engineSetMode
in classCipherSpi
- Throws:
NoSuchAlgorithmException
-
engineSetPadding
- Specified by:
engineSetPadding
in classCipherSpi
- Throws:
NoSuchPaddingException
-
engineGetBlockSize
protected int engineGetBlockSize()- Specified by:
engineGetBlockSize
in classCipherSpi
-
engineGetOutputSize
protected int engineGetOutputSize(int inputLen) - Specified by:
engineGetOutputSize
in classCipherSpi
-
engineGetIV
protected byte[] engineGetIV()- Specified by:
engineGetIV
in classCipherSpi
-
engineGetParameters
- Specified by:
engineGetParameters
in classCipherSpi
-
engineInit
- Specified by:
engineInit
in classCipherSpi
- Throws:
InvalidKeyException
-
engineInit
protected void engineInit(int opmode, Key key, AlgorithmParameterSpec params, SecureRandom random) throws InvalidKeyException, InvalidAlgorithmParameterException - Specified by:
engineInit
in classCipherSpi
- Throws:
InvalidKeyException
InvalidAlgorithmParameterException
-
engineInit
protected void engineInit(int opmode, Key key, AlgorithmParameters params, SecureRandom random) throws InvalidKeyException, InvalidAlgorithmParameterException - Specified by:
engineInit
in classCipherSpi
- Throws:
InvalidKeyException
InvalidAlgorithmParameterException
-
engineUpdate
protected byte[] engineUpdate(byte[] input, int inputOffset, int inputLen) - Specified by:
engineUpdate
in classCipherSpi
-
engineUpdate
protected int engineUpdate(byte[] input, int inputOffset, int inputLen, byte[] output, int outputOffset) - Specified by:
engineUpdate
in classCipherSpi
-
engineUpdateAAD
protected void engineUpdateAAD(byte[] src, int offset, int len) - Overrides:
engineUpdateAAD
in classCipherSpi
-
engineUpdateAAD
- Overrides:
engineUpdateAAD
in classCipherSpi
-
engineDoFinal
protected byte[] engineDoFinal(byte[] input, int inputOffset, int inputLen) - Specified by:
engineDoFinal
in classCipherSpi
-
engineDoFinal
protected int engineDoFinal(byte[] input, int inputOffset, int inputLen, byte[] output, int outputOffset) throws ShortBufferException - Specified by:
engineDoFinal
in classCipherSpi
- Throws:
ShortBufferException
-