mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-15 04:18:53 +01:00
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:
@@ -67,4 +67,8 @@ class AuthenticatedCipherImpl implements AuthenticatedCipher {
|
||||
public int getMacLength() {
|
||||
return macLength;
|
||||
}
|
||||
|
||||
public int getBlockSize() {
|
||||
return cipher.getUnderlyingCipher().getBlockSize();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user