mirror of
https://github.com/vanitasvitae/Smack.git
synced 2025-09-14 11:39:39 +02:00
Temporary commit
This commit is contained in:
parent
daab6039a1
commit
a749bc4cc4
15 changed files with 273 additions and 164 deletions
|
@ -0,0 +1,51 @@
|
|||
/**
|
||||
*
|
||||
* Copyright 2019 Paul Schaub
|
||||
*
|
||||
* This file is part of smack-omemo-signal.
|
||||
*
|
||||
* smack-omemo-signal is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package org.jivesoftware.smackx.omemo.signal;
|
||||
|
||||
import org.jivesoftware.smackx.omemo.OmemoStore;
|
||||
import org.jivesoftware.smackx.omemo.util.ChainKeyIndexStalenessStrategy;
|
||||
|
||||
import org.whispersystems.libsignal.IdentityKey;
|
||||
import org.whispersystems.libsignal.IdentityKeyPair;
|
||||
import org.whispersystems.libsignal.SessionCipher;
|
||||
import org.whispersystems.libsignal.SignalProtocolAddress;
|
||||
import org.whispersystems.libsignal.ecc.ECPublicKey;
|
||||
import org.whispersystems.libsignal.state.PreKeyBundle;
|
||||
import org.whispersystems.libsignal.state.PreKeyRecord;
|
||||
import org.whispersystems.libsignal.state.SessionRecord;
|
||||
import org.whispersystems.libsignal.state.SignedPreKeyRecord;
|
||||
|
||||
public class SignalChainKeyIndexStalenessStrategy extends ChainKeyIndexStalenessStrategy<IdentityKeyPair, IdentityKey,
|
||||
PreKeyRecord, SignedPreKeyRecord, SessionRecord, SignalProtocolAddress, ECPublicKey, PreKeyBundle, SessionCipher> {
|
||||
|
||||
/**
|
||||
* Create a new {@link SignalChainKeyIndexStalenessStrategy}.
|
||||
*
|
||||
* @param store {@link OmemoStore} from which we can read the devices {@link SessionRecord}.
|
||||
* @param maxChainKeyIndex the maximum value of messages we are allowed to send to the device unanswered before
|
||||
*/
|
||||
public SignalChainKeyIndexStalenessStrategy(
|
||||
OmemoStore<IdentityKeyPair, IdentityKey, PreKeyRecord, SignedPreKeyRecord, SessionRecord,
|
||||
SignalProtocolAddress, ECPublicKey, PreKeyBundle, SessionCipher> store,
|
||||
int maxChainKeyIndex) {
|
||||
super(store, maxChainKeyIndex);
|
||||
}
|
||||
}
|
|
@ -96,6 +96,11 @@ public class SignalOmemoKeyUtil extends OmemoKeyUtil<IdentityKeyPair, IdentityKe
|
|||
return session.serialize();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int lengthOfSessionSendingChain(SessionRecord session) {
|
||||
return session.getSessionState().getSenderChainKey().getIndex();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IdentityKeyPair identityKeyPairFromBytes(byte[] data) throws CorruptedOmemoKeyException {
|
||||
if (data == null) return null;
|
||||
|
|
|
@ -22,11 +22,13 @@ package org.jivesoftware.smackx.omemo.signal;
|
|||
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.jivesoftware.smackx.omemo.OmemoConfiguration;
|
||||
import org.jivesoftware.smackx.omemo.OmemoManager;
|
||||
import org.jivesoftware.smackx.omemo.OmemoService;
|
||||
import org.jivesoftware.smackx.omemo.OmemoStore;
|
||||
import org.jivesoftware.smackx.omemo.exceptions.CorruptedOmemoKeyException;
|
||||
import org.jivesoftware.smackx.omemo.internal.OmemoDevice;
|
||||
import org.jivesoftware.smackx.omemo.util.StalenessStrategy;
|
||||
|
||||
import org.whispersystems.libsignal.IdentityKey;
|
||||
import org.whispersystems.libsignal.IdentityKeyPair;
|
||||
|
@ -87,6 +89,19 @@ public final class SignalOmemoService
|
|||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a {@link StalenessStrategy} which is used to determine, whether or not an OMEMO session is stale or not.
|
||||
* Staleness is used in order to stop encrypting messages to read-only devices after a certain amount of time
|
||||
* or unanswered messages.
|
||||
*
|
||||
* @return strategy
|
||||
*/
|
||||
@Override
|
||||
protected StalenessStrategy getStalenessStrategy() {
|
||||
return new SignalChainKeyIndexStalenessStrategy(getOmemoStoreBackend(),
|
||||
OmemoConfiguration.getMaxReadOnlyMessageCount());
|
||||
}
|
||||
|
||||
public static void acknowledgeLicense() {
|
||||
LICENSE_ACKNOWLEDGED = true;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue