Hi I am using Robolectric for test cases. I am facing some issue while simulating for encryption relateed test cases. I tried to use cipher with AES for encryption. And it is giving me some error. I tried it in following manner :
    @Test
public void testGet() {
    Cipher cipher = null;
    try {
        SecretKey sks= getKeySpec(pass, salt);
        cipher = Cipher.getInstance("AES");
        cipher.init(Cipher.DECRYPT_MODE, sks);
    } catch (NoSuchAlgorithmException e) {
        e.printStackTrace();
    } catch (NoSuchPaddingException e) {
        e.printStackTrace();
    } catch (InvalidKeySpecException e) {
        e.printStackTrace();
    } catch (InvalidKeyException e) {
        e.printStackTrace();
    }
}
public SecretKey getKeySpec(char[] pass, byte[] salt) throws NoSuchAlgorithmException, InvalidKeySpecException {
    //generate key spec...
    return secretKeyFactory.generateSecret(keySpec);
}
It gives me following error :
Illegal key size or default parameters
I already added JCE for illegal size exception. It is working if I run it on device and properly working in my application. Only thing when I try with robolectric it is giving me this error.Need some help. Thank you.
 
     
    