import java.security.SecureRandom;
import java.nio.ByteBuffer;
+
+import java.util.*;
+
/**
* This class provides a communication API to the webserver. It also
* validates the HMACs on the slots and handles encryption.
private byte[] encryptSlotAndPrependIV(byte[] rawData, byte[] ivBytes) {
try {
IvParameterSpec ivSpec = new IvParameterSpec(ivBytes);
- Cipher cipher = Cipher.getInstance("AES/CTR/PKCS5Padding");
+ Cipher cipher = Cipher.getInstance("AES/CTR/NoPadding");
cipher.init(Cipher.ENCRYPT_MODE, key, ivSpec);
byte[] encryptedBytes = cipher.doFinal(rawData);
IvParameterSpec ivSpec = new IvParameterSpec(ivBytes);
- Cipher cipher = Cipher.getInstance("AES/CTR/PKCS5Padding");
+ Cipher cipher = Cipher.getInstance("AES/CTR/NoPadding");
cipher.init(Cipher.DECRYPT_MODE, key, ivSpec);
-
return cipher.doFinal(encryptedBytes);
} catch (Exception e) {