Forgot to specify NoPadding for temporary storage cipher.

This commit is contained in:
akwizgran
2013-03-07 10:20:07 +00:00
parent edaf4e4b23
commit ecfb4e98a1

View File

@@ -43,7 +43,7 @@ import com.google.inject.Inject;
class CryptoComponentImpl implements CryptoComponent { class CryptoComponentImpl implements CryptoComponent {
private static final String PROVIDER = "SC"; private static final String PROVIDER = "SC"; // Spongy Castle
private static final String AGREEMENT_KEY_PAIR_ALGO = "ECDH"; private static final String AGREEMENT_KEY_PAIR_ALGO = "ECDH";
private static final int AGREEMENT_KEY_PAIR_BITS = 384; private static final int AGREEMENT_KEY_PAIR_BITS = 384;
private static final String AGREEMENT_ALGO = "ECDHC"; private static final String AGREEMENT_ALGO = "ECDHC";
@@ -57,7 +57,7 @@ class CryptoComponentImpl implements CryptoComponent {
private static final String SIGNATURE_ALGO = "ECDSA"; private static final String SIGNATURE_ALGO = "ECDSA";
private static final String TAG_CIPHER_ALGO = "AES/ECB/NoPadding"; private static final String TAG_CIPHER_ALGO = "AES/ECB/NoPadding";
private static final int GCM_MAC_LENGTH = 16; // 128 bits private static final int GCM_MAC_LENGTH = 16; // 128 bits
private static final String STORAGE_CIPHER_ALGO = "AES/GCM"; private static final String STORAGE_CIPHER_ALGO = "AES/GCM/NoPadding";
private static final int STORAGE_IV_LENGTH = 32; // 256 bits private static final int STORAGE_IV_LENGTH = 32; // 256 bits
// Labels for key derivation // Labels for key derivation
@@ -397,12 +397,11 @@ class CryptoComponentImpl implements CryptoComponent {
try { try {
cipher = Cipher.getInstance(STORAGE_CIPHER_ALGO, PROVIDER); cipher = Cipher.getInstance(STORAGE_CIPHER_ALGO, PROVIDER);
cipher.init(ENCRYPT_MODE, temporaryStorageKey, iv); cipher.init(ENCRYPT_MODE, temporaryStorageKey, iv);
cipher.doFinal(input, 0, input.length, output, cipher.doFinal(input, 0, input.length, output, STORAGE_IV_LENGTH);
STORAGE_IV_LENGTH); return output;
} catch(GeneralSecurityException e) { } catch(GeneralSecurityException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
return output;
} }
public byte[] decryptTemporaryStorage(byte[] input) { public byte[] decryptTemporaryStorage(byte[] input) {