Class CryptographicEngine
java.lang.Object
com.sath.idhub.util.CryptographicEngine
Common cryptographic engine for managing Envelope Encryption across services.
Uses native Java JCE classes (AES/GCM/NoPadding).
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordstatic final record -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringdecryptData(String cipherTextBase64, byte[] rawDek, String ivBase64) Decrypts encrypted database records using the active Tenant DEK.encryptData(String plainText, byte[] rawDek) Encrypts plain-text configuration strings using the active Tenant DEK.static byte[]Generates a random, high-entropy 256-bit AES key for a new tenant (DEK).static byte[]Decrypts (unwraps) the Tenant DEK using the Master KEK.wrapDEK(byte[] rawDek, byte[] masterKek) Encrypts (wraps) the Tenant DEK using the Master KEK.
-
Constructor Details
-
CryptographicEngine
public CryptographicEngine()
-
-
Method Details
-
generateDEK
Generates a random, high-entropy 256-bit AES key for a new tenant (DEK).- Throws:
NoSuchAlgorithmException
-
wrapDEK
public static CryptographicEngine.WrappedKeyResult wrapDEK(byte[] rawDek, byte[] masterKek) throws NoSuchPaddingException, NoSuchAlgorithmException, InvalidAlgorithmParameterException, InvalidKeyException, IllegalBlockSizeException, BadPaddingException Encrypts (wraps) the Tenant DEK using the Master KEK. -
unwrapDEK
public static byte[] unwrapDEK(String encryptedDekBase64, byte[] masterKek, String ivBase64) throws NoSuchPaddingException, NoSuchAlgorithmException, InvalidAlgorithmParameterException, InvalidKeyException, IllegalBlockSizeException, BadPaddingException Decrypts (unwraps) the Tenant DEK using the Master KEK. -
encryptData
public static CryptographicEngine.CryptoResult encryptData(String plainText, byte[] rawDek) throws NoSuchPaddingException, NoSuchAlgorithmException, InvalidAlgorithmParameterException, InvalidKeyException, IllegalBlockSizeException, BadPaddingException Encrypts plain-text configuration strings using the active Tenant DEK. -
decryptData
public static String decryptData(String cipherTextBase64, byte[] rawDek, String ivBase64) throws NoSuchPaddingException, NoSuchAlgorithmException, InvalidAlgorithmParameterException, InvalidKeyException, IllegalBlockSizeException, BadPaddingException Decrypts encrypted database records using the active Tenant DEK.
-