org.whispersystems.libsignal.state.PreKeyStore Java Examples
The following examples show how to use
org.whispersystems.libsignal.state.PreKeyStore.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PreKeyUtil.java From mollyim-android with GNU General Public License v3.0 | 6 votes |
public synchronized static List<PreKeyRecord> generatePreKeys(Context context) { PreKeyStore preKeyStore = new TextSecurePreKeyStore(context); List<PreKeyRecord> records = new LinkedList<>(); int preKeyIdOffset = TextSecurePreferences.getNextPreKeyId(context); for (int i=0;i<BATCH_SIZE;i++) { int preKeyId = (preKeyIdOffset + i) % Medium.MAX_VALUE; ECKeyPair keyPair = Curve.generateKeyPair(); PreKeyRecord record = new PreKeyRecord(preKeyId, keyPair); preKeyStore.storePreKey(preKeyId, record); records.add(record); } TextSecurePreferences.setNextPreKeyId(context, (preKeyIdOffset + BATCH_SIZE + 1) % Medium.MAX_VALUE); return records; }
Example #2
Source File: PreKeyUtil.java From bcm-android with GNU General Public License v3.0 | 6 votes |
public static List<PreKeyRecord> generatePreKeys(Context context, AccountContext accountContext) { PreKeyStore preKeyStore = new TextSecurePreKeyStore(context, accountContext); List<PreKeyRecord> records = new LinkedList<>(); int preKeyIdOffset = getNextPreKeyId(context, accountContext); for (int i = 0; i < BATCH_SIZE; i++) { int preKeyId = (preKeyIdOffset + i) % Medium.MAX_VALUE; ECKeyPair keyPair = Curve.generateKeyPair(); PreKeyRecord record = new PreKeyRecord(preKeyId, keyPair); preKeyStore.storePreKey(preKeyId, record); records.add(record); } setNextPreKeyId(context, accountContext,(preKeyIdOffset + BATCH_SIZE + 1) % Medium.MAX_VALUE); return records; }
Example #3
Source File: KeyExchangeInitiator.java From Silence with GNU General Public License v3.0 | 6 votes |
public static void initiateKeyExchange(Context context, MasterSecret masterSecret, Recipients recipients, int subscriptionId) { Recipient recipient = recipients.getPrimaryRecipient(); SessionStore sessionStore = new SilenceSessionStore(context, masterSecret, subscriptionId); PreKeyStore preKeyStore = new SilencePreKeyStore(context, masterSecret, subscriptionId); SignedPreKeyStore signedPreKeyStore = new SilencePreKeyStore(context, masterSecret, subscriptionId); IdentityKeyStore identityKeyStore = new SilenceIdentityKeyStore(context, masterSecret, subscriptionId); SessionBuilder sessionBuilder = new SessionBuilder(sessionStore, preKeyStore, signedPreKeyStore, identityKeyStore, new SignalProtocolAddress(recipient.getNumber(), 1)); if (identityKeyStore.getIdentityKeyPair() != null) { KeyExchangeMessage keyExchangeMessage = sessionBuilder.process(); String serializedMessage = Base64.encodeBytesWithoutPadding(keyExchangeMessage.serialize()); OutgoingKeyExchangeMessage textMessage = new OutgoingKeyExchangeMessage(recipients, serializedMessage, subscriptionId); MessageSender.send(context, masterSecret, textMessage, -1, false); } else { Toast.makeText(context, R.string.VerifyIdentityActivity_you_do_not_have_an_identity_key, Toast.LENGTH_LONG).show(); } }
Example #4
Source File: SessionBuilder.java From Silence with GNU General Public License v3.0 | 5 votes |
/** * Constructs a SessionBuilder. * * @param sessionStore The {@link org.whispersystems.libsignal.state.SessionStore} to store the constructed session in. * @param preKeyStore The {@link org.whispersystems.libsignal.state.PreKeyStore} where the client's local {@link org.whispersystems.libsignal.state.PreKeyRecord}s are stored. * @param identityKeyStore The {@link org.whispersystems.libsignal.state.IdentityKeyStore} containing the client's identity key information. * @param remoteAddress The address of the remote user to build a session with. */ public SessionBuilder(SessionStore sessionStore, PreKeyStore preKeyStore, SignedPreKeyStore signedPreKeyStore, IdentityKeyStore identityKeyStore, SignalProtocolAddress remoteAddress) { this.sessionStore = sessionStore; this.preKeyStore = preKeyStore; this.signedPreKeyStore = signedPreKeyStore; this.identityKeyStore = identityKeyStore; this.remoteAddress = remoteAddress; }
Example #5
Source File: SessionBuilder.java From libsignal-protocol-java with GNU General Public License v3.0 | 5 votes |
/** * Constructs a SessionBuilder. * * @param sessionStore The {@link org.whispersystems.libsignal.state.SessionStore} to store the constructed session in. * @param preKeyStore The {@link org.whispersystems.libsignal.state.PreKeyStore} where the client's local {@link org.whispersystems.libsignal.state.PreKeyRecord}s are stored. * @param identityKeyStore The {@link org.whispersystems.libsignal.state.IdentityKeyStore} containing the client's identity key information. * @param remoteAddress The address of the remote user to build a session with. */ public SessionBuilder(SessionStore sessionStore, PreKeyStore preKeyStore, SignedPreKeyStore signedPreKeyStore, IdentityKeyStore identityKeyStore, SignalProtocolAddress remoteAddress) { this.sessionStore = sessionStore; this.preKeyStore = preKeyStore; this.signedPreKeyStore = signedPreKeyStore; this.identityKeyStore = identityKeyStore; this.remoteAddress = remoteAddress; }
Example #6
Source File: SessionCipher.java From libsignal-protocol-java with GNU General Public License v3.0 | 5 votes |
/** * Construct a SessionCipher for encrypt/decrypt operations on a session. * In order to use SessionCipher, a session must have already been created * and stored using {@link SessionBuilder}. * * @param sessionStore The {@link SessionStore} that contains a session for this recipient. * @param remoteAddress The remote address that messages will be encrypted to or decrypted from. */ public SessionCipher(SessionStore sessionStore, PreKeyStore preKeyStore, SignedPreKeyStore signedPreKeyStore, IdentityKeyStore identityKeyStore, SignalProtocolAddress remoteAddress) { this.sessionStore = sessionStore; this.preKeyStore = preKeyStore; this.identityKeyStore = identityKeyStore; this.remoteAddress = remoteAddress; this.sessionBuilder = new SessionBuilder(sessionStore, preKeyStore, signedPreKeyStore, identityKeyStore, remoteAddress); }