List of usage examples for javax.crypto.spec SecretKeySpec SecretKeySpec
public SecretKeySpec(byte[] key, String algorithm)
From source file:cl.niclabs.tscrypto.common.messages.EncryptedData.java
/** * Returns a decrypted version of the included data * @return/*from w w w. j a va2s. co m*/ * @throws NoSuchAlgorithmException * @throws NoSuchPaddingException * @throws InvalidKeyException * @throws IllegalBlockSizeException * @throws BadPaddingException */ public byte[] decrypt() throws NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, IllegalBlockSizeException, BadPaddingException { byte[] plainAESKey = KeyChain.getInstance().decrypt(rsaKeyAlias, encryptedKey); SecretKeySpec skeySpec = new SecretKeySpec(plainAESKey, "AES"); Cipher cipher = Cipher.getInstance("AES"); cipher.init(Cipher.DECRYPT_MODE, skeySpec); return cipher.doFinal(Base64.decodeBase64(encryptedData)); }