79359818

Date: 2025-01-15 22:04:27
Score: 1
Natty:
Report link

follow @Topaco advice my current workable code is:

private SecretKey decryptDataKey(byte[] encryptedDataKey, byte[] iv) throws NoSuchAlgorithmException, InvalidKeyException,
        NoSuchPaddingException, IllegalBlockSizeException, BadPaddingException, UnrecoverableKeyException, java.security.KeyStoreException, InvalidAlgorithmParameterException, NoSuchProviderException {
    Key masterKey = getOrCreateKey();
    Cipher cipher = Cipher.getInstance(transformation);
    GCMParameterSpec gcmParameterSpec = new GCMParameterSpec(gcmTagLength, iv);
    cipher.init(Cipher.DECRYPT_MODE, masterKey, gcmParameterSpec);
    byte[] decryptedDataKey = cipher.doFinal(encryptedDataKey);
    return new SecretKeySpec(decryptedDataKey, KeyProperties.KEY_ALGORITHM_AES);
}
Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • User mentioned (1): @Topaco
  • Self-answer (0.5):
  • Low reputation (0.5):
Posted by: Alex161