add LocalKeyStorage, don't store public keys larger than 50kb in database
This commit is contained in:
@@ -135,7 +135,8 @@ public class BackupOperationTest {
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
DatabaseReadWriteInteractor databaseInteractor = new DatabaseReadWriteInteractor(RuntimeEnvironment.application);
|
||||
DatabaseReadWriteInteractor databaseInteractor =
|
||||
DatabaseReadWriteInteractor.createDatabaseReadWriteInteractor(RuntimeEnvironment.application);
|
||||
|
||||
// don't log verbosely here, we're not here to test imports
|
||||
ShadowLog.stream = oldShadowStream;
|
||||
@@ -150,7 +151,7 @@ public class BackupOperationTest {
|
||||
@Test
|
||||
public void testExportAllLocalStripped() throws Exception {
|
||||
BackupOperation op = new BackupOperation(RuntimeEnvironment.application,
|
||||
new DatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
|
||||
DatabaseReadWriteInteractor.createDatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
|
||||
|
||||
// make sure there is a local cert (so the later checks that there are none are meaningful)
|
||||
assertTrue("second keyring has local certification", checkForLocal(mStaticRing2));
|
||||
@@ -249,7 +250,7 @@ public class BackupOperationTest {
|
||||
when(spyApplication.getContentResolver()).thenReturn(mockResolver);
|
||||
|
||||
BackupOperation op = new BackupOperation(spyApplication,
|
||||
new DatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
|
||||
DatabaseReadWriteInteractor.createDatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
|
||||
|
||||
BackupKeyringParcel parcel = new BackupKeyringParcel(
|
||||
new long[] { mStaticRing1.getMasterKeyId() }, false, false, true, fakeOutputUri);
|
||||
@@ -306,7 +307,7 @@ public class BackupOperationTest {
|
||||
|
||||
{ // export encrypted
|
||||
BackupOperation op = new BackupOperation(spyApplication,
|
||||
new DatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
|
||||
DatabaseReadWriteInteractor.createDatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
|
||||
|
||||
BackupKeyringParcel parcel = new BackupKeyringParcel(
|
||||
new long[] { mStaticRing1.getMasterKeyId() }, false, true, true, fakeOutputUri);
|
||||
@@ -324,7 +325,7 @@ public class BackupOperationTest {
|
||||
|
||||
{
|
||||
PgpDecryptVerifyOperation op = new PgpDecryptVerifyOperation(RuntimeEnvironment.application,
|
||||
new DatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
|
||||
DatabaseReadWriteInteractor.createDatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
|
||||
|
||||
PgpDecryptVerifyInputParcel input = new PgpDecryptVerifyInputParcel(outStream.toByteArray());
|
||||
input.setAllowSymmetricDecryption(true);
|
||||
|
||||
@@ -47,7 +47,7 @@ public class BenchmarkOperationTest {
|
||||
@Test
|
||||
public void testBenchmark() throws Exception {
|
||||
BenchmarkOperation op = new BenchmarkOperation(RuntimeEnvironment.application,
|
||||
new DatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
|
||||
DatabaseReadWriteInteractor.createDatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
|
||||
|
||||
op.execute(new BenchmarkInputParcel(), null);
|
||||
}
|
||||
|
||||
@@ -117,7 +117,8 @@ public class CertifyOperationTest {
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
DatabaseReadWriteInteractor databaseInteractor = new DatabaseReadWriteInteractor(RuntimeEnvironment.application);
|
||||
DatabaseReadWriteInteractor databaseInteractor =
|
||||
DatabaseReadWriteInteractor.createDatabaseReadWriteInteractor(RuntimeEnvironment.application);
|
||||
|
||||
// don't log verbosely here, we're not here to test imports
|
||||
ShadowLog.stream = oldShadowStream;
|
||||
@@ -132,7 +133,7 @@ public class CertifyOperationTest {
|
||||
@Test
|
||||
public void testSelfCertifyFlag() throws Exception {
|
||||
|
||||
CanonicalizedPublicKeyRing ring = new DatabaseReadWriteInteractor(RuntimeEnvironment.application)
|
||||
CanonicalizedPublicKeyRing ring = DatabaseReadWriteInteractor.createDatabaseReadWriteInteractor(RuntimeEnvironment.application)
|
||||
.getCanonicalizedPublicKeyRing(mStaticRing1.getMasterKeyId());
|
||||
Assert.assertEquals("secret key must be marked self-certified in database",
|
||||
// TODO this should be more correctly be VERIFIED_SELF at some point!
|
||||
@@ -143,10 +144,10 @@ public class CertifyOperationTest {
|
||||
@Test
|
||||
public void testCertifyId() throws Exception {
|
||||
CertifyOperation op = new CertifyOperation(RuntimeEnvironment.application,
|
||||
new DatabaseReadWriteInteractor(RuntimeEnvironment.application), null, null);
|
||||
DatabaseReadWriteInteractor.createDatabaseReadWriteInteractor(RuntimeEnvironment.application), null, null);
|
||||
|
||||
{
|
||||
CanonicalizedPublicKeyRing ring = new DatabaseReadWriteInteractor(RuntimeEnvironment.application)
|
||||
CanonicalizedPublicKeyRing ring = DatabaseReadWriteInteractor.createDatabaseReadWriteInteractor(RuntimeEnvironment.application)
|
||||
.getCanonicalizedPublicKeyRing(mStaticRing2.getMasterKeyId());
|
||||
Assert.assertEquals("public key must not be marked verified prior to certification",
|
||||
Certs.UNVERIFIED, ring.getVerified());
|
||||
@@ -160,7 +161,7 @@ public class CertifyOperationTest {
|
||||
Assert.assertTrue("certification must succeed", result.success());
|
||||
|
||||
{
|
||||
CanonicalizedPublicKeyRing ring = new DatabaseReadWriteInteractor(RuntimeEnvironment.application)
|
||||
CanonicalizedPublicKeyRing ring = DatabaseReadWriteInteractor.createDatabaseReadWriteInteractor(RuntimeEnvironment.application)
|
||||
.getCanonicalizedPublicKeyRing(mStaticRing2.getMasterKeyId());
|
||||
Assert.assertEquals("new key must be verified now",
|
||||
Certs.VERIFIED_SECRET, ring.getVerified());
|
||||
@@ -171,10 +172,10 @@ public class CertifyOperationTest {
|
||||
@Test
|
||||
public void testCertifyAttribute() throws Exception {
|
||||
CertifyOperation op = new CertifyOperation(RuntimeEnvironment.application,
|
||||
new DatabaseReadWriteInteractor(RuntimeEnvironment.application), null, null);
|
||||
DatabaseReadWriteInteractor.createDatabaseReadWriteInteractor(RuntimeEnvironment.application), null, null);
|
||||
|
||||
{
|
||||
CanonicalizedPublicKeyRing ring = new DatabaseReadWriteInteractor(RuntimeEnvironment.application)
|
||||
CanonicalizedPublicKeyRing ring = DatabaseReadWriteInteractor.createDatabaseReadWriteInteractor(RuntimeEnvironment.application)
|
||||
.getCanonicalizedPublicKeyRing(mStaticRing2.getMasterKeyId());
|
||||
Assert.assertEquals("public key must not be marked verified prior to certification",
|
||||
Certs.UNVERIFIED, ring.getVerified());
|
||||
@@ -188,7 +189,7 @@ public class CertifyOperationTest {
|
||||
Assert.assertTrue("certification must succeed", result.success());
|
||||
|
||||
{
|
||||
CanonicalizedPublicKeyRing ring = new DatabaseReadWriteInteractor(RuntimeEnvironment.application)
|
||||
CanonicalizedPublicKeyRing ring = DatabaseReadWriteInteractor.createDatabaseReadWriteInteractor(RuntimeEnvironment.application)
|
||||
.getCanonicalizedPublicKeyRing(mStaticRing2.getMasterKeyId());
|
||||
Assert.assertEquals("new key must be verified now",
|
||||
Certs.VERIFIED_SECRET, ring.getVerified());
|
||||
@@ -200,7 +201,7 @@ public class CertifyOperationTest {
|
||||
@Test
|
||||
public void testCertifySelf() throws Exception {
|
||||
CertifyOperation op = new CertifyOperation(RuntimeEnvironment.application,
|
||||
new DatabaseReadWriteInteractor(RuntimeEnvironment.application), null, null);
|
||||
DatabaseReadWriteInteractor.createDatabaseReadWriteInteractor(RuntimeEnvironment.application), null, null);
|
||||
|
||||
CertifyActionsParcel actions = new CertifyActionsParcel(mStaticRing1.getMasterKeyId());
|
||||
actions.add(new CertifyAction(mStaticRing1.getMasterKeyId(),
|
||||
@@ -217,7 +218,7 @@ public class CertifyOperationTest {
|
||||
public void testCertifyNonexistent() throws Exception {
|
||||
|
||||
CertifyOperation op = new CertifyOperation(RuntimeEnvironment.application,
|
||||
new DatabaseReadWriteInteractor(RuntimeEnvironment.application), null, null);
|
||||
DatabaseReadWriteInteractor.createDatabaseReadWriteInteractor(RuntimeEnvironment.application), null, null);
|
||||
|
||||
{
|
||||
CertifyActionsParcel actions = new CertifyActionsParcel(mStaticRing1.getMasterKeyId());
|
||||
|
||||
@@ -90,7 +90,8 @@ public class PromoteKeyOperationTest {
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
DatabaseReadWriteInteractor databaseInteractor = new DatabaseReadWriteInteractor(RuntimeEnvironment.application);
|
||||
DatabaseReadWriteInteractor databaseInteractor =
|
||||
DatabaseReadWriteInteractor.createDatabaseReadWriteInteractor(RuntimeEnvironment.application);
|
||||
|
||||
// don't log verbosely here, we're not here to test imports
|
||||
ShadowLog.stream = oldShadowStream;
|
||||
@@ -104,14 +105,14 @@ public class PromoteKeyOperationTest {
|
||||
@Test
|
||||
public void testPromote() throws Exception {
|
||||
PromoteKeyOperation op = new PromoteKeyOperation(RuntimeEnvironment.application,
|
||||
new DatabaseReadWriteInteractor(RuntimeEnvironment.application), null, null);
|
||||
DatabaseReadWriteInteractor.createDatabaseReadWriteInteractor(RuntimeEnvironment.application), null, null);
|
||||
|
||||
PromoteKeyResult result = op.execute(new PromoteKeyringParcel(mStaticRing.getMasterKeyId(), null, null), null);
|
||||
|
||||
Assert.assertTrue("promotion must succeed", result.success());
|
||||
|
||||
{
|
||||
CachedPublicKeyRing ring = new DatabaseReadWriteInteractor(RuntimeEnvironment.application)
|
||||
CachedPublicKeyRing ring = DatabaseReadWriteInteractor.createDatabaseReadWriteInteractor(RuntimeEnvironment.application)
|
||||
.getCachedPublicKeyRing(mStaticRing.getMasterKeyId());
|
||||
Assert.assertTrue("key must have a secret now", ring.hasAnySecret());
|
||||
|
||||
@@ -128,7 +129,7 @@ public class PromoteKeyOperationTest {
|
||||
@Test
|
||||
public void testPromoteDivert() throws Exception {
|
||||
PromoteKeyOperation op = new PromoteKeyOperation(RuntimeEnvironment.application,
|
||||
new DatabaseReadWriteInteractor(RuntimeEnvironment.application), null, null);
|
||||
DatabaseReadWriteInteractor.createDatabaseReadWriteInteractor(RuntimeEnvironment.application), null, null);
|
||||
|
||||
byte[] aid = Hex.decode("D2760001240102000000012345670000");
|
||||
|
||||
@@ -137,7 +138,7 @@ public class PromoteKeyOperationTest {
|
||||
Assert.assertTrue("promotion must succeed", result.success());
|
||||
|
||||
{
|
||||
CanonicalizedSecretKeyRing ring = new DatabaseReadWriteInteractor(RuntimeEnvironment.application)
|
||||
CanonicalizedSecretKeyRing ring = DatabaseReadWriteInteractor.createDatabaseReadWriteInteractor(RuntimeEnvironment.application)
|
||||
.getCanonicalizedSecretKeyRing(mStaticRing.getMasterKeyId());
|
||||
|
||||
for (CanonicalizedSecretKey key : ring.secretKeyIterator()) {
|
||||
@@ -153,7 +154,7 @@ public class PromoteKeyOperationTest {
|
||||
@Test
|
||||
public void testPromoteDivertSpecific() throws Exception {
|
||||
PromoteKeyOperation op = new PromoteKeyOperation(RuntimeEnvironment.application,
|
||||
new DatabaseReadWriteInteractor(RuntimeEnvironment.application), null, null);
|
||||
DatabaseReadWriteInteractor.createDatabaseReadWriteInteractor(RuntimeEnvironment.application), null, null);
|
||||
|
||||
byte[] aid = Hex.decode("D2760001240102000000012345670000");
|
||||
|
||||
@@ -167,7 +168,7 @@ public class PromoteKeyOperationTest {
|
||||
Assert.assertTrue("promotion must succeed", result.success());
|
||||
|
||||
{
|
||||
CanonicalizedSecretKeyRing ring = new DatabaseReadWriteInteractor(RuntimeEnvironment.application)
|
||||
CanonicalizedSecretKeyRing ring = DatabaseReadWriteInteractor.createDatabaseReadWriteInteractor(RuntimeEnvironment.application)
|
||||
.getCanonicalizedSecretKeyRing(mStaticRing.getMasterKeyId());
|
||||
|
||||
for (CanonicalizedSecretKey key : ring.secretKeyIterator()) {
|
||||
|
||||
@@ -126,7 +126,7 @@ public class InputDataOperationTest {
|
||||
when(spyApplication.getContentResolver()).thenReturn(mockResolver);
|
||||
|
||||
InputDataOperation op = new InputDataOperation(spyApplication,
|
||||
new DatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
|
||||
DatabaseReadWriteInteractor.createDatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
|
||||
|
||||
InputDataParcel input = new InputDataParcel(fakeInputUri, null);
|
||||
|
||||
@@ -306,7 +306,7 @@ public class InputDataOperationTest {
|
||||
when(spyApplication.getContentResolver()).thenReturn(mockResolver);
|
||||
|
||||
InputDataOperation op = new InputDataOperation(spyApplication,
|
||||
new DatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
|
||||
DatabaseReadWriteInteractor.createDatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
|
||||
|
||||
InputDataParcel input = new InputDataParcel(FAKE_CONTENT_INPUT_URI_1, null);
|
||||
return op.execute(input, new CryptoInputParcel());
|
||||
|
||||
@@ -149,7 +149,8 @@ public class PgpEncryptDecryptTest {
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
DatabaseReadWriteInteractor databaseInteractor = new DatabaseReadWriteInteractor(RuntimeEnvironment.application);
|
||||
DatabaseReadWriteInteractor databaseInteractor =
|
||||
DatabaseReadWriteInteractor.createDatabaseReadWriteInteractor(RuntimeEnvironment.application);
|
||||
|
||||
// don't log verbosely here, we're not here to test imports
|
||||
ShadowLog.stream = oldShadowStream;
|
||||
@@ -172,7 +173,7 @@ public class PgpEncryptDecryptTest {
|
||||
ByteArrayInputStream in = new ByteArrayInputStream(plaintext.getBytes());
|
||||
|
||||
PgpSignEncryptOperation op = new PgpSignEncryptOperation(RuntimeEnvironment.application,
|
||||
new DatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
|
||||
DatabaseReadWriteInteractor.createDatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
|
||||
|
||||
InputData data = new InputData(in, in.available());
|
||||
|
||||
@@ -197,7 +198,7 @@ public class PgpEncryptDecryptTest {
|
||||
InputData data = new InputData(in, in.available());
|
||||
|
||||
PgpDecryptVerifyOperation op = new PgpDecryptVerifyOperation(RuntimeEnvironment.application,
|
||||
new DatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
|
||||
DatabaseReadWriteInteractor.createDatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
|
||||
PgpDecryptVerifyInputParcel input = new PgpDecryptVerifyInputParcel();
|
||||
input.setAllowSymmetricDecryption(true);
|
||||
DecryptVerifyResult result = op.execute(
|
||||
@@ -227,7 +228,7 @@ public class PgpEncryptDecryptTest {
|
||||
InputData data = new InputData(in, in.available());
|
||||
|
||||
PgpDecryptVerifyOperation op = new PgpDecryptVerifyOperation(RuntimeEnvironment.application,
|
||||
new DatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
|
||||
DatabaseReadWriteInteractor.createDatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
|
||||
PgpDecryptVerifyInputParcel input = new PgpDecryptVerifyInputParcel();
|
||||
input.setAllowSymmetricDecryption(true);
|
||||
DecryptVerifyResult result = op.execute(input,
|
||||
@@ -249,7 +250,7 @@ public class PgpEncryptDecryptTest {
|
||||
InputData data = new InputData(in, in.available());
|
||||
|
||||
PgpDecryptVerifyOperation op = new PgpDecryptVerifyOperation(RuntimeEnvironment.application,
|
||||
new DatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
|
||||
DatabaseReadWriteInteractor.createDatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
|
||||
PgpDecryptVerifyInputParcel input = new PgpDecryptVerifyInputParcel();
|
||||
input.setAllowSymmetricDecryption(true);
|
||||
DecryptVerifyResult result = op.execute(input,
|
||||
@@ -270,7 +271,7 @@ public class PgpEncryptDecryptTest {
|
||||
InputData data = new InputData(in, in.available());
|
||||
|
||||
PgpDecryptVerifyOperation op = new PgpDecryptVerifyOperation(RuntimeEnvironment.application,
|
||||
new DatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
|
||||
DatabaseReadWriteInteractor.createDatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
|
||||
PgpDecryptVerifyInputParcel input = new PgpDecryptVerifyInputParcel();
|
||||
input.setAllowSymmetricDecryption(false);
|
||||
DecryptVerifyResult result = op.execute(input,
|
||||
@@ -297,7 +298,7 @@ public class PgpEncryptDecryptTest {
|
||||
ByteArrayInputStream in = new ByteArrayInputStream(plaintext.getBytes());
|
||||
|
||||
PgpSignEncryptOperation op = new PgpSignEncryptOperation(RuntimeEnvironment.application,
|
||||
new DatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
|
||||
DatabaseReadWriteInteractor.createDatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
|
||||
|
||||
InputData data = new InputData(in, in.available());
|
||||
|
||||
@@ -353,7 +354,7 @@ public class PgpEncryptDecryptTest {
|
||||
ByteArrayInputStream in = new ByteArrayInputStream(plaintext.getBytes());
|
||||
|
||||
PgpSignEncryptOperation op = new PgpSignEncryptOperation(RuntimeEnvironment.application,
|
||||
new DatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
|
||||
DatabaseReadWriteInteractor.createDatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
|
||||
|
||||
InputData data = new InputData(in, in.available());
|
||||
|
||||
@@ -415,7 +416,7 @@ public class PgpEncryptDecryptTest {
|
||||
ByteArrayInputStream in = new ByteArrayInputStream(plaintext.getBytes());
|
||||
|
||||
PgpSignEncryptOperation op = new PgpSignEncryptOperation(RuntimeEnvironment.application,
|
||||
new DatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
|
||||
DatabaseReadWriteInteractor.createDatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
|
||||
|
||||
InputData data = new InputData(in, in.available());
|
||||
|
||||
@@ -472,7 +473,7 @@ public class PgpEncryptDecryptTest {
|
||||
ByteArrayInputStream in = new ByteArrayInputStream(plaintext.getBytes());
|
||||
|
||||
PgpSignEncryptOperation op = new PgpSignEncryptOperation(RuntimeEnvironment.application,
|
||||
new DatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
|
||||
DatabaseReadWriteInteractor.createDatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
|
||||
|
||||
InputData data = new InputData(in, in.available());
|
||||
|
||||
@@ -575,7 +576,7 @@ public class PgpEncryptDecryptTest {
|
||||
ByteArrayInputStream in = new ByteArrayInputStream(plaintext.getBytes());
|
||||
|
||||
PgpSignEncryptOperation op = new PgpSignEncryptOperation(RuntimeEnvironment.application,
|
||||
new DatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
|
||||
DatabaseReadWriteInteractor.createDatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
|
||||
|
||||
InputData data = new InputData(in, in.available());
|
||||
|
||||
@@ -626,11 +627,12 @@ public class PgpEncryptDecryptTest {
|
||||
new ArrayList<RawPacket>(), new ArrayList<RawPacket>(),
|
||||
new CryptoInputParcel(new Date(), mKeyPhrase1));
|
||||
|
||||
DatabaseReadWriteInteractor databaseInteractor = new DatabaseReadWriteInteractor(RuntimeEnvironment.application);
|
||||
DatabaseReadWriteInteractor databaseInteractor =
|
||||
DatabaseReadWriteInteractor.createDatabaseReadWriteInteractor(RuntimeEnvironment.application);
|
||||
databaseInteractor.saveSecretKeyRing(modified, new ProgressScaler());
|
||||
|
||||
PgpDecryptVerifyOperation op = new PgpDecryptVerifyOperation(RuntimeEnvironment.application,
|
||||
new DatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
|
||||
DatabaseReadWriteInteractor.createDatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
|
||||
PgpDecryptVerifyInputParcel input = new PgpDecryptVerifyInputParcel(ciphertext);
|
||||
DecryptVerifyResult result = op.execute(input, new CryptoInputParcel(mKeyPhrase1));
|
||||
|
||||
@@ -648,11 +650,12 @@ public class PgpEncryptDecryptTest {
|
||||
new ArrayList<RawPacket>(), new ArrayList<RawPacket>(),
|
||||
new CryptoInputParcel(new Date(), mKeyPhrase1));
|
||||
|
||||
DatabaseReadWriteInteractor databaseInteractor = new DatabaseReadWriteInteractor(RuntimeEnvironment.application);
|
||||
DatabaseReadWriteInteractor databaseInteractor =
|
||||
DatabaseReadWriteInteractor.createDatabaseReadWriteInteractor(RuntimeEnvironment.application);
|
||||
databaseInteractor.saveSecretKeyRing(modified, new ProgressScaler());
|
||||
|
||||
PgpDecryptVerifyOperation op = new PgpDecryptVerifyOperation(RuntimeEnvironment.application,
|
||||
new DatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
|
||||
DatabaseReadWriteInteractor.createDatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
|
||||
PgpDecryptVerifyInputParcel input = new PgpDecryptVerifyInputParcel(ciphertext);
|
||||
DecryptVerifyResult result = op.execute(input, new CryptoInputParcel(mKeyPhrase1));
|
||||
|
||||
@@ -675,7 +678,8 @@ public class PgpEncryptDecryptTest {
|
||||
new ArrayList<RawPacket>(), new ArrayList<RawPacket>(),
|
||||
new CryptoInputParcel(new Date(), mKeyPhrase1));
|
||||
|
||||
DatabaseReadWriteInteractor databaseInteractor = new DatabaseReadWriteInteractor(RuntimeEnvironment.application);
|
||||
DatabaseReadWriteInteractor databaseInteractor =
|
||||
DatabaseReadWriteInteractor.createDatabaseReadWriteInteractor(RuntimeEnvironment.application);
|
||||
databaseInteractor.saveSecretKeyRing(modified, new ProgressScaler());
|
||||
}
|
||||
|
||||
@@ -685,7 +689,7 @@ public class PgpEncryptDecryptTest {
|
||||
ByteArrayInputStream in = new ByteArrayInputStream(plaintext.getBytes());
|
||||
|
||||
PgpSignEncryptOperation op = new PgpSignEncryptOperation(RuntimeEnvironment.application,
|
||||
new DatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
|
||||
DatabaseReadWriteInteractor.createDatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
|
||||
|
||||
InputData data = new InputData(in, in.available());
|
||||
|
||||
@@ -730,7 +734,7 @@ public class PgpEncryptDecryptTest {
|
||||
ByteArrayInputStream in = new ByteArrayInputStream(plaintext.getBytes());
|
||||
|
||||
PgpSignEncryptOperation op = new PgpSignEncryptOperation(RuntimeEnvironment.application,
|
||||
new DatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
|
||||
DatabaseReadWriteInteractor.createDatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
|
||||
|
||||
InputData data = new InputData(in, in.available());
|
||||
|
||||
@@ -824,7 +828,7 @@ public class PgpEncryptDecryptTest {
|
||||
{ // decryption with passphrase cached should succeed for the other key if first is gone
|
||||
|
||||
// delete first key from database
|
||||
new DatabaseReadWriteInteractor(RuntimeEnvironment.application).getContentResolver().delete(
|
||||
DatabaseReadWriteInteractor.createDatabaseReadWriteInteractor(RuntimeEnvironment.application).getContentResolver().delete(
|
||||
KeyRingData.buildPublicKeyRingUri(mStaticRing1.getMasterKeyId()), null, null
|
||||
);
|
||||
|
||||
@@ -859,7 +863,7 @@ public class PgpEncryptDecryptTest {
|
||||
ByteArrayInputStream in = new ByteArrayInputStream(plaintext.getBytes());
|
||||
|
||||
PgpSignEncryptOperation op = new PgpSignEncryptOperation(RuntimeEnvironment.application,
|
||||
new DatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
|
||||
DatabaseReadWriteInteractor.createDatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
|
||||
|
||||
InputData data = new InputData(in, in.available());
|
||||
|
||||
@@ -907,7 +911,7 @@ public class PgpEncryptDecryptTest {
|
||||
{ // decryption with passphrase cached should succeed for the other key if first is gone
|
||||
|
||||
// delete first key from database
|
||||
new DatabaseReadWriteInteractor(RuntimeEnvironment.application).getContentResolver().delete(
|
||||
DatabaseReadWriteInteractor.createDatabaseReadWriteInteractor(RuntimeEnvironment.application).getContentResolver().delete(
|
||||
KeyRingData.buildPublicKeyRingUri(mStaticRing1.getMasterKeyId()), null, null
|
||||
);
|
||||
|
||||
@@ -946,7 +950,7 @@ public class PgpEncryptDecryptTest {
|
||||
ByteArrayInputStream in = new ByteArrayInputStream(plaindata);
|
||||
|
||||
PgpSignEncryptOperation op = new PgpSignEncryptOperation(RuntimeEnvironment.application,
|
||||
new DatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
|
||||
DatabaseReadWriteInteractor.createDatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
|
||||
|
||||
InputData data = new InputData(in, in.available());
|
||||
|
||||
@@ -1018,7 +1022,7 @@ public class PgpEncryptDecryptTest {
|
||||
ByteArrayInputStream in = new ByteArrayInputStream(plaintext.getBytes());
|
||||
|
||||
PgpSignEncryptOperation op = new PgpSignEncryptOperation(RuntimeEnvironment.application,
|
||||
new DatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
|
||||
DatabaseReadWriteInteractor.createDatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
|
||||
|
||||
InputData data = new InputData(in, in.available());
|
||||
|
||||
@@ -1069,7 +1073,7 @@ public class PgpEncryptDecryptTest {
|
||||
final Passphrase passphrase, final Long checkMasterKeyId, final Long checkSubKeyId) {
|
||||
|
||||
return new PgpDecryptVerifyOperation(RuntimeEnvironment.application,
|
||||
new DatabaseReadWriteInteractor(RuntimeEnvironment.application), null) {
|
||||
DatabaseReadWriteInteractor.createDatabaseReadWriteInteractor(RuntimeEnvironment.application), null) {
|
||||
@Override
|
||||
public Passphrase getCachedPassphrase(long masterKeyId, long subKeyId)
|
||||
throws NoSecretKeyException {
|
||||
|
||||
@@ -43,7 +43,8 @@ import java.util.Iterator;
|
||||
@RunWith(KeychainTestRunner.class)
|
||||
public class DatabaseInteractorSaveTest {
|
||||
|
||||
DatabaseReadWriteInteractor mDatabaseInteractor = new DatabaseReadWriteInteractor(RuntimeEnvironment.application);
|
||||
DatabaseReadWriteInteractor mDatabaseInteractor =
|
||||
DatabaseReadWriteInteractor.createDatabaseReadWriteInteractor(RuntimeEnvironment.application);
|
||||
|
||||
@BeforeClass
|
||||
public static void setUpOnce() throws Exception {
|
||||
@@ -61,17 +62,17 @@ public class DatabaseInteractorSaveTest {
|
||||
SaveKeyringResult result;
|
||||
|
||||
// insert both keys, second should fail
|
||||
result = new DatabaseReadWriteInteractor(RuntimeEnvironment.application).savePublicKeyRing(first);
|
||||
result = DatabaseReadWriteInteractor.createDatabaseReadWriteInteractor(RuntimeEnvironment.application).savePublicKeyRing(first);
|
||||
Assert.assertTrue("first keyring import should succeed", result.success());
|
||||
result = new DatabaseReadWriteInteractor(RuntimeEnvironment.application).savePublicKeyRing(second);
|
||||
result = DatabaseReadWriteInteractor.createDatabaseReadWriteInteractor(RuntimeEnvironment.application).savePublicKeyRing(second);
|
||||
Assert.assertFalse("second keyring import should fail", result.success());
|
||||
|
||||
new KeychainDatabase(RuntimeEnvironment.application).clearDatabase();
|
||||
|
||||
// and the other way around
|
||||
result = new DatabaseReadWriteInteractor(RuntimeEnvironment.application).savePublicKeyRing(second);
|
||||
result = DatabaseReadWriteInteractor.createDatabaseReadWriteInteractor(RuntimeEnvironment.application).savePublicKeyRing(second);
|
||||
Assert.assertTrue("first keyring import should succeed", result.success());
|
||||
result = new DatabaseReadWriteInteractor(RuntimeEnvironment.application).savePublicKeyRing(first);
|
||||
result = DatabaseReadWriteInteractor.createDatabaseReadWriteInteractor(RuntimeEnvironment.application).savePublicKeyRing(first);
|
||||
Assert.assertFalse("second keyring import should fail", result.success());
|
||||
|
||||
}
|
||||
@@ -90,13 +91,15 @@ public class DatabaseInteractorSaveTest {
|
||||
SaveKeyringResult result;
|
||||
|
||||
// insert secret, this should fail because of missing self-cert
|
||||
result = new DatabaseReadWriteInteractor(RuntimeEnvironment.application).saveSecretKeyRing(seckey, new ProgressScaler());
|
||||
result = DatabaseReadWriteInteractor.createDatabaseReadWriteInteractor(RuntimeEnvironment.application)
|
||||
.saveSecretKeyRing(seckey, new ProgressScaler());
|
||||
Assert.assertFalse("secret keyring import before pubring import should fail", result.success());
|
||||
|
||||
// insert pubkey, then seckey - both should succeed
|
||||
result = new DatabaseReadWriteInteractor(RuntimeEnvironment.application).savePublicKeyRing(pubkey);
|
||||
result = DatabaseReadWriteInteractor.createDatabaseReadWriteInteractor(RuntimeEnvironment.application).savePublicKeyRing(pubkey);
|
||||
Assert.assertTrue("public keyring import should succeed", result.success());
|
||||
result = new DatabaseReadWriteInteractor(RuntimeEnvironment.application).saveSecretKeyRing(seckey, new ProgressScaler());
|
||||
result = DatabaseReadWriteInteractor.createDatabaseReadWriteInteractor(RuntimeEnvironment.application)
|
||||
.saveSecretKeyRing(seckey, new ProgressScaler());
|
||||
Assert.assertTrue("secret keyring import after pubring import should succeed", result.success());
|
||||
|
||||
}
|
||||
|
||||
@@ -45,7 +45,8 @@ public class KeychainExternalProviderTest {
|
||||
static final long KEY_ID_PUBLIC = 0x9A282CE2AB44A382L;
|
||||
|
||||
|
||||
DatabaseReadWriteInteractor databaseInteractor = new DatabaseReadWriteInteractor(RuntimeEnvironment.application);
|
||||
DatabaseReadWriteInteractor databaseInteractor =
|
||||
DatabaseReadWriteInteractor.createDatabaseReadWriteInteractor(RuntimeEnvironment.application);
|
||||
ContentResolver contentResolver = RuntimeEnvironment.application.getContentResolver();
|
||||
ApiPermissionHelper apiPermissionHelper;
|
||||
ApiDataAccessObject apiDao;
|
||||
|
||||
@@ -51,7 +51,8 @@ public class KeyringTestingHelper {
|
||||
|
||||
public boolean addKeyring(Collection<String> blobFiles) throws Exception {
|
||||
|
||||
DatabaseReadWriteInteractor databaseInteractor = new DatabaseReadWriteInteractor(context);
|
||||
DatabaseReadWriteInteractor databaseInteractor =
|
||||
DatabaseReadWriteInteractor.createDatabaseReadWriteInteractor(context);
|
||||
|
||||
byte[] data = TestDataUtil.readAllFully(blobFiles);
|
||||
UncachedKeyRing ring = UncachedKeyRing.decodeFromData(data);
|
||||
|
||||
Reference in New Issue
Block a user