Move the RDE encryption to a dedicated file

Merges the encryptor creation between RyDE and Ghostryde.

The new file - RydeEncryption.java - is a merge of the removed functions in
Ghostryde.java and the RydePgpEncryptionOutputStream.java.

This is one of a series of CLs - each merging a single "part" of the encoding.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=205246053
This commit is contained in:
guyben 2018-07-19 08:34:59 -07:00 committed by jianglai
parent 260a6fb23b
commit 8a8cd9f0d2
7 changed files with 388 additions and 271 deletions

View file

@ -161,13 +161,15 @@ public class GhostrydeTest {
korruption(ciphertext, ciphertext.length / 2);
ByteArrayInputStream bsIn = new ByteArrayInputStream(ciphertext);
assertThrows(
PGPException.class,
() -> {
try (InputStream decoder = Ghostryde.decoder(bsIn, privateKey)) {
ByteStreams.copy(decoder, ByteStreams.nullOutputStream());
}
});
RuntimeException thrown =
assertThrows(
RuntimeException.class,
() -> {
try (InputStream decoder = Ghostryde.decoder(bsIn, privateKey)) {
ByteStreams.copy(decoder, ByteStreams.nullOutputStream());
}
});
assertThat(thrown).hasCauseThat().isInstanceOf(PGPException.class);
}
@Test
@ -219,15 +221,17 @@ public class GhostrydeTest {
}
ByteArrayInputStream bsIn = new ByteArrayInputStream(bsOut.toByteArray());
PGPException thrown =
RuntimeException thrown =
assertThrows(
PGPException.class,
RuntimeException.class,
() -> {
try (InputStream decoder = Ghostryde.decoder(bsIn, privateKey)) {
ByteStreams.copy(decoder, ByteStreams.nullOutputStream());
}
});
assertThat(thrown).hasCauseThat().isInstanceOf(PGPException.class);
assertThat(thrown)
.hasCauseThat()
.hasMessageThat()
.contains(
"Message was encrypted for keyids [a59c132f3589a1d5] but ours is c9598c84ec70b9fd");