mirror of
https://github.com/vanitasvitae/Smack.git
synced 2025-09-10 01:29:38 +02:00
Rebase on master
This commit is contained in:
parent
19a91794c6
commit
ce5b5f88ef
18 changed files with 117 additions and 156 deletions
|
@ -39,8 +39,7 @@ import org.whispersystems.libsignal.state.SignedPreKeyRecord;
|
|||
* excessive storage access, or it can be used standalone as an ephemeral store, which doesn't persist its contents.
|
||||
*/
|
||||
public class SignalCachingOmemoStore extends CachingOmemoStore<IdentityKeyPair, IdentityKey, PreKeyRecord,
|
||||
SignedPreKeyRecord, SessionRecord, SignalProtocolAddress, ECPublicKey, PreKeyBundle, SessionCipher>
|
||||
{
|
||||
SignedPreKeyRecord, SessionRecord, SignalProtocolAddress, ECPublicKey, PreKeyBundle, SessionCipher> {
|
||||
|
||||
/**
|
||||
* Create a new SignalCachingOmemoStore as a caching layer around a persisting OmemoStore
|
||||
|
@ -48,8 +47,7 @@ public class SignalCachingOmemoStore extends CachingOmemoStore<IdentityKeyPair,
|
|||
* @param wrappedStore other store implementation that gets wrapped
|
||||
*/
|
||||
public SignalCachingOmemoStore(OmemoStore<IdentityKeyPair, IdentityKey, PreKeyRecord, SignedPreKeyRecord,
|
||||
SessionRecord, SignalProtocolAddress, ECPublicKey, PreKeyBundle, SessionCipher> wrappedStore)
|
||||
{
|
||||
SessionRecord, SignalProtocolAddress, ECPublicKey, PreKeyBundle, SessionCipher> wrappedStore) {
|
||||
super(wrappedStore);
|
||||
}
|
||||
|
||||
|
|
|
@ -43,16 +43,14 @@ import org.whispersystems.libsignal.state.SignedPreKeyRecord;
|
|||
@SuppressWarnings("unused")
|
||||
public class SignalFileBasedOmemoStore
|
||||
extends FileBasedOmemoStore<IdentityKeyPair, IdentityKey, PreKeyRecord, SignedPreKeyRecord, SessionRecord,
|
||||
SignalProtocolAddress, ECPublicKey, PreKeyBundle, SessionCipher>
|
||||
{
|
||||
SignalProtocolAddress, ECPublicKey, PreKeyBundle, SessionCipher> {
|
||||
|
||||
public SignalFileBasedOmemoStore(File base) {
|
||||
super(base);
|
||||
}
|
||||
|
||||
@Override
|
||||
public OmemoKeyUtil<IdentityKeyPair, IdentityKey, PreKeyRecord, SignedPreKeyRecord, SessionRecord, ECPublicKey, PreKeyBundle> keyUtil()
|
||||
{
|
||||
public OmemoKeyUtil<IdentityKeyPair, IdentityKey, PreKeyRecord, SignedPreKeyRecord, SessionRecord, ECPublicKey, PreKeyBundle> keyUtil() {
|
||||
return new SignalOmemoKeyUtil();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,8 +47,8 @@ import org.whispersystems.libsignal.util.KeyHelper;
|
|||
* @author Paul Schaub
|
||||
*/
|
||||
public class SignalOmemoKeyUtil extends OmemoKeyUtil<IdentityKeyPair, IdentityKey, PreKeyRecord, SignedPreKeyRecord,
|
||||
SessionRecord, ECPublicKey, PreKeyBundle>
|
||||
{
|
||||
SessionRecord, ECPublicKey, PreKeyBundle> {
|
||||
|
||||
@Override
|
||||
public IdentityKeyPair generateOmemoIdentityKeyPair() {
|
||||
return KeyHelper.generateIdentityKeyPair();
|
||||
|
@ -66,8 +66,7 @@ public class SignalOmemoKeyUtil extends OmemoKeyUtil<IdentityKeyPair, IdentityKe
|
|||
|
||||
@Override
|
||||
public SignedPreKeyRecord generateOmemoSignedPreKey(IdentityKeyPair identityKeyPair, int currentPreKeyId)
|
||||
throws CorruptedOmemoKeyException
|
||||
{
|
||||
throws CorruptedOmemoKeyException {
|
||||
try {
|
||||
return KeyHelper.generateSignedPreKey(identityKeyPair, currentPreKeyId);
|
||||
} catch (InvalidKeyException e) {
|
||||
|
@ -140,8 +139,7 @@ public class SignalOmemoKeyUtil extends OmemoKeyUtil<IdentityKeyPair, IdentityKe
|
|||
|
||||
@Override
|
||||
public PreKeyBundle bundleFromOmemoBundle(OmemoBundleElement bundle, OmemoDevice contact, int preKeyId)
|
||||
throws CorruptedOmemoKeyException
|
||||
{
|
||||
throws CorruptedOmemoKeyException {
|
||||
return new PreKeyBundle(0,
|
||||
contact.getDeviceId(),
|
||||
preKeyId,
|
||||
|
|
|
@ -57,16 +57,15 @@ import org.whispersystems.libsignal.state.SignedPreKeyRecord;
|
|||
|
||||
public class SignalOmemoRatchet
|
||||
extends OmemoRatchet<IdentityKeyPair, IdentityKey, PreKeyRecord, SignedPreKeyRecord, SessionRecord,
|
||||
SignalProtocolAddress, ECPublicKey, PreKeyBundle, SessionCipher>
|
||||
{
|
||||
SignalProtocolAddress, ECPublicKey, PreKeyBundle, SessionCipher> {
|
||||
|
||||
private static final Logger LOGGER = Logger.getLogger(OmemoRatchet.class.getName());
|
||||
private final SignalOmemoStoreConnector storeConnector;
|
||||
|
||||
SignalOmemoRatchet(OmemoManager omemoManager,
|
||||
OmemoStore<IdentityKeyPair, IdentityKey, PreKeyRecord, SignedPreKeyRecord,
|
||||
SessionRecord, SignalProtocolAddress, ECPublicKey, PreKeyBundle,
|
||||
SessionCipher> store)
|
||||
{
|
||||
SessionCipher> store) {
|
||||
super(omemoManager, store);
|
||||
this.storeConnector = new SignalOmemoStoreConnector(omemoManager, store);
|
||||
}
|
||||
|
@ -74,8 +73,8 @@ public class SignalOmemoRatchet
|
|||
@Override
|
||||
public byte[] doubleRatchetDecrypt(OmemoDevice sender, byte[] encryptedKey)
|
||||
throws CorruptedOmemoKeyException, NoRawSessionException, CryptoFailedException,
|
||||
UntrustedOmemoIdentityException
|
||||
{
|
||||
UntrustedOmemoIdentityException {
|
||||
|
||||
SessionCipher cipher = getCipher(sender);
|
||||
byte[] decryptedKey;
|
||||
|
||||
|
|
|
@ -48,8 +48,8 @@ import org.whispersystems.libsignal.state.SignedPreKeyRecord;
|
|||
@SuppressWarnings("unused")
|
||||
public final class SignalOmemoService
|
||||
extends OmemoService<IdentityKeyPair, IdentityKey, PreKeyRecord, SignedPreKeyRecord, SessionRecord,
|
||||
SignalProtocolAddress, ECPublicKey, PreKeyBundle, SessionCipher>
|
||||
{
|
||||
SignalProtocolAddress, ECPublicKey, PreKeyBundle, SessionCipher> {
|
||||
|
||||
private static SignalOmemoService INSTANCE;
|
||||
private static boolean LICENSE_ACKNOWLEDGED = false;
|
||||
|
||||
|
@ -57,8 +57,8 @@ public final class SignalOmemoService
|
|||
protected SignalOmemoRatchet instantiateOmemoRatchet(
|
||||
OmemoManager manager,
|
||||
OmemoStore<IdentityKeyPair, IdentityKey, PreKeyRecord, SignedPreKeyRecord, SessionRecord,
|
||||
SignalProtocolAddress, ECPublicKey, PreKeyBundle, SessionCipher> store)
|
||||
{
|
||||
SignalProtocolAddress, ECPublicKey, PreKeyBundle, SessionCipher> store) {
|
||||
|
||||
return new SignalOmemoRatchet(manager, getOmemoStoreBackend());
|
||||
}
|
||||
|
||||
|
@ -95,8 +95,8 @@ public final class SignalOmemoService
|
|||
protected void processBundle(OmemoManager omemoManager,
|
||||
PreKeyBundle contactsBundle,
|
||||
OmemoDevice contactsDevice)
|
||||
throws CorruptedOmemoKeyException
|
||||
{
|
||||
throws CorruptedOmemoKeyException {
|
||||
|
||||
SignalOmemoStoreConnector connector = new SignalOmemoStoreConnector(omemoManager, getOmemoStoreBackend());
|
||||
SessionBuilder builder = new SessionBuilder(connector, connector, connector, connector,
|
||||
SignalOmemoStoreConnector.asAddress(contactsDevice));
|
||||
|
|
|
@ -45,20 +45,17 @@ public class LegacySignalOmemoKeyUtilTest extends SmackTestSuite {
|
|||
private final SignalOmemoKeyUtil keyUtil = new SignalOmemoKeyUtil();
|
||||
|
||||
@Test
|
||||
public void omemoIdentityKeyPairSerializationTest() {
|
||||
public void omemoIdentityKeyPairSerializationTest() throws CorruptedOmemoKeyException {
|
||||
IdentityKeyPair ikp = keyUtil.generateOmemoIdentityKeyPair();
|
||||
byte[] bytes = keyUtil.identityKeyPairToBytes(ikp);
|
||||
assertNotNull("serialized identityKeyPair must not be null.",
|
||||
bytes);
|
||||
assertNotSame("serialized identityKeyPair must not be of length 0.",
|
||||
0, bytes.length);
|
||||
try {
|
||||
IdentityKeyPair ikp2 = keyUtil.identityKeyPairFromBytes(bytes);
|
||||
assertTrue("Deserialized IdentityKeyPairs PublicKey must equal the originals one.",
|
||||
ikp.getPublicKey().equals(ikp2.getPublicKey()));
|
||||
} catch (CorruptedOmemoKeyException e) {
|
||||
fail("Caught exception while deserializing IdentityKeyPair.");
|
||||
}
|
||||
|
||||
IdentityKeyPair ikp2 = keyUtil.identityKeyPairFromBytes(bytes);
|
||||
assertTrue("Deserialized IdentityKeyPairs PublicKey must equal the originals one.",
|
||||
ikp.getPublicKey().equals(ikp2.getPublicKey()));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue