Encrypt bundles in case the OS writes them to unencrypted storage.

Only the bundle contents created by Briar classes are encrypted.
This commit is contained in:
akwizgran
2013-02-18 18:56:00 +00:00
parent 49e6113e5d
commit 51db9ce1fd
12 changed files with 166 additions and 22 deletions

View File

@@ -67,4 +67,8 @@ class AuthenticatedCipherImpl implements AuthenticatedCipher {
public int getMacLength() {
return macLength;
}
public int getBlockSize() {
return cipher.getUnderlyingCipher().getBlockSize();
}
}

View File

@@ -332,7 +332,7 @@ class CryptoComponentImpl implements CryptoComponent {
return signatureKeyParser;
}
public ErasableKey generateTestKey() {
public ErasableKey generateSecretKey() {
byte[] b = new byte[SECRET_KEY_BYTES];
secureRandom.nextBytes(b);
return new ErasableKeyImpl(b, SECRET_KEY_ALGO);
@@ -377,4 +377,11 @@ class CryptoComponentImpl implements CryptoComponent {
AEADBlockCipher cipher = new GCMBlockCipher(new AESEngine());
return new AuthenticatedCipherImpl(cipher, GCM_MAC_LENGTH);
}
public AuthenticatedCipher getBundleCipher() {
// This code is specific to BouncyCastle because javax.crypto.Cipher
// doesn't support additional authenticated data until Java 7
AEADBlockCipher cipher = new GCMBlockCipher(new AESEngine());
return new AuthenticatedCipherImpl(cipher, GCM_MAC_LENGTH);
}
}