diff --git a/app/src/main/java/org/thoughtcrime/securesms/backup/FullBackupExporter.kt b/app/src/main/java/org/thoughtcrime/securesms/backup/FullBackupExporter.kt index 3148fd1420..ff5446a018 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/backup/FullBackupExporter.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/backup/FullBackupExporter.kt @@ -120,10 +120,7 @@ object FullBackupExporter { } private inline fun shouldExportTable(table: String): Boolean { - return table != SignedPreKeyDatabase.TABLE_NAME && - table != OneTimePreKeyDatabase.TABLE_NAME && - table != SessionDatabase.TABLE_NAME && - table != PushDatabase.TABLE_NAME && + return table != PushDatabase.TABLE_NAME && table != LokiBackupFilesDatabase.TABLE_NAME && table != LokiAPIDatabase.openGroupProfilePictureTable && diff --git a/app/src/main/java/org/thoughtcrime/securesms/crypto/SessionUtil.java b/app/src/main/java/org/thoughtcrime/securesms/crypto/SessionUtil.java deleted file mode 100644 index 56ee6178bb..0000000000 --- a/app/src/main/java/org/thoughtcrime/securesms/crypto/SessionUtil.java +++ /dev/null @@ -1,30 +0,0 @@ -package org.thoughtcrime.securesms.crypto; - -import android.content.Context; -import androidx.annotation.NonNull; - -import org.thoughtcrime.securesms.crypto.storage.TextSecureSessionStore; -import org.session.libsession.messaging.threads.Address; -import org.session.libsignal.libsignal.SignalProtocolAddress; -import org.session.libsignal.libsignal.state.SessionStore; -import org.session.libsignal.service.api.push.SignalServiceAddress; - -public class SessionUtil { - - public static boolean hasSession(Context context, @NonNull Address address) { - SessionStore sessionStore = new TextSecureSessionStore(context); - SignalProtocolAddress axolotlAddress = new SignalProtocolAddress(address.serialize(), SignalServiceAddress.DEFAULT_DEVICE_ID); - - return sessionStore.containsSession(axolotlAddress); - } - - public static void archiveSiblingSessions(Context context, SignalProtocolAddress address) { - TextSecureSessionStore sessionStore = new TextSecureSessionStore(context); - sessionStore.archiveSiblingSessions(address); - } - - public static void archiveAllSessions(Context context) { - new TextSecureSessionStore(context).archiveAllSessions(); - } - -} diff --git a/app/src/main/java/org/thoughtcrime/securesms/crypto/storage/SignalProtocolStoreImpl.java b/app/src/main/java/org/thoughtcrime/securesms/crypto/storage/SignalProtocolStoreImpl.java index 572a91256b..6752d6be6c 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/crypto/storage/SignalProtocolStoreImpl.java +++ b/app/src/main/java/org/thoughtcrime/securesms/crypto/storage/SignalProtocolStoreImpl.java @@ -2,150 +2,20 @@ package org.thoughtcrime.securesms.crypto.storage; import android.content.Context; -import org.session.libsignal.libsignal.IdentityKey; import org.session.libsignal.libsignal.IdentityKeyPair; -import org.session.libsignal.libsignal.InvalidKeyIdException; -import org.session.libsignal.libsignal.SignalProtocolAddress; import org.session.libsignal.libsignal.state.IdentityKeyStore; -import org.session.libsignal.libsignal.state.PreKeyRecord; -import org.session.libsignal.libsignal.state.PreKeyStore; -import org.session.libsignal.libsignal.state.SessionRecord; -import org.session.libsignal.libsignal.state.SessionStore; -import org.session.libsignal.libsignal.state.SignalProtocolStore; -import org.session.libsignal.libsignal.state.SignedPreKeyRecord; -import org.session.libsignal.libsignal.state.SignedPreKeyStore; import org.thoughtcrime.securesms.crypto.IdentityKeyUtil; -import java.util.List; - -public class SignalProtocolStoreImpl implements SignalProtocolStore { +public class SignalProtocolStoreImpl implements IdentityKeyStore { private final Context context; - // private final PreKeyStore preKeyStore; - // private final SignedPreKeyStore signedPreKeyStore; - // private final IdentityKeyStore identityKeyStore; - private final SessionStore sessionStore; public SignalProtocolStoreImpl(Context context) { -// this.preKeyStore = new TextSecurePreKeyStore(context); -// this.signedPreKeyStore = new TextSecurePreKeyStore(context); -// this.identityKeyStore = new TextSecureIdentityKeyStore(context); - this.sessionStore = new TextSecureSessionStore(context); this.context = context; } @Override public IdentityKeyPair getIdentityKeyPair() { return IdentityKeyUtil.getIdentityKeyPair(context); -// return identityKeyStore.getIdentityKeyPair(); -// throw new UnsupportedOperationException("This method will be removed with refactor."); - } - - @Override - public int getLocalRegistrationId() { -// return identityKeyStore.getLocalRegistrationId(); - throw new UnsupportedOperationException("This method will be removed with refactor."); - } - - @Override - public boolean saveIdentity(SignalProtocolAddress address, IdentityKey identityKey) { -// return identityKeyStore.saveIdentity(address, identityKey); - throw new UnsupportedOperationException("This method will be removed with refactor."); - } - - @Override - public boolean isTrustedIdentity(SignalProtocolAddress address, IdentityKey identityKey, Direction direction) { -// return identityKeyStore.isTrustedIdentity(address, identityKey, direction); - throw new UnsupportedOperationException("This method will be removed with refactor."); - } - - @Override - public IdentityKey getIdentity(SignalProtocolAddress address) { -// return identityKeyStore.getIdentity(address); - throw new UnsupportedOperationException("This method will be removed with refactor."); - } - - @Override - public PreKeyRecord loadPreKey(int preKeyId) throws InvalidKeyIdException { -// return preKeyStore.loadPreKey(preKeyId); - throw new UnsupportedOperationException("This method will be removed with refactor."); - } - - @Override - public void storePreKey(int preKeyId, PreKeyRecord record) { -// preKeyStore.storePreKey(preKeyId, record); - throw new UnsupportedOperationException("This method will be removed with refactor."); - } - - @Override - public boolean containsPreKey(int preKeyId) { -// return preKeyStore.containsPreKey(preKeyId); - throw new UnsupportedOperationException("This method will be removed with refactor."); - } - - @Override - public void removePreKey(int preKeyId) { -// preKeyStore.removePreKey(preKeyId); - throw new UnsupportedOperationException("This method will be removed with refactor."); - } - - @Override - public SessionRecord loadSession(SignalProtocolAddress axolotlAddress) { - return sessionStore.loadSession(axolotlAddress); - } - - @Override - public List getSubDeviceSessions(String number) { - return sessionStore.getSubDeviceSessions(number); - } - - @Override - public void storeSession(SignalProtocolAddress axolotlAddress, SessionRecord record) { - sessionStore.storeSession(axolotlAddress, record); - } - - @Override - public boolean containsSession(SignalProtocolAddress axolotlAddress) { - return sessionStore.containsSession(axolotlAddress); - } - - @Override - public void deleteSession(SignalProtocolAddress axolotlAddress) { - sessionStore.deleteSession(axolotlAddress); - } - - @Override - public void deleteAllSessions(String number) { - sessionStore.deleteAllSessions(number); - } - - @Override - public SignedPreKeyRecord loadSignedPreKey(int signedPreKeyId) throws InvalidKeyIdException { - throw new UnsupportedOperationException("This method will be removed with refactor."); -// return signedPreKeyStore.loadSignedPreKey(signedPreKeyId); - } - - @Override - public List loadSignedPreKeys() { - throw new UnsupportedOperationException("This method will be removed with refactor."); -// return signedPreKeyStore.loadSignedPreKeys(); - } - - @Override - public void storeSignedPreKey(int signedPreKeyId, SignedPreKeyRecord record) { - throw new UnsupportedOperationException("This method will be removed with refactor."); -// signedPreKeyStore.storeSignedPreKey(signedPreKeyId, record); - } - - @Override - public boolean containsSignedPreKey(int signedPreKeyId) { - throw new UnsupportedOperationException("This method will be removed with refactor."); -// return signedPreKeyStore.containsSignedPreKey(signedPreKeyId); - } - - @Override - public void removeSignedPreKey(int signedPreKeyId) { - throw new UnsupportedOperationException("This method will be removed with refactor."); -// signedPreKeyStore.removeSignedPreKey(signedPreKeyId); } } diff --git a/app/src/main/java/org/thoughtcrime/securesms/crypto/storage/TextSecureSessionStore.java b/app/src/main/java/org/thoughtcrime/securesms/crypto/storage/TextSecureSessionStore.java deleted file mode 100644 index 0470b83db1..0000000000 --- a/app/src/main/java/org/thoughtcrime/securesms/crypto/storage/TextSecureSessionStore.java +++ /dev/null @@ -1,110 +0,0 @@ -package org.thoughtcrime.securesms.crypto.storage; - -import android.content.Context; -import androidx.annotation.NonNull; - -import org.session.libsession.messaging.threads.Address; -import org.thoughtcrime.securesms.database.DatabaseFactory; -import org.thoughtcrime.securesms.database.SessionDatabase; -import org.session.libsignal.utilities.logging.Log; -import org.session.libsignal.libsignal.SignalProtocolAddress; -import org.session.libsignal.libsignal.protocol.CiphertextMessage; -import org.session.libsignal.libsignal.state.SessionRecord; -import org.session.libsignal.libsignal.state.SessionStore; - -import java.util.List; - -public class TextSecureSessionStore implements SessionStore { - - private static final String TAG = TextSecureSessionStore.class.getSimpleName(); - - private static final Object FILE_LOCK = new Object(); - - @NonNull private final Context context; - - public TextSecureSessionStore(@NonNull Context context) { - this.context = context; - } - - @Override - public SessionRecord loadSession(@NonNull SignalProtocolAddress address) { - synchronized (FILE_LOCK) { - SessionRecord sessionRecord = DatabaseFactory.getSessionDatabase(context).load(Address.fromSerialized(address.getName()), address.getDeviceId()); - - if (sessionRecord == null) { - Log.w(TAG, "No existing session information found."); - return new SessionRecord(); - } - - return sessionRecord; - } - } - - @Override - public void storeSession(@NonNull SignalProtocolAddress address, @NonNull SessionRecord record) { - synchronized (FILE_LOCK) { - DatabaseFactory.getSessionDatabase(context).store(Address.fromSerialized(address.getName()), address.getDeviceId(), record); - } - } - - @Override - public boolean containsSession(SignalProtocolAddress address) { - synchronized (FILE_LOCK) { - SessionRecord sessionRecord = DatabaseFactory.getSessionDatabase(context).load(Address.fromSerialized(address.getName()), address.getDeviceId()); - - return sessionRecord != null && - sessionRecord.getSessionState().hasSenderChain() && - sessionRecord.getSessionState().getSessionVersion() == CiphertextMessage.CURRENT_VERSION; - } - } - - @Override - public void deleteSession(SignalProtocolAddress address) { - synchronized (FILE_LOCK) { - DatabaseFactory.getSessionDatabase(context).delete(Address.fromSerialized(address.getName()), address.getDeviceId()); - } - } - - @Override - public void deleteAllSessions(String name) { - synchronized (FILE_LOCK) { - DatabaseFactory.getSessionDatabase(context).deleteAllFor(Address.fromSerialized(name)); - } - } - - @Override - public List getSubDeviceSessions(String name) { - synchronized (FILE_LOCK) { - return DatabaseFactory.getSessionDatabase(context).getSubDevices(Address.fromSerialized(name)); - } - } - - public void archiveSiblingSessions(@NonNull SignalProtocolAddress address) { - synchronized (FILE_LOCK) { - List sessions = DatabaseFactory.getSessionDatabase(context).getAllFor(Address.fromSerialized(address.getName())); - - for (SessionDatabase.SessionRow row : sessions) { - if (row.getDeviceId() != address.getDeviceId()) { - row.getRecord().archiveCurrentState(); - storeSession(new SignalProtocolAddress(row.getAddress().serialize(), row.getDeviceId()), row.getRecord()); - } - } - } - } - - public void archiveAllSessions(@NonNull String hexEncodedPublicKey) { - SignalProtocolAddress address = new SignalProtocolAddress(hexEncodedPublicKey, -1); - archiveSiblingSessions(address); - } - - public void archiveAllSessions() { - synchronized (FILE_LOCK) { - List sessions = DatabaseFactory.getSessionDatabase(context).getAll(); - - for (SessionDatabase.SessionRow row : sessions) { - row.getRecord().archiveCurrentState(); - storeSession(new SignalProtocolAddress(row.getAddress().serialize(), row.getDeviceId()), row.getRecord()); - } - } - } -} diff --git a/app/src/main/java/org/thoughtcrime/securesms/database/DatabaseFactory.java b/app/src/main/java/org/thoughtcrime/securesms/database/DatabaseFactory.java index 8a50e06f0b..9994a78ace 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/database/DatabaseFactory.java +++ b/app/src/main/java/org/thoughtcrime/securesms/database/DatabaseFactory.java @@ -53,9 +53,6 @@ public class DatabaseFactory { private final GroupDatabase groupDatabase; private final RecipientDatabase recipientDatabase; private final GroupReceiptDatabase groupReceiptDatabase; - private final OneTimePreKeyDatabase preKeyDatabase; - private final SignedPreKeyDatabase signedPreKeyDatabase; - private final SessionDatabase sessionDatabase; private final SearchDatabase searchDatabase; private final JobDatabase jobDatabase; private final StickerDatabase stickerDatabase; @@ -125,18 +122,6 @@ public class DatabaseFactory { return getInstance(context).groupReceiptDatabase; } - public static OneTimePreKeyDatabase getPreKeyDatabase(Context context) { - return getInstance(context).preKeyDatabase; - } - - public static SignedPreKeyDatabase getSignedPreKeyDatabase(Context context) { - return getInstance(context).signedPreKeyDatabase; - } - - public static SessionDatabase getSessionDatabase(Context context) { - return getInstance(context).sessionDatabase; - } - public static SearchDatabase getSearchDatabase(Context context) { return getInstance(context).searchDatabase; } @@ -212,9 +197,6 @@ public class DatabaseFactory { this.groupDatabase = new GroupDatabase(context, databaseHelper); this.recipientDatabase = new RecipientDatabase(context, databaseHelper); this.groupReceiptDatabase = new GroupReceiptDatabase(context, databaseHelper); - this.preKeyDatabase = new OneTimePreKeyDatabase(context, databaseHelper); - this.signedPreKeyDatabase = new SignedPreKeyDatabase(context, databaseHelper); - this.sessionDatabase = new SessionDatabase(context, databaseHelper); this.searchDatabase = new SearchDatabase(context, databaseHelper); this.jobDatabase = new JobDatabase(context, databaseHelper); this.stickerDatabase = new StickerDatabase(context, databaseHelper, attachmentSecret); diff --git a/app/src/main/java/org/thoughtcrime/securesms/database/OneTimePreKeyDatabase.java b/app/src/main/java/org/thoughtcrime/securesms/database/OneTimePreKeyDatabase.java deleted file mode 100644 index bb93cf12d5..0000000000 --- a/app/src/main/java/org/thoughtcrime/securesms/database/OneTimePreKeyDatabase.java +++ /dev/null @@ -1,81 +0,0 @@ -package org.thoughtcrime.securesms.database; - - -import android.content.ContentValues; -import android.content.Context; -import android.database.Cursor; -import androidx.annotation.Nullable; -import org.session.libsignal.utilities.logging.Log; - -import net.sqlcipher.database.SQLiteDatabase; - -import org.thoughtcrime.securesms.database.helpers.SQLCipherOpenHelper; -import org.session.libsignal.utilities.Base64; -import org.session.libsignal.libsignal.InvalidKeyException; -import org.session.libsignal.libsignal.ecc.Curve; -import org.session.libsignal.libsignal.ecc.ECKeyPair; -import org.session.libsignal.libsignal.ecc.ECPrivateKey; -import org.session.libsignal.libsignal.ecc.ECPublicKey; -import org.session.libsignal.libsignal.state.PreKeyRecord; - -import java.io.IOException; - -public class OneTimePreKeyDatabase extends Database { - - private static final String TAG = OneTimePreKeyDatabase.class.getSimpleName(); - - public static final String TABLE_NAME = "one_time_prekeys"; - private static final String ID = "_id"; - public static final String KEY_ID = "key_id"; - public static final String PUBLIC_KEY = "public_key"; - public static final String PRIVATE_KEY = "private_key"; - - public static final String CREATE_TABLE = "CREATE TABLE " + TABLE_NAME + - " (" + ID + " INTEGER PRIMARY KEY, " + - KEY_ID + " INTEGER UNIQUE, " + - PUBLIC_KEY + " TEXT NOT NULL, " + - PRIVATE_KEY + " TEXT NOT NULL);"; - - OneTimePreKeyDatabase(Context context, SQLCipherOpenHelper databaseHelper) { - super(context, databaseHelper); - } - - public @Nullable PreKeyRecord getPreKey(int keyId) { - SQLiteDatabase database = databaseHelper.getReadableDatabase(); - - try (Cursor cursor = database.query(TABLE_NAME, null, KEY_ID + " = ?", - new String[] {String.valueOf(keyId)}, - null, null, null)) - { - if (cursor != null && cursor.moveToFirst()) { - try { - ECPublicKey publicKey = Curve.decodePoint(Base64.decode(cursor.getString(cursor.getColumnIndexOrThrow(PUBLIC_KEY))), 0); - ECPrivateKey privateKey = Curve.decodePrivatePoint(Base64.decode(cursor.getString(cursor.getColumnIndexOrThrow(PRIVATE_KEY)))); - - return new PreKeyRecord(keyId, new ECKeyPair(publicKey, privateKey)); - } catch (InvalidKeyException | IOException e) { - Log.w(TAG, e); - } - } - } - - return null; - } - - public void insertPreKey(int keyId, PreKeyRecord record) { - SQLiteDatabase database = databaseHelper.getWritableDatabase(); - - ContentValues contentValues = new ContentValues(); - contentValues.put(KEY_ID, keyId); - contentValues.put(PUBLIC_KEY, Base64.encodeBytes(record.getKeyPair().getPublicKey().serialize())); - contentValues.put(PRIVATE_KEY, Base64.encodeBytes(record.getKeyPair().getPrivateKey().serialize())); - - database.replace(TABLE_NAME, null, contentValues); - } - - public void removePreKey(int keyId) { - SQLiteDatabase database = databaseHelper.getWritableDatabase(); - database.delete(TABLE_NAME, KEY_ID + " = ?", new String[] {String.valueOf(keyId)}); - } - -} diff --git a/app/src/main/java/org/thoughtcrime/securesms/database/SessionDatabase.java b/app/src/main/java/org/thoughtcrime/securesms/database/SessionDatabase.java deleted file mode 100644 index 630610342f..0000000000 --- a/app/src/main/java/org/thoughtcrime/securesms/database/SessionDatabase.java +++ /dev/null @@ -1,173 +0,0 @@ -package org.thoughtcrime.securesms.database; - - -import android.content.ContentValues; -import android.content.Context; -import android.database.Cursor; -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; - -import net.sqlcipher.database.SQLiteDatabase; - -import org.thoughtcrime.securesms.database.helpers.SQLCipherOpenHelper; -import org.session.libsignal.utilities.logging.Log; - -import org.session.libsession.messaging.threads.Address; - -import org.session.libsignal.libsignal.state.SessionRecord; -import org.session.libsignal.service.api.push.SignalServiceAddress; - -import java.io.IOException; -import java.util.LinkedList; -import java.util.List; - -public class SessionDatabase extends Database { - - private static final String TAG = SessionDatabase.class.getSimpleName(); - - public static final String TABLE_NAME = "sessions"; - - private static final String ID = "_id"; - public static final String ADDRESS = "address"; - public static final String DEVICE = "device"; - public static final String RECORD = "record"; - - public static final String CREATE_TABLE = "CREATE TABLE " + TABLE_NAME + - "(" + ID + " INTEGER PRIMARY KEY, " + ADDRESS + " TEXT NOT NULL, " + - DEVICE + " INTEGER NOT NULL, " + RECORD + " BLOB NOT NULL, " + - "UNIQUE(" + ADDRESS + "," + DEVICE + ") ON CONFLICT REPLACE);"; - - SessionDatabase(Context context, SQLCipherOpenHelper databaseHelper) { - super(context, databaseHelper); - } - - public void store(@NonNull Address address, int deviceId, @NonNull SessionRecord record) { - SQLiteDatabase database = databaseHelper.getWritableDatabase(); - - ContentValues values = new ContentValues(); - values.put(ADDRESS, address.serialize()); - values.put(DEVICE, deviceId); - values.put(RECORD, record.serialize()); - - database.insertWithOnConflict(TABLE_NAME, null, values, SQLiteDatabase.CONFLICT_REPLACE); - } - - public @Nullable SessionRecord load(@NonNull Address address, int deviceId) { - SQLiteDatabase database = databaseHelper.getReadableDatabase(); - - try (Cursor cursor = database.query(TABLE_NAME, new String[]{RECORD}, - ADDRESS + " = ? AND " + DEVICE + " = ?", - new String[] {address.serialize(), String.valueOf(deviceId)}, - null, null, null)) - { - if (cursor != null && cursor.moveToFirst()) { - try { - return new SessionRecord(cursor.getBlob(cursor.getColumnIndexOrThrow(RECORD))); - } catch (IOException e) { - Log.w(TAG, e); - } - } - } - - return null; - } - - public @NonNull List getAllFor(@NonNull Address address) { - SQLiteDatabase database = databaseHelper.getReadableDatabase(); - List results = new LinkedList<>(); - - try (Cursor cursor = database.query(TABLE_NAME, null, - ADDRESS + " = ?", - new String[] {address.serialize()}, - null, null, null)) - { - while (cursor != null && cursor.moveToNext()) { - try { - results.add(new SessionRow(address, - cursor.getInt(cursor.getColumnIndexOrThrow(DEVICE)), - new SessionRecord(cursor.getBlob(cursor.getColumnIndexOrThrow(RECORD))))); - } catch (IOException e) { - Log.w(TAG, e); - } - } - } - - return results; - } - - public @NonNull List getAll() { - SQLiteDatabase database = databaseHelper.getReadableDatabase(); - List results = new LinkedList<>(); - - try (Cursor cursor = database.query(TABLE_NAME, null, null, null, null, null, null)) { - while (cursor != null && cursor.moveToNext()) { - try { - results.add(new SessionRow(Address.fromSerialized(cursor.getString(cursor.getColumnIndexOrThrow(ADDRESS))), - cursor.getInt(cursor.getColumnIndexOrThrow(DEVICE)), - new SessionRecord(cursor.getBlob(cursor.getColumnIndexOrThrow(RECORD))))); - } catch (IOException e) { - Log.w(TAG, e); - } - } - } - - return results; - } - - public @NonNull List getSubDevices(@NonNull Address address) { - SQLiteDatabase database = databaseHelper.getReadableDatabase(); - List results = new LinkedList<>(); - - try (Cursor cursor = database.query(TABLE_NAME, new String[] {DEVICE}, - ADDRESS + " = ?", - new String[] {address.serialize()}, - null, null, null)) - { - while (cursor != null && cursor.moveToNext()) { - int device = cursor.getInt(cursor.getColumnIndexOrThrow(DEVICE)); - - if (device != SignalServiceAddress.DEFAULT_DEVICE_ID) { - results.add(device); - } - } - } - - return results; - } - - public void delete(@NonNull Address address, int deviceId) { - SQLiteDatabase database = databaseHelper.getWritableDatabase(); - - database.delete(TABLE_NAME, ADDRESS + " = ? AND " + DEVICE + " = ?", - new String[] {address.serialize(), String.valueOf(deviceId)}); - } - - public void deleteAllFor(@NonNull Address address) { - SQLiteDatabase database = databaseHelper.getWritableDatabase(); - database.delete(TABLE_NAME, ADDRESS + " = ?", new String[] {address.serialize()}); - } - - public static final class SessionRow { - private final Address address; - private final int deviceId; - private final SessionRecord record; - - public SessionRow(Address address, int deviceId, SessionRecord record) { - this.address = address; - this.deviceId = deviceId; - this.record = record; - } - - public Address getAddress() { - return address; - } - - public int getDeviceId() { - return deviceId; - } - - public SessionRecord getRecord() { - return record; - } - } -} diff --git a/app/src/main/java/org/thoughtcrime/securesms/database/SignedPreKeyDatabase.java b/app/src/main/java/org/thoughtcrime/securesms/database/SignedPreKeyDatabase.java deleted file mode 100644 index 81931a0f94..0000000000 --- a/app/src/main/java/org/thoughtcrime/securesms/database/SignedPreKeyDatabase.java +++ /dev/null @@ -1,117 +0,0 @@ -package org.thoughtcrime.securesms.database; - - -import android.content.ContentValues; -import android.content.Context; -import android.database.Cursor; -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; - -import net.sqlcipher.database.SQLiteDatabase; - -import org.thoughtcrime.securesms.database.helpers.SQLCipherOpenHelper; -import org.session.libsignal.utilities.logging.Log; -import org.session.libsignal.utilities.Base64; -import org.session.libsignal.libsignal.InvalidKeyException; -import org.session.libsignal.libsignal.ecc.Curve; -import org.session.libsignal.libsignal.ecc.ECKeyPair; -import org.session.libsignal.libsignal.ecc.ECPrivateKey; -import org.session.libsignal.libsignal.ecc.ECPublicKey; -import org.session.libsignal.libsignal.state.SignedPreKeyRecord; - -import java.io.IOException; -import java.util.LinkedList; -import java.util.List; - -public class SignedPreKeyDatabase extends Database { - - private static final String TAG = SignedPreKeyDatabase.class.getSimpleName(); - - public static final String TABLE_NAME = "signed_prekeys"; - - private static final String ID = "_id"; - public static final String KEY_ID = "key_id"; - public static final String PUBLIC_KEY = "public_key"; - public static final String PRIVATE_KEY = "private_key"; - public static final String SIGNATURE = "signature"; - public static final String TIMESTAMP = "timestamp"; - - public static final String CREATE_TABLE = "CREATE TABLE " + TABLE_NAME + - " (" + ID + " INTEGER PRIMARY KEY, " + - KEY_ID + " INTEGER UNIQUE, " + - PUBLIC_KEY + " TEXT NOT NULL, " + - PRIVATE_KEY + " TEXT NOT NULL, " + - SIGNATURE + " TEXT NOT NULL, " + - TIMESTAMP + " INTEGER DEFAULT 0);"; - - SignedPreKeyDatabase(Context context, SQLCipherOpenHelper databaseHelper) { - super(context, databaseHelper); - } - - public @Nullable SignedPreKeyRecord getSignedPreKey(int keyId) { - SQLiteDatabase database = databaseHelper.getReadableDatabase(); - - try (Cursor cursor = database.query(TABLE_NAME, null, KEY_ID + " = ?", - new String[] {String.valueOf(keyId)}, - null, null, null)) - { - if (cursor != null && cursor.moveToFirst()) { - try { - ECPublicKey publicKey = Curve.decodePoint(Base64.decode(cursor.getString(cursor.getColumnIndexOrThrow(PUBLIC_KEY))), 0); - ECPrivateKey privateKey = Curve.decodePrivatePoint(Base64.decode(cursor.getString(cursor.getColumnIndexOrThrow(PRIVATE_KEY)))); - byte[] signature = Base64.decode(cursor.getString(cursor.getColumnIndexOrThrow(SIGNATURE))); - long timestamp = cursor.getLong(cursor.getColumnIndexOrThrow(TIMESTAMP)); - - return new SignedPreKeyRecord(keyId, timestamp, new ECKeyPair(publicKey, privateKey), signature); - } catch (InvalidKeyException | IOException e) { - Log.w(TAG, e); - } - } - } - - return null; - } - - public @NonNull List getAllSignedPreKeys() { - SQLiteDatabase database = databaseHelper.getReadableDatabase(); - List results = new LinkedList<>(); - - try (Cursor cursor = database.query(TABLE_NAME, null, null, null, null, null, null)) { - while (cursor != null && cursor.moveToNext()) { - try { - int keyId = cursor.getInt(cursor.getColumnIndexOrThrow(KEY_ID)); - ECPublicKey publicKey = Curve.decodePoint(Base64.decode(cursor.getString(cursor.getColumnIndexOrThrow(PUBLIC_KEY))), 0); - ECPrivateKey privateKey = Curve.decodePrivatePoint(Base64.decode(cursor.getString(cursor.getColumnIndexOrThrow(PRIVATE_KEY)))); - byte[] signature = Base64.decode(cursor.getString(cursor.getColumnIndexOrThrow(SIGNATURE))); - long timestamp = cursor.getLong(cursor.getColumnIndexOrThrow(TIMESTAMP)); - - results.add(new SignedPreKeyRecord(keyId, timestamp, new ECKeyPair(publicKey, privateKey), signature)); - } catch (InvalidKeyException | IOException e) { - Log.w(TAG, e); - } - } - } - - return results; - } - - public void insertSignedPreKey(int keyId, SignedPreKeyRecord record) { - SQLiteDatabase database = databaseHelper.getWritableDatabase(); - - ContentValues contentValues = new ContentValues(); - contentValues.put(KEY_ID, keyId); - contentValues.put(PUBLIC_KEY, Base64.encodeBytes(record.getKeyPair().getPublicKey().serialize())); - contentValues.put(PRIVATE_KEY, Base64.encodeBytes(record.getKeyPair().getPrivateKey().serialize())); - contentValues.put(SIGNATURE, Base64.encodeBytes(record.getSignature())); - contentValues.put(TIMESTAMP, record.getTimestamp()); - - database.replace(TABLE_NAME, null, contentValues); - } - - - public void removeSignedPreKey(int keyId) { - SQLiteDatabase database = databaseHelper.getWritableDatabase(); - database.delete(TABLE_NAME, KEY_ID + " = ? AND " + SIGNATURE + " IS NOT NULL", new String[] {String.valueOf(keyId)}); - } - -} diff --git a/app/src/main/java/org/thoughtcrime/securesms/database/helpers/SQLCipherOpenHelper.java b/app/src/main/java/org/thoughtcrime/securesms/database/helpers/SQLCipherOpenHelper.java index 12346381da..4e81149342 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/database/helpers/SQLCipherOpenHelper.java +++ b/app/src/main/java/org/thoughtcrime/securesms/database/helpers/SQLCipherOpenHelper.java @@ -17,12 +17,9 @@ import org.thoughtcrime.securesms.database.GroupDatabase; import org.thoughtcrime.securesms.database.GroupReceiptDatabase; import org.thoughtcrime.securesms.database.JobDatabase; import org.thoughtcrime.securesms.database.MmsDatabase; -import org.thoughtcrime.securesms.database.OneTimePreKeyDatabase; import org.thoughtcrime.securesms.database.PushDatabase; import org.thoughtcrime.securesms.database.RecipientDatabase; import org.thoughtcrime.securesms.database.SearchDatabase; -import org.thoughtcrime.securesms.database.SessionDatabase; -import org.thoughtcrime.securesms.database.SignedPreKeyDatabase; import org.thoughtcrime.securesms.database.SmsDatabase; import org.thoughtcrime.securesms.database.StickerDatabase; import org.thoughtcrime.securesms.database.ThreadDatabase; @@ -94,9 +91,6 @@ public class SQLCipherOpenHelper extends SQLiteOpenHelper { db.execSQL(GroupDatabase.CREATE_TABLE); db.execSQL(RecipientDatabase.CREATE_TABLE); db.execSQL(GroupReceiptDatabase.CREATE_TABLE); - db.execSQL(OneTimePreKeyDatabase.CREATE_TABLE); - db.execSQL(SignedPreKeyDatabase.CREATE_TABLE); - db.execSQL(SessionDatabase.CREATE_TABLE); for (String sql : SearchDatabase.CREATE_TABLE) { db.execSQL(sql); } diff --git a/app/src/main/java/org/thoughtcrime/securesms/dependencies/SignalCommunicationModule.java b/app/src/main/java/org/thoughtcrime/securesms/dependencies/SignalCommunicationModule.java index 1095d9c3f5..2d0fe001ba 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/dependencies/SignalCommunicationModule.java +++ b/app/src/main/java/org/thoughtcrime/securesms/dependencies/SignalCommunicationModule.java @@ -3,7 +3,6 @@ package org.thoughtcrime.securesms.dependencies; import android.content.Context; import org.session.libsignal.libsignal.util.guava.Optional; -import org.session.libsignal.service.api.SignalServiceAccountManager; import org.session.libsignal.service.api.SignalServiceMessageReceiver; import org.session.libsignal.service.api.SignalServiceMessageSender; import org.session.libsignal.service.api.util.CredentialsProvider; @@ -74,7 +73,6 @@ public class SignalCommunicationModule { private final Context context; private final SignalServiceNetworkAccess networkAccess; - private SignalServiceAccountManager accountManager; private SignalServiceMessageSender messageSender; private SignalServiceMessageReceiver messageReceiver; diff --git a/app/src/main/java/org/thoughtcrime/securesms/jobs/PushDecryptJob.java b/app/src/main/java/org/thoughtcrime/securesms/jobs/PushDecryptJob.java index ad20f5346c..9a6f3e34e7 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/jobs/PushDecryptJob.java +++ b/app/src/main/java/org/thoughtcrime/securesms/jobs/PushDecryptJob.java @@ -15,7 +15,6 @@ import com.annimon.stream.Collectors; import com.annimon.stream.Stream; import org.session.libsession.messaging.jobs.Data; -import org.session.libsession.utilities.MediaTypes; import org.session.libsignal.metadata.InvalidMetadataMessageException; import org.session.libsignal.metadata.ProtocolInvalidMessageException; import org.session.libsignal.service.api.crypto.SignalServiceCipher; @@ -37,7 +36,6 @@ import org.session.libsession.utilities.TextSecurePreferences; import org.thoughtcrime.securesms.contactshare.ContactModelMapper; import org.thoughtcrime.securesms.crypto.IdentityKeyUtil; -import org.thoughtcrime.securesms.crypto.storage.SignalProtocolStoreImpl; import org.thoughtcrime.securesms.database.AttachmentDatabase; import org.thoughtcrime.securesms.database.DatabaseFactory; import org.thoughtcrime.securesms.database.GroupDatabase; @@ -47,11 +45,9 @@ import org.thoughtcrime.securesms.database.MmsDatabase; import org.thoughtcrime.securesms.database.NoSuchMessageException; import org.thoughtcrime.securesms.database.PushDatabase; import org.thoughtcrime.securesms.database.SmsDatabase; -import org.thoughtcrime.securesms.database.StickerDatabase; import org.thoughtcrime.securesms.database.ThreadDatabase; import org.thoughtcrime.securesms.database.model.MessageRecord; import org.thoughtcrime.securesms.database.model.MmsMessageRecord; -import org.thoughtcrime.securesms.database.model.StickerRecord; import org.thoughtcrime.securesms.dependencies.InjectableType; import org.thoughtcrime.securesms.groups.GroupMessageProcessor; import org.thoughtcrime.securesms.jobmanager.Job; @@ -70,15 +66,11 @@ import org.thoughtcrime.securesms.loki.utilities.MentionManagerUtilities; import org.thoughtcrime.securesms.mms.IncomingMediaMessage; import org.thoughtcrime.securesms.mms.MmsException; import org.thoughtcrime.securesms.mms.OutgoingMediaMessage; -import org.thoughtcrime.securesms.mms.StickerSlide; import org.thoughtcrime.securesms.notifications.NotificationChannels; import org.thoughtcrime.securesms.sms.IncomingEncryptedMessage; import org.thoughtcrime.securesms.sms.IncomingEndSessionMessage; import org.thoughtcrime.securesms.sms.IncomingTextMessage; import org.thoughtcrime.securesms.sms.OutgoingTextMessage; -import org.session.libsignal.utilities.Hex; -import org.session.libsignal.libsignal.InvalidMessageException; -import org.session.libsignal.libsignal.state.SignalProtocolStore; import org.session.libsignal.libsignal.util.guava.Optional; import org.session.libsignal.service.api.SignalServiceMessageSender; import org.session.libsignal.service.api.messages.SignalServiceContent; @@ -89,11 +81,9 @@ import org.session.libsignal.service.api.messages.SignalServiceGroup; import org.session.libsignal.service.api.messages.SignalServiceReceiptMessage; import org.session.libsignal.service.api.messages.SignalServiceTypingMessage; import org.session.libsignal.service.api.messages.shared.SharedContact; -import org.session.libsignal.service.api.push.SignalServiceAddress; import org.session.libsignal.service.loki.utilities.mentions.MentionsManager; import org.session.libsignal.service.loki.utilities.PublicKeyValidation; -import java.security.SecureRandom; import java.util.ArrayList; import java.util.Collections; import java.util.LinkedList; diff --git a/app/src/main/java/org/thoughtcrime/securesms/jobs/PushGroupSendJob.java b/app/src/main/java/org/thoughtcrime/securesms/jobs/PushGroupSendJob.java index 64050b831d..0db956eb7a 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/jobs/PushGroupSendJob.java +++ b/app/src/main/java/org/thoughtcrime/securesms/jobs/PushGroupSendJob.java @@ -290,7 +290,6 @@ public class PushGroupSendJob extends PushSendJob implements InjectableType { .asExpirationUpdate(message.isExpirationUpdate()) .withProfileKey(profileKey.orNull()) .withQuote(quote.orNull()) - .withSticker(sticker.orNull()) .withSharedContacts(sharedContacts) .withPreviews(previews); } diff --git a/app/src/main/java/org/thoughtcrime/securesms/jobs/PushMediaSendJob.java b/app/src/main/java/org/thoughtcrime/securesms/jobs/PushMediaSendJob.java index 7ff01e739d..998b4a21e4 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/jobs/PushMediaSendJob.java +++ b/app/src/main/java/org/thoughtcrime/securesms/jobs/PushMediaSendJob.java @@ -263,7 +263,6 @@ public class PushMediaSendJob extends PushSendJob implements InjectableType { .withExpiration((int)(message.getExpiresIn() / 1000)) .withProfileKey(profileKey.orNull()) .withQuote(quote.orNull()) - .withSticker(sticker.orNull()) .withSharedContacts(sharedContacts) .withPreviews(previews) .asExpirationUpdate(message.isExpirationUpdate()) @@ -277,7 +276,6 @@ public class PushMediaSendJob extends PushSendJob implements InjectableType { .withExpiration((int)(message.getExpiresIn() / 1000)) .withProfileKey(profileKey.orNull()) .withQuote(quote.orNull()) - .withSticker(sticker.orNull()) .withSharedContacts(sharedContacts) .withPreviews(previews) .asExpirationUpdate(message.isExpirationUpdate()) diff --git a/app/src/main/java/org/thoughtcrime/securesms/jobs/PushTextSendJob.java b/app/src/main/java/org/thoughtcrime/securesms/jobs/PushTextSendJob.java index aeea404bea..c74fd15aa8 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/jobs/PushTextSendJob.java +++ b/app/src/main/java/org/thoughtcrime/securesms/jobs/PushTextSendJob.java @@ -210,7 +210,6 @@ public class PushTextSendJob extends PushSendJob implements InjectableType { .withBody(message.getBody()) .withExpiration((int)(message.getExpiresIn() / 1000)) .withProfileKey(profileKey.orNull()) - .asEndSessionMessage(message.isEndSession()) .build(); SignalServiceDataMessage textSecureSelfSendMessage = SignalServiceDataMessage.newBuilder() @@ -219,7 +218,6 @@ public class PushTextSendJob extends PushSendJob implements InjectableType { .withSyncTarget(destination.serialize()) .withExpiration((int)(message.getExpiresIn() / 1000)) .withProfileKey(profileKey.orNull()) - .asEndSessionMessage(message.isEndSession()) .build(); if (userPublicKey.equals(address.getNumber())) { diff --git a/libsignal/src/main/java/org/session/libsignal/libsignal/IdentityKeyPair.java b/libsignal/src/main/java/org/session/libsignal/libsignal/IdentityKeyPair.java index b973da2112..84b843548b 100644 --- a/libsignal/src/main/java/org/session/libsignal/libsignal/IdentityKeyPair.java +++ b/libsignal/src/main/java/org/session/libsignal/libsignal/IdentityKeyPair.java @@ -5,14 +5,8 @@ */ package org.session.libsignal.libsignal; -import com.google.protobuf.ByteString; -import com.google.protobuf.InvalidProtocolBufferException; - -import org.session.libsignal.libsignal.ecc.Curve; import org.session.libsignal.libsignal.ecc.ECPrivateKey; -import static org.session.libsignal.libsignal.state.StorageProtos.IdentityKeyPairStructure; - /** * Holder for public and private identity key pair. * @@ -28,16 +22,6 @@ public class IdentityKeyPair { this.privateKey = privateKey; } - public IdentityKeyPair(byte[] serialized) throws InvalidKeyException { - try { - IdentityKeyPairStructure structure = IdentityKeyPairStructure.parseFrom(serialized); - this.publicKey = new IdentityKey(structure.getPublicKey().toByteArray(), 0); - this.privateKey = Curve.decodePrivatePoint(structure.getPrivateKey().toByteArray()); - } catch (InvalidProtocolBufferException e) { - throw new InvalidKeyException(e); - } - } - public IdentityKey getPublicKey() { return publicKey; } @@ -45,11 +29,4 @@ public class IdentityKeyPair { public ECPrivateKey getPrivateKey() { return privateKey; } - - public byte[] serialize() { - return IdentityKeyPairStructure.newBuilder() - .setPublicKey(ByteString.copyFrom(publicKey.serialize())) - .setPrivateKey(ByteString.copyFrom(privateKey.serialize())) - .build().toByteArray(); - } } diff --git a/libsignal/src/main/java/org/session/libsignal/libsignal/groups/GroupCipher.java b/libsignal/src/main/java/org/session/libsignal/libsignal/groups/GroupCipher.java deleted file mode 100644 index c1a4944cce..0000000000 --- a/libsignal/src/main/java/org/session/libsignal/libsignal/groups/GroupCipher.java +++ /dev/null @@ -1,187 +0,0 @@ -/** - * Copyright (C) 2014-2016 Open Whisper Systems - * - * Licensed according to the LICENSE file in this repository. - */ -package org.session.libsignal.libsignal.groups; - -import org.session.libsignal.libsignal.DuplicateMessageException; -import org.session.libsignal.libsignal.InvalidKeyIdException; -import org.session.libsignal.libsignal.InvalidMessageException; -import org.session.libsignal.libsignal.LegacyMessageException; -import org.session.libsignal.libsignal.NoSessionException; -import org.session.libsignal.libsignal.groups.ratchet.SenderChainKey; -import org.session.libsignal.libsignal.groups.ratchet.SenderMessageKey; -import org.session.libsignal.libsignal.groups.state.SenderKeyRecord; -import org.session.libsignal.libsignal.groups.state.SenderKeyState; -import org.session.libsignal.libsignal.groups.state.SenderKeyStore; -import org.session.libsignal.libsignal.protocol.SenderKeyMessage; - -import java.security.InvalidAlgorithmParameterException; -import java.security.NoSuchAlgorithmException; - -import javax.crypto.BadPaddingException; -import javax.crypto.Cipher; -import javax.crypto.IllegalBlockSizeException; -import javax.crypto.NoSuchPaddingException; -import javax.crypto.spec.IvParameterSpec; -import javax.crypto.spec.SecretKeySpec; - -/** - * The main entry point for Signal Protocol group encrypt/decrypt operations. - * - * Once a session has been established with {@link org.session.libsignal.libsignal.groups.GroupSessionBuilder} - * and a {@link org.session.libsignal.libsignal.protocol.SenderKeyDistributionMessage} has been - * distributed to each member of the group, this class can be used for all subsequent encrypt/decrypt - * operations within that session (ie: until group membership changes). - * - * @author Moxie Marlinspike - */ -public class GroupCipher { - - static final Object LOCK = new Object(); - - private final SenderKeyStore senderKeyStore; - private final SenderKeyName senderKeyId; - - public GroupCipher(SenderKeyStore senderKeyStore, SenderKeyName senderKeyId) { - this.senderKeyStore = senderKeyStore; - this.senderKeyId = senderKeyId; - } - - /** - * Encrypt a message. - * - * @param paddedPlaintext The plaintext message bytes, optionally padded. - * @return Ciphertext. - * @throws NoSessionException - */ - public byte[] encrypt(byte[] paddedPlaintext) throws NoSessionException { - synchronized (LOCK) { - try { - SenderKeyRecord record = senderKeyStore.loadSenderKey(senderKeyId); - SenderKeyState senderKeyState = record.getSenderKeyState(); - SenderMessageKey senderKey = senderKeyState.getSenderChainKey().getSenderMessageKey(); - byte[] ciphertext = getCipherText(senderKey.getIv(), senderKey.getCipherKey(), paddedPlaintext); - - SenderKeyMessage senderKeyMessage = new SenderKeyMessage(senderKeyState.getKeyId(), - senderKey.getIteration(), - ciphertext, - senderKeyState.getSigningKeyPrivate()); - - senderKeyState.setSenderChainKey(senderKeyState.getSenderChainKey().getNext()); - - senderKeyStore.storeSenderKey(senderKeyId, record); - - return senderKeyMessage.serialize(); - } catch (InvalidKeyIdException e) { - throw new NoSessionException(e); - } - } - } - - public byte[] decrypt(byte[] senderKeyMessageBytes) throws LegacyMessageException, InvalidMessageException, DuplicateMessageException, NoSessionException - { - synchronized (LOCK) { - try { - SenderKeyRecord record = senderKeyStore.loadSenderKey(senderKeyId); - - if (record.isEmpty()) { - throw new NoSessionException("No sender key for: " + senderKeyId); - } - - SenderKeyMessage senderKeyMessage = new SenderKeyMessage(senderKeyMessageBytes); - SenderKeyState senderKeyState = record.getSenderKeyState(senderKeyMessage.getKeyId()); - - senderKeyMessage.verifySignature(senderKeyState.getSigningKeyPublic()); - - SenderMessageKey senderKey = getSenderKey(senderKeyState, senderKeyMessage.getIteration()); - - byte[] plaintext = getPlainText(senderKey.getIv(), senderKey.getCipherKey(), senderKeyMessage.getCipherText()); - - senderKeyStore.storeSenderKey(senderKeyId, record); - - return plaintext; - } catch (org.session.libsignal.libsignal.InvalidKeyException e) { - throw new InvalidMessageException(e); - } catch (InvalidKeyIdException e) { - throw new InvalidMessageException(e); - } - } - } - - private SenderMessageKey getSenderKey(SenderKeyState senderKeyState, int iteration) - throws DuplicateMessageException, InvalidMessageException - { - SenderChainKey senderChainKey = senderKeyState.getSenderChainKey(); - - if (senderChainKey.getIteration() > iteration) { - if (senderKeyState.hasSenderMessageKey(iteration)) { - return senderKeyState.removeSenderMessageKey(iteration); - } else { - throw new DuplicateMessageException("Received message with old counter: " + - senderChainKey.getIteration() + " , " + iteration); - } - } - - if (iteration - senderChainKey.getIteration() > 2000) { - throw new InvalidMessageException("Over 2000 messages into the future!"); - } - - while (senderChainKey.getIteration() < iteration) { - senderKeyState.addSenderMessageKey(senderChainKey.getSenderMessageKey()); - senderChainKey = senderChainKey.getNext(); - } - - senderKeyState.setSenderChainKey(senderChainKey.getNext()); - return senderChainKey.getSenderMessageKey(); - } - - private byte[] getPlainText(byte[] iv, byte[] key, byte[] ciphertext) - throws InvalidMessageException - { - try { - IvParameterSpec ivParameterSpec = new IvParameterSpec(iv); - Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding"); - - cipher.init(Cipher.DECRYPT_MODE, new SecretKeySpec(key, "AES"), ivParameterSpec); - - return cipher.doFinal(ciphertext); - } catch (NoSuchAlgorithmException e) { - throw new AssertionError(e); - } catch (NoSuchPaddingException e) { - throw new AssertionError(e); - } catch(java.security.InvalidKeyException e) { - throw new AssertionError(e); - } catch (InvalidAlgorithmParameterException e) { - throw new AssertionError(e); - } catch (IllegalBlockSizeException e) { - throw new InvalidMessageException(e); - } catch (BadPaddingException e) { - throw new InvalidMessageException(e); - } - } - - private byte[] getCipherText(byte[] iv, byte[] key, byte[] plaintext) { - try { - IvParameterSpec ivParameterSpec = new IvParameterSpec(iv); - Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding"); - - cipher.init(Cipher.ENCRYPT_MODE, new SecretKeySpec(key, "AES"), ivParameterSpec); - - return cipher.doFinal(plaintext); - } catch (NoSuchAlgorithmException e) { - throw new AssertionError(e); - } catch (NoSuchPaddingException e) { - throw new AssertionError(e); - } catch (InvalidAlgorithmParameterException e) { - throw new AssertionError(e); - } catch (IllegalBlockSizeException e) { - throw new AssertionError(e); - } catch (BadPaddingException e) { - throw new AssertionError(e); - } catch (java.security.InvalidKeyException e) { - throw new AssertionError(e); - } - } -} diff --git a/libsignal/src/main/java/org/session/libsignal/libsignal/groups/GroupSessionBuilder.java b/libsignal/src/main/java/org/session/libsignal/libsignal/groups/GroupSessionBuilder.java deleted file mode 100644 index 9f71c18d5a..0000000000 --- a/libsignal/src/main/java/org/session/libsignal/libsignal/groups/GroupSessionBuilder.java +++ /dev/null @@ -1,90 +0,0 @@ -/** - * Copyright (C) 2014-2016 Open Whisper Systems - * - * Licensed according to the LICENSE file in this repository. - */ -package org.session.libsignal.libsignal.groups; - -import org.session.libsignal.libsignal.InvalidKeyException; -import org.session.libsignal.libsignal.InvalidKeyIdException; -import org.session.libsignal.libsignal.groups.state.SenderKeyRecord; -import org.session.libsignal.libsignal.groups.state.SenderKeyState; -import org.session.libsignal.libsignal.groups.state.SenderKeyStore; -import org.session.libsignal.libsignal.protocol.SenderKeyDistributionMessage; -import org.session.libsignal.libsignal.util.KeyHelper; - -/** - * GroupSessionBuilder is responsible for setting up group SenderKey encrypted sessions. - * - * Once a session has been established, {@link org.session.libsignal.libsignal.groups.GroupCipher} - * can be used to encrypt/decrypt messages in that session. - *

- * The built sessions are unidirectional: they can be used either for sending or for receiving, - * but not both. - * - * Sessions are constructed per (groupId + senderId + deviceId) tuple. Remote logical users - * are identified by their senderId, and each logical recipientId can have multiple physical - * devices. - * - * @author Moxie Marlinspike - */ - -public class GroupSessionBuilder { - - private final SenderKeyStore senderKeyStore; - - public GroupSessionBuilder(SenderKeyStore senderKeyStore) { - this.senderKeyStore = senderKeyStore; - } - - /** - * Construct a group session for receiving messages from senderKeyName. - * - * @param senderKeyName The (groupId, senderId, deviceId) tuple associated with the SenderKeyDistributionMessage. - * @param senderKeyDistributionMessage A received SenderKeyDistributionMessage. - */ - public void process(SenderKeyName senderKeyName, SenderKeyDistributionMessage senderKeyDistributionMessage) { - synchronized (GroupCipher.LOCK) { - SenderKeyRecord senderKeyRecord = senderKeyStore.loadSenderKey(senderKeyName); - senderKeyRecord.addSenderKeyState(senderKeyDistributionMessage.getId(), - senderKeyDistributionMessage.getIteration(), - senderKeyDistributionMessage.getChainKey(), - senderKeyDistributionMessage.getSignatureKey()); - senderKeyStore.storeSenderKey(senderKeyName, senderKeyRecord); - } - } - - /** - * Construct a group session for sending messages. - * - * @param senderKeyName The (groupId, senderId, deviceId) tuple. In this case, 'senderId' should be the caller. - * @return A SenderKeyDistributionMessage that is individually distributed to each member of the group. - */ - public SenderKeyDistributionMessage create(SenderKeyName senderKeyName) { - synchronized (GroupCipher.LOCK) { - try { - SenderKeyRecord senderKeyRecord = senderKeyStore.loadSenderKey(senderKeyName); - - if (senderKeyRecord.isEmpty()) { - senderKeyRecord.setSenderKeyState(KeyHelper.generateSenderKeyId(), - 0, - KeyHelper.generateSenderKey(), - KeyHelper.generateSenderSigningKey()); - senderKeyStore.storeSenderKey(senderKeyName, senderKeyRecord); - } - - SenderKeyState state = senderKeyRecord.getSenderKeyState(); - - return new SenderKeyDistributionMessage(state.getKeyId(), - state.getSenderChainKey().getIteration(), - state.getSenderChainKey().getSeed(), - state.getSigningKeyPublic()); - - } catch (InvalidKeyIdException e) { - throw new AssertionError(e); - } catch (InvalidKeyException e) { - throw new AssertionError(e); - } - } - } -} diff --git a/libsignal/src/main/java/org/session/libsignal/libsignal/groups/SenderKeyName.java b/libsignal/src/main/java/org/session/libsignal/libsignal/groups/SenderKeyName.java deleted file mode 100644 index 836c7ca6c7..0000000000 --- a/libsignal/src/main/java/org/session/libsignal/libsignal/groups/SenderKeyName.java +++ /dev/null @@ -1,52 +0,0 @@ -/** - * Copyright (C) 2014-2016 Open Whisper Systems - * - * Licensed according to the LICENSE file in this repository. - */ -package org.session.libsignal.libsignal.groups; - -import org.session.libsignal.libsignal.SignalProtocolAddress; - -/** - * A representation of a (groupId + senderId + deviceId) tuple. - */ -public class SenderKeyName { - - private final String groupId; - private final SignalProtocolAddress sender; - - public SenderKeyName(String groupId, SignalProtocolAddress sender) { - this.groupId = groupId; - this.sender = sender; - } - - public String getGroupId() { - return groupId; - } - - public SignalProtocolAddress getSender() { - return sender; - } - - public String serialize() { - return groupId + "::" + sender.getName() + "::" + String.valueOf(sender.getDeviceId()); - } - - @Override - public boolean equals(Object other) { - if (other == null) return false; - if (!(other instanceof SenderKeyName)) return false; - - SenderKeyName that = (SenderKeyName)other; - - return - this.groupId.equals(that.groupId) && - this.sender.equals(that.sender); - } - - @Override - public int hashCode() { - return this.groupId.hashCode() ^ this.sender.hashCode(); - } - -} diff --git a/libsignal/src/main/java/org/session/libsignal/libsignal/groups/ratchet/SenderChainKey.java b/libsignal/src/main/java/org/session/libsignal/libsignal/groups/ratchet/SenderChainKey.java deleted file mode 100644 index 38a0d0520f..0000000000 --- a/libsignal/src/main/java/org/session/libsignal/libsignal/groups/ratchet/SenderChainKey.java +++ /dev/null @@ -1,68 +0,0 @@ -/** - * Copyright (C) 2014-2016 Open Whisper Systems - * - * Licensed according to the LICENSE file in this repository. - */ -package org.session.libsignal.libsignal.groups.ratchet; - -import org.session.libsignal.libsignal.groups.ratchet.SenderMessageKey; - -import java.security.InvalidKeyException; -import java.security.NoSuchAlgorithmException; - -import javax.crypto.Mac; -import javax.crypto.spec.SecretKeySpec; - -/** - * Each SenderKey is a "chain" of keys, each derived from the previous. - * - * At any given point in time, the state of a SenderKey can be represented - * as the current chain key value, along with its iteration count. From there, - * subsequent iterations can be derived, as well as individual message keys from - * each chain key. - * - * @author Moxie Marlinspike - */ -public class SenderChainKey { - - private static final byte[] MESSAGE_KEY_SEED = {0x01}; - private static final byte[] CHAIN_KEY_SEED = {0x02}; - - private final int iteration; - private final byte[] chainKey; - - public SenderChainKey(int iteration, byte[] chainKey) { - this.iteration = iteration; - this.chainKey = chainKey; - } - - public int getIteration() { - return iteration; - } - - public SenderMessageKey getSenderMessageKey() { - return new SenderMessageKey(iteration, getDerivative(MESSAGE_KEY_SEED, chainKey)); - } - - public SenderChainKey getNext() { - return new SenderChainKey(iteration + 1, getDerivative(CHAIN_KEY_SEED, chainKey)); - } - - public byte[] getSeed() { - return chainKey; - } - - private byte[] getDerivative(byte[] seed, byte[] key) { - try { - Mac mac = Mac.getInstance("HmacSHA256"); - mac.init(new SecretKeySpec(key, "HmacSHA256")); - - return mac.doFinal(seed); - } catch (NoSuchAlgorithmException e) { - throw new AssertionError(e); - } catch (InvalidKeyException e) { - throw new AssertionError(e); - } - } - -} diff --git a/libsignal/src/main/java/org/session/libsignal/libsignal/groups/ratchet/SenderMessageKey.java b/libsignal/src/main/java/org/session/libsignal/libsignal/groups/ratchet/SenderMessageKey.java deleted file mode 100644 index e27f788ea8..0000000000 --- a/libsignal/src/main/java/org/session/libsignal/libsignal/groups/ratchet/SenderMessageKey.java +++ /dev/null @@ -1,50 +0,0 @@ -/** - * Copyright (C) 2014-2016 Open Whisper Systems - * - * Licensed according to the LICENSE file in this repository. - */ - -package org.session.libsignal.libsignal.groups.ratchet; - -import org.session.libsignal.libsignal.kdf.HKDFv3; -import org.session.libsignal.libsignal.util.ByteUtil; - -/** - * The final symmetric material (IV and Cipher Key) used for encrypting - * individual SenderKey messages. - * - * @author Moxie Marlinspike - */ -public class SenderMessageKey { - - private final int iteration; - private final byte[] iv; - private final byte[] cipherKey; - private final byte[] seed; - - public SenderMessageKey(int iteration, byte[] seed) { - byte[] derivative = new HKDFv3().deriveSecrets(seed, "WhisperGroup".getBytes(), 48); - byte[][] parts = ByteUtil.split(derivative, 16, 32); - - this.iteration = iteration; - this.seed = seed; - this.iv = parts[0]; - this.cipherKey = parts[1]; - } - - public int getIteration() { - return iteration; - } - - public byte[] getIv() { - return iv; - } - - public byte[] getCipherKey() { - return cipherKey; - } - - public byte[] getSeed() { - return seed; - } -} diff --git a/libsignal/src/main/java/org/session/libsignal/libsignal/groups/state/SenderKeyRecord.java b/libsignal/src/main/java/org/session/libsignal/libsignal/groups/state/SenderKeyRecord.java deleted file mode 100644 index 12c0446b5a..0000000000 --- a/libsignal/src/main/java/org/session/libsignal/libsignal/groups/state/SenderKeyRecord.java +++ /dev/null @@ -1,85 +0,0 @@ -/** - * Copyright (C) 2014-2016 Open Whisper Systems - * - * Licensed according to the LICENSE file in this repository. - */ -package org.session.libsignal.libsignal.groups.state; - -import org.session.libsignal.libsignal.InvalidKeyIdException; -import org.session.libsignal.libsignal.ecc.ECKeyPair; -import org.session.libsignal.libsignal.ecc.ECPublicKey; -import org.session.libsignal.libsignal.state.StorageProtos; - -import java.io.IOException; -import java.util.LinkedList; -import java.util.List; - -import static org.session.libsignal.libsignal.state.StorageProtos.SenderKeyRecordStructure; - -/** - * A durable representation of a set of SenderKeyStates for a specific - * SenderKeyName. - * - * @author Moxie Marlisnpike - */ -public class SenderKeyRecord { - - private static final int MAX_STATES = 5; - - private LinkedList senderKeyStates = new LinkedList(); - - public SenderKeyRecord() {} - - public SenderKeyRecord(byte[] serialized) throws IOException { - SenderKeyRecordStructure senderKeyRecordStructure = SenderKeyRecordStructure.parseFrom(serialized); - - for (StorageProtos.SenderKeyStateStructure structure : senderKeyRecordStructure.getSenderKeyStatesList()) { - this.senderKeyStates.add(new SenderKeyState(structure)); - } - } - - public boolean isEmpty() { - return senderKeyStates.isEmpty(); - } - - public SenderKeyState getSenderKeyState() throws InvalidKeyIdException { - if (!senderKeyStates.isEmpty()) { - return senderKeyStates.get(0); - } else { - throw new InvalidKeyIdException("No key state in record!"); - } - } - - public SenderKeyState getSenderKeyState(int keyId) throws InvalidKeyIdException { - for (SenderKeyState state : senderKeyStates) { - if (state.getKeyId() == keyId) { - return state; - } - } - - throw new InvalidKeyIdException("No keys for: " + keyId); - } - - public void addSenderKeyState(int id, int iteration, byte[] chainKey, ECPublicKey signatureKey) { - senderKeyStates.addFirst(new SenderKeyState(id, iteration, chainKey, signatureKey)); - - if (senderKeyStates.size() > MAX_STATES) { - senderKeyStates.removeLast(); - } - } - - public void setSenderKeyState(int id, int iteration, byte[] chainKey, ECKeyPair signatureKey) { - senderKeyStates.clear(); - senderKeyStates.add(new SenderKeyState(id, iteration, chainKey, signatureKey)); - } - - public byte[] serialize() { - SenderKeyRecordStructure.Builder recordStructure = SenderKeyRecordStructure.newBuilder(); - - for (SenderKeyState senderKeyState : senderKeyStates) { - recordStructure.addSenderKeyStates(senderKeyState.getStructure()); - } - - return recordStructure.build().toByteArray(); - } -} diff --git a/libsignal/src/main/java/org/session/libsignal/libsignal/groups/state/SenderKeyState.java b/libsignal/src/main/java/org/session/libsignal/libsignal/groups/state/SenderKeyState.java deleted file mode 100644 index 34417523ab..0000000000 --- a/libsignal/src/main/java/org/session/libsignal/libsignal/groups/state/SenderKeyState.java +++ /dev/null @@ -1,162 +0,0 @@ -/** - * Copyright (C) 2014-2016 Open Whisper Systems - * - * Licensed according to the LICENSE file in this repository. - */ -package org.session.libsignal.libsignal.groups.state; - -import com.google.protobuf.ByteString; - -import org.session.libsignal.libsignal.InvalidKeyException; -import org.session.libsignal.libsignal.ecc.Curve; -import org.session.libsignal.libsignal.ecc.ECKeyPair; -import org.session.libsignal.libsignal.ecc.ECPrivateKey; -import org.session.libsignal.libsignal.ecc.ECPublicKey; -import org.session.libsignal.libsignal.groups.ratchet.SenderChainKey; -import org.session.libsignal.libsignal.groups.ratchet.SenderMessageKey; -import org.session.libsignal.libsignal.util.guava.Optional; - -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; - -import static org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure; - -/** - * Represents the state of an individual SenderKey ratchet. - * - * @author Moxie Marlinspike - */ -public class SenderKeyState { - - private static final int MAX_MESSAGE_KEYS = 2000; - - private SenderKeyStateStructure senderKeyStateStructure; - - public SenderKeyState(int id, int iteration, byte[] chainKey, ECPublicKey signatureKey) { - this(id, iteration, chainKey, signatureKey, Optional.absent()); - } - - public SenderKeyState(int id, int iteration, byte[] chainKey, ECKeyPair signatureKey) { - this(id, iteration, chainKey, signatureKey.getPublicKey(), Optional.of(signatureKey.getPrivateKey())); - } - - private SenderKeyState(int id, int iteration, byte[] chainKey, - ECPublicKey signatureKeyPublic, - Optional signatureKeyPrivate) - { - SenderKeyStateStructure.SenderChainKey senderChainKeyStructure = - SenderKeyStateStructure.SenderChainKey.newBuilder() - .setIteration(iteration) - .setSeed(ByteString.copyFrom(chainKey)) - .build(); - - SenderKeyStateStructure.SenderSigningKey.Builder signingKeyStructure = - SenderKeyStateStructure.SenderSigningKey.newBuilder() - .setPublic(ByteString.copyFrom(signatureKeyPublic.serialize())); - - if (signatureKeyPrivate.isPresent()) { - signingKeyStructure.setPrivate(ByteString.copyFrom(signatureKeyPrivate.get().serialize())); - } - - this.senderKeyStateStructure = SenderKeyStateStructure.newBuilder() - .setSenderKeyId(id) - .setSenderChainKey(senderChainKeyStructure) - .setSenderSigningKey(signingKeyStructure) - .build(); - } - - public SenderKeyState(SenderKeyStateStructure senderKeyStateStructure) { - this.senderKeyStateStructure = senderKeyStateStructure; - } - - public int getKeyId() { - return senderKeyStateStructure.getSenderKeyId(); - } - - public SenderChainKey getSenderChainKey() { - return new SenderChainKey(senderKeyStateStructure.getSenderChainKey().getIteration(), - senderKeyStateStructure.getSenderChainKey().getSeed().toByteArray()); - } - - public void setSenderChainKey(SenderChainKey chainKey) { - SenderKeyStateStructure.SenderChainKey senderChainKeyStructure = - SenderKeyStateStructure.SenderChainKey.newBuilder() - .setIteration(chainKey.getIteration()) - .setSeed(ByteString.copyFrom(chainKey.getSeed())) - .build(); - - this.senderKeyStateStructure = senderKeyStateStructure.toBuilder() - .setSenderChainKey(senderChainKeyStructure) - .build(); - } - - public ECPublicKey getSigningKeyPublic() throws InvalidKeyException { - return Curve.decodePoint(senderKeyStateStructure.getSenderSigningKey() - .getPublic() - .toByteArray(), 0); - } - - public ECPrivateKey getSigningKeyPrivate() { - return Curve.decodePrivatePoint(senderKeyStateStructure.getSenderSigningKey() - .getPrivate().toByteArray()); - } - - public boolean hasSenderMessageKey(int iteration) { - for (SenderKeyStateStructure.SenderMessageKey senderMessageKey : senderKeyStateStructure.getSenderMessageKeysList()) { - if (senderMessageKey.getIteration() == iteration) return true; - } - - return false; - } - - public void addSenderMessageKey(SenderMessageKey senderMessageKey) { - SenderKeyStateStructure.SenderMessageKey senderMessageKeyStructure = - SenderKeyStateStructure.SenderMessageKey.newBuilder() - .setIteration(senderMessageKey.getIteration()) - .setSeed(ByteString.copyFrom(senderMessageKey.getSeed())) - .build(); - - SenderKeyStateStructure.Builder builder = this.senderKeyStateStructure.toBuilder(); - - builder.addSenderMessageKeys(senderMessageKeyStructure); - - if (builder.getSenderMessageKeysCount() > MAX_MESSAGE_KEYS) { - builder.removeSenderMessageKeys(0); - } - - this.senderKeyStateStructure = builder.build(); - } - - public SenderMessageKey removeSenderMessageKey(int iteration) { - List keys = new LinkedList(senderKeyStateStructure.getSenderMessageKeysList()); - Iterator iterator = keys.iterator(); - - SenderKeyStateStructure.SenderMessageKey result = null; - - while (iterator.hasNext()) { - SenderKeyStateStructure.SenderMessageKey senderMessageKey = iterator.next(); - - if (senderMessageKey.getIteration() == iteration) { - result = senderMessageKey; - iterator.remove(); - break; - } - } - - this.senderKeyStateStructure = this.senderKeyStateStructure.toBuilder() - .clearSenderMessageKeys() - .addAllSenderMessageKeys(keys) - .build(); - - if (result != null) { - return new SenderMessageKey(result.getIteration(), result.getSeed().toByteArray()); - } else { - return null; - } - } - - public SenderKeyStateStructure getStructure() { - return senderKeyStateStructure; - } -} diff --git a/libsignal/src/main/java/org/session/libsignal/libsignal/groups/state/SenderKeyStore.java b/libsignal/src/main/java/org/session/libsignal/libsignal/groups/state/SenderKeyStore.java deleted file mode 100644 index 10f0df9972..0000000000 --- a/libsignal/src/main/java/org/session/libsignal/libsignal/groups/state/SenderKeyStore.java +++ /dev/null @@ -1,38 +0,0 @@ -/** - * Copyright (C) 2014-2016 Open Whisper Systems - * - * Licensed according to the LICENSE file in this repository. - */ -package org.session.libsignal.libsignal.groups.state; - -import org.session.libsignal.libsignal.groups.SenderKeyName; -import org.session.libsignal.libsignal.groups.state.SenderKeyRecord; - -public interface SenderKeyStore { - - /** - * Commit to storage the {@link org.session.libsignal.libsignal.groups.state.SenderKeyRecord} for a - * given (groupId + senderId + deviceId) tuple. - * - * @param senderKeyName the (groupId + senderId + deviceId) tuple. - * @param record the current SenderKeyRecord for the specified senderKeyName. - */ - public void storeSenderKey(SenderKeyName senderKeyName, SenderKeyRecord record); - - /** - * Returns a copy of the {@link SenderKeyRecord} - * corresponding to the (groupId + senderId + deviceId) tuple, or a new SenderKeyRecord if - * one does not currently exist. - *

- * It is important that implementations return a copy of the current durable information. The - * returned SenderKeyRecord may be modified, but those changes should not have an effect on the - * durable session state (what is returned by subsequent calls to this method) without the - * store method being called here first. - * - * @param senderKeyName The (groupId + senderId + deviceId) tuple. - * @return a copy of the SenderKeyRecord corresponding to the (groupId + senderId + deviceId tuple, or - * a new SenderKeyRecord if one does not currently exist. - */ - - public SenderKeyRecord loadSenderKey(SenderKeyName senderKeyName); -} diff --git a/libsignal/src/main/java/org/session/libsignal/libsignal/protocol/CiphertextMessage.java b/libsignal/src/main/java/org/session/libsignal/libsignal/protocol/CiphertextMessage.java deleted file mode 100644 index 233a982d5e..0000000000 --- a/libsignal/src/main/java/org/session/libsignal/libsignal/protocol/CiphertextMessage.java +++ /dev/null @@ -1,26 +0,0 @@ -/** - * Copyright (C) 2014-2016 Open Whisper Systems - *

- * Licensed according to the LICENSE file in this repository. - */ -package org.session.libsignal.libsignal.protocol; - -public interface CiphertextMessage { - - public static final int CURRENT_VERSION = 3; - - public static final int WHISPER_TYPE = 2; - public static final int PREKEY_TYPE = 3; - public static final int SENDERKEY_TYPE = 4; - public static final int SENDERKEY_DISTRIBUTION_TYPE = 5; - public static final int CLOSED_GROUP_CIPHERTEXT = 6; - public static final int FALLBACK_MESSAGE_TYPE = 999; // Loki - - // This should be the worst case (worse than V2). So not always accurate, but good enough for padding. - public static final int ENCRYPTED_MESSAGE_OVERHEAD = 53; - - public byte[] serialize(); - - public int getType(); - -} diff --git a/libsignal/src/main/java/org/session/libsignal/libsignal/protocol/PreKeySignalMessage.java b/libsignal/src/main/java/org/session/libsignal/libsignal/protocol/PreKeySignalMessage.java deleted file mode 100644 index 1356518586..0000000000 --- a/libsignal/src/main/java/org/session/libsignal/libsignal/protocol/PreKeySignalMessage.java +++ /dev/null @@ -1,143 +0,0 @@ -/** - * Copyright (C) 2014-2016 Open Whisper Systems - * - * Licensed according to the LICENSE file in this repository. - */ -package org.session.libsignal.libsignal.protocol; - -import com.google.protobuf.ByteString; -import com.google.protobuf.InvalidProtocolBufferException; - -import org.session.libsignal.libsignal.IdentityKey; -import org.session.libsignal.libsignal.InvalidKeyException; -import org.session.libsignal.libsignal.InvalidMessageException; -import org.session.libsignal.libsignal.InvalidVersionException; -import org.session.libsignal.libsignal.LegacyMessageException; -import org.session.libsignal.libsignal.ecc.Curve; -import org.session.libsignal.libsignal.ecc.ECPublicKey; -import org.session.libsignal.libsignal.util.ByteUtil; -import org.session.libsignal.libsignal.util.guava.Optional; - - -public class PreKeySignalMessage implements CiphertextMessage { - - private final int version; - private final int registrationId; - private final Optional preKeyId; - private final int signedPreKeyId; - private final ECPublicKey baseKey; - private final IdentityKey identityKey; - private final SignalMessage message; - private final byte[] serialized; - - public PreKeySignalMessage(byte[] serialized) - throws InvalidMessageException, InvalidVersionException - { - try { - this.version = ByteUtil.highBitsToInt(serialized[0]); - - if (this.version > CiphertextMessage.CURRENT_VERSION) { - throw new InvalidVersionException("Unknown version: " + this.version); - } - - if (this.version < CiphertextMessage.CURRENT_VERSION) { - throw new LegacyMessageException("Legacy version: " + this.version); - } - - SignalProtos.PreKeySignalMessage preKeyWhisperMessage - = SignalProtos.PreKeySignalMessage.parseFrom(ByteString.copyFrom(serialized, 1, - serialized.length-1)); - - if (!preKeyWhisperMessage.hasSignedPreKeyId() || - !preKeyWhisperMessage.hasBaseKey() || - !preKeyWhisperMessage.hasIdentityKey() || - !preKeyWhisperMessage.hasMessage()) - { - throw new InvalidMessageException("Incomplete message."); - } - - this.serialized = serialized; - this.registrationId = preKeyWhisperMessage.getRegistrationId(); - this.preKeyId = preKeyWhisperMessage.hasPreKeyId() ? Optional.of(preKeyWhisperMessage.getPreKeyId()) : Optional.absent(); - this.signedPreKeyId = preKeyWhisperMessage.hasSignedPreKeyId() ? preKeyWhisperMessage.getSignedPreKeyId() : -1; - this.baseKey = Curve.decodePoint(preKeyWhisperMessage.getBaseKey().toByteArray(), 0); - this.identityKey = new IdentityKey(Curve.decodePoint(preKeyWhisperMessage.getIdentityKey().toByteArray(), 0)); - this.message = new SignalMessage(preKeyWhisperMessage.getMessage().toByteArray()); - } catch (InvalidProtocolBufferException e) { - throw new InvalidMessageException(e); - } catch (InvalidKeyException e) { - throw new InvalidMessageException(e); - } catch (LegacyMessageException e) { - throw new InvalidMessageException(e); - } - } - - public PreKeySignalMessage(int messageVersion, int registrationId, Optional preKeyId, - int signedPreKeyId, ECPublicKey baseKey, IdentityKey identityKey, - SignalMessage message) - { - this.version = messageVersion; - this.registrationId = registrationId; - this.preKeyId = preKeyId; - this.signedPreKeyId = signedPreKeyId; - this.baseKey = baseKey; - this.identityKey = identityKey; - this.message = message; - - SignalProtos.PreKeySignalMessage.Builder builder = - SignalProtos.PreKeySignalMessage.newBuilder() - .setSignedPreKeyId(signedPreKeyId) - .setBaseKey(ByteString.copyFrom(baseKey.serialize())) - .setIdentityKey(ByteString.copyFrom(identityKey.serialize())) - .setMessage(ByteString.copyFrom(message.serialize())) - .setRegistrationId(registrationId); - - if (preKeyId.isPresent()) { - builder.setPreKeyId(preKeyId.get()); - } - - byte[] versionBytes = {ByteUtil.intsToByteHighAndLow(this.version, CURRENT_VERSION)}; - byte[] messageBytes = builder.build().toByteArray(); - - this.serialized = ByteUtil.combine(versionBytes, messageBytes); - } - - public int getMessageVersion() { - return version; - } - - public IdentityKey getIdentityKey() { - return identityKey; - } - - public int getRegistrationId() { - return registrationId; - } - - public Optional getPreKeyId() { - return preKeyId; - } - - public int getSignedPreKeyId() { - return signedPreKeyId; - } - - public ECPublicKey getBaseKey() { - return baseKey; - } - - public SignalMessage getWhisperMessage() { - return message; - } - - @Override - public byte[] serialize() { - return serialized; - } - - @Override - public int getType() { - return CiphertextMessage.PREKEY_TYPE; - } - -} diff --git a/libsignal/src/main/java/org/session/libsignal/libsignal/protocol/SenderKeyDistributionMessage.java b/libsignal/src/main/java/org/session/libsignal/libsignal/protocol/SenderKeyDistributionMessage.java deleted file mode 100644 index 290f121cdb..0000000000 --- a/libsignal/src/main/java/org/session/libsignal/libsignal/protocol/SenderKeyDistributionMessage.java +++ /dev/null @@ -1,103 +0,0 @@ -/** - * Copyright (C) 2014-2016 Open Whisper Systems - * - * Licensed according to the LICENSE file in this repository. - */ -package org.session.libsignal.libsignal.protocol; - -import com.google.protobuf.ByteString; -import com.google.protobuf.InvalidProtocolBufferException; - -import org.session.libsignal.libsignal.InvalidKeyException; -import org.session.libsignal.libsignal.InvalidMessageException; -import org.session.libsignal.libsignal.LegacyMessageException; -import org.session.libsignal.libsignal.ecc.Curve; -import org.session.libsignal.libsignal.ecc.ECPublicKey; -import org.session.libsignal.libsignal.util.ByteUtil; - -public class SenderKeyDistributionMessage implements CiphertextMessage { - - private final int id; - private final int iteration; - private final byte[] chainKey; - private final ECPublicKey signatureKey; - private final byte[] serialized; - - public SenderKeyDistributionMessage(int id, int iteration, byte[] chainKey, ECPublicKey signatureKey) { - byte[] version = {ByteUtil.intsToByteHighAndLow(CURRENT_VERSION, CURRENT_VERSION)}; - byte[] protobuf = SignalProtos.SenderKeyDistributionMessage.newBuilder() - .setId(id) - .setIteration(iteration) - .setChainKey(ByteString.copyFrom(chainKey)) - .setSigningKey(ByteString.copyFrom(signatureKey.serialize())) - .build().toByteArray(); - - this.id = id; - this.iteration = iteration; - this.chainKey = chainKey; - this.signatureKey = signatureKey; - this.serialized = ByteUtil.combine(version, protobuf); - } - - public SenderKeyDistributionMessage(byte[] serialized) throws LegacyMessageException, InvalidMessageException { - try { - byte[][] messageParts = ByteUtil.split(serialized, 1, serialized.length - 1); - byte version = messageParts[0][0]; - byte[] message = messageParts[1]; - - if (ByteUtil.highBitsToInt(version) < CiphertextMessage.CURRENT_VERSION) { - throw new LegacyMessageException("Legacy message: " + ByteUtil.highBitsToInt(version)); - } - - if (ByteUtil.highBitsToInt(version) > CURRENT_VERSION) { - throw new InvalidMessageException("Unknown version: " + ByteUtil.highBitsToInt(version)); - } - - SignalProtos.SenderKeyDistributionMessage distributionMessage = SignalProtos.SenderKeyDistributionMessage.parseFrom(message); - - if (!distributionMessage.hasId() || - !distributionMessage.hasIteration() || - !distributionMessage.hasChainKey() || - !distributionMessage.hasSigningKey()) - { - throw new InvalidMessageException("Incomplete message."); - } - - this.serialized = serialized; - this.id = distributionMessage.getId(); - this.iteration = distributionMessage.getIteration(); - this.chainKey = distributionMessage.getChainKey().toByteArray(); - this.signatureKey = Curve.decodePoint(distributionMessage.getSigningKey().toByteArray(), 0); - } catch (InvalidProtocolBufferException e) { - throw new InvalidMessageException(e); - } catch (InvalidKeyException e) { - throw new InvalidMessageException(e); - } - } - - @Override - public byte[] serialize() { - return serialized; - } - - @Override - public int getType() { - return SENDERKEY_DISTRIBUTION_TYPE; - } - - public int getIteration() { - return iteration; - } - - public byte[] getChainKey() { - return chainKey; - } - - public ECPublicKey getSignatureKey() { - return signatureKey; - } - - public int getId() { - return id; - } -} diff --git a/libsignal/src/main/java/org/session/libsignal/libsignal/protocol/SenderKeyMessage.java b/libsignal/src/main/java/org/session/libsignal/libsignal/protocol/SenderKeyMessage.java deleted file mode 100644 index da40f6f376..0000000000 --- a/libsignal/src/main/java/org/session/libsignal/libsignal/protocol/SenderKeyMessage.java +++ /dev/null @@ -1,129 +0,0 @@ -/** - * Copyright (C) 2014-2016 Open Whisper Systems - * - * Licensed according to the LICENSE file in this repository. - */ -package org.session.libsignal.libsignal.protocol; - -import com.google.protobuf.ByteString; -import com.google.protobuf.InvalidProtocolBufferException; - -import org.session.libsignal.libsignal.InvalidKeyException; -import org.session.libsignal.libsignal.InvalidMessageException; -import org.session.libsignal.libsignal.LegacyMessageException; -import org.session.libsignal.libsignal.ecc.Curve; -import org.session.libsignal.libsignal.ecc.ECPrivateKey; -import org.session.libsignal.libsignal.ecc.ECPublicKey; -import org.session.libsignal.libsignal.protocol.CiphertextMessage; -import org.session.libsignal.libsignal.util.ByteUtil; - -import java.text.ParseException; - -public class SenderKeyMessage implements CiphertextMessage { - - private static final int SIGNATURE_LENGTH = 64; - - private final int messageVersion; - private final int keyId; - private final int iteration; - private final byte[] ciphertext; - private final byte[] serialized; - - public SenderKeyMessage(byte[] serialized) throws InvalidMessageException, LegacyMessageException { - try { - byte[][] messageParts = ByteUtil.split(serialized, 1, serialized.length - 1 - SIGNATURE_LENGTH, SIGNATURE_LENGTH); - byte version = messageParts[0][0]; - byte[] message = messageParts[1]; - byte[] signature = messageParts[2]; - - if (ByteUtil.highBitsToInt(version) < 3) { - throw new LegacyMessageException("Legacy message: " + ByteUtil.highBitsToInt(version)); - } - - if (ByteUtil.highBitsToInt(version) > CURRENT_VERSION) { - throw new InvalidMessageException("Unknown version: " + ByteUtil.highBitsToInt(version)); - } - - SignalProtos.SenderKeyMessage senderKeyMessage = SignalProtos.SenderKeyMessage.parseFrom(message); - - if (!senderKeyMessage.hasId() || - !senderKeyMessage.hasIteration() || - !senderKeyMessage.hasCiphertext()) - { - throw new InvalidMessageException("Incomplete message."); - } - - this.serialized = serialized; - this.messageVersion = ByteUtil.highBitsToInt(version); - this.keyId = senderKeyMessage.getId(); - this.iteration = senderKeyMessage.getIteration(); - this.ciphertext = senderKeyMessage.getCiphertext().toByteArray(); - } catch (InvalidProtocolBufferException e) { - throw new InvalidMessageException(e); - } catch (ParseException e) { - throw new InvalidMessageException(e); - } - } - - public SenderKeyMessage(int keyId, int iteration, byte[] ciphertext, ECPrivateKey signatureKey) { - byte[] version = {ByteUtil.intsToByteHighAndLow(CURRENT_VERSION, CURRENT_VERSION)}; - byte[] message = SignalProtos.SenderKeyMessage.newBuilder() - .setId(keyId) - .setIteration(iteration) - .setCiphertext(ByteString.copyFrom(ciphertext)) - .build().toByteArray(); - - byte[] signature = getSignature(signatureKey, ByteUtil.combine(version, message)); - - this.serialized = ByteUtil.combine(version, message, signature); - this.messageVersion = CURRENT_VERSION; - this.keyId = keyId; - this.iteration = iteration; - this.ciphertext = ciphertext; - } - - public int getKeyId() { - return keyId; - } - - public int getIteration() { - return iteration; - } - - public byte[] getCipherText() { - return ciphertext; - } - - public void verifySignature(ECPublicKey signatureKey) - throws InvalidMessageException - { - try { - byte[][] parts = ByteUtil.split(serialized, serialized.length - SIGNATURE_LENGTH, SIGNATURE_LENGTH); - - if (!Curve.verifySignature(signatureKey, parts[0], parts[1])) { - throw new InvalidMessageException("Invalid signature!"); - } - - } catch (InvalidKeyException e) { - throw new InvalidMessageException(e); - } - } - - private byte[] getSignature(ECPrivateKey signatureKey, byte[] serialized) { - try { - return Curve.calculateSignature(signatureKey, serialized); - } catch (InvalidKeyException e) { - throw new AssertionError(e); - } - } - - @Override - public byte[] serialize() { - return serialized; - } - - @Override - public int getType() { - return CiphertextMessage.SENDERKEY_TYPE; - } -} diff --git a/libsignal/src/main/java/org/session/libsignal/libsignal/protocol/SignalMessage.java b/libsignal/src/main/java/org/session/libsignal/libsignal/protocol/SignalMessage.java deleted file mode 100644 index b72a9aae19..0000000000 --- a/libsignal/src/main/java/org/session/libsignal/libsignal/protocol/SignalMessage.java +++ /dev/null @@ -1,157 +0,0 @@ -/** - * Copyright (C) 2014-2016 Open Whisper Systems - * - * Licensed according to the LICENSE file in this repository. - */ -package org.session.libsignal.libsignal.protocol; - -import com.google.protobuf.ByteString; -import com.google.protobuf.InvalidProtocolBufferException; - -import org.session.libsignal.libsignal.IdentityKey; -import org.session.libsignal.libsignal.InvalidKeyException; -import org.session.libsignal.libsignal.InvalidMessageException; -import org.session.libsignal.libsignal.LegacyMessageException; -import org.session.libsignal.libsignal.ecc.Curve; -import org.session.libsignal.libsignal.ecc.ECPublicKey; -import org.session.libsignal.libsignal.protocol.CiphertextMessage; -import org.session.libsignal.libsignal.util.ByteUtil; - -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; -import java.text.ParseException; - -import javax.crypto.Mac; -import javax.crypto.spec.SecretKeySpec; - -public class SignalMessage implements CiphertextMessage { - - private static final int MAC_LENGTH = 8; - - private final int messageVersion; - private final ECPublicKey senderRatchetKey; - private final int counter; - private final int previousCounter; - private final byte[] ciphertext; - private final byte[] serialized; - - public SignalMessage(byte[] serialized) throws InvalidMessageException, LegacyMessageException { - try { - byte[][] messageParts = ByteUtil.split(serialized, 1, serialized.length - 1 - MAC_LENGTH, MAC_LENGTH); - byte version = messageParts[0][0]; - byte[] message = messageParts[1]; - byte[] mac = messageParts[2]; - - if (ByteUtil.highBitsToInt(version) < CURRENT_VERSION) { - throw new LegacyMessageException("Legacy message: " + ByteUtil.highBitsToInt(version)); - } - - if (ByteUtil.highBitsToInt(version) > CURRENT_VERSION) { - throw new InvalidMessageException("Unknown version: " + ByteUtil.highBitsToInt(version)); - } - - SignalProtos.SignalMessage whisperMessage = SignalProtos.SignalMessage.parseFrom(message); - - if (!whisperMessage.hasCiphertext() || - !whisperMessage.hasCounter() || - !whisperMessage.hasRatchetKey()) - { - throw new InvalidMessageException("Incomplete message."); - } - - this.serialized = serialized; - this.senderRatchetKey = Curve.decodePoint(whisperMessage.getRatchetKey().toByteArray(), 0); - this.messageVersion = ByteUtil.highBitsToInt(version); - this.counter = whisperMessage.getCounter(); - this.previousCounter = whisperMessage.getPreviousCounter(); - this.ciphertext = whisperMessage.getCiphertext().toByteArray(); - } catch (InvalidProtocolBufferException e) { - throw new InvalidMessageException(e); - } catch (InvalidKeyException e) { - throw new InvalidMessageException(e); - } catch (ParseException e) { - throw new InvalidMessageException(e); - } - } - - public SignalMessage(int messageVersion, SecretKeySpec macKey, ECPublicKey senderRatchetKey, - int counter, int previousCounter, byte[] ciphertext, - IdentityKey senderIdentityKey, - IdentityKey receiverIdentityKey) - { - byte[] version = {ByteUtil.intsToByteHighAndLow(messageVersion, CURRENT_VERSION)}; - byte[] message = SignalProtos.SignalMessage.newBuilder() - .setRatchetKey(ByteString.copyFrom(senderRatchetKey.serialize())) - .setCounter(counter) - .setPreviousCounter(previousCounter) - .setCiphertext(ByteString.copyFrom(ciphertext)) - .build().toByteArray(); - - byte[] mac = getMac(senderIdentityKey, receiverIdentityKey, macKey, ByteUtil.combine(version, message)); - - this.serialized = ByteUtil.combine(version, message, mac); - this.senderRatchetKey = senderRatchetKey; - this.counter = counter; - this.previousCounter = previousCounter; - this.ciphertext = ciphertext; - this.messageVersion = messageVersion; - } - - public ECPublicKey getSenderRatchetKey() { - return senderRatchetKey; - } - - public int getMessageVersion() { - return messageVersion; - } - - public int getCounter() { - return counter; - } - - public byte[] getBody() { - return ciphertext; - } - - public void verifyMac(IdentityKey senderIdentityKey, IdentityKey receiverIdentityKey, SecretKeySpec macKey) - throws InvalidMessageException - { - byte[][] parts = ByteUtil.split(serialized, serialized.length - MAC_LENGTH, MAC_LENGTH); - byte[] ourMac = getMac(senderIdentityKey, receiverIdentityKey, macKey, parts[0]); - byte[] theirMac = parts[1]; - - if (!MessageDigest.isEqual(ourMac, theirMac)) { - throw new InvalidMessageException("Bad Mac!"); - } - } - - private byte[] getMac(IdentityKey senderIdentityKey, - IdentityKey receiverIdentityKey, - SecretKeySpec macKey, byte[] serialized) - { - try { - Mac mac = Mac.getInstance("HmacSHA256"); - mac.init(macKey); - - mac.update(senderIdentityKey.getPublicKey().serialize()); - mac.update(receiverIdentityKey.getPublicKey().serialize()); - - byte[] fullMac = mac.doFinal(serialized); - return ByteUtil.trim(fullMac, MAC_LENGTH); - } catch (NoSuchAlgorithmException e) { - throw new AssertionError(e); - } catch (java.security.InvalidKeyException e) { - throw new AssertionError(e); - } - } - - @Override - public byte[] serialize() { - return serialized; - } - - @Override - public int getType() { - return CiphertextMessage.WHISPER_TYPE; - } -} diff --git a/libsignal/src/main/java/org/session/libsignal/libsignal/ratchet/AliceSignalProtocolParameters.java b/libsignal/src/main/java/org/session/libsignal/libsignal/ratchet/AliceSignalProtocolParameters.java deleted file mode 100644 index 7dad4c76cf..0000000000 --- a/libsignal/src/main/java/org/session/libsignal/libsignal/ratchet/AliceSignalProtocolParameters.java +++ /dev/null @@ -1,114 +0,0 @@ -/** - * Copyright (C) 2014-2016 Open Whisper Systems - * - * Licensed according to the LICENSE file in this repository. - */ -package org.session.libsignal.libsignal.ratchet; - -import org.session.libsignal.libsignal.IdentityKey; -import org.session.libsignal.libsignal.IdentityKeyPair; -import org.session.libsignal.libsignal.ecc.ECKeyPair; -import org.session.libsignal.libsignal.ecc.ECPublicKey; -import org.session.libsignal.libsignal.util.guava.Optional; - -public class AliceSignalProtocolParameters { - - private final IdentityKeyPair ourIdentityKey; - private final ECKeyPair ourBaseKey; - - private final IdentityKey theirIdentityKey; - private final ECPublicKey theirSignedPreKey; - private final Optional theirOneTimePreKey; - private final ECPublicKey theirRatchetKey; - - private AliceSignalProtocolParameters(IdentityKeyPair ourIdentityKey, ECKeyPair ourBaseKey, - IdentityKey theirIdentityKey, ECPublicKey theirSignedPreKey, - ECPublicKey theirRatchetKey, Optional theirOneTimePreKey) - { - this.ourIdentityKey = ourIdentityKey; - this.ourBaseKey = ourBaseKey; - this.theirIdentityKey = theirIdentityKey; - this.theirSignedPreKey = theirSignedPreKey; - this.theirRatchetKey = theirRatchetKey; - this.theirOneTimePreKey = theirOneTimePreKey; - - if (ourIdentityKey == null || ourBaseKey == null || theirIdentityKey == null || - theirSignedPreKey == null || theirRatchetKey == null || theirOneTimePreKey == null) - { - throw new IllegalArgumentException("Null values!"); - } - } - - public IdentityKeyPair getOurIdentityKey() { - return ourIdentityKey; - } - - public ECKeyPair getOurBaseKey() { - return ourBaseKey; - } - - public IdentityKey getTheirIdentityKey() { - return theirIdentityKey; - } - - public ECPublicKey getTheirSignedPreKey() { - return theirSignedPreKey; - } - - public Optional getTheirOneTimePreKey() { - return theirOneTimePreKey; - } - - public static Builder newBuilder() { - return new Builder(); - } - - public ECPublicKey getTheirRatchetKey() { - return theirRatchetKey; - } - - public static class Builder { - private IdentityKeyPair ourIdentityKey; - private ECKeyPair ourBaseKey; - - private IdentityKey theirIdentityKey; - private ECPublicKey theirSignedPreKey; - private ECPublicKey theirRatchetKey; - private Optional theirOneTimePreKey; - - public Builder setOurIdentityKey(IdentityKeyPair ourIdentityKey) { - this.ourIdentityKey = ourIdentityKey; - return this; - } - - public Builder setOurBaseKey(ECKeyPair ourBaseKey) { - this.ourBaseKey = ourBaseKey; - return this; - } - - public Builder setTheirRatchetKey(ECPublicKey theirRatchetKey) { - this.theirRatchetKey = theirRatchetKey; - return this; - } - - public Builder setTheirIdentityKey(IdentityKey theirIdentityKey) { - this.theirIdentityKey = theirIdentityKey; - return this; - } - - public Builder setTheirSignedPreKey(ECPublicKey theirSignedPreKey) { - this.theirSignedPreKey = theirSignedPreKey; - return this; - } - - public Builder setTheirOneTimePreKey(Optional theirOneTimePreKey) { - this.theirOneTimePreKey = theirOneTimePreKey; - return this; - } - - public AliceSignalProtocolParameters create() { - return new AliceSignalProtocolParameters(ourIdentityKey, ourBaseKey, theirIdentityKey, - theirSignedPreKey, theirRatchetKey, theirOneTimePreKey); - } - } -} diff --git a/libsignal/src/main/java/org/session/libsignal/libsignal/ratchet/BobSignalProtocolParameters.java b/libsignal/src/main/java/org/session/libsignal/libsignal/ratchet/BobSignalProtocolParameters.java deleted file mode 100644 index 030a2f734a..0000000000 --- a/libsignal/src/main/java/org/session/libsignal/libsignal/ratchet/BobSignalProtocolParameters.java +++ /dev/null @@ -1,114 +0,0 @@ -/** - * Copyright (C) 2014-2016 Open Whisper Systems - * - * Licensed according to the LICENSE file in this repository. - */ -package org.session.libsignal.libsignal.ratchet; - -import org.session.libsignal.libsignal.IdentityKey; -import org.session.libsignal.libsignal.IdentityKeyPair; -import org.session.libsignal.libsignal.ecc.ECKeyPair; -import org.session.libsignal.libsignal.ecc.ECPublicKey; -import org.session.libsignal.libsignal.util.guava.Optional; - -public class BobSignalProtocolParameters { - - private final IdentityKeyPair ourIdentityKey; - private final ECKeyPair ourSignedPreKey; - private final Optional ourOneTimePreKey; - private final ECKeyPair ourRatchetKey; - - private final IdentityKey theirIdentityKey; - private final ECPublicKey theirBaseKey; - - BobSignalProtocolParameters(IdentityKeyPair ourIdentityKey, ECKeyPair ourSignedPreKey, - ECKeyPair ourRatchetKey, Optional ourOneTimePreKey, - IdentityKey theirIdentityKey, ECPublicKey theirBaseKey) - { - this.ourIdentityKey = ourIdentityKey; - this.ourSignedPreKey = ourSignedPreKey; - this.ourRatchetKey = ourRatchetKey; - this.ourOneTimePreKey = ourOneTimePreKey; - this.theirIdentityKey = theirIdentityKey; - this.theirBaseKey = theirBaseKey; - - if (ourIdentityKey == null || ourSignedPreKey == null || ourRatchetKey == null || - ourOneTimePreKey == null || theirIdentityKey == null || theirBaseKey == null) - { - throw new IllegalArgumentException("Null value!"); - } - } - - public IdentityKeyPair getOurIdentityKey() { - return ourIdentityKey; - } - - public ECKeyPair getOurSignedPreKey() { - return ourSignedPreKey; - } - - public Optional getOurOneTimePreKey() { - return ourOneTimePreKey; - } - - public IdentityKey getTheirIdentityKey() { - return theirIdentityKey; - } - - public ECPublicKey getTheirBaseKey() { - return theirBaseKey; - } - - public static Builder newBuilder() { - return new Builder(); - } - - public ECKeyPair getOurRatchetKey() { - return ourRatchetKey; - } - - public static class Builder { - private IdentityKeyPair ourIdentityKey; - private ECKeyPair ourSignedPreKey; - private Optional ourOneTimePreKey; - private ECKeyPair ourRatchetKey; - - private IdentityKey theirIdentityKey; - private ECPublicKey theirBaseKey; - - public Builder setOurIdentityKey(IdentityKeyPair ourIdentityKey) { - this.ourIdentityKey = ourIdentityKey; - return this; - } - - public Builder setOurSignedPreKey(ECKeyPair ourSignedPreKey) { - this.ourSignedPreKey = ourSignedPreKey; - return this; - } - - public Builder setOurOneTimePreKey(Optional ourOneTimePreKey) { - this.ourOneTimePreKey = ourOneTimePreKey; - return this; - } - - public Builder setTheirIdentityKey(IdentityKey theirIdentityKey) { - this.theirIdentityKey = theirIdentityKey; - return this; - } - - public Builder setTheirBaseKey(ECPublicKey theirBaseKey) { - this.theirBaseKey = theirBaseKey; - return this; - } - - public Builder setOurRatchetKey(ECKeyPair ourRatchetKey) { - this.ourRatchetKey = ourRatchetKey; - return this; - } - - public BobSignalProtocolParameters create() { - return new BobSignalProtocolParameters(ourIdentityKey, ourSignedPreKey, ourRatchetKey, - ourOneTimePreKey, theirIdentityKey, theirBaseKey); - } - } -} diff --git a/libsignal/src/main/java/org/session/libsignal/libsignal/ratchet/ChainKey.java b/libsignal/src/main/java/org/session/libsignal/libsignal/ratchet/ChainKey.java deleted file mode 100644 index e5204f40c7..0000000000 --- a/libsignal/src/main/java/org/session/libsignal/libsignal/ratchet/ChainKey.java +++ /dev/null @@ -1,67 +0,0 @@ -/** - * Copyright (C) 2014-2016 Open Whisper Systems - * - * Licensed according to the LICENSE file in this repository. - */ -package org.session.libsignal.libsignal.ratchet; - - -import org.session.libsignal.libsignal.kdf.DerivedMessageSecrets; -import org.session.libsignal.libsignal.kdf.HKDF; -import org.session.libsignal.libsignal.ratchet.MessageKeys; - -import java.security.InvalidKeyException; -import java.security.NoSuchAlgorithmException; - -import javax.crypto.Mac; -import javax.crypto.spec.SecretKeySpec; - -public class ChainKey { - - private static final byte[] MESSAGE_KEY_SEED = {0x01}; - private static final byte[] CHAIN_KEY_SEED = {0x02}; - - private final HKDF kdf; - private final byte[] key; - private final int index; - - public ChainKey(HKDF kdf, byte[] key, int index) { - this.kdf = kdf; - this.key = key; - this.index = index; - } - - public byte[] getKey() { - return key; - } - - public int getIndex() { - return index; - } - - public ChainKey getNextChainKey() { - byte[] nextKey = getBaseMaterial(CHAIN_KEY_SEED); - return new ChainKey(kdf, nextKey, index + 1); - } - - public MessageKeys getMessageKeys() { - byte[] inputKeyMaterial = getBaseMaterial(MESSAGE_KEY_SEED); - byte[] keyMaterialBytes = kdf.deriveSecrets(inputKeyMaterial, "WhisperMessageKeys".getBytes(), DerivedMessageSecrets.SIZE); - DerivedMessageSecrets keyMaterial = new DerivedMessageSecrets(keyMaterialBytes); - - return new MessageKeys(keyMaterial.getCipherKey(), keyMaterial.getMacKey(), keyMaterial.getIv(), index); - } - - private byte[] getBaseMaterial(byte[] seed) { - try { - Mac mac = Mac.getInstance("HmacSHA256"); - mac.init(new SecretKeySpec(key, "HmacSHA256")); - - return mac.doFinal(seed); - } catch (NoSuchAlgorithmException e) { - throw new AssertionError(e); - } catch (InvalidKeyException e) { - throw new AssertionError(e); - } - } -} diff --git a/libsignal/src/main/java/org/session/libsignal/libsignal/ratchet/MessageKeys.java b/libsignal/src/main/java/org/session/libsignal/libsignal/ratchet/MessageKeys.java deleted file mode 100644 index cbe2d8030d..0000000000 --- a/libsignal/src/main/java/org/session/libsignal/libsignal/ratchet/MessageKeys.java +++ /dev/null @@ -1,40 +0,0 @@ -/** - * Copyright (C) 2014-2016 Open Whisper Systems - * - * Licensed according to the LICENSE file in this repository. - */ -package org.session.libsignal.libsignal.ratchet; - -import javax.crypto.spec.IvParameterSpec; -import javax.crypto.spec.SecretKeySpec; - -public class MessageKeys { - - private final SecretKeySpec cipherKey; - private final SecretKeySpec macKey; - private final IvParameterSpec iv; - private final int counter; - - public MessageKeys(SecretKeySpec cipherKey, SecretKeySpec macKey, IvParameterSpec iv, int counter) { - this.cipherKey = cipherKey; - this.macKey = macKey; - this.iv = iv; - this.counter = counter; - } - - public SecretKeySpec getCipherKey() { - return cipherKey; - } - - public SecretKeySpec getMacKey() { - return macKey; - } - - public IvParameterSpec getIv() { - return iv; - } - - public int getCounter() { - return counter; - } -} diff --git a/libsignal/src/main/java/org/session/libsignal/libsignal/ratchet/RatchetingSession.java b/libsignal/src/main/java/org/session/libsignal/libsignal/ratchet/RatchetingSession.java deleted file mode 100644 index 8eaa1abd58..0000000000 --- a/libsignal/src/main/java/org/session/libsignal/libsignal/ratchet/RatchetingSession.java +++ /dev/null @@ -1,163 +0,0 @@ -/** - * Copyright (C) 2014-2016 Open Whisper Systems - * - * Licensed according to the LICENSE file in this repository. - */ -package org.session.libsignal.libsignal.ratchet; - -import org.session.libsignal.libsignal.InvalidKeyException; -import org.session.libsignal.libsignal.ecc.Curve; -import org.session.libsignal.libsignal.ecc.ECKeyPair; -import org.session.libsignal.libsignal.ecc.ECPublicKey; -import org.session.libsignal.libsignal.kdf.HKDF; -import org.session.libsignal.libsignal.kdf.HKDFv3; -import org.session.libsignal.libsignal.protocol.CiphertextMessage; -import org.session.libsignal.libsignal.ratchet.AliceSignalProtocolParameters; -import org.session.libsignal.libsignal.ratchet.BobSignalProtocolParameters; -import org.session.libsignal.libsignal.ratchet.SymmetricSignalProtocolParameters; -import org.session.libsignal.libsignal.state.SessionState; -import org.session.libsignal.libsignal.util.ByteUtil; -import org.session.libsignal.libsignal.util.Pair; -import org.session.libsignal.libsignal.util.guava.Optional; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.util.Arrays; - -public class RatchetingSession { - - public static void initializeSession(SessionState sessionState, SymmetricSignalProtocolParameters parameters) - throws InvalidKeyException - { - if (isAlice(parameters.getOurBaseKey().getPublicKey(), parameters.getTheirBaseKey())) { - AliceSignalProtocolParameters.Builder aliceParameters = AliceSignalProtocolParameters.newBuilder(); - - aliceParameters.setOurBaseKey(parameters.getOurBaseKey()) - .setOurIdentityKey(parameters.getOurIdentityKey()) - .setTheirRatchetKey(parameters.getTheirRatchetKey()) - .setTheirIdentityKey(parameters.getTheirIdentityKey()) - .setTheirSignedPreKey(parameters.getTheirBaseKey()) - .setTheirOneTimePreKey(Optional.absent()); - - RatchetingSession.initializeSession(sessionState, aliceParameters.create()); - } else { - BobSignalProtocolParameters.Builder bobParameters = BobSignalProtocolParameters.newBuilder(); - - bobParameters.setOurIdentityKey(parameters.getOurIdentityKey()) - .setOurRatchetKey(parameters.getOurRatchetKey()) - .setOurSignedPreKey(parameters.getOurBaseKey()) - .setOurOneTimePreKey(Optional.absent()) - .setTheirBaseKey(parameters.getTheirBaseKey()) - .setTheirIdentityKey(parameters.getTheirIdentityKey()); - - RatchetingSession.initializeSession(sessionState, bobParameters.create()); - } - } - - public static void initializeSession(SessionState sessionState, AliceSignalProtocolParameters parameters) - throws InvalidKeyException - { - try { - sessionState.setSessionVersion(CiphertextMessage.CURRENT_VERSION); - sessionState.setRemoteIdentityKey(parameters.getTheirIdentityKey()); - sessionState.setLocalIdentityKey(parameters.getOurIdentityKey().getPublicKey()); - - ECKeyPair sendingRatchetKey = Curve.generateKeyPair(); - ByteArrayOutputStream secrets = new ByteArrayOutputStream(); - - secrets.write(getDiscontinuityBytes()); - - secrets.write(Curve.calculateAgreement(parameters.getTheirSignedPreKey(), - parameters.getOurIdentityKey().getPrivateKey())); - secrets.write(Curve.calculateAgreement(parameters.getTheirIdentityKey().getPublicKey(), - parameters.getOurBaseKey().getPrivateKey())); - secrets.write(Curve.calculateAgreement(parameters.getTheirSignedPreKey(), - parameters.getOurBaseKey().getPrivateKey())); - - if (parameters.getTheirOneTimePreKey().isPresent()) { - secrets.write(Curve.calculateAgreement(parameters.getTheirOneTimePreKey().get(), - parameters.getOurBaseKey().getPrivateKey())); - } - - DerivedKeys derivedKeys = calculateDerivedKeys(secrets.toByteArray()); - Pair sendingChain = derivedKeys.getRootKey().createChain(parameters.getTheirRatchetKey(), sendingRatchetKey); - - sessionState.addReceiverChain(parameters.getTheirRatchetKey(), derivedKeys.getChainKey()); - sessionState.setSenderChain(sendingRatchetKey, sendingChain.second()); - sessionState.setRootKey(sendingChain.first()); - } catch (IOException e) { - throw new AssertionError(e); - } - } - - public static void initializeSession(SessionState sessionState, BobSignalProtocolParameters parameters) - throws InvalidKeyException - { - - try { - sessionState.setSessionVersion(CiphertextMessage.CURRENT_VERSION); - sessionState.setRemoteIdentityKey(parameters.getTheirIdentityKey()); - sessionState.setLocalIdentityKey(parameters.getOurIdentityKey().getPublicKey()); - - ByteArrayOutputStream secrets = new ByteArrayOutputStream(); - - secrets.write(getDiscontinuityBytes()); - - secrets.write(Curve.calculateAgreement(parameters.getTheirIdentityKey().getPublicKey(), - parameters.getOurSignedPreKey().getPrivateKey())); - secrets.write(Curve.calculateAgreement(parameters.getTheirBaseKey(), - parameters.getOurIdentityKey().getPrivateKey())); - secrets.write(Curve.calculateAgreement(parameters.getTheirBaseKey(), - parameters.getOurSignedPreKey().getPrivateKey())); - - if (parameters.getOurOneTimePreKey().isPresent()) { - secrets.write(Curve.calculateAgreement(parameters.getTheirBaseKey(), - parameters.getOurOneTimePreKey().get().getPrivateKey())); - } - - DerivedKeys derivedKeys = calculateDerivedKeys(secrets.toByteArray()); - - sessionState.setSenderChain(parameters.getOurRatchetKey(), derivedKeys.getChainKey()); - sessionState.setRootKey(derivedKeys.getRootKey()); - } catch (IOException e) { - throw new AssertionError(e); - } - } - - private static byte[] getDiscontinuityBytes() { - byte[] discontinuity = new byte[32]; - Arrays.fill(discontinuity, (byte) 0xFF); - return discontinuity; - } - - private static DerivedKeys calculateDerivedKeys(byte[] masterSecret) { - HKDF kdf = new HKDFv3(); - byte[] derivedSecretBytes = kdf.deriveSecrets(masterSecret, "WhisperText".getBytes(), 64); - byte[][] derivedSecrets = ByteUtil.split(derivedSecretBytes, 32, 32); - - return new DerivedKeys(new RootKey(kdf, derivedSecrets[0]), - new ChainKey(kdf, derivedSecrets[1], 0)); - } - - private static boolean isAlice(ECPublicKey ourKey, ECPublicKey theirKey) { - return ourKey.compareTo(theirKey) < 0; - } - - private static class DerivedKeys { - private final RootKey rootKey; - private final ChainKey chainKey; - - private DerivedKeys(RootKey rootKey, ChainKey chainKey) { - this.rootKey = rootKey; - this.chainKey = chainKey; - } - - public RootKey getRootKey() { - return rootKey; - } - - public ChainKey getChainKey() { - return chainKey; - } - } -} diff --git a/libsignal/src/main/java/org/session/libsignal/libsignal/ratchet/RootKey.java b/libsignal/src/main/java/org/session/libsignal/libsignal/ratchet/RootKey.java deleted file mode 100644 index cc88605cb1..0000000000 --- a/libsignal/src/main/java/org/session/libsignal/libsignal/ratchet/RootKey.java +++ /dev/null @@ -1,44 +0,0 @@ -/** - * Copyright (C) 2014-2016 Open Whisper Systems - * - * Licensed according to the LICENSE file in this repository. - */ -package org.session.libsignal.libsignal.ratchet; - -import org.session.libsignal.libsignal.InvalidKeyException; -import org.session.libsignal.libsignal.ecc.Curve; -import org.session.libsignal.libsignal.ecc.ECKeyPair; -import org.session.libsignal.libsignal.ecc.ECPublicKey; -import org.session.libsignal.libsignal.kdf.DerivedRootSecrets; -import org.session.libsignal.libsignal.kdf.HKDF; -import org.session.libsignal.libsignal.ratchet.ChainKey; -import org.session.libsignal.libsignal.util.ByteUtil; -import org.session.libsignal.libsignal.util.Pair; - -public class RootKey { - - private final HKDF kdf; - private final byte[] key; - - public RootKey(HKDF kdf, byte[] key) { - this.kdf = kdf; - this.key = key; - } - - public byte[] getKeyBytes() { - return key; - } - - public Pair createChain(ECPublicKey theirRatchetKey, ECKeyPair ourRatchetKey) - throws InvalidKeyException - { - byte[] sharedSecret = Curve.calculateAgreement(theirRatchetKey, ourRatchetKey.getPrivateKey()); - byte[] derivedSecretBytes = kdf.deriveSecrets(sharedSecret, key, "WhisperRatchet".getBytes(), DerivedRootSecrets.SIZE); - DerivedRootSecrets derivedSecrets = new DerivedRootSecrets(derivedSecretBytes); - - RootKey newRootKey = new RootKey(kdf, derivedSecrets.getRootKey()); - ChainKey newChainKey = new ChainKey(kdf, derivedSecrets.getChainKey(), 0); - - return new Pair(newRootKey, newChainKey); - } -} diff --git a/libsignal/src/main/java/org/session/libsignal/libsignal/ratchet/SymmetricSignalProtocolParameters.java b/libsignal/src/main/java/org/session/libsignal/libsignal/ratchet/SymmetricSignalProtocolParameters.java deleted file mode 100644 index 11397af1a7..0000000000 --- a/libsignal/src/main/java/org/session/libsignal/libsignal/ratchet/SymmetricSignalProtocolParameters.java +++ /dev/null @@ -1,113 +0,0 @@ -/** - * Copyright (C) 2014-2016 Open Whisper Systems - * - * Licensed according to the LICENSE file in this repository. - */ -package org.session.libsignal.libsignal.ratchet; - -import org.session.libsignal.libsignal.IdentityKey; -import org.session.libsignal.libsignal.IdentityKeyPair; -import org.session.libsignal.libsignal.ecc.ECKeyPair; -import org.session.libsignal.libsignal.ecc.ECPublicKey; - -public class SymmetricSignalProtocolParameters { - - private final ECKeyPair ourBaseKey; - private final ECKeyPair ourRatchetKey; - private final IdentityKeyPair ourIdentityKey; - - private final ECPublicKey theirBaseKey; - private final ECPublicKey theirRatchetKey; - private final IdentityKey theirIdentityKey; - - SymmetricSignalProtocolParameters(ECKeyPair ourBaseKey, ECKeyPair ourRatchetKey, - IdentityKeyPair ourIdentityKey, ECPublicKey theirBaseKey, - ECPublicKey theirRatchetKey, IdentityKey theirIdentityKey) - { - this.ourBaseKey = ourBaseKey; - this.ourRatchetKey = ourRatchetKey; - this.ourIdentityKey = ourIdentityKey; - this.theirBaseKey = theirBaseKey; - this.theirRatchetKey = theirRatchetKey; - this.theirIdentityKey = theirIdentityKey; - - if (ourBaseKey == null || ourRatchetKey == null || ourIdentityKey == null || - theirBaseKey == null || theirRatchetKey == null || theirIdentityKey == null) - { - throw new IllegalArgumentException("Null values!"); - } - } - - public ECKeyPair getOurBaseKey() { - return ourBaseKey; - } - - public ECKeyPair getOurRatchetKey() { - return ourRatchetKey; - } - - public IdentityKeyPair getOurIdentityKey() { - return ourIdentityKey; - } - - public ECPublicKey getTheirBaseKey() { - return theirBaseKey; - } - - public ECPublicKey getTheirRatchetKey() { - return theirRatchetKey; - } - - public IdentityKey getTheirIdentityKey() { - return theirIdentityKey; - } - - public static Builder newBuilder() { - return new Builder(); - } - - public static class Builder { - private ECKeyPair ourBaseKey; - private ECKeyPair ourRatchetKey; - private IdentityKeyPair ourIdentityKey; - - private ECPublicKey theirBaseKey; - private ECPublicKey theirRatchetKey; - private IdentityKey theirIdentityKey; - - public Builder setOurBaseKey(ECKeyPair ourBaseKey) { - this.ourBaseKey = ourBaseKey; - return this; - } - - public Builder setOurRatchetKey(ECKeyPair ourRatchetKey) { - this.ourRatchetKey = ourRatchetKey; - return this; - } - - public Builder setOurIdentityKey(IdentityKeyPair ourIdentityKey) { - this.ourIdentityKey = ourIdentityKey; - return this; - } - - public Builder setTheirBaseKey(ECPublicKey theirBaseKey) { - this.theirBaseKey = theirBaseKey; - return this; - } - - public Builder setTheirRatchetKey(ECPublicKey theirRatchetKey) { - this.theirRatchetKey = theirRatchetKey; - return this; - } - - public Builder setTheirIdentityKey(IdentityKey theirIdentityKey) { - this.theirIdentityKey = theirIdentityKey; - return this; - } - - public SymmetricSignalProtocolParameters create() { - return new SymmetricSignalProtocolParameters(ourBaseKey, ourRatchetKey, ourIdentityKey, - theirBaseKey, theirRatchetKey, theirIdentityKey); - } - } -} diff --git a/libsignal/src/main/java/org/session/libsignal/libsignal/state/IdentityKeyStore.java b/libsignal/src/main/java/org/session/libsignal/libsignal/state/IdentityKeyStore.java index 2444842ef2..389cb8be6f 100644 --- a/libsignal/src/main/java/org/session/libsignal/libsignal/state/IdentityKeyStore.java +++ b/libsignal/src/main/java/org/session/libsignal/libsignal/state/IdentityKeyStore.java @@ -27,56 +27,4 @@ public interface IdentityKeyStore { */ public IdentityKeyPair getIdentityKeyPair(); - /** - * Return the local client's registration ID. - *

- * Clients should maintain a registration ID, a random number - * between 1 and 16380 that's generated once at install time. - * - * @return the local client's registration ID. - */ - public int getLocalRegistrationId(); - - /** - * Save a remote client's identity key - *

- * Store a remote client's identity key as trusted. - * - * @param address The address of the remote client. - * @param identityKey The remote client's identity key. - * @return True if the identity key replaces a previous identity, false if not - */ - public boolean saveIdentity(SignalProtocolAddress address, IdentityKey identityKey); - - - /** - * Verify a remote client's identity key. - *

- * Determine whether a remote client's identity is trusted. Convention is - * that the Signal Protocol is 'trust on first use.' This means that - * an identity key is considered 'trusted' if there is no entry for the recipient - * in the local store, or if it matches the saved key for a recipient in the local - * store. Only if it mismatches an entry in the local store is it considered - * 'untrusted.' - * - * Clients may wish to make a distinction as to how keys are trusted based on the - * direction of travel. For instance, clients may wish to accept all 'incoming' identity - * key changes, while only blocking identity key changes when sending a message. - * - * @param address The address of the remote client. - * @param identityKey The identity key to verify. - * @param direction The direction (sending or receiving) this identity is being used for. - * @return true if trusted, false if untrusted. - */ - public boolean isTrustedIdentity(SignalProtocolAddress address, IdentityKey identityKey, Direction direction); - - - /** - * Return the saved public identity key for a remote client - * - * @param address The address of the remote client - * @return The public identity key, or null if absent - */ - public IdentityKey getIdentity(SignalProtocolAddress address); - } diff --git a/libsignal/src/main/java/org/session/libsignal/libsignal/state/PreKeyBundle.java b/libsignal/src/main/java/org/session/libsignal/libsignal/state/PreKeyBundle.java deleted file mode 100644 index bc12d58d53..0000000000 --- a/libsignal/src/main/java/org/session/libsignal/libsignal/state/PreKeyBundle.java +++ /dev/null @@ -1,101 +0,0 @@ -/** - * Copyright (C) 2014-2016 Open Whisper Systems - * - * Licensed according to the LICENSE file in this repository. - */ -package org.session.libsignal.libsignal.state; - -import org.session.libsignal.libsignal.IdentityKey; -import org.session.libsignal.libsignal.ecc.ECPublicKey; - -/** - * A class that contains a remote PreKey and collection - * of associated items. - * - * @author Moxie Marlinspike - */ -public class PreKeyBundle { - - private int registrationId; - - private int deviceId; - - private int preKeyId; - private ECPublicKey preKeyPublic; - - private int signedPreKeyId; - private ECPublicKey signedPreKeyPublic; - private byte[] signedPreKeySignature; - - private IdentityKey identityKey; - - public PreKeyBundle(int registrationId, int deviceId, int preKeyId, ECPublicKey preKeyPublic, - int signedPreKeyId, ECPublicKey signedPreKeyPublic, byte[] signedPreKeySignature, - IdentityKey identityKey) - { - this.registrationId = registrationId; - this.deviceId = deviceId; - this.preKeyId = preKeyId; - this.preKeyPublic = preKeyPublic; - this.signedPreKeyId = signedPreKeyId; - this.signedPreKeyPublic = signedPreKeyPublic; - this.signedPreKeySignature = signedPreKeySignature; - this.identityKey = identityKey; - } - - /** - * @return the device ID this PreKey belongs to. - */ - public int getDeviceId() { - return deviceId; - } - - /** - * @return the unique key ID for this PreKey. - */ - public int getPreKeyId() { - return preKeyId; - } - - /** - * @return the public key for this PreKey. - */ - public ECPublicKey getPreKey() { - return preKeyPublic; - } - - /** - * @return the unique key ID for this signed prekey. - */ - public int getSignedPreKeyId() { - return signedPreKeyId; - } - - /** - * @return the signed prekey for this PreKeyBundle. - */ - public ECPublicKey getSignedPreKey() { - return signedPreKeyPublic; - } - - /** - * @return the signature over the signed prekey. - */ - public byte[] getSignedPreKeySignature() { - return signedPreKeySignature; - } - - /** - * @return the {@link IdentityKey} of this PreKeys owner. - */ - public IdentityKey getIdentityKey() { - return identityKey; - } - - /** - * @return the registration ID associated with this PreKey. - */ - public int getRegistrationId() { - return registrationId; - } -} diff --git a/libsignal/src/main/java/org/session/libsignal/libsignal/state/PreKeyRecord.java b/libsignal/src/main/java/org/session/libsignal/libsignal/state/PreKeyRecord.java deleted file mode 100644 index c5706f9487..0000000000 --- a/libsignal/src/main/java/org/session/libsignal/libsignal/state/PreKeyRecord.java +++ /dev/null @@ -1,56 +0,0 @@ -/** - * Copyright (C) 2014-2016 Open Whisper Systems - * - * Licensed according to the LICENSE file in this repository. - */ -package org.session.libsignal.libsignal.state; - -import com.google.protobuf.ByteString; - -import org.session.libsignal.libsignal.InvalidKeyException; -import org.session.libsignal.libsignal.ecc.Curve; -import org.session.libsignal.libsignal.ecc.ECKeyPair; -import org.session.libsignal.libsignal.ecc.ECPrivateKey; -import org.session.libsignal.libsignal.ecc.ECPublicKey; - -import java.io.IOException; - -import static org.session.libsignal.libsignal.state.StorageProtos.PreKeyRecordStructure; - -public class PreKeyRecord { - - private PreKeyRecordStructure structure; - - public PreKeyRecord(int id, ECKeyPair keyPair) { - this.structure = PreKeyRecordStructure.newBuilder() - .setId(id) - .setPublicKey(ByteString.copyFrom(keyPair.getPublicKey() - .serialize())) - .setPrivateKey(ByteString.copyFrom(keyPair.getPrivateKey() - .serialize())) - .build(); - } - - public PreKeyRecord(byte[] serialized) throws IOException { - this.structure = PreKeyRecordStructure.parseFrom(serialized); - } - - public int getId() { - return this.structure.getId(); - } - - public ECKeyPair getKeyPair() { - try { - ECPublicKey publicKey = Curve.decodePoint(this.structure.getPublicKey().toByteArray(), 0); - ECPrivateKey privateKey = Curve.decodePrivatePoint(this.structure.getPrivateKey().toByteArray()); - - return new ECKeyPair(publicKey, privateKey); - } catch (InvalidKeyException e) { - throw new AssertionError(e); - } - } - - public byte[] serialize() { - return this.structure.toByteArray(); - } -} diff --git a/libsignal/src/main/java/org/session/libsignal/libsignal/state/PreKeyStore.java b/libsignal/src/main/java/org/session/libsignal/libsignal/state/PreKeyStore.java deleted file mode 100644 index e7969571da..0000000000 --- a/libsignal/src/main/java/org/session/libsignal/libsignal/state/PreKeyStore.java +++ /dev/null @@ -1,48 +0,0 @@ -/** - * Copyright (C) 2014-2016 Open Whisper Systems - * - * Licensed according to the LICENSE file in this repository. - */ -package org.session.libsignal.libsignal.state; - -import org.session.libsignal.libsignal.InvalidKeyIdException; -import org.session.libsignal.libsignal.state.PreKeyRecord; - -/** - * An interface describing the local storage of {@link PreKeyRecord}s. - * - * @author Moxie Marlinspike - */ -public interface PreKeyStore { - - /** - * Load a local PreKeyRecord. - * - * @param preKeyId the ID of the local PreKeyRecord. - * @return the corresponding PreKeyRecord. - * @throws InvalidKeyIdException when there is no corresponding PreKeyRecord. - */ - public PreKeyRecord loadPreKey(int preKeyId) throws InvalidKeyIdException; - - /** - * Store a local PreKeyRecord. - * - * @param preKeyId the ID of the PreKeyRecord to store. - * @param record the PreKeyRecord. - */ - public void storePreKey(int preKeyId, PreKeyRecord record); - - /** - * @param preKeyId A PreKeyRecord ID. - * @return true if the store has a record for the preKeyId, otherwise false. - */ - public boolean containsPreKey(int preKeyId); - - /** - * Delete a PreKeyRecord from local storage. - * - * @param preKeyId The ID of the PreKeyRecord to remove. - */ - public void removePreKey(int preKeyId); - -} diff --git a/libsignal/src/main/java/org/session/libsignal/libsignal/state/SessionRecord.java b/libsignal/src/main/java/org/session/libsignal/libsignal/state/SessionRecord.java deleted file mode 100644 index df1d0ff25c..0000000000 --- a/libsignal/src/main/java/org/session/libsignal/libsignal/state/SessionRecord.java +++ /dev/null @@ -1,125 +0,0 @@ -/** - * Copyright (C) 2014-2016 Open Whisper Systems - * - * Licensed according to the LICENSE file in this repository. - */ -package org.session.libsignal.libsignal.state; - -import java.io.IOException; -import java.util.Arrays; -import java.util.LinkedList; -import java.util.List; - -import static org.session.libsignal.libsignal.state.StorageProtos.RecordStructure; -import static org.session.libsignal.libsignal.state.StorageProtos.SessionStructure; - -/** - * A SessionRecord encapsulates the state of an ongoing session. - * - * @author Moxie Marlinspike - */ -public class SessionRecord { - - private static final int ARCHIVED_STATES_MAX_LENGTH = 40; - - private SessionState sessionState = new SessionState(); - private LinkedList previousStates = new LinkedList(); - private boolean fresh = false; - - public SessionRecord() { - this.fresh = true; - } - - public SessionRecord(SessionState sessionState) { - this.sessionState = sessionState; - this.fresh = false; - } - - public SessionRecord(byte[] serialized) throws IOException { - RecordStructure record = RecordStructure.parseFrom(serialized); - this.sessionState = new SessionState(record.getCurrentSession()); - this.fresh = false; - - for (SessionStructure previousStructure : record.getPreviousSessionsList()) { - previousStates.add(new SessionState(previousStructure)); - } - } - - public boolean hasSessionState(int version, byte[] aliceBaseKey) { - if (sessionState.getSessionVersion() == version && - Arrays.equals(aliceBaseKey, sessionState.getAliceBaseKey())) - { - return true; - } - - for (SessionState state : previousStates) { - if (state.getSessionVersion() == version && - Arrays.equals(aliceBaseKey, state.getAliceBaseKey())) - { - return true; - } - } - - return false; - } - - public SessionState getSessionState() { - return sessionState; - } - - /** - * @return the list of all currently maintained "previous" session states. - */ - public List getPreviousSessionStates() { - return previousStates; - } - - public void removePreviousSessionStates() { - previousStates.clear(); - } - - public boolean isFresh() { - return fresh; - } - - /** - * Move the current {@link SessionState} into the list of "previous" session states, - * and replace the current {@link org.session.libsignal.libsignal.state.SessionState} - * with a fresh reset instance. - */ - public void archiveCurrentState() { - promoteState(new SessionState()); - } - - public void promoteState(SessionState promotedState) { - this.previousStates.addFirst(sessionState); - this.sessionState = promotedState; - - if (previousStates.size() > ARCHIVED_STATES_MAX_LENGTH) { - previousStates.removeLast(); - } - } - - public void setState(SessionState sessionState) { - this.sessionState = sessionState; - } - - /** - * @return a serialized version of the current SessionRecord. - */ - public byte[] serialize() { - List previousStructures = new LinkedList(); - - for (SessionState previousState : previousStates) { - previousStructures.add(previousState.getStructure()); - } - - RecordStructure record = RecordStructure.newBuilder() - .setCurrentSession(sessionState.getStructure()) - .addAllPreviousSessions(previousStructures) - .build(); - - return record.toByteArray(); - } - -} diff --git a/libsignal/src/main/java/org/session/libsignal/libsignal/state/SessionState.java b/libsignal/src/main/java/org/session/libsignal/libsignal/state/SessionState.java deleted file mode 100644 index a7a9c39388..0000000000 --- a/libsignal/src/main/java/org/session/libsignal/libsignal/state/SessionState.java +++ /dev/null @@ -1,503 +0,0 @@ -/** - * Copyright (C) 2014-2016 Open Whisper Systems - * - * Licensed according to the LICENSE file in this repository. - */ - -package org.session.libsignal.libsignal.state; - - -import com.google.protobuf.ByteString; - -import org.session.libsignal.libsignal.IdentityKey; -import org.session.libsignal.libsignal.IdentityKeyPair; -import org.session.libsignal.libsignal.InvalidKeyException; -import org.session.libsignal.libsignal.ecc.Curve; -import org.session.libsignal.libsignal.ecc.ECKeyPair; -import org.session.libsignal.libsignal.ecc.ECPrivateKey; -import org.session.libsignal.libsignal.ecc.ECPublicKey; -import org.session.libsignal.libsignal.kdf.HKDF; -import org.session.libsignal.utilities.logging.Log; -import org.session.libsignal.libsignal.ratchet.ChainKey; -import org.session.libsignal.libsignal.ratchet.MessageKeys; -import org.session.libsignal.libsignal.ratchet.RootKey; -import org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain; -import org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.PendingKeyExchange; -import org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.PendingPreKey; -import org.session.libsignal.libsignal.util.Pair; -import org.session.libsignal.libsignal.util.guava.Optional; - -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; - -import javax.crypto.spec.IvParameterSpec; -import javax.crypto.spec.SecretKeySpec; - -import static org.session.libsignal.libsignal.state.StorageProtos.SessionStructure; - -public class SessionState { - - private static final int MAX_MESSAGE_KEYS = 2000; - - private SessionStructure sessionStructure; - - public SessionState() { - this.sessionStructure = SessionStructure.newBuilder().build(); - } - - public SessionState(SessionStructure sessionStructure) { - this.sessionStructure = sessionStructure; - } - - public SessionState(SessionState copy) { - this.sessionStructure = copy.sessionStructure.toBuilder().build(); - } - - public SessionStructure getStructure() { - return sessionStructure; - } - - public byte[] getAliceBaseKey() { - return this.sessionStructure.getAliceBaseKey().toByteArray(); - } - - public void setAliceBaseKey(byte[] aliceBaseKey) { - this.sessionStructure = this.sessionStructure.toBuilder() - .setAliceBaseKey(ByteString.copyFrom(aliceBaseKey)) - .build(); - } - - public void setSessionVersion(int version) { - this.sessionStructure = this.sessionStructure.toBuilder() - .setSessionVersion(version) - .build(); - } - - public int getSessionVersion() { - int sessionVersion = this.sessionStructure.getSessionVersion(); - - if (sessionVersion == 0) return 2; - else return sessionVersion; - } - - public void setRemoteIdentityKey(IdentityKey identityKey) { - this.sessionStructure = this.sessionStructure.toBuilder() - .setRemoteIdentityPublic(ByteString.copyFrom(identityKey.serialize())) - .build(); - } - - public void setLocalIdentityKey(IdentityKey identityKey) { - this.sessionStructure = this.sessionStructure.toBuilder() - .setLocalIdentityPublic(ByteString.copyFrom(identityKey.serialize())) - .build(); - } - - public IdentityKey getRemoteIdentityKey() { - try { - if (!this.sessionStructure.hasRemoteIdentityPublic()) { - return null; - } - - return new IdentityKey(this.sessionStructure.getRemoteIdentityPublic().toByteArray(), 0); - } catch (InvalidKeyException e) { - Log.w("SessionRecordV2", e); - return null; - } - } - - public IdentityKey getLocalIdentityKey() { - try { - return new IdentityKey(this.sessionStructure.getLocalIdentityPublic().toByteArray(), 0); - } catch (InvalidKeyException e) { - throw new AssertionError(e); - } - } - - public int getPreviousCounter() { - return sessionStructure.getPreviousCounter(); - } - - public void setPreviousCounter(int previousCounter) { - this.sessionStructure = this.sessionStructure.toBuilder() - .setPreviousCounter(previousCounter) - .build(); - } - - public RootKey getRootKey() { - return new RootKey(HKDF.createFor(getSessionVersion()), - this.sessionStructure.getRootKey().toByteArray()); - } - - public void setRootKey(RootKey rootKey) { - this.sessionStructure = this.sessionStructure.toBuilder() - .setRootKey(ByteString.copyFrom(rootKey.getKeyBytes())) - .build(); - } - - public ECPublicKey getSenderRatchetKey() { - try { - return Curve.decodePoint(sessionStructure.getSenderChain().getSenderRatchetKey().toByteArray(), 0); - } catch (InvalidKeyException e) { - throw new AssertionError(e); - } - } - - public ECKeyPair getSenderRatchetKeyPair() { - ECPublicKey publicKey = getSenderRatchetKey(); - ECPrivateKey privateKey = Curve.decodePrivatePoint(sessionStructure.getSenderChain() - .getSenderRatchetKeyPrivate() - .toByteArray()); - - return new ECKeyPair(publicKey, privateKey); - } - - public boolean hasReceiverChain(ECPublicKey senderEphemeral) { - return getReceiverChain(senderEphemeral) != null; - } - - public boolean hasSenderChain() { - return sessionStructure.hasSenderChain(); - } - - private Pair getReceiverChain(ECPublicKey senderEphemeral) { - List receiverChains = sessionStructure.getReceiverChainsList(); - int index = 0; - - for (Chain receiverChain : receiverChains) { - try { - ECPublicKey chainSenderRatchetKey = Curve.decodePoint(receiverChain.getSenderRatchetKey().toByteArray(), 0); - - if (chainSenderRatchetKey.equals(senderEphemeral)) { - return new Pair(receiverChain,index); - } - } catch (InvalidKeyException e) { - Log.w("SessionRecordV2", e); - } - - index++; - } - - return null; - } - - public ChainKey getReceiverChainKey(ECPublicKey senderEphemeral) { - Pair receiverChainAndIndex = getReceiverChain(senderEphemeral); - Chain receiverChain = receiverChainAndIndex.first(); - - if (receiverChain == null) { - return null; - } else { - return new ChainKey(HKDF.createFor(getSessionVersion()), - receiverChain.getChainKey().getKey().toByteArray(), - receiverChain.getChainKey().getIndex()); - } - } - - public void addReceiverChain(ECPublicKey senderRatchetKey, ChainKey chainKey) { - Chain.ChainKey chainKeyStructure = Chain.ChainKey.newBuilder() - .setKey(ByteString.copyFrom(chainKey.getKey())) - .setIndex(chainKey.getIndex()) - .build(); - - Chain chain = Chain.newBuilder() - .setChainKey(chainKeyStructure) - .setSenderRatchetKey(ByteString.copyFrom(senderRatchetKey.serialize())) - .build(); - - this.sessionStructure = this.sessionStructure.toBuilder().addReceiverChains(chain).build(); - - if (this.sessionStructure.getReceiverChainsList().size() > 5) { - this.sessionStructure = this.sessionStructure.toBuilder() - .removeReceiverChains(0) - .build(); - } - } - - public void setSenderChain(ECKeyPair senderRatchetKeyPair, ChainKey chainKey) { - Chain.ChainKey chainKeyStructure = Chain.ChainKey.newBuilder() - .setKey(ByteString.copyFrom(chainKey.getKey())) - .setIndex(chainKey.getIndex()) - .build(); - - Chain senderChain = Chain.newBuilder() - .setSenderRatchetKey(ByteString.copyFrom(senderRatchetKeyPair.getPublicKey().serialize())) - .setSenderRatchetKeyPrivate(ByteString.copyFrom(senderRatchetKeyPair.getPrivateKey().serialize())) - .setChainKey(chainKeyStructure) - .build(); - - this.sessionStructure = this.sessionStructure.toBuilder().setSenderChain(senderChain).build(); - } - - public ChainKey getSenderChainKey() { - Chain.ChainKey chainKeyStructure = sessionStructure.getSenderChain().getChainKey(); - return new ChainKey(HKDF.createFor(getSessionVersion()), - chainKeyStructure.getKey().toByteArray(), chainKeyStructure.getIndex()); - } - - - public void setSenderChainKey(ChainKey nextChainKey) { - Chain.ChainKey chainKey = Chain.ChainKey.newBuilder() - .setKey(ByteString.copyFrom(nextChainKey.getKey())) - .setIndex(nextChainKey.getIndex()) - .build(); - - Chain chain = sessionStructure.getSenderChain().toBuilder() - .setChainKey(chainKey).build(); - - this.sessionStructure = this.sessionStructure.toBuilder().setSenderChain(chain).build(); - } - - public boolean hasMessageKeys(ECPublicKey senderEphemeral, int counter) { - Pair chainAndIndex = getReceiverChain(senderEphemeral); - Chain chain = chainAndIndex.first(); - - if (chain == null) { - return false; - } - - List messageKeyList = chain.getMessageKeysList(); - - for (Chain.MessageKey messageKey : messageKeyList) { - if (messageKey.getIndex() == counter) { - return true; - } - } - - return false; - } - - public MessageKeys removeMessageKeys(ECPublicKey senderEphemeral, int counter) { - Pair chainAndIndex = getReceiverChain(senderEphemeral); - Chain chain = chainAndIndex.first(); - - if (chain == null) { - return null; - } - - List messageKeyList = new LinkedList(chain.getMessageKeysList()); - Iterator messageKeyIterator = messageKeyList.iterator(); - MessageKeys result = null; - - while (messageKeyIterator.hasNext()) { - Chain.MessageKey messageKey = messageKeyIterator.next(); - - if (messageKey.getIndex() == counter) { - result = new MessageKeys(new SecretKeySpec(messageKey.getCipherKey().toByteArray(), "AES"), - new SecretKeySpec(messageKey.getMacKey().toByteArray(), "HmacSHA256"), - new IvParameterSpec(messageKey.getIv().toByteArray()), - messageKey.getIndex()); - - messageKeyIterator.remove(); - break; - } - } - - Chain updatedChain = chain.toBuilder().clearMessageKeys() - .addAllMessageKeys(messageKeyList) - .build(); - - this.sessionStructure = this.sessionStructure.toBuilder() - .setReceiverChains(chainAndIndex.second(), updatedChain) - .build(); - - return result; - } - - public void setMessageKeys(ECPublicKey senderEphemeral, MessageKeys messageKeys) { - Pair chainAndIndex = getReceiverChain(senderEphemeral); - Chain chain = chainAndIndex.first(); - Chain.MessageKey messageKeyStructure = Chain.MessageKey.newBuilder() - .setCipherKey(ByteString.copyFrom(messageKeys.getCipherKey().getEncoded())) - .setMacKey(ByteString.copyFrom(messageKeys.getMacKey().getEncoded())) - .setIndex(messageKeys.getCounter()) - .setIv(ByteString.copyFrom(messageKeys.getIv().getIV())) - .build(); - - Chain.Builder updatedChain = chain.toBuilder().addMessageKeys(messageKeyStructure); - - if (updatedChain.getMessageKeysCount() > MAX_MESSAGE_KEYS) { - updatedChain.removeMessageKeys(0); - } - - this.sessionStructure = this.sessionStructure.toBuilder() - .setReceiverChains(chainAndIndex.second(), - updatedChain.build()) - .build(); - } - - public void setReceiverChainKey(ECPublicKey senderEphemeral, ChainKey chainKey) { - Pair chainAndIndex = getReceiverChain(senderEphemeral); - Chain chain = chainAndIndex.first(); - - Chain.ChainKey chainKeyStructure = Chain.ChainKey.newBuilder() - .setKey(ByteString.copyFrom(chainKey.getKey())) - .setIndex(chainKey.getIndex()) - .build(); - - Chain updatedChain = chain.toBuilder().setChainKey(chainKeyStructure).build(); - - this.sessionStructure = this.sessionStructure.toBuilder() - .setReceiverChains(chainAndIndex.second(), updatedChain) - .build(); - } - - public void setPendingKeyExchange(int sequence, - ECKeyPair ourBaseKey, - ECKeyPair ourRatchetKey, - IdentityKeyPair ourIdentityKey) - { - PendingKeyExchange structure = - PendingKeyExchange.newBuilder() - .setSequence(sequence) - .setLocalBaseKey(ByteString.copyFrom(ourBaseKey.getPublicKey().serialize())) - .setLocalBaseKeyPrivate(ByteString.copyFrom(ourBaseKey.getPrivateKey().serialize())) - .setLocalRatchetKey(ByteString.copyFrom(ourRatchetKey.getPublicKey().serialize())) - .setLocalRatchetKeyPrivate(ByteString.copyFrom(ourRatchetKey.getPrivateKey().serialize())) - .setLocalIdentityKey(ByteString.copyFrom(ourIdentityKey.getPublicKey().serialize())) - .setLocalIdentityKeyPrivate(ByteString.copyFrom(ourIdentityKey.getPrivateKey().serialize())) - .build(); - - this.sessionStructure = this.sessionStructure.toBuilder() - .setPendingKeyExchange(structure) - .build(); - } - - public int getPendingKeyExchangeSequence() { - return sessionStructure.getPendingKeyExchange().getSequence(); - } - - public ECKeyPair getPendingKeyExchangeBaseKey() throws InvalidKeyException { - ECPublicKey publicKey = Curve.decodePoint(sessionStructure.getPendingKeyExchange() - .getLocalBaseKey().toByteArray(), 0); - - ECPrivateKey privateKey = Curve.decodePrivatePoint(sessionStructure.getPendingKeyExchange() - .getLocalBaseKeyPrivate() - .toByteArray()); - - return new ECKeyPair(publicKey, privateKey); - } - - public ECKeyPair getPendingKeyExchangeRatchetKey() throws InvalidKeyException { - ECPublicKey publicKey = Curve.decodePoint(sessionStructure.getPendingKeyExchange() - .getLocalRatchetKey().toByteArray(), 0); - - ECPrivateKey privateKey = Curve.decodePrivatePoint(sessionStructure.getPendingKeyExchange() - .getLocalRatchetKeyPrivate() - .toByteArray()); - - return new ECKeyPair(publicKey, privateKey); - } - - public IdentityKeyPair getPendingKeyExchangeIdentityKey() throws InvalidKeyException { - IdentityKey publicKey = new IdentityKey(sessionStructure.getPendingKeyExchange() - .getLocalIdentityKey().toByteArray(), 0); - - ECPrivateKey privateKey = Curve.decodePrivatePoint(sessionStructure.getPendingKeyExchange() - .getLocalIdentityKeyPrivate() - .toByteArray()); - - return new IdentityKeyPair(publicKey, privateKey); - } - - public boolean hasPendingKeyExchange() { - return sessionStructure.hasPendingKeyExchange(); - } - - public void setUnacknowledgedPreKeyMessage(Optional preKeyId, int signedPreKeyId, ECPublicKey baseKey) { - PendingPreKey.Builder pending = PendingPreKey.newBuilder() - .setSignedPreKeyId(signedPreKeyId) - .setBaseKey(ByteString.copyFrom(baseKey.serialize())); - - if (preKeyId.isPresent()) { - pending.setPreKeyId(preKeyId.get()); - } - - this.sessionStructure = this.sessionStructure.toBuilder() - .setPendingPreKey(pending.build()) - .build(); - } - - public boolean hasUnacknowledgedPreKeyMessage() { - return this.sessionStructure.hasPendingPreKey(); - } - - public UnacknowledgedPreKeyMessageItems getUnacknowledgedPreKeyMessageItems() { - try { - Optional preKeyId; - - if (sessionStructure.getPendingPreKey().hasPreKeyId()) { - preKeyId = Optional.of(sessionStructure.getPendingPreKey().getPreKeyId()); - } else { - preKeyId = Optional.absent(); - } - - return - new UnacknowledgedPreKeyMessageItems(preKeyId, - sessionStructure.getPendingPreKey().getSignedPreKeyId(), - Curve.decodePoint(sessionStructure.getPendingPreKey() - .getBaseKey() - .toByteArray(), 0)); - } catch (InvalidKeyException e) { - throw new AssertionError(e); - } - } - - public void clearUnacknowledgedPreKeyMessage() { - this.sessionStructure = this.sessionStructure.toBuilder() - .clearPendingPreKey() - .build(); - } - - public void setRemoteRegistrationId(int registrationId) { - this.sessionStructure = this.sessionStructure.toBuilder() - .setRemoteRegistrationId(registrationId) - .build(); - } - - public int getRemoteRegistrationId() { - return this.sessionStructure.getRemoteRegistrationId(); - } - - public void setLocalRegistrationId(int registrationId) { - this.sessionStructure = this.sessionStructure.toBuilder() - .setLocalRegistrationId(registrationId) - .build(); - } - - public int getLocalRegistrationId() { - return this.sessionStructure.getLocalRegistrationId(); - } - - public byte[] serialize() { - return sessionStructure.toByteArray(); - } - - public static class UnacknowledgedPreKeyMessageItems { - private final Optional preKeyId; - private final int signedPreKeyId; - private final ECPublicKey baseKey; - - public UnacknowledgedPreKeyMessageItems(Optional preKeyId, - int signedPreKeyId, - ECPublicKey baseKey) - { - this.preKeyId = preKeyId; - this.signedPreKeyId = signedPreKeyId; - this.baseKey = baseKey; - } - - - public Optional getPreKeyId() { - return preKeyId; - } - - public int getSignedPreKeyId() { - return signedPreKeyId; - } - - public ECPublicKey getBaseKey() { - return baseKey; - } - } -} diff --git a/libsignal/src/main/java/org/session/libsignal/libsignal/state/SessionStore.java b/libsignal/src/main/java/org/session/libsignal/libsignal/state/SessionStore.java deleted file mode 100644 index e1029b13ff..0000000000 --- a/libsignal/src/main/java/org/session/libsignal/libsignal/state/SessionStore.java +++ /dev/null @@ -1,72 +0,0 @@ -/** - * Copyright (C) 2014-2016 Open Whisper Systems - * - * Licensed according to the LICENSE file in this repository. - */ -package org.session.libsignal.libsignal.state; - -import org.session.libsignal.libsignal.SignalProtocolAddress; -import org.session.libsignal.libsignal.state.SessionRecord; - -import java.util.List; - -/** - * The interface to the durable store of session state information - * for remote clients. - * - * @author Moxie Marlinspike - */ -public interface SessionStore { - - /** - * Returns a copy of the {@link SessionRecord} corresponding to the recipientId + deviceId tuple, - * or a new SessionRecord if one does not currently exist. - *

- * It is important that implementations return a copy of the current durable information. The - * returned SessionRecord may be modified, but those changes should not have an effect on the - * durable session state (what is returned by subsequent calls to this method) without the - * store method being called here first. - * - * @param address The name and device ID of the remote client. - * @return a copy of the SessionRecord corresponding to the recipientId + deviceId tuple, or - * a new SessionRecord if one does not currently exist. - */ - public SessionRecord loadSession(SignalProtocolAddress address); - - /** - * Returns all known devices with active sessions for a recipient - * - * @param name the name of the client. - * @return all known sub-devices with active sessions. - */ - public List getSubDeviceSessions(String name); - - /** - * Commit to storage the {@link SessionRecord} for a given recipientId + deviceId tuple. - * @param address the address of the remote client. - * @param record the current SessionRecord for the remote client. - */ - public void storeSession(SignalProtocolAddress address, SessionRecord record); - - /** - * Determine whether there is a committed {@link SessionRecord} for a recipientId + deviceId tuple. - * @param address the address of the remote client. - * @return true if a {@link SessionRecord} exists, false otherwise. - */ - public boolean containsSession(SignalProtocolAddress address); - - /** - * Remove a {@link SessionRecord} for a recipientId + deviceId tuple. - * - * @param address the address of the remote client. - */ - public void deleteSession(SignalProtocolAddress address); - - /** - * Remove the {@link SessionRecord}s corresponding to all devices of a recipientId. - * - * @param name the name of the remote client. - */ - public void deleteAllSessions(String name); - -} diff --git a/libsignal/src/main/java/org/session/libsignal/libsignal/state/SignalProtocolStore.java b/libsignal/src/main/java/org/session/libsignal/libsignal/state/SignalProtocolStore.java deleted file mode 100644 index 08fc8e9195..0000000000 --- a/libsignal/src/main/java/org/session/libsignal/libsignal/state/SignalProtocolStore.java +++ /dev/null @@ -1,11 +0,0 @@ -/** - * Copyright (C) 2014-2016 Open Whisper Systems - * - * Licensed according to the LICENSE file in this repository. - */ -package org.session.libsignal.libsignal.state; - -public interface SignalProtocolStore - extends IdentityKeyStore, PreKeyStore, SessionStore, SignedPreKeyStore -{ -} diff --git a/libsignal/src/main/java/org/session/libsignal/libsignal/state/SignedPreKeyRecord.java b/libsignal/src/main/java/org/session/libsignal/libsignal/state/SignedPreKeyRecord.java deleted file mode 100644 index 3478ea6ed1..0000000000 --- a/libsignal/src/main/java/org/session/libsignal/libsignal/state/SignedPreKeyRecord.java +++ /dev/null @@ -1,66 +0,0 @@ -/** - * Copyright (C) 2014-2016 Open Whisper Systems - * - * Licensed according to the LICENSE file in this repository. - */ -package org.session.libsignal.libsignal.state; - -import com.google.protobuf.ByteString; - -import org.session.libsignal.libsignal.InvalidKeyException; -import org.session.libsignal.libsignal.ecc.Curve; -import org.session.libsignal.libsignal.ecc.ECKeyPair; -import org.session.libsignal.libsignal.ecc.ECPrivateKey; -import org.session.libsignal.libsignal.ecc.ECPublicKey; - -import java.io.IOException; - -import static org.session.libsignal.libsignal.state.StorageProtos.SignedPreKeyRecordStructure; - -public class SignedPreKeyRecord { - - private SignedPreKeyRecordStructure structure; - - public SignedPreKeyRecord(int id, long timestamp, ECKeyPair keyPair, byte[] signature) { - this.structure = SignedPreKeyRecordStructure.newBuilder() - .setId(id) - .setPublicKey(ByteString.copyFrom(keyPair.getPublicKey() - .serialize())) - .setPrivateKey(ByteString.copyFrom(keyPair.getPrivateKey() - .serialize())) - .setSignature(ByteString.copyFrom(signature)) - .setTimestamp(timestamp) - .build(); - } - - public SignedPreKeyRecord(byte[] serialized) throws IOException { - this.structure = SignedPreKeyRecordStructure.parseFrom(serialized); - } - - public int getId() { - return this.structure.getId(); - } - - public long getTimestamp() { - return this.structure.getTimestamp(); - } - - public ECKeyPair getKeyPair() { - try { - ECPublicKey publicKey = Curve.decodePoint(this.structure.getPublicKey().toByteArray(), 0); - ECPrivateKey privateKey = Curve.decodePrivatePoint(this.structure.getPrivateKey().toByteArray()); - - return new ECKeyPair(publicKey, privateKey); - } catch (InvalidKeyException e) { - throw new AssertionError(e); - } - } - - public byte[] getSignature() { - return this.structure.getSignature().toByteArray(); - } - - public byte[] serialize() { - return this.structure.toByteArray(); - } -} diff --git a/libsignal/src/main/java/org/session/libsignal/libsignal/state/SignedPreKeyStore.java b/libsignal/src/main/java/org/session/libsignal/libsignal/state/SignedPreKeyStore.java deleted file mode 100644 index a25857227c..0000000000 --- a/libsignal/src/main/java/org/session/libsignal/libsignal/state/SignedPreKeyStore.java +++ /dev/null @@ -1,53 +0,0 @@ -/** - * Copyright (C) 2014-2016 Open Whisper Systems - * - * Licensed according to the LICENSE file in this repository. - */ -package org.session.libsignal.libsignal.state; - -import org.session.libsignal.libsignal.InvalidKeyIdException; -import org.session.libsignal.libsignal.state.SignedPreKeyRecord; - -import java.util.List; - -public interface SignedPreKeyStore { - - - /** - * Load a local SignedPreKeyRecord. - * - * @param signedPreKeyId the ID of the local SignedPreKeyRecord. - * @return the corresponding SignedPreKeyRecord. - * @throws InvalidKeyIdException when there is no corresponding SignedPreKeyRecord. - */ - public SignedPreKeyRecord loadSignedPreKey(int signedPreKeyId) throws InvalidKeyIdException; - - /** - * Load all local SignedPreKeyRecords. - * - * @return All stored SignedPreKeyRecords. - */ - public List loadSignedPreKeys(); - - /** - * Store a local SignedPreKeyRecord. - * - * @param signedPreKeyId the ID of the SignedPreKeyRecord to store. - * @param record the SignedPreKeyRecord. - */ - public void storeSignedPreKey(int signedPreKeyId, SignedPreKeyRecord record); - - /** - * @param signedPreKeyId A SignedPreKeyRecord ID. - * @return true if the store has a record for the signedPreKeyId, otherwise false. - */ - public boolean containsSignedPreKey(int signedPreKeyId); - - /** - * Delete a SignedPreKeyRecord from local storage. - * - * @param signedPreKeyId The ID of the SignedPreKeyRecord to remove. - */ - public void removeSignedPreKey(int signedPreKeyId); - -} diff --git a/libsignal/src/main/java/org/session/libsignal/libsignal/state/StorageProtos.java b/libsignal/src/main/java/org/session/libsignal/libsignal/state/StorageProtos.java deleted file mode 100644 index 407ceb4407..0000000000 --- a/libsignal/src/main/java/org/session/libsignal/libsignal/state/StorageProtos.java +++ /dev/null @@ -1,11779 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: LocalStorageProtocol.proto - -package org.session.libsignal.libsignal.state; - -public final class StorageProtos { - private StorageProtos() {} - public static void registerAllExtensions( - com.google.protobuf.ExtensionRegistry registry) { - } - public interface SessionStructureOrBuilder - extends com.google.protobuf.MessageOrBuilder { - - // optional uint32 sessionVersion = 1; - /** - * optional uint32 sessionVersion = 1; - */ - boolean hasSessionVersion(); - /** - * optional uint32 sessionVersion = 1; - */ - int getSessionVersion(); - - // optional bytes localIdentityPublic = 2; - /** - * optional bytes localIdentityPublic = 2; - */ - boolean hasLocalIdentityPublic(); - /** - * optional bytes localIdentityPublic = 2; - */ - com.google.protobuf.ByteString getLocalIdentityPublic(); - - // optional bytes remoteIdentityPublic = 3; - /** - * optional bytes remoteIdentityPublic = 3; - */ - boolean hasRemoteIdentityPublic(); - /** - * optional bytes remoteIdentityPublic = 3; - */ - com.google.protobuf.ByteString getRemoteIdentityPublic(); - - // optional bytes rootKey = 4; - /** - * optional bytes rootKey = 4; - */ - boolean hasRootKey(); - /** - * optional bytes rootKey = 4; - */ - com.google.protobuf.ByteString getRootKey(); - - // optional uint32 previousCounter = 5; - /** - * optional uint32 previousCounter = 5; - */ - boolean hasPreviousCounter(); - /** - * optional uint32 previousCounter = 5; - */ - int getPreviousCounter(); - - // optional .textsecure.SessionStructure.Chain senderChain = 6; - /** - * optional .textsecure.SessionStructure.Chain senderChain = 6; - */ - boolean hasSenderChain(); - /** - * optional .textsecure.SessionStructure.Chain senderChain = 6; - */ - org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain getSenderChain(); - /** - * optional .textsecure.SessionStructure.Chain senderChain = 6; - */ - org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.ChainOrBuilder getSenderChainOrBuilder(); - - // repeated .textsecure.SessionStructure.Chain receiverChains = 7; - /** - * repeated .textsecure.SessionStructure.Chain receiverChains = 7; - */ - java.util.List - getReceiverChainsList(); - /** - * repeated .textsecure.SessionStructure.Chain receiverChains = 7; - */ - org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain getReceiverChains(int index); - /** - * repeated .textsecure.SessionStructure.Chain receiverChains = 7; - */ - int getReceiverChainsCount(); - /** - * repeated .textsecure.SessionStructure.Chain receiverChains = 7; - */ - java.util.List - getReceiverChainsOrBuilderList(); - /** - * repeated .textsecure.SessionStructure.Chain receiverChains = 7; - */ - org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.ChainOrBuilder getReceiverChainsOrBuilder( - int index); - - // optional .textsecure.SessionStructure.PendingKeyExchange pendingKeyExchange = 8; - /** - * optional .textsecure.SessionStructure.PendingKeyExchange pendingKeyExchange = 8; - */ - boolean hasPendingKeyExchange(); - /** - * optional .textsecure.SessionStructure.PendingKeyExchange pendingKeyExchange = 8; - */ - org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.PendingKeyExchange getPendingKeyExchange(); - /** - * optional .textsecure.SessionStructure.PendingKeyExchange pendingKeyExchange = 8; - */ - org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.PendingKeyExchangeOrBuilder getPendingKeyExchangeOrBuilder(); - - // optional .textsecure.SessionStructure.PendingPreKey pendingPreKey = 9; - /** - * optional .textsecure.SessionStructure.PendingPreKey pendingPreKey = 9; - */ - boolean hasPendingPreKey(); - /** - * optional .textsecure.SessionStructure.PendingPreKey pendingPreKey = 9; - */ - org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.PendingPreKey getPendingPreKey(); - /** - * optional .textsecure.SessionStructure.PendingPreKey pendingPreKey = 9; - */ - org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.PendingPreKeyOrBuilder getPendingPreKeyOrBuilder(); - - // optional uint32 remoteRegistrationId = 10; - /** - * optional uint32 remoteRegistrationId = 10; - */ - boolean hasRemoteRegistrationId(); - /** - * optional uint32 remoteRegistrationId = 10; - */ - int getRemoteRegistrationId(); - - // optional uint32 localRegistrationId = 11; - /** - * optional uint32 localRegistrationId = 11; - */ - boolean hasLocalRegistrationId(); - /** - * optional uint32 localRegistrationId = 11; - */ - int getLocalRegistrationId(); - - // optional bool needsRefresh = 12; - /** - * optional bool needsRefresh = 12; - */ - boolean hasNeedsRefresh(); - /** - * optional bool needsRefresh = 12; - */ - boolean getNeedsRefresh(); - - // optional bytes aliceBaseKey = 13; - /** - * optional bytes aliceBaseKey = 13; - */ - boolean hasAliceBaseKey(); - /** - * optional bytes aliceBaseKey = 13; - */ - com.google.protobuf.ByteString getAliceBaseKey(); - } - /** - * Protobuf type {@code textsecure.SessionStructure} - */ - public static final class SessionStructure extends - com.google.protobuf.GeneratedMessage - implements SessionStructureOrBuilder { - // Use SessionStructure.newBuilder() to construct. - private SessionStructure(com.google.protobuf.GeneratedMessage.Builder builder) { - super(builder); - this.unknownFields = builder.getUnknownFields(); - } - private SessionStructure(boolean noInit) { this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); } - - private static final SessionStructure defaultInstance; - public static SessionStructure getDefaultInstance() { - return defaultInstance; - } - - public SessionStructure getDefaultInstanceForType() { - return defaultInstance; - } - - private final com.google.protobuf.UnknownFieldSet unknownFields; - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return this.unknownFields; - } - private SessionStructure( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - initFields(); - int mutable_bitField0_ = 0; - com.google.protobuf.UnknownFieldSet.Builder unknownFields = - com.google.protobuf.UnknownFieldSet.newBuilder(); - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: { - if (!parseUnknownField(input, unknownFields, - extensionRegistry, tag)) { - done = true; - } - break; - } - case 8: { - bitField0_ |= 0x00000001; - sessionVersion_ = input.readUInt32(); - break; - } - case 18: { - bitField0_ |= 0x00000002; - localIdentityPublic_ = input.readBytes(); - break; - } - case 26: { - bitField0_ |= 0x00000004; - remoteIdentityPublic_ = input.readBytes(); - break; - } - case 34: { - bitField0_ |= 0x00000008; - rootKey_ = input.readBytes(); - break; - } - case 40: { - bitField0_ |= 0x00000010; - previousCounter_ = input.readUInt32(); - break; - } - case 50: { - org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.Builder subBuilder = null; - if (((bitField0_ & 0x00000020) == 0x00000020)) { - subBuilder = senderChain_.toBuilder(); - } - senderChain_ = input.readMessage(org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.PARSER, extensionRegistry); - if (subBuilder != null) { - subBuilder.mergeFrom(senderChain_); - senderChain_ = subBuilder.buildPartial(); - } - bitField0_ |= 0x00000020; - break; - } - case 58: { - if (!((mutable_bitField0_ & 0x00000040) == 0x00000040)) { - receiverChains_ = new java.util.ArrayList(); - mutable_bitField0_ |= 0x00000040; - } - receiverChains_.add(input.readMessage(org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.PARSER, extensionRegistry)); - break; - } - case 66: { - org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.PendingKeyExchange.Builder subBuilder = null; - if (((bitField0_ & 0x00000040) == 0x00000040)) { - subBuilder = pendingKeyExchange_.toBuilder(); - } - pendingKeyExchange_ = input.readMessage(org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.PendingKeyExchange.PARSER, extensionRegistry); - if (subBuilder != null) { - subBuilder.mergeFrom(pendingKeyExchange_); - pendingKeyExchange_ = subBuilder.buildPartial(); - } - bitField0_ |= 0x00000040; - break; - } - case 74: { - org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.PendingPreKey.Builder subBuilder = null; - if (((bitField0_ & 0x00000080) == 0x00000080)) { - subBuilder = pendingPreKey_.toBuilder(); - } - pendingPreKey_ = input.readMessage(org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.PendingPreKey.PARSER, extensionRegistry); - if (subBuilder != null) { - subBuilder.mergeFrom(pendingPreKey_); - pendingPreKey_ = subBuilder.buildPartial(); - } - bitField0_ |= 0x00000080; - break; - } - case 80: { - bitField0_ |= 0x00000100; - remoteRegistrationId_ = input.readUInt32(); - break; - } - case 88: { - bitField0_ |= 0x00000200; - localRegistrationId_ = input.readUInt32(); - break; - } - case 96: { - bitField0_ |= 0x00000400; - needsRefresh_ = input.readBool(); - break; - } - case 106: { - bitField0_ |= 0x00000800; - aliceBaseKey_ = input.readBytes(); - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(this); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException( - e.getMessage()).setUnfinishedMessage(this); - } finally { - if (((mutable_bitField0_ & 0x00000040) == 0x00000040)) { - receiverChains_ = java.util.Collections.unmodifiableList(receiverChains_); - } - this.unknownFields = unknownFields.build(); - makeExtensionsImmutable(); - } - } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return org.session.libsignal.libsignal.state.StorageProtos.internal_static_textsecure_SessionStructure_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return org.session.libsignal.libsignal.state.StorageProtos.internal_static_textsecure_SessionStructure_fieldAccessorTable - .ensureFieldAccessorsInitialized( - org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.class, org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Builder.class); - } - - public static com.google.protobuf.Parser PARSER = - new com.google.protobuf.AbstractParser() { - public SessionStructure parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return new SessionStructure(input, extensionRegistry); - } - }; - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - public interface ChainOrBuilder - extends com.google.protobuf.MessageOrBuilder { - - // optional bytes senderRatchetKey = 1; - /** - * optional bytes senderRatchetKey = 1; - */ - boolean hasSenderRatchetKey(); - /** - * optional bytes senderRatchetKey = 1; - */ - com.google.protobuf.ByteString getSenderRatchetKey(); - - // optional bytes senderRatchetKeyPrivate = 2; - /** - * optional bytes senderRatchetKeyPrivate = 2; - */ - boolean hasSenderRatchetKeyPrivate(); - /** - * optional bytes senderRatchetKeyPrivate = 2; - */ - com.google.protobuf.ByteString getSenderRatchetKeyPrivate(); - - // optional .textsecure.SessionStructure.Chain.ChainKey chainKey = 3; - /** - * optional .textsecure.SessionStructure.Chain.ChainKey chainKey = 3; - */ - boolean hasChainKey(); - /** - * optional .textsecure.SessionStructure.Chain.ChainKey chainKey = 3; - */ - org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.ChainKey getChainKey(); - /** - * optional .textsecure.SessionStructure.Chain.ChainKey chainKey = 3; - */ - org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.ChainKeyOrBuilder getChainKeyOrBuilder(); - - // repeated .textsecure.SessionStructure.Chain.MessageKey messageKeys = 4; - /** - * repeated .textsecure.SessionStructure.Chain.MessageKey messageKeys = 4; - */ - java.util.List - getMessageKeysList(); - /** - * repeated .textsecure.SessionStructure.Chain.MessageKey messageKeys = 4; - */ - org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.MessageKey getMessageKeys(int index); - /** - * repeated .textsecure.SessionStructure.Chain.MessageKey messageKeys = 4; - */ - int getMessageKeysCount(); - /** - * repeated .textsecure.SessionStructure.Chain.MessageKey messageKeys = 4; - */ - java.util.List - getMessageKeysOrBuilderList(); - /** - * repeated .textsecure.SessionStructure.Chain.MessageKey messageKeys = 4; - */ - org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.MessageKeyOrBuilder getMessageKeysOrBuilder( - int index); - } - /** - * Protobuf type {@code textsecure.SessionStructure.Chain} - */ - public static final class Chain extends - com.google.protobuf.GeneratedMessage - implements ChainOrBuilder { - // Use Chain.newBuilder() to construct. - private Chain(com.google.protobuf.GeneratedMessage.Builder builder) { - super(builder); - this.unknownFields = builder.getUnknownFields(); - } - private Chain(boolean noInit) { this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); } - - private static final Chain defaultInstance; - public static Chain getDefaultInstance() { - return defaultInstance; - } - - public Chain getDefaultInstanceForType() { - return defaultInstance; - } - - private final com.google.protobuf.UnknownFieldSet unknownFields; - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return this.unknownFields; - } - private Chain( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - initFields(); - int mutable_bitField0_ = 0; - com.google.protobuf.UnknownFieldSet.Builder unknownFields = - com.google.protobuf.UnknownFieldSet.newBuilder(); - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: { - if (!parseUnknownField(input, unknownFields, - extensionRegistry, tag)) { - done = true; - } - break; - } - case 10: { - bitField0_ |= 0x00000001; - senderRatchetKey_ = input.readBytes(); - break; - } - case 18: { - bitField0_ |= 0x00000002; - senderRatchetKeyPrivate_ = input.readBytes(); - break; - } - case 26: { - org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.ChainKey.Builder subBuilder = null; - if (((bitField0_ & 0x00000004) == 0x00000004)) { - subBuilder = chainKey_.toBuilder(); - } - chainKey_ = input.readMessage(org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.ChainKey.PARSER, extensionRegistry); - if (subBuilder != null) { - subBuilder.mergeFrom(chainKey_); - chainKey_ = subBuilder.buildPartial(); - } - bitField0_ |= 0x00000004; - break; - } - case 34: { - if (!((mutable_bitField0_ & 0x00000008) == 0x00000008)) { - messageKeys_ = new java.util.ArrayList(); - mutable_bitField0_ |= 0x00000008; - } - messageKeys_.add(input.readMessage(org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.MessageKey.PARSER, extensionRegistry)); - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(this); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException( - e.getMessage()).setUnfinishedMessage(this); - } finally { - if (((mutable_bitField0_ & 0x00000008) == 0x00000008)) { - messageKeys_ = java.util.Collections.unmodifiableList(messageKeys_); - } - this.unknownFields = unknownFields.build(); - makeExtensionsImmutable(); - } - } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return org.session.libsignal.libsignal.state.StorageProtos.internal_static_textsecure_SessionStructure_Chain_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return org.session.libsignal.libsignal.state.StorageProtos.internal_static_textsecure_SessionStructure_Chain_fieldAccessorTable - .ensureFieldAccessorsInitialized( - org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.class, org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.Builder.class); - } - - public static com.google.protobuf.Parser PARSER = - new com.google.protobuf.AbstractParser() { - public Chain parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return new Chain(input, extensionRegistry); - } - }; - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - public interface ChainKeyOrBuilder - extends com.google.protobuf.MessageOrBuilder { - - // optional uint32 index = 1; - /** - * optional uint32 index = 1; - */ - boolean hasIndex(); - /** - * optional uint32 index = 1; - */ - int getIndex(); - - // optional bytes key = 2; - /** - * optional bytes key = 2; - */ - boolean hasKey(); - /** - * optional bytes key = 2; - */ - com.google.protobuf.ByteString getKey(); - } - /** - * Protobuf type {@code textsecure.SessionStructure.Chain.ChainKey} - */ - public static final class ChainKey extends - com.google.protobuf.GeneratedMessage - implements ChainKeyOrBuilder { - // Use ChainKey.newBuilder() to construct. - private ChainKey(com.google.protobuf.GeneratedMessage.Builder builder) { - super(builder); - this.unknownFields = builder.getUnknownFields(); - } - private ChainKey(boolean noInit) { this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); } - - private static final ChainKey defaultInstance; - public static ChainKey getDefaultInstance() { - return defaultInstance; - } - - public ChainKey getDefaultInstanceForType() { - return defaultInstance; - } - - private final com.google.protobuf.UnknownFieldSet unknownFields; - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return this.unknownFields; - } - private ChainKey( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - initFields(); - int mutable_bitField0_ = 0; - com.google.protobuf.UnknownFieldSet.Builder unknownFields = - com.google.protobuf.UnknownFieldSet.newBuilder(); - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: { - if (!parseUnknownField(input, unknownFields, - extensionRegistry, tag)) { - done = true; - } - break; - } - case 8: { - bitField0_ |= 0x00000001; - index_ = input.readUInt32(); - break; - } - case 18: { - bitField0_ |= 0x00000002; - key_ = input.readBytes(); - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(this); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException( - e.getMessage()).setUnfinishedMessage(this); - } finally { - this.unknownFields = unknownFields.build(); - makeExtensionsImmutable(); - } - } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return org.session.libsignal.libsignal.state.StorageProtos.internal_static_textsecure_SessionStructure_Chain_ChainKey_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return org.session.libsignal.libsignal.state.StorageProtos.internal_static_textsecure_SessionStructure_Chain_ChainKey_fieldAccessorTable - .ensureFieldAccessorsInitialized( - org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.ChainKey.class, org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.ChainKey.Builder.class); - } - - public static com.google.protobuf.Parser PARSER = - new com.google.protobuf.AbstractParser() { - public ChainKey parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return new ChainKey(input, extensionRegistry); - } - }; - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - private int bitField0_; - // optional uint32 index = 1; - public static final int INDEX_FIELD_NUMBER = 1; - private int index_; - /** - * optional uint32 index = 1; - */ - public boolean hasIndex() { - return ((bitField0_ & 0x00000001) == 0x00000001); - } - /** - * optional uint32 index = 1; - */ - public int getIndex() { - return index_; - } - - // optional bytes key = 2; - public static final int KEY_FIELD_NUMBER = 2; - private com.google.protobuf.ByteString key_; - /** - * optional bytes key = 2; - */ - public boolean hasKey() { - return ((bitField0_ & 0x00000002) == 0x00000002); - } - /** - * optional bytes key = 2; - */ - public com.google.protobuf.ByteString getKey() { - return key_; - } - - private void initFields() { - index_ = 0; - key_ = com.google.protobuf.ByteString.EMPTY; - } - private byte memoizedIsInitialized = -1; - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized != -1) return isInitialized == 1; - - memoizedIsInitialized = 1; - return true; - } - - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - getSerializedSize(); - if (((bitField0_ & 0x00000001) == 0x00000001)) { - output.writeUInt32(1, index_); - } - if (((bitField0_ & 0x00000002) == 0x00000002)) { - output.writeBytes(2, key_); - } - getUnknownFields().writeTo(output); - } - - private int memoizedSerializedSize = -1; - public int getSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (((bitField0_ & 0x00000001) == 0x00000001)) { - size += com.google.protobuf.CodedOutputStream - .computeUInt32Size(1, index_); - } - if (((bitField0_ & 0x00000002) == 0x00000002)) { - size += com.google.protobuf.CodedOutputStream - .computeBytesSize(2, key_); - } - size += getUnknownFields().getSerializedSize(); - memoizedSerializedSize = size; - return size; - } - - private static final long serialVersionUID = 0L; - @java.lang.Override - protected java.lang.Object writeReplace() - throws java.io.ObjectStreamException { - return super.writeReplace(); - } - - public static org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.ChainKey parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.ChainKey parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.ChainKey parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.ChainKey parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.ChainKey parseFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.ChainKey parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - public static org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.ChainKey parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input); - } - public static org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.ChainKey parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input, extensionRegistry); - } - public static org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.ChainKey parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.ChainKey parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - - public static Builder newBuilder() { return Builder.create(); } - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder(org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.ChainKey prototype) { - return newBuilder().mergeFrom(prototype); - } - public Builder toBuilder() { return newBuilder(this); } - - @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * Protobuf type {@code textsecure.SessionStructure.Chain.ChainKey} - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessage.Builder - implements org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.ChainKeyOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return org.session.libsignal.libsignal.state.StorageProtos.internal_static_textsecure_SessionStructure_Chain_ChainKey_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return org.session.libsignal.libsignal.state.StorageProtos.internal_static_textsecure_SessionStructure_Chain_ChainKey_fieldAccessorTable - .ensureFieldAccessorsInitialized( - org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.ChainKey.class, org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.ChainKey.Builder.class); - } - - // Construct using org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.ChainKey.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { - } - } - private static Builder create() { - return new Builder(); - } - - public Builder clear() { - super.clear(); - index_ = 0; - bitField0_ = (bitField0_ & ~0x00000001); - key_ = com.google.protobuf.ByteString.EMPTY; - bitField0_ = (bitField0_ & ~0x00000002); - return this; - } - - public Builder clone() { - return create().mergeFrom(buildPartial()); - } - - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return org.session.libsignal.libsignal.state.StorageProtos.internal_static_textsecure_SessionStructure_Chain_ChainKey_descriptor; - } - - public org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.ChainKey getDefaultInstanceForType() { - return org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.ChainKey.getDefaultInstance(); - } - - public org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.ChainKey build() { - org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.ChainKey result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - public org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.ChainKey buildPartial() { - org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.ChainKey result = new org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.ChainKey(this); - int from_bitField0_ = bitField0_; - int to_bitField0_ = 0; - if (((from_bitField0_ & 0x00000001) == 0x00000001)) { - to_bitField0_ |= 0x00000001; - } - result.index_ = index_; - if (((from_bitField0_ & 0x00000002) == 0x00000002)) { - to_bitField0_ |= 0x00000002; - } - result.key_ = key_; - result.bitField0_ = to_bitField0_; - onBuilt(); - return result; - } - - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.ChainKey) { - return mergeFrom((org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.ChainKey)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.ChainKey other) { - if (other == org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.ChainKey.getDefaultInstance()) return this; - if (other.hasIndex()) { - setIndex(other.getIndex()); - } - if (other.hasKey()) { - setKey(other.getKey()); - } - this.mergeUnknownFields(other.getUnknownFields()); - return this; - } - - public final boolean isInitialized() { - return true; - } - - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.ChainKey parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.ChainKey) e.getUnfinishedMessage(); - throw e; - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - private int bitField0_; - - // optional uint32 index = 1; - private int index_ ; - /** - * optional uint32 index = 1; - */ - public boolean hasIndex() { - return ((bitField0_ & 0x00000001) == 0x00000001); - } - /** - * optional uint32 index = 1; - */ - public int getIndex() { - return index_; - } - /** - * optional uint32 index = 1; - */ - public Builder setIndex(int value) { - bitField0_ |= 0x00000001; - index_ = value; - onChanged(); - return this; - } - /** - * optional uint32 index = 1; - */ - public Builder clearIndex() { - bitField0_ = (bitField0_ & ~0x00000001); - index_ = 0; - onChanged(); - return this; - } - - // optional bytes key = 2; - private com.google.protobuf.ByteString key_ = com.google.protobuf.ByteString.EMPTY; - /** - * optional bytes key = 2; - */ - public boolean hasKey() { - return ((bitField0_ & 0x00000002) == 0x00000002); - } - /** - * optional bytes key = 2; - */ - public com.google.protobuf.ByteString getKey() { - return key_; - } - /** - * optional bytes key = 2; - */ - public Builder setKey(com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - bitField0_ |= 0x00000002; - key_ = value; - onChanged(); - return this; - } - /** - * optional bytes key = 2; - */ - public Builder clearKey() { - bitField0_ = (bitField0_ & ~0x00000002); - key_ = getDefaultInstance().getKey(); - onChanged(); - return this; - } - - // @@protoc_insertion_point(builder_scope:textsecure.SessionStructure.Chain.ChainKey) - } - - static { - defaultInstance = new ChainKey(true); - defaultInstance.initFields(); - } - - // @@protoc_insertion_point(class_scope:textsecure.SessionStructure.Chain.ChainKey) - } - - public interface MessageKeyOrBuilder - extends com.google.protobuf.MessageOrBuilder { - - // optional uint32 index = 1; - /** - * optional uint32 index = 1; - */ - boolean hasIndex(); - /** - * optional uint32 index = 1; - */ - int getIndex(); - - // optional bytes cipherKey = 2; - /** - * optional bytes cipherKey = 2; - */ - boolean hasCipherKey(); - /** - * optional bytes cipherKey = 2; - */ - com.google.protobuf.ByteString getCipherKey(); - - // optional bytes macKey = 3; - /** - * optional bytes macKey = 3; - */ - boolean hasMacKey(); - /** - * optional bytes macKey = 3; - */ - com.google.protobuf.ByteString getMacKey(); - - // optional bytes iv = 4; - /** - * optional bytes iv = 4; - */ - boolean hasIv(); - /** - * optional bytes iv = 4; - */ - com.google.protobuf.ByteString getIv(); - } - /** - * Protobuf type {@code textsecure.SessionStructure.Chain.MessageKey} - */ - public static final class MessageKey extends - com.google.protobuf.GeneratedMessage - implements MessageKeyOrBuilder { - // Use MessageKey.newBuilder() to construct. - private MessageKey(com.google.protobuf.GeneratedMessage.Builder builder) { - super(builder); - this.unknownFields = builder.getUnknownFields(); - } - private MessageKey(boolean noInit) { this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); } - - private static final MessageKey defaultInstance; - public static MessageKey getDefaultInstance() { - return defaultInstance; - } - - public MessageKey getDefaultInstanceForType() { - return defaultInstance; - } - - private final com.google.protobuf.UnknownFieldSet unknownFields; - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return this.unknownFields; - } - private MessageKey( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - initFields(); - int mutable_bitField0_ = 0; - com.google.protobuf.UnknownFieldSet.Builder unknownFields = - com.google.protobuf.UnknownFieldSet.newBuilder(); - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: { - if (!parseUnknownField(input, unknownFields, - extensionRegistry, tag)) { - done = true; - } - break; - } - case 8: { - bitField0_ |= 0x00000001; - index_ = input.readUInt32(); - break; - } - case 18: { - bitField0_ |= 0x00000002; - cipherKey_ = input.readBytes(); - break; - } - case 26: { - bitField0_ |= 0x00000004; - macKey_ = input.readBytes(); - break; - } - case 34: { - bitField0_ |= 0x00000008; - iv_ = input.readBytes(); - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(this); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException( - e.getMessage()).setUnfinishedMessage(this); - } finally { - this.unknownFields = unknownFields.build(); - makeExtensionsImmutable(); - } - } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return org.session.libsignal.libsignal.state.StorageProtos.internal_static_textsecure_SessionStructure_Chain_MessageKey_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return org.session.libsignal.libsignal.state.StorageProtos.internal_static_textsecure_SessionStructure_Chain_MessageKey_fieldAccessorTable - .ensureFieldAccessorsInitialized( - org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.MessageKey.class, org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.MessageKey.Builder.class); - } - - public static com.google.protobuf.Parser PARSER = - new com.google.protobuf.AbstractParser() { - public MessageKey parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return new MessageKey(input, extensionRegistry); - } - }; - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - private int bitField0_; - // optional uint32 index = 1; - public static final int INDEX_FIELD_NUMBER = 1; - private int index_; - /** - * optional uint32 index = 1; - */ - public boolean hasIndex() { - return ((bitField0_ & 0x00000001) == 0x00000001); - } - /** - * optional uint32 index = 1; - */ - public int getIndex() { - return index_; - } - - // optional bytes cipherKey = 2; - public static final int CIPHERKEY_FIELD_NUMBER = 2; - private com.google.protobuf.ByteString cipherKey_; - /** - * optional bytes cipherKey = 2; - */ - public boolean hasCipherKey() { - return ((bitField0_ & 0x00000002) == 0x00000002); - } - /** - * optional bytes cipherKey = 2; - */ - public com.google.protobuf.ByteString getCipherKey() { - return cipherKey_; - } - - // optional bytes macKey = 3; - public static final int MACKEY_FIELD_NUMBER = 3; - private com.google.protobuf.ByteString macKey_; - /** - * optional bytes macKey = 3; - */ - public boolean hasMacKey() { - return ((bitField0_ & 0x00000004) == 0x00000004); - } - /** - * optional bytes macKey = 3; - */ - public com.google.protobuf.ByteString getMacKey() { - return macKey_; - } - - // optional bytes iv = 4; - public static final int IV_FIELD_NUMBER = 4; - private com.google.protobuf.ByteString iv_; - /** - * optional bytes iv = 4; - */ - public boolean hasIv() { - return ((bitField0_ & 0x00000008) == 0x00000008); - } - /** - * optional bytes iv = 4; - */ - public com.google.protobuf.ByteString getIv() { - return iv_; - } - - private void initFields() { - index_ = 0; - cipherKey_ = com.google.protobuf.ByteString.EMPTY; - macKey_ = com.google.protobuf.ByteString.EMPTY; - iv_ = com.google.protobuf.ByteString.EMPTY; - } - private byte memoizedIsInitialized = -1; - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized != -1) return isInitialized == 1; - - memoizedIsInitialized = 1; - return true; - } - - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - getSerializedSize(); - if (((bitField0_ & 0x00000001) == 0x00000001)) { - output.writeUInt32(1, index_); - } - if (((bitField0_ & 0x00000002) == 0x00000002)) { - output.writeBytes(2, cipherKey_); - } - if (((bitField0_ & 0x00000004) == 0x00000004)) { - output.writeBytes(3, macKey_); - } - if (((bitField0_ & 0x00000008) == 0x00000008)) { - output.writeBytes(4, iv_); - } - getUnknownFields().writeTo(output); - } - - private int memoizedSerializedSize = -1; - public int getSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (((bitField0_ & 0x00000001) == 0x00000001)) { - size += com.google.protobuf.CodedOutputStream - .computeUInt32Size(1, index_); - } - if (((bitField0_ & 0x00000002) == 0x00000002)) { - size += com.google.protobuf.CodedOutputStream - .computeBytesSize(2, cipherKey_); - } - if (((bitField0_ & 0x00000004) == 0x00000004)) { - size += com.google.protobuf.CodedOutputStream - .computeBytesSize(3, macKey_); - } - if (((bitField0_ & 0x00000008) == 0x00000008)) { - size += com.google.protobuf.CodedOutputStream - .computeBytesSize(4, iv_); - } - size += getUnknownFields().getSerializedSize(); - memoizedSerializedSize = size; - return size; - } - - private static final long serialVersionUID = 0L; - @java.lang.Override - protected java.lang.Object writeReplace() - throws java.io.ObjectStreamException { - return super.writeReplace(); - } - - public static org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.MessageKey parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.MessageKey parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.MessageKey parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.MessageKey parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.MessageKey parseFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.MessageKey parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - public static org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.MessageKey parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input); - } - public static org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.MessageKey parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input, extensionRegistry); - } - public static org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.MessageKey parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.MessageKey parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - - public static Builder newBuilder() { return Builder.create(); } - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder(org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.MessageKey prototype) { - return newBuilder().mergeFrom(prototype); - } - public Builder toBuilder() { return newBuilder(this); } - - @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * Protobuf type {@code textsecure.SessionStructure.Chain.MessageKey} - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessage.Builder - implements org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.MessageKeyOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return org.session.libsignal.libsignal.state.StorageProtos.internal_static_textsecure_SessionStructure_Chain_MessageKey_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return org.session.libsignal.libsignal.state.StorageProtos.internal_static_textsecure_SessionStructure_Chain_MessageKey_fieldAccessorTable - .ensureFieldAccessorsInitialized( - org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.MessageKey.class, org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.MessageKey.Builder.class); - } - - // Construct using org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.MessageKey.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { - } - } - private static Builder create() { - return new Builder(); - } - - public Builder clear() { - super.clear(); - index_ = 0; - bitField0_ = (bitField0_ & ~0x00000001); - cipherKey_ = com.google.protobuf.ByteString.EMPTY; - bitField0_ = (bitField0_ & ~0x00000002); - macKey_ = com.google.protobuf.ByteString.EMPTY; - bitField0_ = (bitField0_ & ~0x00000004); - iv_ = com.google.protobuf.ByteString.EMPTY; - bitField0_ = (bitField0_ & ~0x00000008); - return this; - } - - public Builder clone() { - return create().mergeFrom(buildPartial()); - } - - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return org.session.libsignal.libsignal.state.StorageProtos.internal_static_textsecure_SessionStructure_Chain_MessageKey_descriptor; - } - - public org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.MessageKey getDefaultInstanceForType() { - return org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.MessageKey.getDefaultInstance(); - } - - public org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.MessageKey build() { - org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.MessageKey result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - public org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.MessageKey buildPartial() { - org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.MessageKey result = new org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.MessageKey(this); - int from_bitField0_ = bitField0_; - int to_bitField0_ = 0; - if (((from_bitField0_ & 0x00000001) == 0x00000001)) { - to_bitField0_ |= 0x00000001; - } - result.index_ = index_; - if (((from_bitField0_ & 0x00000002) == 0x00000002)) { - to_bitField0_ |= 0x00000002; - } - result.cipherKey_ = cipherKey_; - if (((from_bitField0_ & 0x00000004) == 0x00000004)) { - to_bitField0_ |= 0x00000004; - } - result.macKey_ = macKey_; - if (((from_bitField0_ & 0x00000008) == 0x00000008)) { - to_bitField0_ |= 0x00000008; - } - result.iv_ = iv_; - result.bitField0_ = to_bitField0_; - onBuilt(); - return result; - } - - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.MessageKey) { - return mergeFrom((org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.MessageKey)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.MessageKey other) { - if (other == org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.MessageKey.getDefaultInstance()) return this; - if (other.hasIndex()) { - setIndex(other.getIndex()); - } - if (other.hasCipherKey()) { - setCipherKey(other.getCipherKey()); - } - if (other.hasMacKey()) { - setMacKey(other.getMacKey()); - } - if (other.hasIv()) { - setIv(other.getIv()); - } - this.mergeUnknownFields(other.getUnknownFields()); - return this; - } - - public final boolean isInitialized() { - return true; - } - - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.MessageKey parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.MessageKey) e.getUnfinishedMessage(); - throw e; - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - private int bitField0_; - - // optional uint32 index = 1; - private int index_ ; - /** - * optional uint32 index = 1; - */ - public boolean hasIndex() { - return ((bitField0_ & 0x00000001) == 0x00000001); - } - /** - * optional uint32 index = 1; - */ - public int getIndex() { - return index_; - } - /** - * optional uint32 index = 1; - */ - public Builder setIndex(int value) { - bitField0_ |= 0x00000001; - index_ = value; - onChanged(); - return this; - } - /** - * optional uint32 index = 1; - */ - public Builder clearIndex() { - bitField0_ = (bitField0_ & ~0x00000001); - index_ = 0; - onChanged(); - return this; - } - - // optional bytes cipherKey = 2; - private com.google.protobuf.ByteString cipherKey_ = com.google.protobuf.ByteString.EMPTY; - /** - * optional bytes cipherKey = 2; - */ - public boolean hasCipherKey() { - return ((bitField0_ & 0x00000002) == 0x00000002); - } - /** - * optional bytes cipherKey = 2; - */ - public com.google.protobuf.ByteString getCipherKey() { - return cipherKey_; - } - /** - * optional bytes cipherKey = 2; - */ - public Builder setCipherKey(com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - bitField0_ |= 0x00000002; - cipherKey_ = value; - onChanged(); - return this; - } - /** - * optional bytes cipherKey = 2; - */ - public Builder clearCipherKey() { - bitField0_ = (bitField0_ & ~0x00000002); - cipherKey_ = getDefaultInstance().getCipherKey(); - onChanged(); - return this; - } - - // optional bytes macKey = 3; - private com.google.protobuf.ByteString macKey_ = com.google.protobuf.ByteString.EMPTY; - /** - * optional bytes macKey = 3; - */ - public boolean hasMacKey() { - return ((bitField0_ & 0x00000004) == 0x00000004); - } - /** - * optional bytes macKey = 3; - */ - public com.google.protobuf.ByteString getMacKey() { - return macKey_; - } - /** - * optional bytes macKey = 3; - */ - public Builder setMacKey(com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - bitField0_ |= 0x00000004; - macKey_ = value; - onChanged(); - return this; - } - /** - * optional bytes macKey = 3; - */ - public Builder clearMacKey() { - bitField0_ = (bitField0_ & ~0x00000004); - macKey_ = getDefaultInstance().getMacKey(); - onChanged(); - return this; - } - - // optional bytes iv = 4; - private com.google.protobuf.ByteString iv_ = com.google.protobuf.ByteString.EMPTY; - /** - * optional bytes iv = 4; - */ - public boolean hasIv() { - return ((bitField0_ & 0x00000008) == 0x00000008); - } - /** - * optional bytes iv = 4; - */ - public com.google.protobuf.ByteString getIv() { - return iv_; - } - /** - * optional bytes iv = 4; - */ - public Builder setIv(com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - bitField0_ |= 0x00000008; - iv_ = value; - onChanged(); - return this; - } - /** - * optional bytes iv = 4; - */ - public Builder clearIv() { - bitField0_ = (bitField0_ & ~0x00000008); - iv_ = getDefaultInstance().getIv(); - onChanged(); - return this; - } - - // @@protoc_insertion_point(builder_scope:textsecure.SessionStructure.Chain.MessageKey) - } - - static { - defaultInstance = new MessageKey(true); - defaultInstance.initFields(); - } - - // @@protoc_insertion_point(class_scope:textsecure.SessionStructure.Chain.MessageKey) - } - - private int bitField0_; - // optional bytes senderRatchetKey = 1; - public static final int SENDERRATCHETKEY_FIELD_NUMBER = 1; - private com.google.protobuf.ByteString senderRatchetKey_; - /** - * optional bytes senderRatchetKey = 1; - */ - public boolean hasSenderRatchetKey() { - return ((bitField0_ & 0x00000001) == 0x00000001); - } - /** - * optional bytes senderRatchetKey = 1; - */ - public com.google.protobuf.ByteString getSenderRatchetKey() { - return senderRatchetKey_; - } - - // optional bytes senderRatchetKeyPrivate = 2; - public static final int SENDERRATCHETKEYPRIVATE_FIELD_NUMBER = 2; - private com.google.protobuf.ByteString senderRatchetKeyPrivate_; - /** - * optional bytes senderRatchetKeyPrivate = 2; - */ - public boolean hasSenderRatchetKeyPrivate() { - return ((bitField0_ & 0x00000002) == 0x00000002); - } - /** - * optional bytes senderRatchetKeyPrivate = 2; - */ - public com.google.protobuf.ByteString getSenderRatchetKeyPrivate() { - return senderRatchetKeyPrivate_; - } - - // optional .textsecure.SessionStructure.Chain.ChainKey chainKey = 3; - public static final int CHAINKEY_FIELD_NUMBER = 3; - private org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.ChainKey chainKey_; - /** - * optional .textsecure.SessionStructure.Chain.ChainKey chainKey = 3; - */ - public boolean hasChainKey() { - return ((bitField0_ & 0x00000004) == 0x00000004); - } - /** - * optional .textsecure.SessionStructure.Chain.ChainKey chainKey = 3; - */ - public org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.ChainKey getChainKey() { - return chainKey_; - } - /** - * optional .textsecure.SessionStructure.Chain.ChainKey chainKey = 3; - */ - public org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.ChainKeyOrBuilder getChainKeyOrBuilder() { - return chainKey_; - } - - // repeated .textsecure.SessionStructure.Chain.MessageKey messageKeys = 4; - public static final int MESSAGEKEYS_FIELD_NUMBER = 4; - private java.util.List messageKeys_; - /** - * repeated .textsecure.SessionStructure.Chain.MessageKey messageKeys = 4; - */ - public java.util.List getMessageKeysList() { - return messageKeys_; - } - /** - * repeated .textsecure.SessionStructure.Chain.MessageKey messageKeys = 4; - */ - public java.util.List - getMessageKeysOrBuilderList() { - return messageKeys_; - } - /** - * repeated .textsecure.SessionStructure.Chain.MessageKey messageKeys = 4; - */ - public int getMessageKeysCount() { - return messageKeys_.size(); - } - /** - * repeated .textsecure.SessionStructure.Chain.MessageKey messageKeys = 4; - */ - public org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.MessageKey getMessageKeys(int index) { - return messageKeys_.get(index); - } - /** - * repeated .textsecure.SessionStructure.Chain.MessageKey messageKeys = 4; - */ - public org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.MessageKeyOrBuilder getMessageKeysOrBuilder( - int index) { - return messageKeys_.get(index); - } - - private void initFields() { - senderRatchetKey_ = com.google.protobuf.ByteString.EMPTY; - senderRatchetKeyPrivate_ = com.google.protobuf.ByteString.EMPTY; - chainKey_ = org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.ChainKey.getDefaultInstance(); - messageKeys_ = java.util.Collections.emptyList(); - } - private byte memoizedIsInitialized = -1; - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized != -1) return isInitialized == 1; - - memoizedIsInitialized = 1; - return true; - } - - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - getSerializedSize(); - if (((bitField0_ & 0x00000001) == 0x00000001)) { - output.writeBytes(1, senderRatchetKey_); - } - if (((bitField0_ & 0x00000002) == 0x00000002)) { - output.writeBytes(2, senderRatchetKeyPrivate_); - } - if (((bitField0_ & 0x00000004) == 0x00000004)) { - output.writeMessage(3, chainKey_); - } - for (int i = 0; i < messageKeys_.size(); i++) { - output.writeMessage(4, messageKeys_.get(i)); - } - getUnknownFields().writeTo(output); - } - - private int memoizedSerializedSize = -1; - public int getSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (((bitField0_ & 0x00000001) == 0x00000001)) { - size += com.google.protobuf.CodedOutputStream - .computeBytesSize(1, senderRatchetKey_); - } - if (((bitField0_ & 0x00000002) == 0x00000002)) { - size += com.google.protobuf.CodedOutputStream - .computeBytesSize(2, senderRatchetKeyPrivate_); - } - if (((bitField0_ & 0x00000004) == 0x00000004)) { - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(3, chainKey_); - } - for (int i = 0; i < messageKeys_.size(); i++) { - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(4, messageKeys_.get(i)); - } - size += getUnknownFields().getSerializedSize(); - memoizedSerializedSize = size; - return size; - } - - private static final long serialVersionUID = 0L; - @java.lang.Override - protected java.lang.Object writeReplace() - throws java.io.ObjectStreamException { - return super.writeReplace(); - } - - public static org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain parseFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - public static org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input); - } - public static org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input, extensionRegistry); - } - public static org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - - public static Builder newBuilder() { return Builder.create(); } - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder(org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain prototype) { - return newBuilder().mergeFrom(prototype); - } - public Builder toBuilder() { return newBuilder(this); } - - @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * Protobuf type {@code textsecure.SessionStructure.Chain} - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessage.Builder - implements org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.ChainOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return org.session.libsignal.libsignal.state.StorageProtos.internal_static_textsecure_SessionStructure_Chain_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return org.session.libsignal.libsignal.state.StorageProtos.internal_static_textsecure_SessionStructure_Chain_fieldAccessorTable - .ensureFieldAccessorsInitialized( - org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.class, org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.Builder.class); - } - - // Construct using org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { - getChainKeyFieldBuilder(); - getMessageKeysFieldBuilder(); - } - } - private static Builder create() { - return new Builder(); - } - - public Builder clear() { - super.clear(); - senderRatchetKey_ = com.google.protobuf.ByteString.EMPTY; - bitField0_ = (bitField0_ & ~0x00000001); - senderRatchetKeyPrivate_ = com.google.protobuf.ByteString.EMPTY; - bitField0_ = (bitField0_ & ~0x00000002); - if (chainKeyBuilder_ == null) { - chainKey_ = org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.ChainKey.getDefaultInstance(); - } else { - chainKeyBuilder_.clear(); - } - bitField0_ = (bitField0_ & ~0x00000004); - if (messageKeysBuilder_ == null) { - messageKeys_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000008); - } else { - messageKeysBuilder_.clear(); - } - return this; - } - - public Builder clone() { - return create().mergeFrom(buildPartial()); - } - - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return org.session.libsignal.libsignal.state.StorageProtos.internal_static_textsecure_SessionStructure_Chain_descriptor; - } - - public org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain getDefaultInstanceForType() { - return org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.getDefaultInstance(); - } - - public org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain build() { - org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - public org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain buildPartial() { - org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain result = new org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain(this); - int from_bitField0_ = bitField0_; - int to_bitField0_ = 0; - if (((from_bitField0_ & 0x00000001) == 0x00000001)) { - to_bitField0_ |= 0x00000001; - } - result.senderRatchetKey_ = senderRatchetKey_; - if (((from_bitField0_ & 0x00000002) == 0x00000002)) { - to_bitField0_ |= 0x00000002; - } - result.senderRatchetKeyPrivate_ = senderRatchetKeyPrivate_; - if (((from_bitField0_ & 0x00000004) == 0x00000004)) { - to_bitField0_ |= 0x00000004; - } - if (chainKeyBuilder_ == null) { - result.chainKey_ = chainKey_; - } else { - result.chainKey_ = chainKeyBuilder_.build(); - } - if (messageKeysBuilder_ == null) { - if (((bitField0_ & 0x00000008) == 0x00000008)) { - messageKeys_ = java.util.Collections.unmodifiableList(messageKeys_); - bitField0_ = (bitField0_ & ~0x00000008); - } - result.messageKeys_ = messageKeys_; - } else { - result.messageKeys_ = messageKeysBuilder_.build(); - } - result.bitField0_ = to_bitField0_; - onBuilt(); - return result; - } - - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain) { - return mergeFrom((org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain other) { - if (other == org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.getDefaultInstance()) return this; - if (other.hasSenderRatchetKey()) { - setSenderRatchetKey(other.getSenderRatchetKey()); - } - if (other.hasSenderRatchetKeyPrivate()) { - setSenderRatchetKeyPrivate(other.getSenderRatchetKeyPrivate()); - } - if (other.hasChainKey()) { - mergeChainKey(other.getChainKey()); - } - if (messageKeysBuilder_ == null) { - if (!other.messageKeys_.isEmpty()) { - if (messageKeys_.isEmpty()) { - messageKeys_ = other.messageKeys_; - bitField0_ = (bitField0_ & ~0x00000008); - } else { - ensureMessageKeysIsMutable(); - messageKeys_.addAll(other.messageKeys_); - } - onChanged(); - } - } else { - if (!other.messageKeys_.isEmpty()) { - if (messageKeysBuilder_.isEmpty()) { - messageKeysBuilder_.dispose(); - messageKeysBuilder_ = null; - messageKeys_ = other.messageKeys_; - bitField0_ = (bitField0_ & ~0x00000008); - messageKeysBuilder_ = - com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders ? - getMessageKeysFieldBuilder() : null; - } else { - messageKeysBuilder_.addAllMessages(other.messageKeys_); - } - } - } - this.mergeUnknownFields(other.getUnknownFields()); - return this; - } - - public final boolean isInitialized() { - return true; - } - - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain) e.getUnfinishedMessage(); - throw e; - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - private int bitField0_; - - // optional bytes senderRatchetKey = 1; - private com.google.protobuf.ByteString senderRatchetKey_ = com.google.protobuf.ByteString.EMPTY; - /** - * optional bytes senderRatchetKey = 1; - */ - public boolean hasSenderRatchetKey() { - return ((bitField0_ & 0x00000001) == 0x00000001); - } - /** - * optional bytes senderRatchetKey = 1; - */ - public com.google.protobuf.ByteString getSenderRatchetKey() { - return senderRatchetKey_; - } - /** - * optional bytes senderRatchetKey = 1; - */ - public Builder setSenderRatchetKey(com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - bitField0_ |= 0x00000001; - senderRatchetKey_ = value; - onChanged(); - return this; - } - /** - * optional bytes senderRatchetKey = 1; - */ - public Builder clearSenderRatchetKey() { - bitField0_ = (bitField0_ & ~0x00000001); - senderRatchetKey_ = getDefaultInstance().getSenderRatchetKey(); - onChanged(); - return this; - } - - // optional bytes senderRatchetKeyPrivate = 2; - private com.google.protobuf.ByteString senderRatchetKeyPrivate_ = com.google.protobuf.ByteString.EMPTY; - /** - * optional bytes senderRatchetKeyPrivate = 2; - */ - public boolean hasSenderRatchetKeyPrivate() { - return ((bitField0_ & 0x00000002) == 0x00000002); - } - /** - * optional bytes senderRatchetKeyPrivate = 2; - */ - public com.google.protobuf.ByteString getSenderRatchetKeyPrivate() { - return senderRatchetKeyPrivate_; - } - /** - * optional bytes senderRatchetKeyPrivate = 2; - */ - public Builder setSenderRatchetKeyPrivate(com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - bitField0_ |= 0x00000002; - senderRatchetKeyPrivate_ = value; - onChanged(); - return this; - } - /** - * optional bytes senderRatchetKeyPrivate = 2; - */ - public Builder clearSenderRatchetKeyPrivate() { - bitField0_ = (bitField0_ & ~0x00000002); - senderRatchetKeyPrivate_ = getDefaultInstance().getSenderRatchetKeyPrivate(); - onChanged(); - return this; - } - - // optional .textsecure.SessionStructure.Chain.ChainKey chainKey = 3; - private org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.ChainKey chainKey_ = org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.ChainKey.getDefaultInstance(); - private com.google.protobuf.SingleFieldBuilder< - org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.ChainKey, org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.ChainKey.Builder, org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.ChainKeyOrBuilder> chainKeyBuilder_; - /** - * optional .textsecure.SessionStructure.Chain.ChainKey chainKey = 3; - */ - public boolean hasChainKey() { - return ((bitField0_ & 0x00000004) == 0x00000004); - } - /** - * optional .textsecure.SessionStructure.Chain.ChainKey chainKey = 3; - */ - public org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.ChainKey getChainKey() { - if (chainKeyBuilder_ == null) { - return chainKey_; - } else { - return chainKeyBuilder_.getMessage(); - } - } - /** - * optional .textsecure.SessionStructure.Chain.ChainKey chainKey = 3; - */ - public Builder setChainKey(org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.ChainKey value) { - if (chainKeyBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - chainKey_ = value; - onChanged(); - } else { - chainKeyBuilder_.setMessage(value); - } - bitField0_ |= 0x00000004; - return this; - } - /** - * optional .textsecure.SessionStructure.Chain.ChainKey chainKey = 3; - */ - public Builder setChainKey( - org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.ChainKey.Builder builderForValue) { - if (chainKeyBuilder_ == null) { - chainKey_ = builderForValue.build(); - onChanged(); - } else { - chainKeyBuilder_.setMessage(builderForValue.build()); - } - bitField0_ |= 0x00000004; - return this; - } - /** - * optional .textsecure.SessionStructure.Chain.ChainKey chainKey = 3; - */ - public Builder mergeChainKey(org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.ChainKey value) { - if (chainKeyBuilder_ == null) { - if (((bitField0_ & 0x00000004) == 0x00000004) && - chainKey_ != org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.ChainKey.getDefaultInstance()) { - chainKey_ = - org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.ChainKey.newBuilder(chainKey_).mergeFrom(value).buildPartial(); - } else { - chainKey_ = value; - } - onChanged(); - } else { - chainKeyBuilder_.mergeFrom(value); - } - bitField0_ |= 0x00000004; - return this; - } - /** - * optional .textsecure.SessionStructure.Chain.ChainKey chainKey = 3; - */ - public Builder clearChainKey() { - if (chainKeyBuilder_ == null) { - chainKey_ = org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.ChainKey.getDefaultInstance(); - onChanged(); - } else { - chainKeyBuilder_.clear(); - } - bitField0_ = (bitField0_ & ~0x00000004); - return this; - } - /** - * optional .textsecure.SessionStructure.Chain.ChainKey chainKey = 3; - */ - public org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.ChainKey.Builder getChainKeyBuilder() { - bitField0_ |= 0x00000004; - onChanged(); - return getChainKeyFieldBuilder().getBuilder(); - } - /** - * optional .textsecure.SessionStructure.Chain.ChainKey chainKey = 3; - */ - public org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.ChainKeyOrBuilder getChainKeyOrBuilder() { - if (chainKeyBuilder_ != null) { - return chainKeyBuilder_.getMessageOrBuilder(); - } else { - return chainKey_; - } - } - /** - * optional .textsecure.SessionStructure.Chain.ChainKey chainKey = 3; - */ - private com.google.protobuf.SingleFieldBuilder< - org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.ChainKey, org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.ChainKey.Builder, org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.ChainKeyOrBuilder> - getChainKeyFieldBuilder() { - if (chainKeyBuilder_ == null) { - chainKeyBuilder_ = new com.google.protobuf.SingleFieldBuilder< - org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.ChainKey, org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.ChainKey.Builder, org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.ChainKeyOrBuilder>( - chainKey_, - getParentForChildren(), - isClean()); - chainKey_ = null; - } - return chainKeyBuilder_; - } - - // repeated .textsecure.SessionStructure.Chain.MessageKey messageKeys = 4; - private java.util.List messageKeys_ = - java.util.Collections.emptyList(); - private void ensureMessageKeysIsMutable() { - if (!((bitField0_ & 0x00000008) == 0x00000008)) { - messageKeys_ = new java.util.ArrayList(messageKeys_); - bitField0_ |= 0x00000008; - } - } - - private com.google.protobuf.RepeatedFieldBuilder< - org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.MessageKey, org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.MessageKey.Builder, org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.MessageKeyOrBuilder> messageKeysBuilder_; - - /** - * repeated .textsecure.SessionStructure.Chain.MessageKey messageKeys = 4; - */ - public java.util.List getMessageKeysList() { - if (messageKeysBuilder_ == null) { - return java.util.Collections.unmodifiableList(messageKeys_); - } else { - return messageKeysBuilder_.getMessageList(); - } - } - /** - * repeated .textsecure.SessionStructure.Chain.MessageKey messageKeys = 4; - */ - public int getMessageKeysCount() { - if (messageKeysBuilder_ == null) { - return messageKeys_.size(); - } else { - return messageKeysBuilder_.getCount(); - } - } - /** - * repeated .textsecure.SessionStructure.Chain.MessageKey messageKeys = 4; - */ - public org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.MessageKey getMessageKeys(int index) { - if (messageKeysBuilder_ == null) { - return messageKeys_.get(index); - } else { - return messageKeysBuilder_.getMessage(index); - } - } - /** - * repeated .textsecure.SessionStructure.Chain.MessageKey messageKeys = 4; - */ - public Builder setMessageKeys( - int index, org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.MessageKey value) { - if (messageKeysBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureMessageKeysIsMutable(); - messageKeys_.set(index, value); - onChanged(); - } else { - messageKeysBuilder_.setMessage(index, value); - } - return this; - } - /** - * repeated .textsecure.SessionStructure.Chain.MessageKey messageKeys = 4; - */ - public Builder setMessageKeys( - int index, org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.MessageKey.Builder builderForValue) { - if (messageKeysBuilder_ == null) { - ensureMessageKeysIsMutable(); - messageKeys_.set(index, builderForValue.build()); - onChanged(); - } else { - messageKeysBuilder_.setMessage(index, builderForValue.build()); - } - return this; - } - /** - * repeated .textsecure.SessionStructure.Chain.MessageKey messageKeys = 4; - */ - public Builder addMessageKeys(org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.MessageKey value) { - if (messageKeysBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureMessageKeysIsMutable(); - messageKeys_.add(value); - onChanged(); - } else { - messageKeysBuilder_.addMessage(value); - } - return this; - } - /** - * repeated .textsecure.SessionStructure.Chain.MessageKey messageKeys = 4; - */ - public Builder addMessageKeys( - int index, org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.MessageKey value) { - if (messageKeysBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureMessageKeysIsMutable(); - messageKeys_.add(index, value); - onChanged(); - } else { - messageKeysBuilder_.addMessage(index, value); - } - return this; - } - /** - * repeated .textsecure.SessionStructure.Chain.MessageKey messageKeys = 4; - */ - public Builder addMessageKeys( - org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.MessageKey.Builder builderForValue) { - if (messageKeysBuilder_ == null) { - ensureMessageKeysIsMutable(); - messageKeys_.add(builderForValue.build()); - onChanged(); - } else { - messageKeysBuilder_.addMessage(builderForValue.build()); - } - return this; - } - /** - * repeated .textsecure.SessionStructure.Chain.MessageKey messageKeys = 4; - */ - public Builder addMessageKeys( - int index, org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.MessageKey.Builder builderForValue) { - if (messageKeysBuilder_ == null) { - ensureMessageKeysIsMutable(); - messageKeys_.add(index, builderForValue.build()); - onChanged(); - } else { - messageKeysBuilder_.addMessage(index, builderForValue.build()); - } - return this; - } - /** - * repeated .textsecure.SessionStructure.Chain.MessageKey messageKeys = 4; - */ - public Builder addAllMessageKeys( - java.lang.Iterable values) { - if (messageKeysBuilder_ == null) { - ensureMessageKeysIsMutable(); - super.addAll(values, messageKeys_); - onChanged(); - } else { - messageKeysBuilder_.addAllMessages(values); - } - return this; - } - /** - * repeated .textsecure.SessionStructure.Chain.MessageKey messageKeys = 4; - */ - public Builder clearMessageKeys() { - if (messageKeysBuilder_ == null) { - messageKeys_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000008); - onChanged(); - } else { - messageKeysBuilder_.clear(); - } - return this; - } - /** - * repeated .textsecure.SessionStructure.Chain.MessageKey messageKeys = 4; - */ - public Builder removeMessageKeys(int index) { - if (messageKeysBuilder_ == null) { - ensureMessageKeysIsMutable(); - messageKeys_.remove(index); - onChanged(); - } else { - messageKeysBuilder_.remove(index); - } - return this; - } - /** - * repeated .textsecure.SessionStructure.Chain.MessageKey messageKeys = 4; - */ - public org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.MessageKey.Builder getMessageKeysBuilder( - int index) { - return getMessageKeysFieldBuilder().getBuilder(index); - } - /** - * repeated .textsecure.SessionStructure.Chain.MessageKey messageKeys = 4; - */ - public org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.MessageKeyOrBuilder getMessageKeysOrBuilder( - int index) { - if (messageKeysBuilder_ == null) { - return messageKeys_.get(index); } else { - return messageKeysBuilder_.getMessageOrBuilder(index); - } - } - /** - * repeated .textsecure.SessionStructure.Chain.MessageKey messageKeys = 4; - */ - public java.util.List - getMessageKeysOrBuilderList() { - if (messageKeysBuilder_ != null) { - return messageKeysBuilder_.getMessageOrBuilderList(); - } else { - return java.util.Collections.unmodifiableList(messageKeys_); - } - } - /** - * repeated .textsecure.SessionStructure.Chain.MessageKey messageKeys = 4; - */ - public org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.MessageKey.Builder addMessageKeysBuilder() { - return getMessageKeysFieldBuilder().addBuilder( - org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.MessageKey.getDefaultInstance()); - } - /** - * repeated .textsecure.SessionStructure.Chain.MessageKey messageKeys = 4; - */ - public org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.MessageKey.Builder addMessageKeysBuilder( - int index) { - return getMessageKeysFieldBuilder().addBuilder( - index, org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.MessageKey.getDefaultInstance()); - } - /** - * repeated .textsecure.SessionStructure.Chain.MessageKey messageKeys = 4; - */ - public java.util.List - getMessageKeysBuilderList() { - return getMessageKeysFieldBuilder().getBuilderList(); - } - private com.google.protobuf.RepeatedFieldBuilder< - org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.MessageKey, org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.MessageKey.Builder, org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.MessageKeyOrBuilder> - getMessageKeysFieldBuilder() { - if (messageKeysBuilder_ == null) { - messageKeysBuilder_ = new com.google.protobuf.RepeatedFieldBuilder< - org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.MessageKey, org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.MessageKey.Builder, org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.MessageKeyOrBuilder>( - messageKeys_, - ((bitField0_ & 0x00000008) == 0x00000008), - getParentForChildren(), - isClean()); - messageKeys_ = null; - } - return messageKeysBuilder_; - } - - // @@protoc_insertion_point(builder_scope:textsecure.SessionStructure.Chain) - } - - static { - defaultInstance = new Chain(true); - defaultInstance.initFields(); - } - - // @@protoc_insertion_point(class_scope:textsecure.SessionStructure.Chain) - } - - public interface PendingKeyExchangeOrBuilder - extends com.google.protobuf.MessageOrBuilder { - - // optional uint32 sequence = 1; - /** - * optional uint32 sequence = 1; - */ - boolean hasSequence(); - /** - * optional uint32 sequence = 1; - */ - int getSequence(); - - // optional bytes localBaseKey = 2; - /** - * optional bytes localBaseKey = 2; - */ - boolean hasLocalBaseKey(); - /** - * optional bytes localBaseKey = 2; - */ - com.google.protobuf.ByteString getLocalBaseKey(); - - // optional bytes localBaseKeyPrivate = 3; - /** - * optional bytes localBaseKeyPrivate = 3; - */ - boolean hasLocalBaseKeyPrivate(); - /** - * optional bytes localBaseKeyPrivate = 3; - */ - com.google.protobuf.ByteString getLocalBaseKeyPrivate(); - - // optional bytes localRatchetKey = 4; - /** - * optional bytes localRatchetKey = 4; - */ - boolean hasLocalRatchetKey(); - /** - * optional bytes localRatchetKey = 4; - */ - com.google.protobuf.ByteString getLocalRatchetKey(); - - // optional bytes localRatchetKeyPrivate = 5; - /** - * optional bytes localRatchetKeyPrivate = 5; - */ - boolean hasLocalRatchetKeyPrivate(); - /** - * optional bytes localRatchetKeyPrivate = 5; - */ - com.google.protobuf.ByteString getLocalRatchetKeyPrivate(); - - // optional bytes localIdentityKey = 7; - /** - * optional bytes localIdentityKey = 7; - */ - boolean hasLocalIdentityKey(); - /** - * optional bytes localIdentityKey = 7; - */ - com.google.protobuf.ByteString getLocalIdentityKey(); - - // optional bytes localIdentityKeyPrivate = 8; - /** - * optional bytes localIdentityKeyPrivate = 8; - */ - boolean hasLocalIdentityKeyPrivate(); - /** - * optional bytes localIdentityKeyPrivate = 8; - */ - com.google.protobuf.ByteString getLocalIdentityKeyPrivate(); - } - /** - * Protobuf type {@code textsecure.SessionStructure.PendingKeyExchange} - */ - public static final class PendingKeyExchange extends - com.google.protobuf.GeneratedMessage - implements PendingKeyExchangeOrBuilder { - // Use PendingKeyExchange.newBuilder() to construct. - private PendingKeyExchange(com.google.protobuf.GeneratedMessage.Builder builder) { - super(builder); - this.unknownFields = builder.getUnknownFields(); - } - private PendingKeyExchange(boolean noInit) { this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); } - - private static final PendingKeyExchange defaultInstance; - public static PendingKeyExchange getDefaultInstance() { - return defaultInstance; - } - - public PendingKeyExchange getDefaultInstanceForType() { - return defaultInstance; - } - - private final com.google.protobuf.UnknownFieldSet unknownFields; - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return this.unknownFields; - } - private PendingKeyExchange( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - initFields(); - int mutable_bitField0_ = 0; - com.google.protobuf.UnknownFieldSet.Builder unknownFields = - com.google.protobuf.UnknownFieldSet.newBuilder(); - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: { - if (!parseUnknownField(input, unknownFields, - extensionRegistry, tag)) { - done = true; - } - break; - } - case 8: { - bitField0_ |= 0x00000001; - sequence_ = input.readUInt32(); - break; - } - case 18: { - bitField0_ |= 0x00000002; - localBaseKey_ = input.readBytes(); - break; - } - case 26: { - bitField0_ |= 0x00000004; - localBaseKeyPrivate_ = input.readBytes(); - break; - } - case 34: { - bitField0_ |= 0x00000008; - localRatchetKey_ = input.readBytes(); - break; - } - case 42: { - bitField0_ |= 0x00000010; - localRatchetKeyPrivate_ = input.readBytes(); - break; - } - case 58: { - bitField0_ |= 0x00000020; - localIdentityKey_ = input.readBytes(); - break; - } - case 66: { - bitField0_ |= 0x00000040; - localIdentityKeyPrivate_ = input.readBytes(); - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(this); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException( - e.getMessage()).setUnfinishedMessage(this); - } finally { - this.unknownFields = unknownFields.build(); - makeExtensionsImmutable(); - } - } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return org.session.libsignal.libsignal.state.StorageProtos.internal_static_textsecure_SessionStructure_PendingKeyExchange_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return org.session.libsignal.libsignal.state.StorageProtos.internal_static_textsecure_SessionStructure_PendingKeyExchange_fieldAccessorTable - .ensureFieldAccessorsInitialized( - org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.PendingKeyExchange.class, org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.PendingKeyExchange.Builder.class); - } - - public static com.google.protobuf.Parser PARSER = - new com.google.protobuf.AbstractParser() { - public PendingKeyExchange parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return new PendingKeyExchange(input, extensionRegistry); - } - }; - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - private int bitField0_; - // optional uint32 sequence = 1; - public static final int SEQUENCE_FIELD_NUMBER = 1; - private int sequence_; - /** - * optional uint32 sequence = 1; - */ - public boolean hasSequence() { - return ((bitField0_ & 0x00000001) == 0x00000001); - } - /** - * optional uint32 sequence = 1; - */ - public int getSequence() { - return sequence_; - } - - // optional bytes localBaseKey = 2; - public static final int LOCALBASEKEY_FIELD_NUMBER = 2; - private com.google.protobuf.ByteString localBaseKey_; - /** - * optional bytes localBaseKey = 2; - */ - public boolean hasLocalBaseKey() { - return ((bitField0_ & 0x00000002) == 0x00000002); - } - /** - * optional bytes localBaseKey = 2; - */ - public com.google.protobuf.ByteString getLocalBaseKey() { - return localBaseKey_; - } - - // optional bytes localBaseKeyPrivate = 3; - public static final int LOCALBASEKEYPRIVATE_FIELD_NUMBER = 3; - private com.google.protobuf.ByteString localBaseKeyPrivate_; - /** - * optional bytes localBaseKeyPrivate = 3; - */ - public boolean hasLocalBaseKeyPrivate() { - return ((bitField0_ & 0x00000004) == 0x00000004); - } - /** - * optional bytes localBaseKeyPrivate = 3; - */ - public com.google.protobuf.ByteString getLocalBaseKeyPrivate() { - return localBaseKeyPrivate_; - } - - // optional bytes localRatchetKey = 4; - public static final int LOCALRATCHETKEY_FIELD_NUMBER = 4; - private com.google.protobuf.ByteString localRatchetKey_; - /** - * optional bytes localRatchetKey = 4; - */ - public boolean hasLocalRatchetKey() { - return ((bitField0_ & 0x00000008) == 0x00000008); - } - /** - * optional bytes localRatchetKey = 4; - */ - public com.google.protobuf.ByteString getLocalRatchetKey() { - return localRatchetKey_; - } - - // optional bytes localRatchetKeyPrivate = 5; - public static final int LOCALRATCHETKEYPRIVATE_FIELD_NUMBER = 5; - private com.google.protobuf.ByteString localRatchetKeyPrivate_; - /** - * optional bytes localRatchetKeyPrivate = 5; - */ - public boolean hasLocalRatchetKeyPrivate() { - return ((bitField0_ & 0x00000010) == 0x00000010); - } - /** - * optional bytes localRatchetKeyPrivate = 5; - */ - public com.google.protobuf.ByteString getLocalRatchetKeyPrivate() { - return localRatchetKeyPrivate_; - } - - // optional bytes localIdentityKey = 7; - public static final int LOCALIDENTITYKEY_FIELD_NUMBER = 7; - private com.google.protobuf.ByteString localIdentityKey_; - /** - * optional bytes localIdentityKey = 7; - */ - public boolean hasLocalIdentityKey() { - return ((bitField0_ & 0x00000020) == 0x00000020); - } - /** - * optional bytes localIdentityKey = 7; - */ - public com.google.protobuf.ByteString getLocalIdentityKey() { - return localIdentityKey_; - } - - // optional bytes localIdentityKeyPrivate = 8; - public static final int LOCALIDENTITYKEYPRIVATE_FIELD_NUMBER = 8; - private com.google.protobuf.ByteString localIdentityKeyPrivate_; - /** - * optional bytes localIdentityKeyPrivate = 8; - */ - public boolean hasLocalIdentityKeyPrivate() { - return ((bitField0_ & 0x00000040) == 0x00000040); - } - /** - * optional bytes localIdentityKeyPrivate = 8; - */ - public com.google.protobuf.ByteString getLocalIdentityKeyPrivate() { - return localIdentityKeyPrivate_; - } - - private void initFields() { - sequence_ = 0; - localBaseKey_ = com.google.protobuf.ByteString.EMPTY; - localBaseKeyPrivate_ = com.google.protobuf.ByteString.EMPTY; - localRatchetKey_ = com.google.protobuf.ByteString.EMPTY; - localRatchetKeyPrivate_ = com.google.protobuf.ByteString.EMPTY; - localIdentityKey_ = com.google.protobuf.ByteString.EMPTY; - localIdentityKeyPrivate_ = com.google.protobuf.ByteString.EMPTY; - } - private byte memoizedIsInitialized = -1; - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized != -1) return isInitialized == 1; - - memoizedIsInitialized = 1; - return true; - } - - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - getSerializedSize(); - if (((bitField0_ & 0x00000001) == 0x00000001)) { - output.writeUInt32(1, sequence_); - } - if (((bitField0_ & 0x00000002) == 0x00000002)) { - output.writeBytes(2, localBaseKey_); - } - if (((bitField0_ & 0x00000004) == 0x00000004)) { - output.writeBytes(3, localBaseKeyPrivate_); - } - if (((bitField0_ & 0x00000008) == 0x00000008)) { - output.writeBytes(4, localRatchetKey_); - } - if (((bitField0_ & 0x00000010) == 0x00000010)) { - output.writeBytes(5, localRatchetKeyPrivate_); - } - if (((bitField0_ & 0x00000020) == 0x00000020)) { - output.writeBytes(7, localIdentityKey_); - } - if (((bitField0_ & 0x00000040) == 0x00000040)) { - output.writeBytes(8, localIdentityKeyPrivate_); - } - getUnknownFields().writeTo(output); - } - - private int memoizedSerializedSize = -1; - public int getSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (((bitField0_ & 0x00000001) == 0x00000001)) { - size += com.google.protobuf.CodedOutputStream - .computeUInt32Size(1, sequence_); - } - if (((bitField0_ & 0x00000002) == 0x00000002)) { - size += com.google.protobuf.CodedOutputStream - .computeBytesSize(2, localBaseKey_); - } - if (((bitField0_ & 0x00000004) == 0x00000004)) { - size += com.google.protobuf.CodedOutputStream - .computeBytesSize(3, localBaseKeyPrivate_); - } - if (((bitField0_ & 0x00000008) == 0x00000008)) { - size += com.google.protobuf.CodedOutputStream - .computeBytesSize(4, localRatchetKey_); - } - if (((bitField0_ & 0x00000010) == 0x00000010)) { - size += com.google.protobuf.CodedOutputStream - .computeBytesSize(5, localRatchetKeyPrivate_); - } - if (((bitField0_ & 0x00000020) == 0x00000020)) { - size += com.google.protobuf.CodedOutputStream - .computeBytesSize(7, localIdentityKey_); - } - if (((bitField0_ & 0x00000040) == 0x00000040)) { - size += com.google.protobuf.CodedOutputStream - .computeBytesSize(8, localIdentityKeyPrivate_); - } - size += getUnknownFields().getSerializedSize(); - memoizedSerializedSize = size; - return size; - } - - private static final long serialVersionUID = 0L; - @java.lang.Override - protected java.lang.Object writeReplace() - throws java.io.ObjectStreamException { - return super.writeReplace(); - } - - public static org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.PendingKeyExchange parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.PendingKeyExchange parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.PendingKeyExchange parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.PendingKeyExchange parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.PendingKeyExchange parseFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.PendingKeyExchange parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - public static org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.PendingKeyExchange parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input); - } - public static org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.PendingKeyExchange parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input, extensionRegistry); - } - public static org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.PendingKeyExchange parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.PendingKeyExchange parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - - public static Builder newBuilder() { return Builder.create(); } - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder(org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.PendingKeyExchange prototype) { - return newBuilder().mergeFrom(prototype); - } - public Builder toBuilder() { return newBuilder(this); } - - @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * Protobuf type {@code textsecure.SessionStructure.PendingKeyExchange} - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessage.Builder - implements org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.PendingKeyExchangeOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return org.session.libsignal.libsignal.state.StorageProtos.internal_static_textsecure_SessionStructure_PendingKeyExchange_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return org.session.libsignal.libsignal.state.StorageProtos.internal_static_textsecure_SessionStructure_PendingKeyExchange_fieldAccessorTable - .ensureFieldAccessorsInitialized( - org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.PendingKeyExchange.class, org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.PendingKeyExchange.Builder.class); - } - - // Construct using org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.PendingKeyExchange.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { - } - } - private static Builder create() { - return new Builder(); - } - - public Builder clear() { - super.clear(); - sequence_ = 0; - bitField0_ = (bitField0_ & ~0x00000001); - localBaseKey_ = com.google.protobuf.ByteString.EMPTY; - bitField0_ = (bitField0_ & ~0x00000002); - localBaseKeyPrivate_ = com.google.protobuf.ByteString.EMPTY; - bitField0_ = (bitField0_ & ~0x00000004); - localRatchetKey_ = com.google.protobuf.ByteString.EMPTY; - bitField0_ = (bitField0_ & ~0x00000008); - localRatchetKeyPrivate_ = com.google.protobuf.ByteString.EMPTY; - bitField0_ = (bitField0_ & ~0x00000010); - localIdentityKey_ = com.google.protobuf.ByteString.EMPTY; - bitField0_ = (bitField0_ & ~0x00000020); - localIdentityKeyPrivate_ = com.google.protobuf.ByteString.EMPTY; - bitField0_ = (bitField0_ & ~0x00000040); - return this; - } - - public Builder clone() { - return create().mergeFrom(buildPartial()); - } - - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return org.session.libsignal.libsignal.state.StorageProtos.internal_static_textsecure_SessionStructure_PendingKeyExchange_descriptor; - } - - public org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.PendingKeyExchange getDefaultInstanceForType() { - return org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.PendingKeyExchange.getDefaultInstance(); - } - - public org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.PendingKeyExchange build() { - org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.PendingKeyExchange result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - public org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.PendingKeyExchange buildPartial() { - org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.PendingKeyExchange result = new org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.PendingKeyExchange(this); - int from_bitField0_ = bitField0_; - int to_bitField0_ = 0; - if (((from_bitField0_ & 0x00000001) == 0x00000001)) { - to_bitField0_ |= 0x00000001; - } - result.sequence_ = sequence_; - if (((from_bitField0_ & 0x00000002) == 0x00000002)) { - to_bitField0_ |= 0x00000002; - } - result.localBaseKey_ = localBaseKey_; - if (((from_bitField0_ & 0x00000004) == 0x00000004)) { - to_bitField0_ |= 0x00000004; - } - result.localBaseKeyPrivate_ = localBaseKeyPrivate_; - if (((from_bitField0_ & 0x00000008) == 0x00000008)) { - to_bitField0_ |= 0x00000008; - } - result.localRatchetKey_ = localRatchetKey_; - if (((from_bitField0_ & 0x00000010) == 0x00000010)) { - to_bitField0_ |= 0x00000010; - } - result.localRatchetKeyPrivate_ = localRatchetKeyPrivate_; - if (((from_bitField0_ & 0x00000020) == 0x00000020)) { - to_bitField0_ |= 0x00000020; - } - result.localIdentityKey_ = localIdentityKey_; - if (((from_bitField0_ & 0x00000040) == 0x00000040)) { - to_bitField0_ |= 0x00000040; - } - result.localIdentityKeyPrivate_ = localIdentityKeyPrivate_; - result.bitField0_ = to_bitField0_; - onBuilt(); - return result; - } - - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.PendingKeyExchange) { - return mergeFrom((org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.PendingKeyExchange)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.PendingKeyExchange other) { - if (other == org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.PendingKeyExchange.getDefaultInstance()) return this; - if (other.hasSequence()) { - setSequence(other.getSequence()); - } - if (other.hasLocalBaseKey()) { - setLocalBaseKey(other.getLocalBaseKey()); - } - if (other.hasLocalBaseKeyPrivate()) { - setLocalBaseKeyPrivate(other.getLocalBaseKeyPrivate()); - } - if (other.hasLocalRatchetKey()) { - setLocalRatchetKey(other.getLocalRatchetKey()); - } - if (other.hasLocalRatchetKeyPrivate()) { - setLocalRatchetKeyPrivate(other.getLocalRatchetKeyPrivate()); - } - if (other.hasLocalIdentityKey()) { - setLocalIdentityKey(other.getLocalIdentityKey()); - } - if (other.hasLocalIdentityKeyPrivate()) { - setLocalIdentityKeyPrivate(other.getLocalIdentityKeyPrivate()); - } - this.mergeUnknownFields(other.getUnknownFields()); - return this; - } - - public final boolean isInitialized() { - return true; - } - - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.PendingKeyExchange parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.PendingKeyExchange) e.getUnfinishedMessage(); - throw e; - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - private int bitField0_; - - // optional uint32 sequence = 1; - private int sequence_ ; - /** - * optional uint32 sequence = 1; - */ - public boolean hasSequence() { - return ((bitField0_ & 0x00000001) == 0x00000001); - } - /** - * optional uint32 sequence = 1; - */ - public int getSequence() { - return sequence_; - } - /** - * optional uint32 sequence = 1; - */ - public Builder setSequence(int value) { - bitField0_ |= 0x00000001; - sequence_ = value; - onChanged(); - return this; - } - /** - * optional uint32 sequence = 1; - */ - public Builder clearSequence() { - bitField0_ = (bitField0_ & ~0x00000001); - sequence_ = 0; - onChanged(); - return this; - } - - // optional bytes localBaseKey = 2; - private com.google.protobuf.ByteString localBaseKey_ = com.google.protobuf.ByteString.EMPTY; - /** - * optional bytes localBaseKey = 2; - */ - public boolean hasLocalBaseKey() { - return ((bitField0_ & 0x00000002) == 0x00000002); - } - /** - * optional bytes localBaseKey = 2; - */ - public com.google.protobuf.ByteString getLocalBaseKey() { - return localBaseKey_; - } - /** - * optional bytes localBaseKey = 2; - */ - public Builder setLocalBaseKey(com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - bitField0_ |= 0x00000002; - localBaseKey_ = value; - onChanged(); - return this; - } - /** - * optional bytes localBaseKey = 2; - */ - public Builder clearLocalBaseKey() { - bitField0_ = (bitField0_ & ~0x00000002); - localBaseKey_ = getDefaultInstance().getLocalBaseKey(); - onChanged(); - return this; - } - - // optional bytes localBaseKeyPrivate = 3; - private com.google.protobuf.ByteString localBaseKeyPrivate_ = com.google.protobuf.ByteString.EMPTY; - /** - * optional bytes localBaseKeyPrivate = 3; - */ - public boolean hasLocalBaseKeyPrivate() { - return ((bitField0_ & 0x00000004) == 0x00000004); - } - /** - * optional bytes localBaseKeyPrivate = 3; - */ - public com.google.protobuf.ByteString getLocalBaseKeyPrivate() { - return localBaseKeyPrivate_; - } - /** - * optional bytes localBaseKeyPrivate = 3; - */ - public Builder setLocalBaseKeyPrivate(com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - bitField0_ |= 0x00000004; - localBaseKeyPrivate_ = value; - onChanged(); - return this; - } - /** - * optional bytes localBaseKeyPrivate = 3; - */ - public Builder clearLocalBaseKeyPrivate() { - bitField0_ = (bitField0_ & ~0x00000004); - localBaseKeyPrivate_ = getDefaultInstance().getLocalBaseKeyPrivate(); - onChanged(); - return this; - } - - // optional bytes localRatchetKey = 4; - private com.google.protobuf.ByteString localRatchetKey_ = com.google.protobuf.ByteString.EMPTY; - /** - * optional bytes localRatchetKey = 4; - */ - public boolean hasLocalRatchetKey() { - return ((bitField0_ & 0x00000008) == 0x00000008); - } - /** - * optional bytes localRatchetKey = 4; - */ - public com.google.protobuf.ByteString getLocalRatchetKey() { - return localRatchetKey_; - } - /** - * optional bytes localRatchetKey = 4; - */ - public Builder setLocalRatchetKey(com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - bitField0_ |= 0x00000008; - localRatchetKey_ = value; - onChanged(); - return this; - } - /** - * optional bytes localRatchetKey = 4; - */ - public Builder clearLocalRatchetKey() { - bitField0_ = (bitField0_ & ~0x00000008); - localRatchetKey_ = getDefaultInstance().getLocalRatchetKey(); - onChanged(); - return this; - } - - // optional bytes localRatchetKeyPrivate = 5; - private com.google.protobuf.ByteString localRatchetKeyPrivate_ = com.google.protobuf.ByteString.EMPTY; - /** - * optional bytes localRatchetKeyPrivate = 5; - */ - public boolean hasLocalRatchetKeyPrivate() { - return ((bitField0_ & 0x00000010) == 0x00000010); - } - /** - * optional bytes localRatchetKeyPrivate = 5; - */ - public com.google.protobuf.ByteString getLocalRatchetKeyPrivate() { - return localRatchetKeyPrivate_; - } - /** - * optional bytes localRatchetKeyPrivate = 5; - */ - public Builder setLocalRatchetKeyPrivate(com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - bitField0_ |= 0x00000010; - localRatchetKeyPrivate_ = value; - onChanged(); - return this; - } - /** - * optional bytes localRatchetKeyPrivate = 5; - */ - public Builder clearLocalRatchetKeyPrivate() { - bitField0_ = (bitField0_ & ~0x00000010); - localRatchetKeyPrivate_ = getDefaultInstance().getLocalRatchetKeyPrivate(); - onChanged(); - return this; - } - - // optional bytes localIdentityKey = 7; - private com.google.protobuf.ByteString localIdentityKey_ = com.google.protobuf.ByteString.EMPTY; - /** - * optional bytes localIdentityKey = 7; - */ - public boolean hasLocalIdentityKey() { - return ((bitField0_ & 0x00000020) == 0x00000020); - } - /** - * optional bytes localIdentityKey = 7; - */ - public com.google.protobuf.ByteString getLocalIdentityKey() { - return localIdentityKey_; - } - /** - * optional bytes localIdentityKey = 7; - */ - public Builder setLocalIdentityKey(com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - bitField0_ |= 0x00000020; - localIdentityKey_ = value; - onChanged(); - return this; - } - /** - * optional bytes localIdentityKey = 7; - */ - public Builder clearLocalIdentityKey() { - bitField0_ = (bitField0_ & ~0x00000020); - localIdentityKey_ = getDefaultInstance().getLocalIdentityKey(); - onChanged(); - return this; - } - - // optional bytes localIdentityKeyPrivate = 8; - private com.google.protobuf.ByteString localIdentityKeyPrivate_ = com.google.protobuf.ByteString.EMPTY; - /** - * optional bytes localIdentityKeyPrivate = 8; - */ - public boolean hasLocalIdentityKeyPrivate() { - return ((bitField0_ & 0x00000040) == 0x00000040); - } - /** - * optional bytes localIdentityKeyPrivate = 8; - */ - public com.google.protobuf.ByteString getLocalIdentityKeyPrivate() { - return localIdentityKeyPrivate_; - } - /** - * optional bytes localIdentityKeyPrivate = 8; - */ - public Builder setLocalIdentityKeyPrivate(com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - bitField0_ |= 0x00000040; - localIdentityKeyPrivate_ = value; - onChanged(); - return this; - } - /** - * optional bytes localIdentityKeyPrivate = 8; - */ - public Builder clearLocalIdentityKeyPrivate() { - bitField0_ = (bitField0_ & ~0x00000040); - localIdentityKeyPrivate_ = getDefaultInstance().getLocalIdentityKeyPrivate(); - onChanged(); - return this; - } - - // @@protoc_insertion_point(builder_scope:textsecure.SessionStructure.PendingKeyExchange) - } - - static { - defaultInstance = new PendingKeyExchange(true); - defaultInstance.initFields(); - } - - // @@protoc_insertion_point(class_scope:textsecure.SessionStructure.PendingKeyExchange) - } - - public interface PendingPreKeyOrBuilder - extends com.google.protobuf.MessageOrBuilder { - - // optional uint32 preKeyId = 1; - /** - * optional uint32 preKeyId = 1; - */ - boolean hasPreKeyId(); - /** - * optional uint32 preKeyId = 1; - */ - int getPreKeyId(); - - // optional int32 signedPreKeyId = 3; - /** - * optional int32 signedPreKeyId = 3; - */ - boolean hasSignedPreKeyId(); - /** - * optional int32 signedPreKeyId = 3; - */ - int getSignedPreKeyId(); - - // optional bytes baseKey = 2; - /** - * optional bytes baseKey = 2; - */ - boolean hasBaseKey(); - /** - * optional bytes baseKey = 2; - */ - com.google.protobuf.ByteString getBaseKey(); - } - /** - * Protobuf type {@code textsecure.SessionStructure.PendingPreKey} - */ - public static final class PendingPreKey extends - com.google.protobuf.GeneratedMessage - implements PendingPreKeyOrBuilder { - // Use PendingPreKey.newBuilder() to construct. - private PendingPreKey(com.google.protobuf.GeneratedMessage.Builder builder) { - super(builder); - this.unknownFields = builder.getUnknownFields(); - } - private PendingPreKey(boolean noInit) { this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); } - - private static final PendingPreKey defaultInstance; - public static PendingPreKey getDefaultInstance() { - return defaultInstance; - } - - public PendingPreKey getDefaultInstanceForType() { - return defaultInstance; - } - - private final com.google.protobuf.UnknownFieldSet unknownFields; - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return this.unknownFields; - } - private PendingPreKey( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - initFields(); - int mutable_bitField0_ = 0; - com.google.protobuf.UnknownFieldSet.Builder unknownFields = - com.google.protobuf.UnknownFieldSet.newBuilder(); - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: { - if (!parseUnknownField(input, unknownFields, - extensionRegistry, tag)) { - done = true; - } - break; - } - case 8: { - bitField0_ |= 0x00000001; - preKeyId_ = input.readUInt32(); - break; - } - case 18: { - bitField0_ |= 0x00000004; - baseKey_ = input.readBytes(); - break; - } - case 24: { - bitField0_ |= 0x00000002; - signedPreKeyId_ = input.readInt32(); - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(this); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException( - e.getMessage()).setUnfinishedMessage(this); - } finally { - this.unknownFields = unknownFields.build(); - makeExtensionsImmutable(); - } - } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return org.session.libsignal.libsignal.state.StorageProtos.internal_static_textsecure_SessionStructure_PendingPreKey_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return org.session.libsignal.libsignal.state.StorageProtos.internal_static_textsecure_SessionStructure_PendingPreKey_fieldAccessorTable - .ensureFieldAccessorsInitialized( - org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.PendingPreKey.class, org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.PendingPreKey.Builder.class); - } - - public static com.google.protobuf.Parser PARSER = - new com.google.protobuf.AbstractParser() { - public PendingPreKey parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return new PendingPreKey(input, extensionRegistry); - } - }; - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - private int bitField0_; - // optional uint32 preKeyId = 1; - public static final int PREKEYID_FIELD_NUMBER = 1; - private int preKeyId_; - /** - * optional uint32 preKeyId = 1; - */ - public boolean hasPreKeyId() { - return ((bitField0_ & 0x00000001) == 0x00000001); - } - /** - * optional uint32 preKeyId = 1; - */ - public int getPreKeyId() { - return preKeyId_; - } - - // optional int32 signedPreKeyId = 3; - public static final int SIGNEDPREKEYID_FIELD_NUMBER = 3; - private int signedPreKeyId_; - /** - * optional int32 signedPreKeyId = 3; - */ - public boolean hasSignedPreKeyId() { - return ((bitField0_ & 0x00000002) == 0x00000002); - } - /** - * optional int32 signedPreKeyId = 3; - */ - public int getSignedPreKeyId() { - return signedPreKeyId_; - } - - // optional bytes baseKey = 2; - public static final int BASEKEY_FIELD_NUMBER = 2; - private com.google.protobuf.ByteString baseKey_; - /** - * optional bytes baseKey = 2; - */ - public boolean hasBaseKey() { - return ((bitField0_ & 0x00000004) == 0x00000004); - } - /** - * optional bytes baseKey = 2; - */ - public com.google.protobuf.ByteString getBaseKey() { - return baseKey_; - } - - private void initFields() { - preKeyId_ = 0; - signedPreKeyId_ = 0; - baseKey_ = com.google.protobuf.ByteString.EMPTY; - } - private byte memoizedIsInitialized = -1; - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized != -1) return isInitialized == 1; - - memoizedIsInitialized = 1; - return true; - } - - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - getSerializedSize(); - if (((bitField0_ & 0x00000001) == 0x00000001)) { - output.writeUInt32(1, preKeyId_); - } - if (((bitField0_ & 0x00000004) == 0x00000004)) { - output.writeBytes(2, baseKey_); - } - if (((bitField0_ & 0x00000002) == 0x00000002)) { - output.writeInt32(3, signedPreKeyId_); - } - getUnknownFields().writeTo(output); - } - - private int memoizedSerializedSize = -1; - public int getSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (((bitField0_ & 0x00000001) == 0x00000001)) { - size += com.google.protobuf.CodedOutputStream - .computeUInt32Size(1, preKeyId_); - } - if (((bitField0_ & 0x00000004) == 0x00000004)) { - size += com.google.protobuf.CodedOutputStream - .computeBytesSize(2, baseKey_); - } - if (((bitField0_ & 0x00000002) == 0x00000002)) { - size += com.google.protobuf.CodedOutputStream - .computeInt32Size(3, signedPreKeyId_); - } - size += getUnknownFields().getSerializedSize(); - memoizedSerializedSize = size; - return size; - } - - private static final long serialVersionUID = 0L; - @java.lang.Override - protected java.lang.Object writeReplace() - throws java.io.ObjectStreamException { - return super.writeReplace(); - } - - public static org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.PendingPreKey parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.PendingPreKey parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.PendingPreKey parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.PendingPreKey parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.PendingPreKey parseFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.PendingPreKey parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - public static org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.PendingPreKey parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input); - } - public static org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.PendingPreKey parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input, extensionRegistry); - } - public static org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.PendingPreKey parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.PendingPreKey parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - - public static Builder newBuilder() { return Builder.create(); } - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder(org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.PendingPreKey prototype) { - return newBuilder().mergeFrom(prototype); - } - public Builder toBuilder() { return newBuilder(this); } - - @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * Protobuf type {@code textsecure.SessionStructure.PendingPreKey} - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessage.Builder - implements org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.PendingPreKeyOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return org.session.libsignal.libsignal.state.StorageProtos.internal_static_textsecure_SessionStructure_PendingPreKey_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return org.session.libsignal.libsignal.state.StorageProtos.internal_static_textsecure_SessionStructure_PendingPreKey_fieldAccessorTable - .ensureFieldAccessorsInitialized( - org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.PendingPreKey.class, org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.PendingPreKey.Builder.class); - } - - // Construct using org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.PendingPreKey.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { - } - } - private static Builder create() { - return new Builder(); - } - - public Builder clear() { - super.clear(); - preKeyId_ = 0; - bitField0_ = (bitField0_ & ~0x00000001); - signedPreKeyId_ = 0; - bitField0_ = (bitField0_ & ~0x00000002); - baseKey_ = com.google.protobuf.ByteString.EMPTY; - bitField0_ = (bitField0_ & ~0x00000004); - return this; - } - - public Builder clone() { - return create().mergeFrom(buildPartial()); - } - - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return org.session.libsignal.libsignal.state.StorageProtos.internal_static_textsecure_SessionStructure_PendingPreKey_descriptor; - } - - public org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.PendingPreKey getDefaultInstanceForType() { - return org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.PendingPreKey.getDefaultInstance(); - } - - public org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.PendingPreKey build() { - org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.PendingPreKey result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - public org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.PendingPreKey buildPartial() { - org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.PendingPreKey result = new org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.PendingPreKey(this); - int from_bitField0_ = bitField0_; - int to_bitField0_ = 0; - if (((from_bitField0_ & 0x00000001) == 0x00000001)) { - to_bitField0_ |= 0x00000001; - } - result.preKeyId_ = preKeyId_; - if (((from_bitField0_ & 0x00000002) == 0x00000002)) { - to_bitField0_ |= 0x00000002; - } - result.signedPreKeyId_ = signedPreKeyId_; - if (((from_bitField0_ & 0x00000004) == 0x00000004)) { - to_bitField0_ |= 0x00000004; - } - result.baseKey_ = baseKey_; - result.bitField0_ = to_bitField0_; - onBuilt(); - return result; - } - - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.PendingPreKey) { - return mergeFrom((org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.PendingPreKey)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.PendingPreKey other) { - if (other == org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.PendingPreKey.getDefaultInstance()) return this; - if (other.hasPreKeyId()) { - setPreKeyId(other.getPreKeyId()); - } - if (other.hasSignedPreKeyId()) { - setSignedPreKeyId(other.getSignedPreKeyId()); - } - if (other.hasBaseKey()) { - setBaseKey(other.getBaseKey()); - } - this.mergeUnknownFields(other.getUnknownFields()); - return this; - } - - public final boolean isInitialized() { - return true; - } - - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.PendingPreKey parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.PendingPreKey) e.getUnfinishedMessage(); - throw e; - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - private int bitField0_; - - // optional uint32 preKeyId = 1; - private int preKeyId_ ; - /** - * optional uint32 preKeyId = 1; - */ - public boolean hasPreKeyId() { - return ((bitField0_ & 0x00000001) == 0x00000001); - } - /** - * optional uint32 preKeyId = 1; - */ - public int getPreKeyId() { - return preKeyId_; - } - /** - * optional uint32 preKeyId = 1; - */ - public Builder setPreKeyId(int value) { - bitField0_ |= 0x00000001; - preKeyId_ = value; - onChanged(); - return this; - } - /** - * optional uint32 preKeyId = 1; - */ - public Builder clearPreKeyId() { - bitField0_ = (bitField0_ & ~0x00000001); - preKeyId_ = 0; - onChanged(); - return this; - } - - // optional int32 signedPreKeyId = 3; - private int signedPreKeyId_ ; - /** - * optional int32 signedPreKeyId = 3; - */ - public boolean hasSignedPreKeyId() { - return ((bitField0_ & 0x00000002) == 0x00000002); - } - /** - * optional int32 signedPreKeyId = 3; - */ - public int getSignedPreKeyId() { - return signedPreKeyId_; - } - /** - * optional int32 signedPreKeyId = 3; - */ - public Builder setSignedPreKeyId(int value) { - bitField0_ |= 0x00000002; - signedPreKeyId_ = value; - onChanged(); - return this; - } - /** - * optional int32 signedPreKeyId = 3; - */ - public Builder clearSignedPreKeyId() { - bitField0_ = (bitField0_ & ~0x00000002); - signedPreKeyId_ = 0; - onChanged(); - return this; - } - - // optional bytes baseKey = 2; - private com.google.protobuf.ByteString baseKey_ = com.google.protobuf.ByteString.EMPTY; - /** - * optional bytes baseKey = 2; - */ - public boolean hasBaseKey() { - return ((bitField0_ & 0x00000004) == 0x00000004); - } - /** - * optional bytes baseKey = 2; - */ - public com.google.protobuf.ByteString getBaseKey() { - return baseKey_; - } - /** - * optional bytes baseKey = 2; - */ - public Builder setBaseKey(com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - bitField0_ |= 0x00000004; - baseKey_ = value; - onChanged(); - return this; - } - /** - * optional bytes baseKey = 2; - */ - public Builder clearBaseKey() { - bitField0_ = (bitField0_ & ~0x00000004); - baseKey_ = getDefaultInstance().getBaseKey(); - onChanged(); - return this; - } - - // @@protoc_insertion_point(builder_scope:textsecure.SessionStructure.PendingPreKey) - } - - static { - defaultInstance = new PendingPreKey(true); - defaultInstance.initFields(); - } - - // @@protoc_insertion_point(class_scope:textsecure.SessionStructure.PendingPreKey) - } - - private int bitField0_; - // optional uint32 sessionVersion = 1; - public static final int SESSIONVERSION_FIELD_NUMBER = 1; - private int sessionVersion_; - /** - * optional uint32 sessionVersion = 1; - */ - public boolean hasSessionVersion() { - return ((bitField0_ & 0x00000001) == 0x00000001); - } - /** - * optional uint32 sessionVersion = 1; - */ - public int getSessionVersion() { - return sessionVersion_; - } - - // optional bytes localIdentityPublic = 2; - public static final int LOCALIDENTITYPUBLIC_FIELD_NUMBER = 2; - private com.google.protobuf.ByteString localIdentityPublic_; - /** - * optional bytes localIdentityPublic = 2; - */ - public boolean hasLocalIdentityPublic() { - return ((bitField0_ & 0x00000002) == 0x00000002); - } - /** - * optional bytes localIdentityPublic = 2; - */ - public com.google.protobuf.ByteString getLocalIdentityPublic() { - return localIdentityPublic_; - } - - // optional bytes remoteIdentityPublic = 3; - public static final int REMOTEIDENTITYPUBLIC_FIELD_NUMBER = 3; - private com.google.protobuf.ByteString remoteIdentityPublic_; - /** - * optional bytes remoteIdentityPublic = 3; - */ - public boolean hasRemoteIdentityPublic() { - return ((bitField0_ & 0x00000004) == 0x00000004); - } - /** - * optional bytes remoteIdentityPublic = 3; - */ - public com.google.protobuf.ByteString getRemoteIdentityPublic() { - return remoteIdentityPublic_; - } - - // optional bytes rootKey = 4; - public static final int ROOTKEY_FIELD_NUMBER = 4; - private com.google.protobuf.ByteString rootKey_; - /** - * optional bytes rootKey = 4; - */ - public boolean hasRootKey() { - return ((bitField0_ & 0x00000008) == 0x00000008); - } - /** - * optional bytes rootKey = 4; - */ - public com.google.protobuf.ByteString getRootKey() { - return rootKey_; - } - - // optional uint32 previousCounter = 5; - public static final int PREVIOUSCOUNTER_FIELD_NUMBER = 5; - private int previousCounter_; - /** - * optional uint32 previousCounter = 5; - */ - public boolean hasPreviousCounter() { - return ((bitField0_ & 0x00000010) == 0x00000010); - } - /** - * optional uint32 previousCounter = 5; - */ - public int getPreviousCounter() { - return previousCounter_; - } - - // optional .textsecure.SessionStructure.Chain senderChain = 6; - public static final int SENDERCHAIN_FIELD_NUMBER = 6; - private org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain senderChain_; - /** - * optional .textsecure.SessionStructure.Chain senderChain = 6; - */ - public boolean hasSenderChain() { - return ((bitField0_ & 0x00000020) == 0x00000020); - } - /** - * optional .textsecure.SessionStructure.Chain senderChain = 6; - */ - public org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain getSenderChain() { - return senderChain_; - } - /** - * optional .textsecure.SessionStructure.Chain senderChain = 6; - */ - public org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.ChainOrBuilder getSenderChainOrBuilder() { - return senderChain_; - } - - // repeated .textsecure.SessionStructure.Chain receiverChains = 7; - public static final int RECEIVERCHAINS_FIELD_NUMBER = 7; - private java.util.List receiverChains_; - /** - * repeated .textsecure.SessionStructure.Chain receiverChains = 7; - */ - public java.util.List getReceiverChainsList() { - return receiverChains_; - } - /** - * repeated .textsecure.SessionStructure.Chain receiverChains = 7; - */ - public java.util.List - getReceiverChainsOrBuilderList() { - return receiverChains_; - } - /** - * repeated .textsecure.SessionStructure.Chain receiverChains = 7; - */ - public int getReceiverChainsCount() { - return receiverChains_.size(); - } - /** - * repeated .textsecure.SessionStructure.Chain receiverChains = 7; - */ - public org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain getReceiverChains(int index) { - return receiverChains_.get(index); - } - /** - * repeated .textsecure.SessionStructure.Chain receiverChains = 7; - */ - public org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.ChainOrBuilder getReceiverChainsOrBuilder( - int index) { - return receiverChains_.get(index); - } - - // optional .textsecure.SessionStructure.PendingKeyExchange pendingKeyExchange = 8; - public static final int PENDINGKEYEXCHANGE_FIELD_NUMBER = 8; - private org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.PendingKeyExchange pendingKeyExchange_; - /** - * optional .textsecure.SessionStructure.PendingKeyExchange pendingKeyExchange = 8; - */ - public boolean hasPendingKeyExchange() { - return ((bitField0_ & 0x00000040) == 0x00000040); - } - /** - * optional .textsecure.SessionStructure.PendingKeyExchange pendingKeyExchange = 8; - */ - public org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.PendingKeyExchange getPendingKeyExchange() { - return pendingKeyExchange_; - } - /** - * optional .textsecure.SessionStructure.PendingKeyExchange pendingKeyExchange = 8; - */ - public org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.PendingKeyExchangeOrBuilder getPendingKeyExchangeOrBuilder() { - return pendingKeyExchange_; - } - - // optional .textsecure.SessionStructure.PendingPreKey pendingPreKey = 9; - public static final int PENDINGPREKEY_FIELD_NUMBER = 9; - private org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.PendingPreKey pendingPreKey_; - /** - * optional .textsecure.SessionStructure.PendingPreKey pendingPreKey = 9; - */ - public boolean hasPendingPreKey() { - return ((bitField0_ & 0x00000080) == 0x00000080); - } - /** - * optional .textsecure.SessionStructure.PendingPreKey pendingPreKey = 9; - */ - public org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.PendingPreKey getPendingPreKey() { - return pendingPreKey_; - } - /** - * optional .textsecure.SessionStructure.PendingPreKey pendingPreKey = 9; - */ - public org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.PendingPreKeyOrBuilder getPendingPreKeyOrBuilder() { - return pendingPreKey_; - } - - // optional uint32 remoteRegistrationId = 10; - public static final int REMOTEREGISTRATIONID_FIELD_NUMBER = 10; - private int remoteRegistrationId_; - /** - * optional uint32 remoteRegistrationId = 10; - */ - public boolean hasRemoteRegistrationId() { - return ((bitField0_ & 0x00000100) == 0x00000100); - } - /** - * optional uint32 remoteRegistrationId = 10; - */ - public int getRemoteRegistrationId() { - return remoteRegistrationId_; - } - - // optional uint32 localRegistrationId = 11; - public static final int LOCALREGISTRATIONID_FIELD_NUMBER = 11; - private int localRegistrationId_; - /** - * optional uint32 localRegistrationId = 11; - */ - public boolean hasLocalRegistrationId() { - return ((bitField0_ & 0x00000200) == 0x00000200); - } - /** - * optional uint32 localRegistrationId = 11; - */ - public int getLocalRegistrationId() { - return localRegistrationId_; - } - - // optional bool needsRefresh = 12; - public static final int NEEDSREFRESH_FIELD_NUMBER = 12; - private boolean needsRefresh_; - /** - * optional bool needsRefresh = 12; - */ - public boolean hasNeedsRefresh() { - return ((bitField0_ & 0x00000400) == 0x00000400); - } - /** - * optional bool needsRefresh = 12; - */ - public boolean getNeedsRefresh() { - return needsRefresh_; - } - - // optional bytes aliceBaseKey = 13; - public static final int ALICEBASEKEY_FIELD_NUMBER = 13; - private com.google.protobuf.ByteString aliceBaseKey_; - /** - * optional bytes aliceBaseKey = 13; - */ - public boolean hasAliceBaseKey() { - return ((bitField0_ & 0x00000800) == 0x00000800); - } - /** - * optional bytes aliceBaseKey = 13; - */ - public com.google.protobuf.ByteString getAliceBaseKey() { - return aliceBaseKey_; - } - - private void initFields() { - sessionVersion_ = 0; - localIdentityPublic_ = com.google.protobuf.ByteString.EMPTY; - remoteIdentityPublic_ = com.google.protobuf.ByteString.EMPTY; - rootKey_ = com.google.protobuf.ByteString.EMPTY; - previousCounter_ = 0; - senderChain_ = org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.getDefaultInstance(); - receiverChains_ = java.util.Collections.emptyList(); - pendingKeyExchange_ = org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.PendingKeyExchange.getDefaultInstance(); - pendingPreKey_ = org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.PendingPreKey.getDefaultInstance(); - remoteRegistrationId_ = 0; - localRegistrationId_ = 0; - needsRefresh_ = false; - aliceBaseKey_ = com.google.protobuf.ByteString.EMPTY; - } - private byte memoizedIsInitialized = -1; - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized != -1) return isInitialized == 1; - - memoizedIsInitialized = 1; - return true; - } - - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - getSerializedSize(); - if (((bitField0_ & 0x00000001) == 0x00000001)) { - output.writeUInt32(1, sessionVersion_); - } - if (((bitField0_ & 0x00000002) == 0x00000002)) { - output.writeBytes(2, localIdentityPublic_); - } - if (((bitField0_ & 0x00000004) == 0x00000004)) { - output.writeBytes(3, remoteIdentityPublic_); - } - if (((bitField0_ & 0x00000008) == 0x00000008)) { - output.writeBytes(4, rootKey_); - } - if (((bitField0_ & 0x00000010) == 0x00000010)) { - output.writeUInt32(5, previousCounter_); - } - if (((bitField0_ & 0x00000020) == 0x00000020)) { - output.writeMessage(6, senderChain_); - } - for (int i = 0; i < receiverChains_.size(); i++) { - output.writeMessage(7, receiverChains_.get(i)); - } - if (((bitField0_ & 0x00000040) == 0x00000040)) { - output.writeMessage(8, pendingKeyExchange_); - } - if (((bitField0_ & 0x00000080) == 0x00000080)) { - output.writeMessage(9, pendingPreKey_); - } - if (((bitField0_ & 0x00000100) == 0x00000100)) { - output.writeUInt32(10, remoteRegistrationId_); - } - if (((bitField0_ & 0x00000200) == 0x00000200)) { - output.writeUInt32(11, localRegistrationId_); - } - if (((bitField0_ & 0x00000400) == 0x00000400)) { - output.writeBool(12, needsRefresh_); - } - if (((bitField0_ & 0x00000800) == 0x00000800)) { - output.writeBytes(13, aliceBaseKey_); - } - getUnknownFields().writeTo(output); - } - - private int memoizedSerializedSize = -1; - public int getSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (((bitField0_ & 0x00000001) == 0x00000001)) { - size += com.google.protobuf.CodedOutputStream - .computeUInt32Size(1, sessionVersion_); - } - if (((bitField0_ & 0x00000002) == 0x00000002)) { - size += com.google.protobuf.CodedOutputStream - .computeBytesSize(2, localIdentityPublic_); - } - if (((bitField0_ & 0x00000004) == 0x00000004)) { - size += com.google.protobuf.CodedOutputStream - .computeBytesSize(3, remoteIdentityPublic_); - } - if (((bitField0_ & 0x00000008) == 0x00000008)) { - size += com.google.protobuf.CodedOutputStream - .computeBytesSize(4, rootKey_); - } - if (((bitField0_ & 0x00000010) == 0x00000010)) { - size += com.google.protobuf.CodedOutputStream - .computeUInt32Size(5, previousCounter_); - } - if (((bitField0_ & 0x00000020) == 0x00000020)) { - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(6, senderChain_); - } - for (int i = 0; i < receiverChains_.size(); i++) { - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(7, receiverChains_.get(i)); - } - if (((bitField0_ & 0x00000040) == 0x00000040)) { - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(8, pendingKeyExchange_); - } - if (((bitField0_ & 0x00000080) == 0x00000080)) { - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(9, pendingPreKey_); - } - if (((bitField0_ & 0x00000100) == 0x00000100)) { - size += com.google.protobuf.CodedOutputStream - .computeUInt32Size(10, remoteRegistrationId_); - } - if (((bitField0_ & 0x00000200) == 0x00000200)) { - size += com.google.protobuf.CodedOutputStream - .computeUInt32Size(11, localRegistrationId_); - } - if (((bitField0_ & 0x00000400) == 0x00000400)) { - size += com.google.protobuf.CodedOutputStream - .computeBoolSize(12, needsRefresh_); - } - if (((bitField0_ & 0x00000800) == 0x00000800)) { - size += com.google.protobuf.CodedOutputStream - .computeBytesSize(13, aliceBaseKey_); - } - size += getUnknownFields().getSerializedSize(); - memoizedSerializedSize = size; - return size; - } - - private static final long serialVersionUID = 0L; - @java.lang.Override - protected java.lang.Object writeReplace() - throws java.io.ObjectStreamException { - return super.writeReplace(); - } - - public static org.session.libsignal.libsignal.state.StorageProtos.SessionStructure parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static org.session.libsignal.libsignal.state.StorageProtos.SessionStructure parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static org.session.libsignal.libsignal.state.StorageProtos.SessionStructure parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static org.session.libsignal.libsignal.state.StorageProtos.SessionStructure parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static org.session.libsignal.libsignal.state.StorageProtos.SessionStructure parseFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static org.session.libsignal.libsignal.state.StorageProtos.SessionStructure parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - public static org.session.libsignal.libsignal.state.StorageProtos.SessionStructure parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input); - } - public static org.session.libsignal.libsignal.state.StorageProtos.SessionStructure parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input, extensionRegistry); - } - public static org.session.libsignal.libsignal.state.StorageProtos.SessionStructure parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static org.session.libsignal.libsignal.state.StorageProtos.SessionStructure parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - - public static Builder newBuilder() { return Builder.create(); } - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder(org.session.libsignal.libsignal.state.StorageProtos.SessionStructure prototype) { - return newBuilder().mergeFrom(prototype); - } - public Builder toBuilder() { return newBuilder(this); } - - @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * Protobuf type {@code textsecure.SessionStructure} - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessage.Builder - implements org.session.libsignal.libsignal.state.StorageProtos.SessionStructureOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return org.session.libsignal.libsignal.state.StorageProtos.internal_static_textsecure_SessionStructure_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return org.session.libsignal.libsignal.state.StorageProtos.internal_static_textsecure_SessionStructure_fieldAccessorTable - .ensureFieldAccessorsInitialized( - org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.class, org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Builder.class); - } - - // Construct using org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { - getSenderChainFieldBuilder(); - getReceiverChainsFieldBuilder(); - getPendingKeyExchangeFieldBuilder(); - getPendingPreKeyFieldBuilder(); - } - } - private static Builder create() { - return new Builder(); - } - - public Builder clear() { - super.clear(); - sessionVersion_ = 0; - bitField0_ = (bitField0_ & ~0x00000001); - localIdentityPublic_ = com.google.protobuf.ByteString.EMPTY; - bitField0_ = (bitField0_ & ~0x00000002); - remoteIdentityPublic_ = com.google.protobuf.ByteString.EMPTY; - bitField0_ = (bitField0_ & ~0x00000004); - rootKey_ = com.google.protobuf.ByteString.EMPTY; - bitField0_ = (bitField0_ & ~0x00000008); - previousCounter_ = 0; - bitField0_ = (bitField0_ & ~0x00000010); - if (senderChainBuilder_ == null) { - senderChain_ = org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.getDefaultInstance(); - } else { - senderChainBuilder_.clear(); - } - bitField0_ = (bitField0_ & ~0x00000020); - if (receiverChainsBuilder_ == null) { - receiverChains_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000040); - } else { - receiverChainsBuilder_.clear(); - } - if (pendingKeyExchangeBuilder_ == null) { - pendingKeyExchange_ = org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.PendingKeyExchange.getDefaultInstance(); - } else { - pendingKeyExchangeBuilder_.clear(); - } - bitField0_ = (bitField0_ & ~0x00000080); - if (pendingPreKeyBuilder_ == null) { - pendingPreKey_ = org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.PendingPreKey.getDefaultInstance(); - } else { - pendingPreKeyBuilder_.clear(); - } - bitField0_ = (bitField0_ & ~0x00000100); - remoteRegistrationId_ = 0; - bitField0_ = (bitField0_ & ~0x00000200); - localRegistrationId_ = 0; - bitField0_ = (bitField0_ & ~0x00000400); - needsRefresh_ = false; - bitField0_ = (bitField0_ & ~0x00000800); - aliceBaseKey_ = com.google.protobuf.ByteString.EMPTY; - bitField0_ = (bitField0_ & ~0x00001000); - return this; - } - - public Builder clone() { - return create().mergeFrom(buildPartial()); - } - - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return org.session.libsignal.libsignal.state.StorageProtos.internal_static_textsecure_SessionStructure_descriptor; - } - - public org.session.libsignal.libsignal.state.StorageProtos.SessionStructure getDefaultInstanceForType() { - return org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.getDefaultInstance(); - } - - public org.session.libsignal.libsignal.state.StorageProtos.SessionStructure build() { - org.session.libsignal.libsignal.state.StorageProtos.SessionStructure result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - public org.session.libsignal.libsignal.state.StorageProtos.SessionStructure buildPartial() { - org.session.libsignal.libsignal.state.StorageProtos.SessionStructure result = new org.session.libsignal.libsignal.state.StorageProtos.SessionStructure(this); - int from_bitField0_ = bitField0_; - int to_bitField0_ = 0; - if (((from_bitField0_ & 0x00000001) == 0x00000001)) { - to_bitField0_ |= 0x00000001; - } - result.sessionVersion_ = sessionVersion_; - if (((from_bitField0_ & 0x00000002) == 0x00000002)) { - to_bitField0_ |= 0x00000002; - } - result.localIdentityPublic_ = localIdentityPublic_; - if (((from_bitField0_ & 0x00000004) == 0x00000004)) { - to_bitField0_ |= 0x00000004; - } - result.remoteIdentityPublic_ = remoteIdentityPublic_; - if (((from_bitField0_ & 0x00000008) == 0x00000008)) { - to_bitField0_ |= 0x00000008; - } - result.rootKey_ = rootKey_; - if (((from_bitField0_ & 0x00000010) == 0x00000010)) { - to_bitField0_ |= 0x00000010; - } - result.previousCounter_ = previousCounter_; - if (((from_bitField0_ & 0x00000020) == 0x00000020)) { - to_bitField0_ |= 0x00000020; - } - if (senderChainBuilder_ == null) { - result.senderChain_ = senderChain_; - } else { - result.senderChain_ = senderChainBuilder_.build(); - } - if (receiverChainsBuilder_ == null) { - if (((bitField0_ & 0x00000040) == 0x00000040)) { - receiverChains_ = java.util.Collections.unmodifiableList(receiverChains_); - bitField0_ = (bitField0_ & ~0x00000040); - } - result.receiverChains_ = receiverChains_; - } else { - result.receiverChains_ = receiverChainsBuilder_.build(); - } - if (((from_bitField0_ & 0x00000080) == 0x00000080)) { - to_bitField0_ |= 0x00000040; - } - if (pendingKeyExchangeBuilder_ == null) { - result.pendingKeyExchange_ = pendingKeyExchange_; - } else { - result.pendingKeyExchange_ = pendingKeyExchangeBuilder_.build(); - } - if (((from_bitField0_ & 0x00000100) == 0x00000100)) { - to_bitField0_ |= 0x00000080; - } - if (pendingPreKeyBuilder_ == null) { - result.pendingPreKey_ = pendingPreKey_; - } else { - result.pendingPreKey_ = pendingPreKeyBuilder_.build(); - } - if (((from_bitField0_ & 0x00000200) == 0x00000200)) { - to_bitField0_ |= 0x00000100; - } - result.remoteRegistrationId_ = remoteRegistrationId_; - if (((from_bitField0_ & 0x00000400) == 0x00000400)) { - to_bitField0_ |= 0x00000200; - } - result.localRegistrationId_ = localRegistrationId_; - if (((from_bitField0_ & 0x00000800) == 0x00000800)) { - to_bitField0_ |= 0x00000400; - } - result.needsRefresh_ = needsRefresh_; - if (((from_bitField0_ & 0x00001000) == 0x00001000)) { - to_bitField0_ |= 0x00000800; - } - result.aliceBaseKey_ = aliceBaseKey_; - result.bitField0_ = to_bitField0_; - onBuilt(); - return result; - } - - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof org.session.libsignal.libsignal.state.StorageProtos.SessionStructure) { - return mergeFrom((org.session.libsignal.libsignal.state.StorageProtos.SessionStructure)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(org.session.libsignal.libsignal.state.StorageProtos.SessionStructure other) { - if (other == org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.getDefaultInstance()) return this; - if (other.hasSessionVersion()) { - setSessionVersion(other.getSessionVersion()); - } - if (other.hasLocalIdentityPublic()) { - setLocalIdentityPublic(other.getLocalIdentityPublic()); - } - if (other.hasRemoteIdentityPublic()) { - setRemoteIdentityPublic(other.getRemoteIdentityPublic()); - } - if (other.hasRootKey()) { - setRootKey(other.getRootKey()); - } - if (other.hasPreviousCounter()) { - setPreviousCounter(other.getPreviousCounter()); - } - if (other.hasSenderChain()) { - mergeSenderChain(other.getSenderChain()); - } - if (receiverChainsBuilder_ == null) { - if (!other.receiverChains_.isEmpty()) { - if (receiverChains_.isEmpty()) { - receiverChains_ = other.receiverChains_; - bitField0_ = (bitField0_ & ~0x00000040); - } else { - ensureReceiverChainsIsMutable(); - receiverChains_.addAll(other.receiverChains_); - } - onChanged(); - } - } else { - if (!other.receiverChains_.isEmpty()) { - if (receiverChainsBuilder_.isEmpty()) { - receiverChainsBuilder_.dispose(); - receiverChainsBuilder_ = null; - receiverChains_ = other.receiverChains_; - bitField0_ = (bitField0_ & ~0x00000040); - receiverChainsBuilder_ = - com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders ? - getReceiverChainsFieldBuilder() : null; - } else { - receiverChainsBuilder_.addAllMessages(other.receiverChains_); - } - } - } - if (other.hasPendingKeyExchange()) { - mergePendingKeyExchange(other.getPendingKeyExchange()); - } - if (other.hasPendingPreKey()) { - mergePendingPreKey(other.getPendingPreKey()); - } - if (other.hasRemoteRegistrationId()) { - setRemoteRegistrationId(other.getRemoteRegistrationId()); - } - if (other.hasLocalRegistrationId()) { - setLocalRegistrationId(other.getLocalRegistrationId()); - } - if (other.hasNeedsRefresh()) { - setNeedsRefresh(other.getNeedsRefresh()); - } - if (other.hasAliceBaseKey()) { - setAliceBaseKey(other.getAliceBaseKey()); - } - this.mergeUnknownFields(other.getUnknownFields()); - return this; - } - - public final boolean isInitialized() { - return true; - } - - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - org.session.libsignal.libsignal.state.StorageProtos.SessionStructure parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (org.session.libsignal.libsignal.state.StorageProtos.SessionStructure) e.getUnfinishedMessage(); - throw e; - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - private int bitField0_; - - // optional uint32 sessionVersion = 1; - private int sessionVersion_ ; - /** - * optional uint32 sessionVersion = 1; - */ - public boolean hasSessionVersion() { - return ((bitField0_ & 0x00000001) == 0x00000001); - } - /** - * optional uint32 sessionVersion = 1; - */ - public int getSessionVersion() { - return sessionVersion_; - } - /** - * optional uint32 sessionVersion = 1; - */ - public Builder setSessionVersion(int value) { - bitField0_ |= 0x00000001; - sessionVersion_ = value; - onChanged(); - return this; - } - /** - * optional uint32 sessionVersion = 1; - */ - public Builder clearSessionVersion() { - bitField0_ = (bitField0_ & ~0x00000001); - sessionVersion_ = 0; - onChanged(); - return this; - } - - // optional bytes localIdentityPublic = 2; - private com.google.protobuf.ByteString localIdentityPublic_ = com.google.protobuf.ByteString.EMPTY; - /** - * optional bytes localIdentityPublic = 2; - */ - public boolean hasLocalIdentityPublic() { - return ((bitField0_ & 0x00000002) == 0x00000002); - } - /** - * optional bytes localIdentityPublic = 2; - */ - public com.google.protobuf.ByteString getLocalIdentityPublic() { - return localIdentityPublic_; - } - /** - * optional bytes localIdentityPublic = 2; - */ - public Builder setLocalIdentityPublic(com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - bitField0_ |= 0x00000002; - localIdentityPublic_ = value; - onChanged(); - return this; - } - /** - * optional bytes localIdentityPublic = 2; - */ - public Builder clearLocalIdentityPublic() { - bitField0_ = (bitField0_ & ~0x00000002); - localIdentityPublic_ = getDefaultInstance().getLocalIdentityPublic(); - onChanged(); - return this; - } - - // optional bytes remoteIdentityPublic = 3; - private com.google.protobuf.ByteString remoteIdentityPublic_ = com.google.protobuf.ByteString.EMPTY; - /** - * optional bytes remoteIdentityPublic = 3; - */ - public boolean hasRemoteIdentityPublic() { - return ((bitField0_ & 0x00000004) == 0x00000004); - } - /** - * optional bytes remoteIdentityPublic = 3; - */ - public com.google.protobuf.ByteString getRemoteIdentityPublic() { - return remoteIdentityPublic_; - } - /** - * optional bytes remoteIdentityPublic = 3; - */ - public Builder setRemoteIdentityPublic(com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - bitField0_ |= 0x00000004; - remoteIdentityPublic_ = value; - onChanged(); - return this; - } - /** - * optional bytes remoteIdentityPublic = 3; - */ - public Builder clearRemoteIdentityPublic() { - bitField0_ = (bitField0_ & ~0x00000004); - remoteIdentityPublic_ = getDefaultInstance().getRemoteIdentityPublic(); - onChanged(); - return this; - } - - // optional bytes rootKey = 4; - private com.google.protobuf.ByteString rootKey_ = com.google.protobuf.ByteString.EMPTY; - /** - * optional bytes rootKey = 4; - */ - public boolean hasRootKey() { - return ((bitField0_ & 0x00000008) == 0x00000008); - } - /** - * optional bytes rootKey = 4; - */ - public com.google.protobuf.ByteString getRootKey() { - return rootKey_; - } - /** - * optional bytes rootKey = 4; - */ - public Builder setRootKey(com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - bitField0_ |= 0x00000008; - rootKey_ = value; - onChanged(); - return this; - } - /** - * optional bytes rootKey = 4; - */ - public Builder clearRootKey() { - bitField0_ = (bitField0_ & ~0x00000008); - rootKey_ = getDefaultInstance().getRootKey(); - onChanged(); - return this; - } - - // optional uint32 previousCounter = 5; - private int previousCounter_ ; - /** - * optional uint32 previousCounter = 5; - */ - public boolean hasPreviousCounter() { - return ((bitField0_ & 0x00000010) == 0x00000010); - } - /** - * optional uint32 previousCounter = 5; - */ - public int getPreviousCounter() { - return previousCounter_; - } - /** - * optional uint32 previousCounter = 5; - */ - public Builder setPreviousCounter(int value) { - bitField0_ |= 0x00000010; - previousCounter_ = value; - onChanged(); - return this; - } - /** - * optional uint32 previousCounter = 5; - */ - public Builder clearPreviousCounter() { - bitField0_ = (bitField0_ & ~0x00000010); - previousCounter_ = 0; - onChanged(); - return this; - } - - // optional .textsecure.SessionStructure.Chain senderChain = 6; - private org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain senderChain_ = org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.getDefaultInstance(); - private com.google.protobuf.SingleFieldBuilder< - org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain, org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.Builder, org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.ChainOrBuilder> senderChainBuilder_; - /** - * optional .textsecure.SessionStructure.Chain senderChain = 6; - */ - public boolean hasSenderChain() { - return ((bitField0_ & 0x00000020) == 0x00000020); - } - /** - * optional .textsecure.SessionStructure.Chain senderChain = 6; - */ - public org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain getSenderChain() { - if (senderChainBuilder_ == null) { - return senderChain_; - } else { - return senderChainBuilder_.getMessage(); - } - } - /** - * optional .textsecure.SessionStructure.Chain senderChain = 6; - */ - public Builder setSenderChain(org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain value) { - if (senderChainBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - senderChain_ = value; - onChanged(); - } else { - senderChainBuilder_.setMessage(value); - } - bitField0_ |= 0x00000020; - return this; - } - /** - * optional .textsecure.SessionStructure.Chain senderChain = 6; - */ - public Builder setSenderChain( - org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.Builder builderForValue) { - if (senderChainBuilder_ == null) { - senderChain_ = builderForValue.build(); - onChanged(); - } else { - senderChainBuilder_.setMessage(builderForValue.build()); - } - bitField0_ |= 0x00000020; - return this; - } - /** - * optional .textsecure.SessionStructure.Chain senderChain = 6; - */ - public Builder mergeSenderChain(org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain value) { - if (senderChainBuilder_ == null) { - if (((bitField0_ & 0x00000020) == 0x00000020) && - senderChain_ != org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.getDefaultInstance()) { - senderChain_ = - org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.newBuilder(senderChain_).mergeFrom(value).buildPartial(); - } else { - senderChain_ = value; - } - onChanged(); - } else { - senderChainBuilder_.mergeFrom(value); - } - bitField0_ |= 0x00000020; - return this; - } - /** - * optional .textsecure.SessionStructure.Chain senderChain = 6; - */ - public Builder clearSenderChain() { - if (senderChainBuilder_ == null) { - senderChain_ = org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.getDefaultInstance(); - onChanged(); - } else { - senderChainBuilder_.clear(); - } - bitField0_ = (bitField0_ & ~0x00000020); - return this; - } - /** - * optional .textsecure.SessionStructure.Chain senderChain = 6; - */ - public org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.Builder getSenderChainBuilder() { - bitField0_ |= 0x00000020; - onChanged(); - return getSenderChainFieldBuilder().getBuilder(); - } - /** - * optional .textsecure.SessionStructure.Chain senderChain = 6; - */ - public org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.ChainOrBuilder getSenderChainOrBuilder() { - if (senderChainBuilder_ != null) { - return senderChainBuilder_.getMessageOrBuilder(); - } else { - return senderChain_; - } - } - /** - * optional .textsecure.SessionStructure.Chain senderChain = 6; - */ - private com.google.protobuf.SingleFieldBuilder< - org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain, org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.Builder, org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.ChainOrBuilder> - getSenderChainFieldBuilder() { - if (senderChainBuilder_ == null) { - senderChainBuilder_ = new com.google.protobuf.SingleFieldBuilder< - org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain, org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.Builder, org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.ChainOrBuilder>( - senderChain_, - getParentForChildren(), - isClean()); - senderChain_ = null; - } - return senderChainBuilder_; - } - - // repeated .textsecure.SessionStructure.Chain receiverChains = 7; - private java.util.List receiverChains_ = - java.util.Collections.emptyList(); - private void ensureReceiverChainsIsMutable() { - if (!((bitField0_ & 0x00000040) == 0x00000040)) { - receiverChains_ = new java.util.ArrayList(receiverChains_); - bitField0_ |= 0x00000040; - } - } - - private com.google.protobuf.RepeatedFieldBuilder< - org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain, org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.Builder, org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.ChainOrBuilder> receiverChainsBuilder_; - - /** - * repeated .textsecure.SessionStructure.Chain receiverChains = 7; - */ - public java.util.List getReceiverChainsList() { - if (receiverChainsBuilder_ == null) { - return java.util.Collections.unmodifiableList(receiverChains_); - } else { - return receiverChainsBuilder_.getMessageList(); - } - } - /** - * repeated .textsecure.SessionStructure.Chain receiverChains = 7; - */ - public int getReceiverChainsCount() { - if (receiverChainsBuilder_ == null) { - return receiverChains_.size(); - } else { - return receiverChainsBuilder_.getCount(); - } - } - /** - * repeated .textsecure.SessionStructure.Chain receiverChains = 7; - */ - public org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain getReceiverChains(int index) { - if (receiverChainsBuilder_ == null) { - return receiverChains_.get(index); - } else { - return receiverChainsBuilder_.getMessage(index); - } - } - /** - * repeated .textsecure.SessionStructure.Chain receiverChains = 7; - */ - public Builder setReceiverChains( - int index, org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain value) { - if (receiverChainsBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureReceiverChainsIsMutable(); - receiverChains_.set(index, value); - onChanged(); - } else { - receiverChainsBuilder_.setMessage(index, value); - } - return this; - } - /** - * repeated .textsecure.SessionStructure.Chain receiverChains = 7; - */ - public Builder setReceiverChains( - int index, org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.Builder builderForValue) { - if (receiverChainsBuilder_ == null) { - ensureReceiverChainsIsMutable(); - receiverChains_.set(index, builderForValue.build()); - onChanged(); - } else { - receiverChainsBuilder_.setMessage(index, builderForValue.build()); - } - return this; - } - /** - * repeated .textsecure.SessionStructure.Chain receiverChains = 7; - */ - public Builder addReceiverChains(org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain value) { - if (receiverChainsBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureReceiverChainsIsMutable(); - receiverChains_.add(value); - onChanged(); - } else { - receiverChainsBuilder_.addMessage(value); - } - return this; - } - /** - * repeated .textsecure.SessionStructure.Chain receiverChains = 7; - */ - public Builder addReceiverChains( - int index, org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain value) { - if (receiverChainsBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureReceiverChainsIsMutable(); - receiverChains_.add(index, value); - onChanged(); - } else { - receiverChainsBuilder_.addMessage(index, value); - } - return this; - } - /** - * repeated .textsecure.SessionStructure.Chain receiverChains = 7; - */ - public Builder addReceiverChains( - org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.Builder builderForValue) { - if (receiverChainsBuilder_ == null) { - ensureReceiverChainsIsMutable(); - receiverChains_.add(builderForValue.build()); - onChanged(); - } else { - receiverChainsBuilder_.addMessage(builderForValue.build()); - } - return this; - } - /** - * repeated .textsecure.SessionStructure.Chain receiverChains = 7; - */ - public Builder addReceiverChains( - int index, org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.Builder builderForValue) { - if (receiverChainsBuilder_ == null) { - ensureReceiverChainsIsMutable(); - receiverChains_.add(index, builderForValue.build()); - onChanged(); - } else { - receiverChainsBuilder_.addMessage(index, builderForValue.build()); - } - return this; - } - /** - * repeated .textsecure.SessionStructure.Chain receiverChains = 7; - */ - public Builder addAllReceiverChains( - java.lang.Iterable values) { - if (receiverChainsBuilder_ == null) { - ensureReceiverChainsIsMutable(); - super.addAll(values, receiverChains_); - onChanged(); - } else { - receiverChainsBuilder_.addAllMessages(values); - } - return this; - } - /** - * repeated .textsecure.SessionStructure.Chain receiverChains = 7; - */ - public Builder clearReceiverChains() { - if (receiverChainsBuilder_ == null) { - receiverChains_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000040); - onChanged(); - } else { - receiverChainsBuilder_.clear(); - } - return this; - } - /** - * repeated .textsecure.SessionStructure.Chain receiverChains = 7; - */ - public Builder removeReceiverChains(int index) { - if (receiverChainsBuilder_ == null) { - ensureReceiverChainsIsMutable(); - receiverChains_.remove(index); - onChanged(); - } else { - receiverChainsBuilder_.remove(index); - } - return this; - } - /** - * repeated .textsecure.SessionStructure.Chain receiverChains = 7; - */ - public org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.Builder getReceiverChainsBuilder( - int index) { - return getReceiverChainsFieldBuilder().getBuilder(index); - } - /** - * repeated .textsecure.SessionStructure.Chain receiverChains = 7; - */ - public org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.ChainOrBuilder getReceiverChainsOrBuilder( - int index) { - if (receiverChainsBuilder_ == null) { - return receiverChains_.get(index); } else { - return receiverChainsBuilder_.getMessageOrBuilder(index); - } - } - /** - * repeated .textsecure.SessionStructure.Chain receiverChains = 7; - */ - public java.util.List - getReceiverChainsOrBuilderList() { - if (receiverChainsBuilder_ != null) { - return receiverChainsBuilder_.getMessageOrBuilderList(); - } else { - return java.util.Collections.unmodifiableList(receiverChains_); - } - } - /** - * repeated .textsecure.SessionStructure.Chain receiverChains = 7; - */ - public org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.Builder addReceiverChainsBuilder() { - return getReceiverChainsFieldBuilder().addBuilder( - org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.getDefaultInstance()); - } - /** - * repeated .textsecure.SessionStructure.Chain receiverChains = 7; - */ - public org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.Builder addReceiverChainsBuilder( - int index) { - return getReceiverChainsFieldBuilder().addBuilder( - index, org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.getDefaultInstance()); - } - /** - * repeated .textsecure.SessionStructure.Chain receiverChains = 7; - */ - public java.util.List - getReceiverChainsBuilderList() { - return getReceiverChainsFieldBuilder().getBuilderList(); - } - private com.google.protobuf.RepeatedFieldBuilder< - org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain, org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.Builder, org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.ChainOrBuilder> - getReceiverChainsFieldBuilder() { - if (receiverChainsBuilder_ == null) { - receiverChainsBuilder_ = new com.google.protobuf.RepeatedFieldBuilder< - org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain, org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Chain.Builder, org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.ChainOrBuilder>( - receiverChains_, - ((bitField0_ & 0x00000040) == 0x00000040), - getParentForChildren(), - isClean()); - receiverChains_ = null; - } - return receiverChainsBuilder_; - } - - // optional .textsecure.SessionStructure.PendingKeyExchange pendingKeyExchange = 8; - private org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.PendingKeyExchange pendingKeyExchange_ = org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.PendingKeyExchange.getDefaultInstance(); - private com.google.protobuf.SingleFieldBuilder< - org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.PendingKeyExchange, org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.PendingKeyExchange.Builder, org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.PendingKeyExchangeOrBuilder> pendingKeyExchangeBuilder_; - /** - * optional .textsecure.SessionStructure.PendingKeyExchange pendingKeyExchange = 8; - */ - public boolean hasPendingKeyExchange() { - return ((bitField0_ & 0x00000080) == 0x00000080); - } - /** - * optional .textsecure.SessionStructure.PendingKeyExchange pendingKeyExchange = 8; - */ - public org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.PendingKeyExchange getPendingKeyExchange() { - if (pendingKeyExchangeBuilder_ == null) { - return pendingKeyExchange_; - } else { - return pendingKeyExchangeBuilder_.getMessage(); - } - } - /** - * optional .textsecure.SessionStructure.PendingKeyExchange pendingKeyExchange = 8; - */ - public Builder setPendingKeyExchange(org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.PendingKeyExchange value) { - if (pendingKeyExchangeBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - pendingKeyExchange_ = value; - onChanged(); - } else { - pendingKeyExchangeBuilder_.setMessage(value); - } - bitField0_ |= 0x00000080; - return this; - } - /** - * optional .textsecure.SessionStructure.PendingKeyExchange pendingKeyExchange = 8; - */ - public Builder setPendingKeyExchange( - org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.PendingKeyExchange.Builder builderForValue) { - if (pendingKeyExchangeBuilder_ == null) { - pendingKeyExchange_ = builderForValue.build(); - onChanged(); - } else { - pendingKeyExchangeBuilder_.setMessage(builderForValue.build()); - } - bitField0_ |= 0x00000080; - return this; - } - /** - * optional .textsecure.SessionStructure.PendingKeyExchange pendingKeyExchange = 8; - */ - public Builder mergePendingKeyExchange(org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.PendingKeyExchange value) { - if (pendingKeyExchangeBuilder_ == null) { - if (((bitField0_ & 0x00000080) == 0x00000080) && - pendingKeyExchange_ != org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.PendingKeyExchange.getDefaultInstance()) { - pendingKeyExchange_ = - org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.PendingKeyExchange.newBuilder(pendingKeyExchange_).mergeFrom(value).buildPartial(); - } else { - pendingKeyExchange_ = value; - } - onChanged(); - } else { - pendingKeyExchangeBuilder_.mergeFrom(value); - } - bitField0_ |= 0x00000080; - return this; - } - /** - * optional .textsecure.SessionStructure.PendingKeyExchange pendingKeyExchange = 8; - */ - public Builder clearPendingKeyExchange() { - if (pendingKeyExchangeBuilder_ == null) { - pendingKeyExchange_ = org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.PendingKeyExchange.getDefaultInstance(); - onChanged(); - } else { - pendingKeyExchangeBuilder_.clear(); - } - bitField0_ = (bitField0_ & ~0x00000080); - return this; - } - /** - * optional .textsecure.SessionStructure.PendingKeyExchange pendingKeyExchange = 8; - */ - public org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.PendingKeyExchange.Builder getPendingKeyExchangeBuilder() { - bitField0_ |= 0x00000080; - onChanged(); - return getPendingKeyExchangeFieldBuilder().getBuilder(); - } - /** - * optional .textsecure.SessionStructure.PendingKeyExchange pendingKeyExchange = 8; - */ - public org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.PendingKeyExchangeOrBuilder getPendingKeyExchangeOrBuilder() { - if (pendingKeyExchangeBuilder_ != null) { - return pendingKeyExchangeBuilder_.getMessageOrBuilder(); - } else { - return pendingKeyExchange_; - } - } - /** - * optional .textsecure.SessionStructure.PendingKeyExchange pendingKeyExchange = 8; - */ - private com.google.protobuf.SingleFieldBuilder< - org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.PendingKeyExchange, org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.PendingKeyExchange.Builder, org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.PendingKeyExchangeOrBuilder> - getPendingKeyExchangeFieldBuilder() { - if (pendingKeyExchangeBuilder_ == null) { - pendingKeyExchangeBuilder_ = new com.google.protobuf.SingleFieldBuilder< - org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.PendingKeyExchange, org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.PendingKeyExchange.Builder, org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.PendingKeyExchangeOrBuilder>( - pendingKeyExchange_, - getParentForChildren(), - isClean()); - pendingKeyExchange_ = null; - } - return pendingKeyExchangeBuilder_; - } - - // optional .textsecure.SessionStructure.PendingPreKey pendingPreKey = 9; - private org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.PendingPreKey pendingPreKey_ = org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.PendingPreKey.getDefaultInstance(); - private com.google.protobuf.SingleFieldBuilder< - org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.PendingPreKey, org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.PendingPreKey.Builder, org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.PendingPreKeyOrBuilder> pendingPreKeyBuilder_; - /** - * optional .textsecure.SessionStructure.PendingPreKey pendingPreKey = 9; - */ - public boolean hasPendingPreKey() { - return ((bitField0_ & 0x00000100) == 0x00000100); - } - /** - * optional .textsecure.SessionStructure.PendingPreKey pendingPreKey = 9; - */ - public org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.PendingPreKey getPendingPreKey() { - if (pendingPreKeyBuilder_ == null) { - return pendingPreKey_; - } else { - return pendingPreKeyBuilder_.getMessage(); - } - } - /** - * optional .textsecure.SessionStructure.PendingPreKey pendingPreKey = 9; - */ - public Builder setPendingPreKey(org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.PendingPreKey value) { - if (pendingPreKeyBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - pendingPreKey_ = value; - onChanged(); - } else { - pendingPreKeyBuilder_.setMessage(value); - } - bitField0_ |= 0x00000100; - return this; - } - /** - * optional .textsecure.SessionStructure.PendingPreKey pendingPreKey = 9; - */ - public Builder setPendingPreKey( - org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.PendingPreKey.Builder builderForValue) { - if (pendingPreKeyBuilder_ == null) { - pendingPreKey_ = builderForValue.build(); - onChanged(); - } else { - pendingPreKeyBuilder_.setMessage(builderForValue.build()); - } - bitField0_ |= 0x00000100; - return this; - } - /** - * optional .textsecure.SessionStructure.PendingPreKey pendingPreKey = 9; - */ - public Builder mergePendingPreKey(org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.PendingPreKey value) { - if (pendingPreKeyBuilder_ == null) { - if (((bitField0_ & 0x00000100) == 0x00000100) && - pendingPreKey_ != org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.PendingPreKey.getDefaultInstance()) { - pendingPreKey_ = - org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.PendingPreKey.newBuilder(pendingPreKey_).mergeFrom(value).buildPartial(); - } else { - pendingPreKey_ = value; - } - onChanged(); - } else { - pendingPreKeyBuilder_.mergeFrom(value); - } - bitField0_ |= 0x00000100; - return this; - } - /** - * optional .textsecure.SessionStructure.PendingPreKey pendingPreKey = 9; - */ - public Builder clearPendingPreKey() { - if (pendingPreKeyBuilder_ == null) { - pendingPreKey_ = org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.PendingPreKey.getDefaultInstance(); - onChanged(); - } else { - pendingPreKeyBuilder_.clear(); - } - bitField0_ = (bitField0_ & ~0x00000100); - return this; - } - /** - * optional .textsecure.SessionStructure.PendingPreKey pendingPreKey = 9; - */ - public org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.PendingPreKey.Builder getPendingPreKeyBuilder() { - bitField0_ |= 0x00000100; - onChanged(); - return getPendingPreKeyFieldBuilder().getBuilder(); - } - /** - * optional .textsecure.SessionStructure.PendingPreKey pendingPreKey = 9; - */ - public org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.PendingPreKeyOrBuilder getPendingPreKeyOrBuilder() { - if (pendingPreKeyBuilder_ != null) { - return pendingPreKeyBuilder_.getMessageOrBuilder(); - } else { - return pendingPreKey_; - } - } - /** - * optional .textsecure.SessionStructure.PendingPreKey pendingPreKey = 9; - */ - private com.google.protobuf.SingleFieldBuilder< - org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.PendingPreKey, org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.PendingPreKey.Builder, org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.PendingPreKeyOrBuilder> - getPendingPreKeyFieldBuilder() { - if (pendingPreKeyBuilder_ == null) { - pendingPreKeyBuilder_ = new com.google.protobuf.SingleFieldBuilder< - org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.PendingPreKey, org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.PendingPreKey.Builder, org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.PendingPreKeyOrBuilder>( - pendingPreKey_, - getParentForChildren(), - isClean()); - pendingPreKey_ = null; - } - return pendingPreKeyBuilder_; - } - - // optional uint32 remoteRegistrationId = 10; - private int remoteRegistrationId_ ; - /** - * optional uint32 remoteRegistrationId = 10; - */ - public boolean hasRemoteRegistrationId() { - return ((bitField0_ & 0x00000200) == 0x00000200); - } - /** - * optional uint32 remoteRegistrationId = 10; - */ - public int getRemoteRegistrationId() { - return remoteRegistrationId_; - } - /** - * optional uint32 remoteRegistrationId = 10; - */ - public Builder setRemoteRegistrationId(int value) { - bitField0_ |= 0x00000200; - remoteRegistrationId_ = value; - onChanged(); - return this; - } - /** - * optional uint32 remoteRegistrationId = 10; - */ - public Builder clearRemoteRegistrationId() { - bitField0_ = (bitField0_ & ~0x00000200); - remoteRegistrationId_ = 0; - onChanged(); - return this; - } - - // optional uint32 localRegistrationId = 11; - private int localRegistrationId_ ; - /** - * optional uint32 localRegistrationId = 11; - */ - public boolean hasLocalRegistrationId() { - return ((bitField0_ & 0x00000400) == 0x00000400); - } - /** - * optional uint32 localRegistrationId = 11; - */ - public int getLocalRegistrationId() { - return localRegistrationId_; - } - /** - * optional uint32 localRegistrationId = 11; - */ - public Builder setLocalRegistrationId(int value) { - bitField0_ |= 0x00000400; - localRegistrationId_ = value; - onChanged(); - return this; - } - /** - * optional uint32 localRegistrationId = 11; - */ - public Builder clearLocalRegistrationId() { - bitField0_ = (bitField0_ & ~0x00000400); - localRegistrationId_ = 0; - onChanged(); - return this; - } - - // optional bool needsRefresh = 12; - private boolean needsRefresh_ ; - /** - * optional bool needsRefresh = 12; - */ - public boolean hasNeedsRefresh() { - return ((bitField0_ & 0x00000800) == 0x00000800); - } - /** - * optional bool needsRefresh = 12; - */ - public boolean getNeedsRefresh() { - return needsRefresh_; - } - /** - * optional bool needsRefresh = 12; - */ - public Builder setNeedsRefresh(boolean value) { - bitField0_ |= 0x00000800; - needsRefresh_ = value; - onChanged(); - return this; - } - /** - * optional bool needsRefresh = 12; - */ - public Builder clearNeedsRefresh() { - bitField0_ = (bitField0_ & ~0x00000800); - needsRefresh_ = false; - onChanged(); - return this; - } - - // optional bytes aliceBaseKey = 13; - private com.google.protobuf.ByteString aliceBaseKey_ = com.google.protobuf.ByteString.EMPTY; - /** - * optional bytes aliceBaseKey = 13; - */ - public boolean hasAliceBaseKey() { - return ((bitField0_ & 0x00001000) == 0x00001000); - } - /** - * optional bytes aliceBaseKey = 13; - */ - public com.google.protobuf.ByteString getAliceBaseKey() { - return aliceBaseKey_; - } - /** - * optional bytes aliceBaseKey = 13; - */ - public Builder setAliceBaseKey(com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - bitField0_ |= 0x00001000; - aliceBaseKey_ = value; - onChanged(); - return this; - } - /** - * optional bytes aliceBaseKey = 13; - */ - public Builder clearAliceBaseKey() { - bitField0_ = (bitField0_ & ~0x00001000); - aliceBaseKey_ = getDefaultInstance().getAliceBaseKey(); - onChanged(); - return this; - } - - // @@protoc_insertion_point(builder_scope:textsecure.SessionStructure) - } - - static { - defaultInstance = new SessionStructure(true); - defaultInstance.initFields(); - } - - // @@protoc_insertion_point(class_scope:textsecure.SessionStructure) - } - - public interface RecordStructureOrBuilder - extends com.google.protobuf.MessageOrBuilder { - - // optional .textsecure.SessionStructure currentSession = 1; - /** - * optional .textsecure.SessionStructure currentSession = 1; - */ - boolean hasCurrentSession(); - /** - * optional .textsecure.SessionStructure currentSession = 1; - */ - org.session.libsignal.libsignal.state.StorageProtos.SessionStructure getCurrentSession(); - /** - * optional .textsecure.SessionStructure currentSession = 1; - */ - org.session.libsignal.libsignal.state.StorageProtos.SessionStructureOrBuilder getCurrentSessionOrBuilder(); - - // repeated .textsecure.SessionStructure previousSessions = 2; - /** - * repeated .textsecure.SessionStructure previousSessions = 2; - */ - java.util.List - getPreviousSessionsList(); - /** - * repeated .textsecure.SessionStructure previousSessions = 2; - */ - org.session.libsignal.libsignal.state.StorageProtos.SessionStructure getPreviousSessions(int index); - /** - * repeated .textsecure.SessionStructure previousSessions = 2; - */ - int getPreviousSessionsCount(); - /** - * repeated .textsecure.SessionStructure previousSessions = 2; - */ - java.util.List - getPreviousSessionsOrBuilderList(); - /** - * repeated .textsecure.SessionStructure previousSessions = 2; - */ - org.session.libsignal.libsignal.state.StorageProtos.SessionStructureOrBuilder getPreviousSessionsOrBuilder( - int index); - } - /** - * Protobuf type {@code textsecure.RecordStructure} - */ - public static final class RecordStructure extends - com.google.protobuf.GeneratedMessage - implements RecordStructureOrBuilder { - // Use RecordStructure.newBuilder() to construct. - private RecordStructure(com.google.protobuf.GeneratedMessage.Builder builder) { - super(builder); - this.unknownFields = builder.getUnknownFields(); - } - private RecordStructure(boolean noInit) { this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); } - - private static final RecordStructure defaultInstance; - public static RecordStructure getDefaultInstance() { - return defaultInstance; - } - - public RecordStructure getDefaultInstanceForType() { - return defaultInstance; - } - - private final com.google.protobuf.UnknownFieldSet unknownFields; - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return this.unknownFields; - } - private RecordStructure( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - initFields(); - int mutable_bitField0_ = 0; - com.google.protobuf.UnknownFieldSet.Builder unknownFields = - com.google.protobuf.UnknownFieldSet.newBuilder(); - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: { - if (!parseUnknownField(input, unknownFields, - extensionRegistry, tag)) { - done = true; - } - break; - } - case 10: { - org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Builder subBuilder = null; - if (((bitField0_ & 0x00000001) == 0x00000001)) { - subBuilder = currentSession_.toBuilder(); - } - currentSession_ = input.readMessage(org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.PARSER, extensionRegistry); - if (subBuilder != null) { - subBuilder.mergeFrom(currentSession_); - currentSession_ = subBuilder.buildPartial(); - } - bitField0_ |= 0x00000001; - break; - } - case 18: { - if (!((mutable_bitField0_ & 0x00000002) == 0x00000002)) { - previousSessions_ = new java.util.ArrayList(); - mutable_bitField0_ |= 0x00000002; - } - previousSessions_.add(input.readMessage(org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.PARSER, extensionRegistry)); - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(this); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException( - e.getMessage()).setUnfinishedMessage(this); - } finally { - if (((mutable_bitField0_ & 0x00000002) == 0x00000002)) { - previousSessions_ = java.util.Collections.unmodifiableList(previousSessions_); - } - this.unknownFields = unknownFields.build(); - makeExtensionsImmutable(); - } - } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return org.session.libsignal.libsignal.state.StorageProtos.internal_static_textsecure_RecordStructure_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return org.session.libsignal.libsignal.state.StorageProtos.internal_static_textsecure_RecordStructure_fieldAccessorTable - .ensureFieldAccessorsInitialized( - org.session.libsignal.libsignal.state.StorageProtos.RecordStructure.class, org.session.libsignal.libsignal.state.StorageProtos.RecordStructure.Builder.class); - } - - public static com.google.protobuf.Parser PARSER = - new com.google.protobuf.AbstractParser() { - public RecordStructure parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return new RecordStructure(input, extensionRegistry); - } - }; - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - private int bitField0_; - // optional .textsecure.SessionStructure currentSession = 1; - public static final int CURRENTSESSION_FIELD_NUMBER = 1; - private org.session.libsignal.libsignal.state.StorageProtos.SessionStructure currentSession_; - /** - * optional .textsecure.SessionStructure currentSession = 1; - */ - public boolean hasCurrentSession() { - return ((bitField0_ & 0x00000001) == 0x00000001); - } - /** - * optional .textsecure.SessionStructure currentSession = 1; - */ - public org.session.libsignal.libsignal.state.StorageProtos.SessionStructure getCurrentSession() { - return currentSession_; - } - /** - * optional .textsecure.SessionStructure currentSession = 1; - */ - public org.session.libsignal.libsignal.state.StorageProtos.SessionStructureOrBuilder getCurrentSessionOrBuilder() { - return currentSession_; - } - - // repeated .textsecure.SessionStructure previousSessions = 2; - public static final int PREVIOUSSESSIONS_FIELD_NUMBER = 2; - private java.util.List previousSessions_; - /** - * repeated .textsecure.SessionStructure previousSessions = 2; - */ - public java.util.List getPreviousSessionsList() { - return previousSessions_; - } - /** - * repeated .textsecure.SessionStructure previousSessions = 2; - */ - public java.util.List - getPreviousSessionsOrBuilderList() { - return previousSessions_; - } - /** - * repeated .textsecure.SessionStructure previousSessions = 2; - */ - public int getPreviousSessionsCount() { - return previousSessions_.size(); - } - /** - * repeated .textsecure.SessionStructure previousSessions = 2; - */ - public org.session.libsignal.libsignal.state.StorageProtos.SessionStructure getPreviousSessions(int index) { - return previousSessions_.get(index); - } - /** - * repeated .textsecure.SessionStructure previousSessions = 2; - */ - public org.session.libsignal.libsignal.state.StorageProtos.SessionStructureOrBuilder getPreviousSessionsOrBuilder( - int index) { - return previousSessions_.get(index); - } - - private void initFields() { - currentSession_ = org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.getDefaultInstance(); - previousSessions_ = java.util.Collections.emptyList(); - } - private byte memoizedIsInitialized = -1; - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized != -1) return isInitialized == 1; - - memoizedIsInitialized = 1; - return true; - } - - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - getSerializedSize(); - if (((bitField0_ & 0x00000001) == 0x00000001)) { - output.writeMessage(1, currentSession_); - } - for (int i = 0; i < previousSessions_.size(); i++) { - output.writeMessage(2, previousSessions_.get(i)); - } - getUnknownFields().writeTo(output); - } - - private int memoizedSerializedSize = -1; - public int getSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (((bitField0_ & 0x00000001) == 0x00000001)) { - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(1, currentSession_); - } - for (int i = 0; i < previousSessions_.size(); i++) { - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(2, previousSessions_.get(i)); - } - size += getUnknownFields().getSerializedSize(); - memoizedSerializedSize = size; - return size; - } - - private static final long serialVersionUID = 0L; - @java.lang.Override - protected java.lang.Object writeReplace() - throws java.io.ObjectStreamException { - return super.writeReplace(); - } - - public static org.session.libsignal.libsignal.state.StorageProtos.RecordStructure parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static org.session.libsignal.libsignal.state.StorageProtos.RecordStructure parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static org.session.libsignal.libsignal.state.StorageProtos.RecordStructure parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static org.session.libsignal.libsignal.state.StorageProtos.RecordStructure parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static org.session.libsignal.libsignal.state.StorageProtos.RecordStructure parseFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static org.session.libsignal.libsignal.state.StorageProtos.RecordStructure parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - public static org.session.libsignal.libsignal.state.StorageProtos.RecordStructure parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input); - } - public static org.session.libsignal.libsignal.state.StorageProtos.RecordStructure parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input, extensionRegistry); - } - public static org.session.libsignal.libsignal.state.StorageProtos.RecordStructure parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static org.session.libsignal.libsignal.state.StorageProtos.RecordStructure parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - - public static Builder newBuilder() { return Builder.create(); } - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder(org.session.libsignal.libsignal.state.StorageProtos.RecordStructure prototype) { - return newBuilder().mergeFrom(prototype); - } - public Builder toBuilder() { return newBuilder(this); } - - @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * Protobuf type {@code textsecure.RecordStructure} - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessage.Builder - implements org.session.libsignal.libsignal.state.StorageProtos.RecordStructureOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return org.session.libsignal.libsignal.state.StorageProtos.internal_static_textsecure_RecordStructure_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return org.session.libsignal.libsignal.state.StorageProtos.internal_static_textsecure_RecordStructure_fieldAccessorTable - .ensureFieldAccessorsInitialized( - org.session.libsignal.libsignal.state.StorageProtos.RecordStructure.class, org.session.libsignal.libsignal.state.StorageProtos.RecordStructure.Builder.class); - } - - // Construct using org.session.libsignal.libsignal.state.StorageProtos.RecordStructure.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { - getCurrentSessionFieldBuilder(); - getPreviousSessionsFieldBuilder(); - } - } - private static Builder create() { - return new Builder(); - } - - public Builder clear() { - super.clear(); - if (currentSessionBuilder_ == null) { - currentSession_ = org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.getDefaultInstance(); - } else { - currentSessionBuilder_.clear(); - } - bitField0_ = (bitField0_ & ~0x00000001); - if (previousSessionsBuilder_ == null) { - previousSessions_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000002); - } else { - previousSessionsBuilder_.clear(); - } - return this; - } - - public Builder clone() { - return create().mergeFrom(buildPartial()); - } - - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return org.session.libsignal.libsignal.state.StorageProtos.internal_static_textsecure_RecordStructure_descriptor; - } - - public org.session.libsignal.libsignal.state.StorageProtos.RecordStructure getDefaultInstanceForType() { - return org.session.libsignal.libsignal.state.StorageProtos.RecordStructure.getDefaultInstance(); - } - - public org.session.libsignal.libsignal.state.StorageProtos.RecordStructure build() { - org.session.libsignal.libsignal.state.StorageProtos.RecordStructure result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - public org.session.libsignal.libsignal.state.StorageProtos.RecordStructure buildPartial() { - org.session.libsignal.libsignal.state.StorageProtos.RecordStructure result = new org.session.libsignal.libsignal.state.StorageProtos.RecordStructure(this); - int from_bitField0_ = bitField0_; - int to_bitField0_ = 0; - if (((from_bitField0_ & 0x00000001) == 0x00000001)) { - to_bitField0_ |= 0x00000001; - } - if (currentSessionBuilder_ == null) { - result.currentSession_ = currentSession_; - } else { - result.currentSession_ = currentSessionBuilder_.build(); - } - if (previousSessionsBuilder_ == null) { - if (((bitField0_ & 0x00000002) == 0x00000002)) { - previousSessions_ = java.util.Collections.unmodifiableList(previousSessions_); - bitField0_ = (bitField0_ & ~0x00000002); - } - result.previousSessions_ = previousSessions_; - } else { - result.previousSessions_ = previousSessionsBuilder_.build(); - } - result.bitField0_ = to_bitField0_; - onBuilt(); - return result; - } - - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof org.session.libsignal.libsignal.state.StorageProtos.RecordStructure) { - return mergeFrom((org.session.libsignal.libsignal.state.StorageProtos.RecordStructure)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(org.session.libsignal.libsignal.state.StorageProtos.RecordStructure other) { - if (other == org.session.libsignal.libsignal.state.StorageProtos.RecordStructure.getDefaultInstance()) return this; - if (other.hasCurrentSession()) { - mergeCurrentSession(other.getCurrentSession()); - } - if (previousSessionsBuilder_ == null) { - if (!other.previousSessions_.isEmpty()) { - if (previousSessions_.isEmpty()) { - previousSessions_ = other.previousSessions_; - bitField0_ = (bitField0_ & ~0x00000002); - } else { - ensurePreviousSessionsIsMutable(); - previousSessions_.addAll(other.previousSessions_); - } - onChanged(); - } - } else { - if (!other.previousSessions_.isEmpty()) { - if (previousSessionsBuilder_.isEmpty()) { - previousSessionsBuilder_.dispose(); - previousSessionsBuilder_ = null; - previousSessions_ = other.previousSessions_; - bitField0_ = (bitField0_ & ~0x00000002); - previousSessionsBuilder_ = - com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders ? - getPreviousSessionsFieldBuilder() : null; - } else { - previousSessionsBuilder_.addAllMessages(other.previousSessions_); - } - } - } - this.mergeUnknownFields(other.getUnknownFields()); - return this; - } - - public final boolean isInitialized() { - return true; - } - - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - org.session.libsignal.libsignal.state.StorageProtos.RecordStructure parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (org.session.libsignal.libsignal.state.StorageProtos.RecordStructure) e.getUnfinishedMessage(); - throw e; - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - private int bitField0_; - - // optional .textsecure.SessionStructure currentSession = 1; - private org.session.libsignal.libsignal.state.StorageProtos.SessionStructure currentSession_ = org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.getDefaultInstance(); - private com.google.protobuf.SingleFieldBuilder< - org.session.libsignal.libsignal.state.StorageProtos.SessionStructure, org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Builder, org.session.libsignal.libsignal.state.StorageProtos.SessionStructureOrBuilder> currentSessionBuilder_; - /** - * optional .textsecure.SessionStructure currentSession = 1; - */ - public boolean hasCurrentSession() { - return ((bitField0_ & 0x00000001) == 0x00000001); - } - /** - * optional .textsecure.SessionStructure currentSession = 1; - */ - public org.session.libsignal.libsignal.state.StorageProtos.SessionStructure getCurrentSession() { - if (currentSessionBuilder_ == null) { - return currentSession_; - } else { - return currentSessionBuilder_.getMessage(); - } - } - /** - * optional .textsecure.SessionStructure currentSession = 1; - */ - public Builder setCurrentSession(org.session.libsignal.libsignal.state.StorageProtos.SessionStructure value) { - if (currentSessionBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - currentSession_ = value; - onChanged(); - } else { - currentSessionBuilder_.setMessage(value); - } - bitField0_ |= 0x00000001; - return this; - } - /** - * optional .textsecure.SessionStructure currentSession = 1; - */ - public Builder setCurrentSession( - org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Builder builderForValue) { - if (currentSessionBuilder_ == null) { - currentSession_ = builderForValue.build(); - onChanged(); - } else { - currentSessionBuilder_.setMessage(builderForValue.build()); - } - bitField0_ |= 0x00000001; - return this; - } - /** - * optional .textsecure.SessionStructure currentSession = 1; - */ - public Builder mergeCurrentSession(org.session.libsignal.libsignal.state.StorageProtos.SessionStructure value) { - if (currentSessionBuilder_ == null) { - if (((bitField0_ & 0x00000001) == 0x00000001) && - currentSession_ != org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.getDefaultInstance()) { - currentSession_ = - org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.newBuilder(currentSession_).mergeFrom(value).buildPartial(); - } else { - currentSession_ = value; - } - onChanged(); - } else { - currentSessionBuilder_.mergeFrom(value); - } - bitField0_ |= 0x00000001; - return this; - } - /** - * optional .textsecure.SessionStructure currentSession = 1; - */ - public Builder clearCurrentSession() { - if (currentSessionBuilder_ == null) { - currentSession_ = org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.getDefaultInstance(); - onChanged(); - } else { - currentSessionBuilder_.clear(); - } - bitField0_ = (bitField0_ & ~0x00000001); - return this; - } - /** - * optional .textsecure.SessionStructure currentSession = 1; - */ - public org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Builder getCurrentSessionBuilder() { - bitField0_ |= 0x00000001; - onChanged(); - return getCurrentSessionFieldBuilder().getBuilder(); - } - /** - * optional .textsecure.SessionStructure currentSession = 1; - */ - public org.session.libsignal.libsignal.state.StorageProtos.SessionStructureOrBuilder getCurrentSessionOrBuilder() { - if (currentSessionBuilder_ != null) { - return currentSessionBuilder_.getMessageOrBuilder(); - } else { - return currentSession_; - } - } - /** - * optional .textsecure.SessionStructure currentSession = 1; - */ - private com.google.protobuf.SingleFieldBuilder< - org.session.libsignal.libsignal.state.StorageProtos.SessionStructure, org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Builder, org.session.libsignal.libsignal.state.StorageProtos.SessionStructureOrBuilder> - getCurrentSessionFieldBuilder() { - if (currentSessionBuilder_ == null) { - currentSessionBuilder_ = new com.google.protobuf.SingleFieldBuilder< - org.session.libsignal.libsignal.state.StorageProtos.SessionStructure, org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Builder, org.session.libsignal.libsignal.state.StorageProtos.SessionStructureOrBuilder>( - currentSession_, - getParentForChildren(), - isClean()); - currentSession_ = null; - } - return currentSessionBuilder_; - } - - // repeated .textsecure.SessionStructure previousSessions = 2; - private java.util.List previousSessions_ = - java.util.Collections.emptyList(); - private void ensurePreviousSessionsIsMutable() { - if (!((bitField0_ & 0x00000002) == 0x00000002)) { - previousSessions_ = new java.util.ArrayList(previousSessions_); - bitField0_ |= 0x00000002; - } - } - - private com.google.protobuf.RepeatedFieldBuilder< - org.session.libsignal.libsignal.state.StorageProtos.SessionStructure, org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Builder, org.session.libsignal.libsignal.state.StorageProtos.SessionStructureOrBuilder> previousSessionsBuilder_; - - /** - * repeated .textsecure.SessionStructure previousSessions = 2; - */ - public java.util.List getPreviousSessionsList() { - if (previousSessionsBuilder_ == null) { - return java.util.Collections.unmodifiableList(previousSessions_); - } else { - return previousSessionsBuilder_.getMessageList(); - } - } - /** - * repeated .textsecure.SessionStructure previousSessions = 2; - */ - public int getPreviousSessionsCount() { - if (previousSessionsBuilder_ == null) { - return previousSessions_.size(); - } else { - return previousSessionsBuilder_.getCount(); - } - } - /** - * repeated .textsecure.SessionStructure previousSessions = 2; - */ - public org.session.libsignal.libsignal.state.StorageProtos.SessionStructure getPreviousSessions(int index) { - if (previousSessionsBuilder_ == null) { - return previousSessions_.get(index); - } else { - return previousSessionsBuilder_.getMessage(index); - } - } - /** - * repeated .textsecure.SessionStructure previousSessions = 2; - */ - public Builder setPreviousSessions( - int index, org.session.libsignal.libsignal.state.StorageProtos.SessionStructure value) { - if (previousSessionsBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensurePreviousSessionsIsMutable(); - previousSessions_.set(index, value); - onChanged(); - } else { - previousSessionsBuilder_.setMessage(index, value); - } - return this; - } - /** - * repeated .textsecure.SessionStructure previousSessions = 2; - */ - public Builder setPreviousSessions( - int index, org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Builder builderForValue) { - if (previousSessionsBuilder_ == null) { - ensurePreviousSessionsIsMutable(); - previousSessions_.set(index, builderForValue.build()); - onChanged(); - } else { - previousSessionsBuilder_.setMessage(index, builderForValue.build()); - } - return this; - } - /** - * repeated .textsecure.SessionStructure previousSessions = 2; - */ - public Builder addPreviousSessions(org.session.libsignal.libsignal.state.StorageProtos.SessionStructure value) { - if (previousSessionsBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensurePreviousSessionsIsMutable(); - previousSessions_.add(value); - onChanged(); - } else { - previousSessionsBuilder_.addMessage(value); - } - return this; - } - /** - * repeated .textsecure.SessionStructure previousSessions = 2; - */ - public Builder addPreviousSessions( - int index, org.session.libsignal.libsignal.state.StorageProtos.SessionStructure value) { - if (previousSessionsBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensurePreviousSessionsIsMutable(); - previousSessions_.add(index, value); - onChanged(); - } else { - previousSessionsBuilder_.addMessage(index, value); - } - return this; - } - /** - * repeated .textsecure.SessionStructure previousSessions = 2; - */ - public Builder addPreviousSessions( - org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Builder builderForValue) { - if (previousSessionsBuilder_ == null) { - ensurePreviousSessionsIsMutable(); - previousSessions_.add(builderForValue.build()); - onChanged(); - } else { - previousSessionsBuilder_.addMessage(builderForValue.build()); - } - return this; - } - /** - * repeated .textsecure.SessionStructure previousSessions = 2; - */ - public Builder addPreviousSessions( - int index, org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Builder builderForValue) { - if (previousSessionsBuilder_ == null) { - ensurePreviousSessionsIsMutable(); - previousSessions_.add(index, builderForValue.build()); - onChanged(); - } else { - previousSessionsBuilder_.addMessage(index, builderForValue.build()); - } - return this; - } - /** - * repeated .textsecure.SessionStructure previousSessions = 2; - */ - public Builder addAllPreviousSessions( - java.lang.Iterable values) { - if (previousSessionsBuilder_ == null) { - ensurePreviousSessionsIsMutable(); - super.addAll(values, previousSessions_); - onChanged(); - } else { - previousSessionsBuilder_.addAllMessages(values); - } - return this; - } - /** - * repeated .textsecure.SessionStructure previousSessions = 2; - */ - public Builder clearPreviousSessions() { - if (previousSessionsBuilder_ == null) { - previousSessions_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000002); - onChanged(); - } else { - previousSessionsBuilder_.clear(); - } - return this; - } - /** - * repeated .textsecure.SessionStructure previousSessions = 2; - */ - public Builder removePreviousSessions(int index) { - if (previousSessionsBuilder_ == null) { - ensurePreviousSessionsIsMutable(); - previousSessions_.remove(index); - onChanged(); - } else { - previousSessionsBuilder_.remove(index); - } - return this; - } - /** - * repeated .textsecure.SessionStructure previousSessions = 2; - */ - public org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Builder getPreviousSessionsBuilder( - int index) { - return getPreviousSessionsFieldBuilder().getBuilder(index); - } - /** - * repeated .textsecure.SessionStructure previousSessions = 2; - */ - public org.session.libsignal.libsignal.state.StorageProtos.SessionStructureOrBuilder getPreviousSessionsOrBuilder( - int index) { - if (previousSessionsBuilder_ == null) { - return previousSessions_.get(index); } else { - return previousSessionsBuilder_.getMessageOrBuilder(index); - } - } - /** - * repeated .textsecure.SessionStructure previousSessions = 2; - */ - public java.util.List - getPreviousSessionsOrBuilderList() { - if (previousSessionsBuilder_ != null) { - return previousSessionsBuilder_.getMessageOrBuilderList(); - } else { - return java.util.Collections.unmodifiableList(previousSessions_); - } - } - /** - * repeated .textsecure.SessionStructure previousSessions = 2; - */ - public org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Builder addPreviousSessionsBuilder() { - return getPreviousSessionsFieldBuilder().addBuilder( - org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.getDefaultInstance()); - } - /** - * repeated .textsecure.SessionStructure previousSessions = 2; - */ - public org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Builder addPreviousSessionsBuilder( - int index) { - return getPreviousSessionsFieldBuilder().addBuilder( - index, org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.getDefaultInstance()); - } - /** - * repeated .textsecure.SessionStructure previousSessions = 2; - */ - public java.util.List - getPreviousSessionsBuilderList() { - return getPreviousSessionsFieldBuilder().getBuilderList(); - } - private com.google.protobuf.RepeatedFieldBuilder< - org.session.libsignal.libsignal.state.StorageProtos.SessionStructure, org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Builder, org.session.libsignal.libsignal.state.StorageProtos.SessionStructureOrBuilder> - getPreviousSessionsFieldBuilder() { - if (previousSessionsBuilder_ == null) { - previousSessionsBuilder_ = new com.google.protobuf.RepeatedFieldBuilder< - org.session.libsignal.libsignal.state.StorageProtos.SessionStructure, org.session.libsignal.libsignal.state.StorageProtos.SessionStructure.Builder, org.session.libsignal.libsignal.state.StorageProtos.SessionStructureOrBuilder>( - previousSessions_, - ((bitField0_ & 0x00000002) == 0x00000002), - getParentForChildren(), - isClean()); - previousSessions_ = null; - } - return previousSessionsBuilder_; - } - - // @@protoc_insertion_point(builder_scope:textsecure.RecordStructure) - } - - static { - defaultInstance = new RecordStructure(true); - defaultInstance.initFields(); - } - - // @@protoc_insertion_point(class_scope:textsecure.RecordStructure) - } - - public interface PreKeyRecordStructureOrBuilder - extends com.google.protobuf.MessageOrBuilder { - - // optional uint32 id = 1; - /** - * optional uint32 id = 1; - */ - boolean hasId(); - /** - * optional uint32 id = 1; - */ - int getId(); - - // optional bytes publicKey = 2; - /** - * optional bytes publicKey = 2; - */ - boolean hasPublicKey(); - /** - * optional bytes publicKey = 2; - */ - com.google.protobuf.ByteString getPublicKey(); - - // optional bytes privateKey = 3; - /** - * optional bytes privateKey = 3; - */ - boolean hasPrivateKey(); - /** - * optional bytes privateKey = 3; - */ - com.google.protobuf.ByteString getPrivateKey(); - } - /** - * Protobuf type {@code textsecure.PreKeyRecordStructure} - */ - public static final class PreKeyRecordStructure extends - com.google.protobuf.GeneratedMessage - implements PreKeyRecordStructureOrBuilder { - // Use PreKeyRecordStructure.newBuilder() to construct. - private PreKeyRecordStructure(com.google.protobuf.GeneratedMessage.Builder builder) { - super(builder); - this.unknownFields = builder.getUnknownFields(); - } - private PreKeyRecordStructure(boolean noInit) { this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); } - - private static final PreKeyRecordStructure defaultInstance; - public static PreKeyRecordStructure getDefaultInstance() { - return defaultInstance; - } - - public PreKeyRecordStructure getDefaultInstanceForType() { - return defaultInstance; - } - - private final com.google.protobuf.UnknownFieldSet unknownFields; - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return this.unknownFields; - } - private PreKeyRecordStructure( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - initFields(); - int mutable_bitField0_ = 0; - com.google.protobuf.UnknownFieldSet.Builder unknownFields = - com.google.protobuf.UnknownFieldSet.newBuilder(); - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: { - if (!parseUnknownField(input, unknownFields, - extensionRegistry, tag)) { - done = true; - } - break; - } - case 8: { - bitField0_ |= 0x00000001; - id_ = input.readUInt32(); - break; - } - case 18: { - bitField0_ |= 0x00000002; - publicKey_ = input.readBytes(); - break; - } - case 26: { - bitField0_ |= 0x00000004; - privateKey_ = input.readBytes(); - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(this); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException( - e.getMessage()).setUnfinishedMessage(this); - } finally { - this.unknownFields = unknownFields.build(); - makeExtensionsImmutable(); - } - } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return org.session.libsignal.libsignal.state.StorageProtos.internal_static_textsecure_PreKeyRecordStructure_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return org.session.libsignal.libsignal.state.StorageProtos.internal_static_textsecure_PreKeyRecordStructure_fieldAccessorTable - .ensureFieldAccessorsInitialized( - org.session.libsignal.libsignal.state.StorageProtos.PreKeyRecordStructure.class, org.session.libsignal.libsignal.state.StorageProtos.PreKeyRecordStructure.Builder.class); - } - - public static com.google.protobuf.Parser PARSER = - new com.google.protobuf.AbstractParser() { - public PreKeyRecordStructure parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return new PreKeyRecordStructure(input, extensionRegistry); - } - }; - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - private int bitField0_; - // optional uint32 id = 1; - public static final int ID_FIELD_NUMBER = 1; - private int id_; - /** - * optional uint32 id = 1; - */ - public boolean hasId() { - return ((bitField0_ & 0x00000001) == 0x00000001); - } - /** - * optional uint32 id = 1; - */ - public int getId() { - return id_; - } - - // optional bytes publicKey = 2; - public static final int PUBLICKEY_FIELD_NUMBER = 2; - private com.google.protobuf.ByteString publicKey_; - /** - * optional bytes publicKey = 2; - */ - public boolean hasPublicKey() { - return ((bitField0_ & 0x00000002) == 0x00000002); - } - /** - * optional bytes publicKey = 2; - */ - public com.google.protobuf.ByteString getPublicKey() { - return publicKey_; - } - - // optional bytes privateKey = 3; - public static final int PRIVATEKEY_FIELD_NUMBER = 3; - private com.google.protobuf.ByteString privateKey_; - /** - * optional bytes privateKey = 3; - */ - public boolean hasPrivateKey() { - return ((bitField0_ & 0x00000004) == 0x00000004); - } - /** - * optional bytes privateKey = 3; - */ - public com.google.protobuf.ByteString getPrivateKey() { - return privateKey_; - } - - private void initFields() { - id_ = 0; - publicKey_ = com.google.protobuf.ByteString.EMPTY; - privateKey_ = com.google.protobuf.ByteString.EMPTY; - } - private byte memoizedIsInitialized = -1; - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized != -1) return isInitialized == 1; - - memoizedIsInitialized = 1; - return true; - } - - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - getSerializedSize(); - if (((bitField0_ & 0x00000001) == 0x00000001)) { - output.writeUInt32(1, id_); - } - if (((bitField0_ & 0x00000002) == 0x00000002)) { - output.writeBytes(2, publicKey_); - } - if (((bitField0_ & 0x00000004) == 0x00000004)) { - output.writeBytes(3, privateKey_); - } - getUnknownFields().writeTo(output); - } - - private int memoizedSerializedSize = -1; - public int getSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (((bitField0_ & 0x00000001) == 0x00000001)) { - size += com.google.protobuf.CodedOutputStream - .computeUInt32Size(1, id_); - } - if (((bitField0_ & 0x00000002) == 0x00000002)) { - size += com.google.protobuf.CodedOutputStream - .computeBytesSize(2, publicKey_); - } - if (((bitField0_ & 0x00000004) == 0x00000004)) { - size += com.google.protobuf.CodedOutputStream - .computeBytesSize(3, privateKey_); - } - size += getUnknownFields().getSerializedSize(); - memoizedSerializedSize = size; - return size; - } - - private static final long serialVersionUID = 0L; - @java.lang.Override - protected java.lang.Object writeReplace() - throws java.io.ObjectStreamException { - return super.writeReplace(); - } - - public static org.session.libsignal.libsignal.state.StorageProtos.PreKeyRecordStructure parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static org.session.libsignal.libsignal.state.StorageProtos.PreKeyRecordStructure parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static org.session.libsignal.libsignal.state.StorageProtos.PreKeyRecordStructure parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static org.session.libsignal.libsignal.state.StorageProtos.PreKeyRecordStructure parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static org.session.libsignal.libsignal.state.StorageProtos.PreKeyRecordStructure parseFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static org.session.libsignal.libsignal.state.StorageProtos.PreKeyRecordStructure parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - public static org.session.libsignal.libsignal.state.StorageProtos.PreKeyRecordStructure parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input); - } - public static org.session.libsignal.libsignal.state.StorageProtos.PreKeyRecordStructure parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input, extensionRegistry); - } - public static org.session.libsignal.libsignal.state.StorageProtos.PreKeyRecordStructure parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static org.session.libsignal.libsignal.state.StorageProtos.PreKeyRecordStructure parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - - public static Builder newBuilder() { return Builder.create(); } - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder(org.session.libsignal.libsignal.state.StorageProtos.PreKeyRecordStructure prototype) { - return newBuilder().mergeFrom(prototype); - } - public Builder toBuilder() { return newBuilder(this); } - - @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * Protobuf type {@code textsecure.PreKeyRecordStructure} - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessage.Builder - implements org.session.libsignal.libsignal.state.StorageProtos.PreKeyRecordStructureOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return org.session.libsignal.libsignal.state.StorageProtos.internal_static_textsecure_PreKeyRecordStructure_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return org.session.libsignal.libsignal.state.StorageProtos.internal_static_textsecure_PreKeyRecordStructure_fieldAccessorTable - .ensureFieldAccessorsInitialized( - org.session.libsignal.libsignal.state.StorageProtos.PreKeyRecordStructure.class, org.session.libsignal.libsignal.state.StorageProtos.PreKeyRecordStructure.Builder.class); - } - - // Construct using org.session.libsignal.libsignal.state.StorageProtos.PreKeyRecordStructure.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { - } - } - private static Builder create() { - return new Builder(); - } - - public Builder clear() { - super.clear(); - id_ = 0; - bitField0_ = (bitField0_ & ~0x00000001); - publicKey_ = com.google.protobuf.ByteString.EMPTY; - bitField0_ = (bitField0_ & ~0x00000002); - privateKey_ = com.google.protobuf.ByteString.EMPTY; - bitField0_ = (bitField0_ & ~0x00000004); - return this; - } - - public Builder clone() { - return create().mergeFrom(buildPartial()); - } - - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return org.session.libsignal.libsignal.state.StorageProtos.internal_static_textsecure_PreKeyRecordStructure_descriptor; - } - - public org.session.libsignal.libsignal.state.StorageProtos.PreKeyRecordStructure getDefaultInstanceForType() { - return org.session.libsignal.libsignal.state.StorageProtos.PreKeyRecordStructure.getDefaultInstance(); - } - - public org.session.libsignal.libsignal.state.StorageProtos.PreKeyRecordStructure build() { - org.session.libsignal.libsignal.state.StorageProtos.PreKeyRecordStructure result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - public org.session.libsignal.libsignal.state.StorageProtos.PreKeyRecordStructure buildPartial() { - org.session.libsignal.libsignal.state.StorageProtos.PreKeyRecordStructure result = new org.session.libsignal.libsignal.state.StorageProtos.PreKeyRecordStructure(this); - int from_bitField0_ = bitField0_; - int to_bitField0_ = 0; - if (((from_bitField0_ & 0x00000001) == 0x00000001)) { - to_bitField0_ |= 0x00000001; - } - result.id_ = id_; - if (((from_bitField0_ & 0x00000002) == 0x00000002)) { - to_bitField0_ |= 0x00000002; - } - result.publicKey_ = publicKey_; - if (((from_bitField0_ & 0x00000004) == 0x00000004)) { - to_bitField0_ |= 0x00000004; - } - result.privateKey_ = privateKey_; - result.bitField0_ = to_bitField0_; - onBuilt(); - return result; - } - - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof org.session.libsignal.libsignal.state.StorageProtos.PreKeyRecordStructure) { - return mergeFrom((org.session.libsignal.libsignal.state.StorageProtos.PreKeyRecordStructure)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(org.session.libsignal.libsignal.state.StorageProtos.PreKeyRecordStructure other) { - if (other == org.session.libsignal.libsignal.state.StorageProtos.PreKeyRecordStructure.getDefaultInstance()) return this; - if (other.hasId()) { - setId(other.getId()); - } - if (other.hasPublicKey()) { - setPublicKey(other.getPublicKey()); - } - if (other.hasPrivateKey()) { - setPrivateKey(other.getPrivateKey()); - } - this.mergeUnknownFields(other.getUnknownFields()); - return this; - } - - public final boolean isInitialized() { - return true; - } - - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - org.session.libsignal.libsignal.state.StorageProtos.PreKeyRecordStructure parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (org.session.libsignal.libsignal.state.StorageProtos.PreKeyRecordStructure) e.getUnfinishedMessage(); - throw e; - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - private int bitField0_; - - // optional uint32 id = 1; - private int id_ ; - /** - * optional uint32 id = 1; - */ - public boolean hasId() { - return ((bitField0_ & 0x00000001) == 0x00000001); - } - /** - * optional uint32 id = 1; - */ - public int getId() { - return id_; - } - /** - * optional uint32 id = 1; - */ - public Builder setId(int value) { - bitField0_ |= 0x00000001; - id_ = value; - onChanged(); - return this; - } - /** - * optional uint32 id = 1; - */ - public Builder clearId() { - bitField0_ = (bitField0_ & ~0x00000001); - id_ = 0; - onChanged(); - return this; - } - - // optional bytes publicKey = 2; - private com.google.protobuf.ByteString publicKey_ = com.google.protobuf.ByteString.EMPTY; - /** - * optional bytes publicKey = 2; - */ - public boolean hasPublicKey() { - return ((bitField0_ & 0x00000002) == 0x00000002); - } - /** - * optional bytes publicKey = 2; - */ - public com.google.protobuf.ByteString getPublicKey() { - return publicKey_; - } - /** - * optional bytes publicKey = 2; - */ - public Builder setPublicKey(com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - bitField0_ |= 0x00000002; - publicKey_ = value; - onChanged(); - return this; - } - /** - * optional bytes publicKey = 2; - */ - public Builder clearPublicKey() { - bitField0_ = (bitField0_ & ~0x00000002); - publicKey_ = getDefaultInstance().getPublicKey(); - onChanged(); - return this; - } - - // optional bytes privateKey = 3; - private com.google.protobuf.ByteString privateKey_ = com.google.protobuf.ByteString.EMPTY; - /** - * optional bytes privateKey = 3; - */ - public boolean hasPrivateKey() { - return ((bitField0_ & 0x00000004) == 0x00000004); - } - /** - * optional bytes privateKey = 3; - */ - public com.google.protobuf.ByteString getPrivateKey() { - return privateKey_; - } - /** - * optional bytes privateKey = 3; - */ - public Builder setPrivateKey(com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - bitField0_ |= 0x00000004; - privateKey_ = value; - onChanged(); - return this; - } - /** - * optional bytes privateKey = 3; - */ - public Builder clearPrivateKey() { - bitField0_ = (bitField0_ & ~0x00000004); - privateKey_ = getDefaultInstance().getPrivateKey(); - onChanged(); - return this; - } - - // @@protoc_insertion_point(builder_scope:textsecure.PreKeyRecordStructure) - } - - static { - defaultInstance = new PreKeyRecordStructure(true); - defaultInstance.initFields(); - } - - // @@protoc_insertion_point(class_scope:textsecure.PreKeyRecordStructure) - } - - public interface SignedPreKeyRecordStructureOrBuilder - extends com.google.protobuf.MessageOrBuilder { - - // optional uint32 id = 1; - /** - * optional uint32 id = 1; - */ - boolean hasId(); - /** - * optional uint32 id = 1; - */ - int getId(); - - // optional bytes publicKey = 2; - /** - * optional bytes publicKey = 2; - */ - boolean hasPublicKey(); - /** - * optional bytes publicKey = 2; - */ - com.google.protobuf.ByteString getPublicKey(); - - // optional bytes privateKey = 3; - /** - * optional bytes privateKey = 3; - */ - boolean hasPrivateKey(); - /** - * optional bytes privateKey = 3; - */ - com.google.protobuf.ByteString getPrivateKey(); - - // optional bytes signature = 4; - /** - * optional bytes signature = 4; - */ - boolean hasSignature(); - /** - * optional bytes signature = 4; - */ - com.google.protobuf.ByteString getSignature(); - - // optional fixed64 timestamp = 5; - /** - * optional fixed64 timestamp = 5; - */ - boolean hasTimestamp(); - /** - * optional fixed64 timestamp = 5; - */ - long getTimestamp(); - } - /** - * Protobuf type {@code textsecure.SignedPreKeyRecordStructure} - */ - public static final class SignedPreKeyRecordStructure extends - com.google.protobuf.GeneratedMessage - implements SignedPreKeyRecordStructureOrBuilder { - // Use SignedPreKeyRecordStructure.newBuilder() to construct. - private SignedPreKeyRecordStructure(com.google.protobuf.GeneratedMessage.Builder builder) { - super(builder); - this.unknownFields = builder.getUnknownFields(); - } - private SignedPreKeyRecordStructure(boolean noInit) { this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); } - - private static final SignedPreKeyRecordStructure defaultInstance; - public static SignedPreKeyRecordStructure getDefaultInstance() { - return defaultInstance; - } - - public SignedPreKeyRecordStructure getDefaultInstanceForType() { - return defaultInstance; - } - - private final com.google.protobuf.UnknownFieldSet unknownFields; - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return this.unknownFields; - } - private SignedPreKeyRecordStructure( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - initFields(); - int mutable_bitField0_ = 0; - com.google.protobuf.UnknownFieldSet.Builder unknownFields = - com.google.protobuf.UnknownFieldSet.newBuilder(); - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: { - if (!parseUnknownField(input, unknownFields, - extensionRegistry, tag)) { - done = true; - } - break; - } - case 8: { - bitField0_ |= 0x00000001; - id_ = input.readUInt32(); - break; - } - case 18: { - bitField0_ |= 0x00000002; - publicKey_ = input.readBytes(); - break; - } - case 26: { - bitField0_ |= 0x00000004; - privateKey_ = input.readBytes(); - break; - } - case 34: { - bitField0_ |= 0x00000008; - signature_ = input.readBytes(); - break; - } - case 41: { - bitField0_ |= 0x00000010; - timestamp_ = input.readFixed64(); - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(this); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException( - e.getMessage()).setUnfinishedMessage(this); - } finally { - this.unknownFields = unknownFields.build(); - makeExtensionsImmutable(); - } - } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return org.session.libsignal.libsignal.state.StorageProtos.internal_static_textsecure_SignedPreKeyRecordStructure_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return org.session.libsignal.libsignal.state.StorageProtos.internal_static_textsecure_SignedPreKeyRecordStructure_fieldAccessorTable - .ensureFieldAccessorsInitialized( - org.session.libsignal.libsignal.state.StorageProtos.SignedPreKeyRecordStructure.class, org.session.libsignal.libsignal.state.StorageProtos.SignedPreKeyRecordStructure.Builder.class); - } - - public static com.google.protobuf.Parser PARSER = - new com.google.protobuf.AbstractParser() { - public SignedPreKeyRecordStructure parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return new SignedPreKeyRecordStructure(input, extensionRegistry); - } - }; - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - private int bitField0_; - // optional uint32 id = 1; - public static final int ID_FIELD_NUMBER = 1; - private int id_; - /** - * optional uint32 id = 1; - */ - public boolean hasId() { - return ((bitField0_ & 0x00000001) == 0x00000001); - } - /** - * optional uint32 id = 1; - */ - public int getId() { - return id_; - } - - // optional bytes publicKey = 2; - public static final int PUBLICKEY_FIELD_NUMBER = 2; - private com.google.protobuf.ByteString publicKey_; - /** - * optional bytes publicKey = 2; - */ - public boolean hasPublicKey() { - return ((bitField0_ & 0x00000002) == 0x00000002); - } - /** - * optional bytes publicKey = 2; - */ - public com.google.protobuf.ByteString getPublicKey() { - return publicKey_; - } - - // optional bytes privateKey = 3; - public static final int PRIVATEKEY_FIELD_NUMBER = 3; - private com.google.protobuf.ByteString privateKey_; - /** - * optional bytes privateKey = 3; - */ - public boolean hasPrivateKey() { - return ((bitField0_ & 0x00000004) == 0x00000004); - } - /** - * optional bytes privateKey = 3; - */ - public com.google.protobuf.ByteString getPrivateKey() { - return privateKey_; - } - - // optional bytes signature = 4; - public static final int SIGNATURE_FIELD_NUMBER = 4; - private com.google.protobuf.ByteString signature_; - /** - * optional bytes signature = 4; - */ - public boolean hasSignature() { - return ((bitField0_ & 0x00000008) == 0x00000008); - } - /** - * optional bytes signature = 4; - */ - public com.google.protobuf.ByteString getSignature() { - return signature_; - } - - // optional fixed64 timestamp = 5; - public static final int TIMESTAMP_FIELD_NUMBER = 5; - private long timestamp_; - /** - * optional fixed64 timestamp = 5; - */ - public boolean hasTimestamp() { - return ((bitField0_ & 0x00000010) == 0x00000010); - } - /** - * optional fixed64 timestamp = 5; - */ - public long getTimestamp() { - return timestamp_; - } - - private void initFields() { - id_ = 0; - publicKey_ = com.google.protobuf.ByteString.EMPTY; - privateKey_ = com.google.protobuf.ByteString.EMPTY; - signature_ = com.google.protobuf.ByteString.EMPTY; - timestamp_ = 0L; - } - private byte memoizedIsInitialized = -1; - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized != -1) return isInitialized == 1; - - memoizedIsInitialized = 1; - return true; - } - - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - getSerializedSize(); - if (((bitField0_ & 0x00000001) == 0x00000001)) { - output.writeUInt32(1, id_); - } - if (((bitField0_ & 0x00000002) == 0x00000002)) { - output.writeBytes(2, publicKey_); - } - if (((bitField0_ & 0x00000004) == 0x00000004)) { - output.writeBytes(3, privateKey_); - } - if (((bitField0_ & 0x00000008) == 0x00000008)) { - output.writeBytes(4, signature_); - } - if (((bitField0_ & 0x00000010) == 0x00000010)) { - output.writeFixed64(5, timestamp_); - } - getUnknownFields().writeTo(output); - } - - private int memoizedSerializedSize = -1; - public int getSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (((bitField0_ & 0x00000001) == 0x00000001)) { - size += com.google.protobuf.CodedOutputStream - .computeUInt32Size(1, id_); - } - if (((bitField0_ & 0x00000002) == 0x00000002)) { - size += com.google.protobuf.CodedOutputStream - .computeBytesSize(2, publicKey_); - } - if (((bitField0_ & 0x00000004) == 0x00000004)) { - size += com.google.protobuf.CodedOutputStream - .computeBytesSize(3, privateKey_); - } - if (((bitField0_ & 0x00000008) == 0x00000008)) { - size += com.google.protobuf.CodedOutputStream - .computeBytesSize(4, signature_); - } - if (((bitField0_ & 0x00000010) == 0x00000010)) { - size += com.google.protobuf.CodedOutputStream - .computeFixed64Size(5, timestamp_); - } - size += getUnknownFields().getSerializedSize(); - memoizedSerializedSize = size; - return size; - } - - private static final long serialVersionUID = 0L; - @java.lang.Override - protected java.lang.Object writeReplace() - throws java.io.ObjectStreamException { - return super.writeReplace(); - } - - public static org.session.libsignal.libsignal.state.StorageProtos.SignedPreKeyRecordStructure parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static org.session.libsignal.libsignal.state.StorageProtos.SignedPreKeyRecordStructure parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static org.session.libsignal.libsignal.state.StorageProtos.SignedPreKeyRecordStructure parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static org.session.libsignal.libsignal.state.StorageProtos.SignedPreKeyRecordStructure parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static org.session.libsignal.libsignal.state.StorageProtos.SignedPreKeyRecordStructure parseFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static org.session.libsignal.libsignal.state.StorageProtos.SignedPreKeyRecordStructure parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - public static org.session.libsignal.libsignal.state.StorageProtos.SignedPreKeyRecordStructure parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input); - } - public static org.session.libsignal.libsignal.state.StorageProtos.SignedPreKeyRecordStructure parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input, extensionRegistry); - } - public static org.session.libsignal.libsignal.state.StorageProtos.SignedPreKeyRecordStructure parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static org.session.libsignal.libsignal.state.StorageProtos.SignedPreKeyRecordStructure parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - - public static Builder newBuilder() { return Builder.create(); } - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder(org.session.libsignal.libsignal.state.StorageProtos.SignedPreKeyRecordStructure prototype) { - return newBuilder().mergeFrom(prototype); - } - public Builder toBuilder() { return newBuilder(this); } - - @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * Protobuf type {@code textsecure.SignedPreKeyRecordStructure} - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessage.Builder - implements org.session.libsignal.libsignal.state.StorageProtos.SignedPreKeyRecordStructureOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return org.session.libsignal.libsignal.state.StorageProtos.internal_static_textsecure_SignedPreKeyRecordStructure_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return org.session.libsignal.libsignal.state.StorageProtos.internal_static_textsecure_SignedPreKeyRecordStructure_fieldAccessorTable - .ensureFieldAccessorsInitialized( - org.session.libsignal.libsignal.state.StorageProtos.SignedPreKeyRecordStructure.class, org.session.libsignal.libsignal.state.StorageProtos.SignedPreKeyRecordStructure.Builder.class); - } - - // Construct using org.session.libsignal.libsignal.state.StorageProtos.SignedPreKeyRecordStructure.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { - } - } - private static Builder create() { - return new Builder(); - } - - public Builder clear() { - super.clear(); - id_ = 0; - bitField0_ = (bitField0_ & ~0x00000001); - publicKey_ = com.google.protobuf.ByteString.EMPTY; - bitField0_ = (bitField0_ & ~0x00000002); - privateKey_ = com.google.protobuf.ByteString.EMPTY; - bitField0_ = (bitField0_ & ~0x00000004); - signature_ = com.google.protobuf.ByteString.EMPTY; - bitField0_ = (bitField0_ & ~0x00000008); - timestamp_ = 0L; - bitField0_ = (bitField0_ & ~0x00000010); - return this; - } - - public Builder clone() { - return create().mergeFrom(buildPartial()); - } - - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return org.session.libsignal.libsignal.state.StorageProtos.internal_static_textsecure_SignedPreKeyRecordStructure_descriptor; - } - - public org.session.libsignal.libsignal.state.StorageProtos.SignedPreKeyRecordStructure getDefaultInstanceForType() { - return org.session.libsignal.libsignal.state.StorageProtos.SignedPreKeyRecordStructure.getDefaultInstance(); - } - - public org.session.libsignal.libsignal.state.StorageProtos.SignedPreKeyRecordStructure build() { - org.session.libsignal.libsignal.state.StorageProtos.SignedPreKeyRecordStructure result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - public org.session.libsignal.libsignal.state.StorageProtos.SignedPreKeyRecordStructure buildPartial() { - org.session.libsignal.libsignal.state.StorageProtos.SignedPreKeyRecordStructure result = new org.session.libsignal.libsignal.state.StorageProtos.SignedPreKeyRecordStructure(this); - int from_bitField0_ = bitField0_; - int to_bitField0_ = 0; - if (((from_bitField0_ & 0x00000001) == 0x00000001)) { - to_bitField0_ |= 0x00000001; - } - result.id_ = id_; - if (((from_bitField0_ & 0x00000002) == 0x00000002)) { - to_bitField0_ |= 0x00000002; - } - result.publicKey_ = publicKey_; - if (((from_bitField0_ & 0x00000004) == 0x00000004)) { - to_bitField0_ |= 0x00000004; - } - result.privateKey_ = privateKey_; - if (((from_bitField0_ & 0x00000008) == 0x00000008)) { - to_bitField0_ |= 0x00000008; - } - result.signature_ = signature_; - if (((from_bitField0_ & 0x00000010) == 0x00000010)) { - to_bitField0_ |= 0x00000010; - } - result.timestamp_ = timestamp_; - result.bitField0_ = to_bitField0_; - onBuilt(); - return result; - } - - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof org.session.libsignal.libsignal.state.StorageProtos.SignedPreKeyRecordStructure) { - return mergeFrom((org.session.libsignal.libsignal.state.StorageProtos.SignedPreKeyRecordStructure)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(org.session.libsignal.libsignal.state.StorageProtos.SignedPreKeyRecordStructure other) { - if (other == org.session.libsignal.libsignal.state.StorageProtos.SignedPreKeyRecordStructure.getDefaultInstance()) return this; - if (other.hasId()) { - setId(other.getId()); - } - if (other.hasPublicKey()) { - setPublicKey(other.getPublicKey()); - } - if (other.hasPrivateKey()) { - setPrivateKey(other.getPrivateKey()); - } - if (other.hasSignature()) { - setSignature(other.getSignature()); - } - if (other.hasTimestamp()) { - setTimestamp(other.getTimestamp()); - } - this.mergeUnknownFields(other.getUnknownFields()); - return this; - } - - public final boolean isInitialized() { - return true; - } - - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - org.session.libsignal.libsignal.state.StorageProtos.SignedPreKeyRecordStructure parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (org.session.libsignal.libsignal.state.StorageProtos.SignedPreKeyRecordStructure) e.getUnfinishedMessage(); - throw e; - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - private int bitField0_; - - // optional uint32 id = 1; - private int id_ ; - /** - * optional uint32 id = 1; - */ - public boolean hasId() { - return ((bitField0_ & 0x00000001) == 0x00000001); - } - /** - * optional uint32 id = 1; - */ - public int getId() { - return id_; - } - /** - * optional uint32 id = 1; - */ - public Builder setId(int value) { - bitField0_ |= 0x00000001; - id_ = value; - onChanged(); - return this; - } - /** - * optional uint32 id = 1; - */ - public Builder clearId() { - bitField0_ = (bitField0_ & ~0x00000001); - id_ = 0; - onChanged(); - return this; - } - - // optional bytes publicKey = 2; - private com.google.protobuf.ByteString publicKey_ = com.google.protobuf.ByteString.EMPTY; - /** - * optional bytes publicKey = 2; - */ - public boolean hasPublicKey() { - return ((bitField0_ & 0x00000002) == 0x00000002); - } - /** - * optional bytes publicKey = 2; - */ - public com.google.protobuf.ByteString getPublicKey() { - return publicKey_; - } - /** - * optional bytes publicKey = 2; - */ - public Builder setPublicKey(com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - bitField0_ |= 0x00000002; - publicKey_ = value; - onChanged(); - return this; - } - /** - * optional bytes publicKey = 2; - */ - public Builder clearPublicKey() { - bitField0_ = (bitField0_ & ~0x00000002); - publicKey_ = getDefaultInstance().getPublicKey(); - onChanged(); - return this; - } - - // optional bytes privateKey = 3; - private com.google.protobuf.ByteString privateKey_ = com.google.protobuf.ByteString.EMPTY; - /** - * optional bytes privateKey = 3; - */ - public boolean hasPrivateKey() { - return ((bitField0_ & 0x00000004) == 0x00000004); - } - /** - * optional bytes privateKey = 3; - */ - public com.google.protobuf.ByteString getPrivateKey() { - return privateKey_; - } - /** - * optional bytes privateKey = 3; - */ - public Builder setPrivateKey(com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - bitField0_ |= 0x00000004; - privateKey_ = value; - onChanged(); - return this; - } - /** - * optional bytes privateKey = 3; - */ - public Builder clearPrivateKey() { - bitField0_ = (bitField0_ & ~0x00000004); - privateKey_ = getDefaultInstance().getPrivateKey(); - onChanged(); - return this; - } - - // optional bytes signature = 4; - private com.google.protobuf.ByteString signature_ = com.google.protobuf.ByteString.EMPTY; - /** - * optional bytes signature = 4; - */ - public boolean hasSignature() { - return ((bitField0_ & 0x00000008) == 0x00000008); - } - /** - * optional bytes signature = 4; - */ - public com.google.protobuf.ByteString getSignature() { - return signature_; - } - /** - * optional bytes signature = 4; - */ - public Builder setSignature(com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - bitField0_ |= 0x00000008; - signature_ = value; - onChanged(); - return this; - } - /** - * optional bytes signature = 4; - */ - public Builder clearSignature() { - bitField0_ = (bitField0_ & ~0x00000008); - signature_ = getDefaultInstance().getSignature(); - onChanged(); - return this; - } - - // optional fixed64 timestamp = 5; - private long timestamp_ ; - /** - * optional fixed64 timestamp = 5; - */ - public boolean hasTimestamp() { - return ((bitField0_ & 0x00000010) == 0x00000010); - } - /** - * optional fixed64 timestamp = 5; - */ - public long getTimestamp() { - return timestamp_; - } - /** - * optional fixed64 timestamp = 5; - */ - public Builder setTimestamp(long value) { - bitField0_ |= 0x00000010; - timestamp_ = value; - onChanged(); - return this; - } - /** - * optional fixed64 timestamp = 5; - */ - public Builder clearTimestamp() { - bitField0_ = (bitField0_ & ~0x00000010); - timestamp_ = 0L; - onChanged(); - return this; - } - - // @@protoc_insertion_point(builder_scope:textsecure.SignedPreKeyRecordStructure) - } - - static { - defaultInstance = new SignedPreKeyRecordStructure(true); - defaultInstance.initFields(); - } - - // @@protoc_insertion_point(class_scope:textsecure.SignedPreKeyRecordStructure) - } - - public interface IdentityKeyPairStructureOrBuilder - extends com.google.protobuf.MessageOrBuilder { - - // optional bytes publicKey = 1; - /** - * optional bytes publicKey = 1; - */ - boolean hasPublicKey(); - /** - * optional bytes publicKey = 1; - */ - com.google.protobuf.ByteString getPublicKey(); - - // optional bytes privateKey = 2; - /** - * optional bytes privateKey = 2; - */ - boolean hasPrivateKey(); - /** - * optional bytes privateKey = 2; - */ - com.google.protobuf.ByteString getPrivateKey(); - } - /** - * Protobuf type {@code textsecure.IdentityKeyPairStructure} - */ - public static final class IdentityKeyPairStructure extends - com.google.protobuf.GeneratedMessage - implements IdentityKeyPairStructureOrBuilder { - // Use IdentityKeyPairStructure.newBuilder() to construct. - private IdentityKeyPairStructure(com.google.protobuf.GeneratedMessage.Builder builder) { - super(builder); - this.unknownFields = builder.getUnknownFields(); - } - private IdentityKeyPairStructure(boolean noInit) { this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); } - - private static final IdentityKeyPairStructure defaultInstance; - public static IdentityKeyPairStructure getDefaultInstance() { - return defaultInstance; - } - - public IdentityKeyPairStructure getDefaultInstanceForType() { - return defaultInstance; - } - - private final com.google.protobuf.UnknownFieldSet unknownFields; - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return this.unknownFields; - } - private IdentityKeyPairStructure( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - initFields(); - int mutable_bitField0_ = 0; - com.google.protobuf.UnknownFieldSet.Builder unknownFields = - com.google.protobuf.UnknownFieldSet.newBuilder(); - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: { - if (!parseUnknownField(input, unknownFields, - extensionRegistry, tag)) { - done = true; - } - break; - } - case 10: { - bitField0_ |= 0x00000001; - publicKey_ = input.readBytes(); - break; - } - case 18: { - bitField0_ |= 0x00000002; - privateKey_ = input.readBytes(); - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(this); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException( - e.getMessage()).setUnfinishedMessage(this); - } finally { - this.unknownFields = unknownFields.build(); - makeExtensionsImmutable(); - } - } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return org.session.libsignal.libsignal.state.StorageProtos.internal_static_textsecure_IdentityKeyPairStructure_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return org.session.libsignal.libsignal.state.StorageProtos.internal_static_textsecure_IdentityKeyPairStructure_fieldAccessorTable - .ensureFieldAccessorsInitialized( - org.session.libsignal.libsignal.state.StorageProtos.IdentityKeyPairStructure.class, org.session.libsignal.libsignal.state.StorageProtos.IdentityKeyPairStructure.Builder.class); - } - - public static com.google.protobuf.Parser PARSER = - new com.google.protobuf.AbstractParser() { - public IdentityKeyPairStructure parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return new IdentityKeyPairStructure(input, extensionRegistry); - } - }; - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - private int bitField0_; - // optional bytes publicKey = 1; - public static final int PUBLICKEY_FIELD_NUMBER = 1; - private com.google.protobuf.ByteString publicKey_; - /** - * optional bytes publicKey = 1; - */ - public boolean hasPublicKey() { - return ((bitField0_ & 0x00000001) == 0x00000001); - } - /** - * optional bytes publicKey = 1; - */ - public com.google.protobuf.ByteString getPublicKey() { - return publicKey_; - } - - // optional bytes privateKey = 2; - public static final int PRIVATEKEY_FIELD_NUMBER = 2; - private com.google.protobuf.ByteString privateKey_; - /** - * optional bytes privateKey = 2; - */ - public boolean hasPrivateKey() { - return ((bitField0_ & 0x00000002) == 0x00000002); - } - /** - * optional bytes privateKey = 2; - */ - public com.google.protobuf.ByteString getPrivateKey() { - return privateKey_; - } - - private void initFields() { - publicKey_ = com.google.protobuf.ByteString.EMPTY; - privateKey_ = com.google.protobuf.ByteString.EMPTY; - } - private byte memoizedIsInitialized = -1; - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized != -1) return isInitialized == 1; - - memoizedIsInitialized = 1; - return true; - } - - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - getSerializedSize(); - if (((bitField0_ & 0x00000001) == 0x00000001)) { - output.writeBytes(1, publicKey_); - } - if (((bitField0_ & 0x00000002) == 0x00000002)) { - output.writeBytes(2, privateKey_); - } - getUnknownFields().writeTo(output); - } - - private int memoizedSerializedSize = -1; - public int getSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (((bitField0_ & 0x00000001) == 0x00000001)) { - size += com.google.protobuf.CodedOutputStream - .computeBytesSize(1, publicKey_); - } - if (((bitField0_ & 0x00000002) == 0x00000002)) { - size += com.google.protobuf.CodedOutputStream - .computeBytesSize(2, privateKey_); - } - size += getUnknownFields().getSerializedSize(); - memoizedSerializedSize = size; - return size; - } - - private static final long serialVersionUID = 0L; - @java.lang.Override - protected java.lang.Object writeReplace() - throws java.io.ObjectStreamException { - return super.writeReplace(); - } - - public static org.session.libsignal.libsignal.state.StorageProtos.IdentityKeyPairStructure parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static org.session.libsignal.libsignal.state.StorageProtos.IdentityKeyPairStructure parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static org.session.libsignal.libsignal.state.StorageProtos.IdentityKeyPairStructure parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static org.session.libsignal.libsignal.state.StorageProtos.IdentityKeyPairStructure parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static org.session.libsignal.libsignal.state.StorageProtos.IdentityKeyPairStructure parseFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static org.session.libsignal.libsignal.state.StorageProtos.IdentityKeyPairStructure parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - public static org.session.libsignal.libsignal.state.StorageProtos.IdentityKeyPairStructure parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input); - } - public static org.session.libsignal.libsignal.state.StorageProtos.IdentityKeyPairStructure parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input, extensionRegistry); - } - public static org.session.libsignal.libsignal.state.StorageProtos.IdentityKeyPairStructure parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static org.session.libsignal.libsignal.state.StorageProtos.IdentityKeyPairStructure parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - - public static Builder newBuilder() { return Builder.create(); } - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder(org.session.libsignal.libsignal.state.StorageProtos.IdentityKeyPairStructure prototype) { - return newBuilder().mergeFrom(prototype); - } - public Builder toBuilder() { return newBuilder(this); } - - @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * Protobuf type {@code textsecure.IdentityKeyPairStructure} - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessage.Builder - implements org.session.libsignal.libsignal.state.StorageProtos.IdentityKeyPairStructureOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return org.session.libsignal.libsignal.state.StorageProtos.internal_static_textsecure_IdentityKeyPairStructure_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return org.session.libsignal.libsignal.state.StorageProtos.internal_static_textsecure_IdentityKeyPairStructure_fieldAccessorTable - .ensureFieldAccessorsInitialized( - org.session.libsignal.libsignal.state.StorageProtos.IdentityKeyPairStructure.class, org.session.libsignal.libsignal.state.StorageProtos.IdentityKeyPairStructure.Builder.class); - } - - // Construct using org.session.libsignal.libsignal.state.StorageProtos.IdentityKeyPairStructure.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { - } - } - private static Builder create() { - return new Builder(); - } - - public Builder clear() { - super.clear(); - publicKey_ = com.google.protobuf.ByteString.EMPTY; - bitField0_ = (bitField0_ & ~0x00000001); - privateKey_ = com.google.protobuf.ByteString.EMPTY; - bitField0_ = (bitField0_ & ~0x00000002); - return this; - } - - public Builder clone() { - return create().mergeFrom(buildPartial()); - } - - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return org.session.libsignal.libsignal.state.StorageProtos.internal_static_textsecure_IdentityKeyPairStructure_descriptor; - } - - public org.session.libsignal.libsignal.state.StorageProtos.IdentityKeyPairStructure getDefaultInstanceForType() { - return org.session.libsignal.libsignal.state.StorageProtos.IdentityKeyPairStructure.getDefaultInstance(); - } - - public org.session.libsignal.libsignal.state.StorageProtos.IdentityKeyPairStructure build() { - org.session.libsignal.libsignal.state.StorageProtos.IdentityKeyPairStructure result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - public org.session.libsignal.libsignal.state.StorageProtos.IdentityKeyPairStructure buildPartial() { - org.session.libsignal.libsignal.state.StorageProtos.IdentityKeyPairStructure result = new org.session.libsignal.libsignal.state.StorageProtos.IdentityKeyPairStructure(this); - int from_bitField0_ = bitField0_; - int to_bitField0_ = 0; - if (((from_bitField0_ & 0x00000001) == 0x00000001)) { - to_bitField0_ |= 0x00000001; - } - result.publicKey_ = publicKey_; - if (((from_bitField0_ & 0x00000002) == 0x00000002)) { - to_bitField0_ |= 0x00000002; - } - result.privateKey_ = privateKey_; - result.bitField0_ = to_bitField0_; - onBuilt(); - return result; - } - - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof org.session.libsignal.libsignal.state.StorageProtos.IdentityKeyPairStructure) { - return mergeFrom((org.session.libsignal.libsignal.state.StorageProtos.IdentityKeyPairStructure)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(org.session.libsignal.libsignal.state.StorageProtos.IdentityKeyPairStructure other) { - if (other == org.session.libsignal.libsignal.state.StorageProtos.IdentityKeyPairStructure.getDefaultInstance()) return this; - if (other.hasPublicKey()) { - setPublicKey(other.getPublicKey()); - } - if (other.hasPrivateKey()) { - setPrivateKey(other.getPrivateKey()); - } - this.mergeUnknownFields(other.getUnknownFields()); - return this; - } - - public final boolean isInitialized() { - return true; - } - - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - org.session.libsignal.libsignal.state.StorageProtos.IdentityKeyPairStructure parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (org.session.libsignal.libsignal.state.StorageProtos.IdentityKeyPairStructure) e.getUnfinishedMessage(); - throw e; - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - private int bitField0_; - - // optional bytes publicKey = 1; - private com.google.protobuf.ByteString publicKey_ = com.google.protobuf.ByteString.EMPTY; - /** - * optional bytes publicKey = 1; - */ - public boolean hasPublicKey() { - return ((bitField0_ & 0x00000001) == 0x00000001); - } - /** - * optional bytes publicKey = 1; - */ - public com.google.protobuf.ByteString getPublicKey() { - return publicKey_; - } - /** - * optional bytes publicKey = 1; - */ - public Builder setPublicKey(com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - bitField0_ |= 0x00000001; - publicKey_ = value; - onChanged(); - return this; - } - /** - * optional bytes publicKey = 1; - */ - public Builder clearPublicKey() { - bitField0_ = (bitField0_ & ~0x00000001); - publicKey_ = getDefaultInstance().getPublicKey(); - onChanged(); - return this; - } - - // optional bytes privateKey = 2; - private com.google.protobuf.ByteString privateKey_ = com.google.protobuf.ByteString.EMPTY; - /** - * optional bytes privateKey = 2; - */ - public boolean hasPrivateKey() { - return ((bitField0_ & 0x00000002) == 0x00000002); - } - /** - * optional bytes privateKey = 2; - */ - public com.google.protobuf.ByteString getPrivateKey() { - return privateKey_; - } - /** - * optional bytes privateKey = 2; - */ - public Builder setPrivateKey(com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - bitField0_ |= 0x00000002; - privateKey_ = value; - onChanged(); - return this; - } - /** - * optional bytes privateKey = 2; - */ - public Builder clearPrivateKey() { - bitField0_ = (bitField0_ & ~0x00000002); - privateKey_ = getDefaultInstance().getPrivateKey(); - onChanged(); - return this; - } - - // @@protoc_insertion_point(builder_scope:textsecure.IdentityKeyPairStructure) - } - - static { - defaultInstance = new IdentityKeyPairStructure(true); - defaultInstance.initFields(); - } - - // @@protoc_insertion_point(class_scope:textsecure.IdentityKeyPairStructure) - } - - public interface SenderKeyStateStructureOrBuilder - extends com.google.protobuf.MessageOrBuilder { - - // optional uint32 senderKeyId = 1; - /** - * optional uint32 senderKeyId = 1; - */ - boolean hasSenderKeyId(); - /** - * optional uint32 senderKeyId = 1; - */ - int getSenderKeyId(); - - // optional .textsecure.SenderKeyStateStructure.SenderChainKey senderChainKey = 2; - /** - * optional .textsecure.SenderKeyStateStructure.SenderChainKey senderChainKey = 2; - */ - boolean hasSenderChainKey(); - /** - * optional .textsecure.SenderKeyStateStructure.SenderChainKey senderChainKey = 2; - */ - org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderChainKey getSenderChainKey(); - /** - * optional .textsecure.SenderKeyStateStructure.SenderChainKey senderChainKey = 2; - */ - org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderChainKeyOrBuilder getSenderChainKeyOrBuilder(); - - // optional .textsecure.SenderKeyStateStructure.SenderSigningKey senderSigningKey = 3; - /** - * optional .textsecure.SenderKeyStateStructure.SenderSigningKey senderSigningKey = 3; - */ - boolean hasSenderSigningKey(); - /** - * optional .textsecure.SenderKeyStateStructure.SenderSigningKey senderSigningKey = 3; - */ - org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderSigningKey getSenderSigningKey(); - /** - * optional .textsecure.SenderKeyStateStructure.SenderSigningKey senderSigningKey = 3; - */ - org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderSigningKeyOrBuilder getSenderSigningKeyOrBuilder(); - - // repeated .textsecure.SenderKeyStateStructure.SenderMessageKey senderMessageKeys = 4; - /** - * repeated .textsecure.SenderKeyStateStructure.SenderMessageKey senderMessageKeys = 4; - */ - java.util.List - getSenderMessageKeysList(); - /** - * repeated .textsecure.SenderKeyStateStructure.SenderMessageKey senderMessageKeys = 4; - */ - org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderMessageKey getSenderMessageKeys(int index); - /** - * repeated .textsecure.SenderKeyStateStructure.SenderMessageKey senderMessageKeys = 4; - */ - int getSenderMessageKeysCount(); - /** - * repeated .textsecure.SenderKeyStateStructure.SenderMessageKey senderMessageKeys = 4; - */ - java.util.List - getSenderMessageKeysOrBuilderList(); - /** - * repeated .textsecure.SenderKeyStateStructure.SenderMessageKey senderMessageKeys = 4; - */ - org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderMessageKeyOrBuilder getSenderMessageKeysOrBuilder( - int index); - } - /** - * Protobuf type {@code textsecure.SenderKeyStateStructure} - */ - public static final class SenderKeyStateStructure extends - com.google.protobuf.GeneratedMessage - implements SenderKeyStateStructureOrBuilder { - // Use SenderKeyStateStructure.newBuilder() to construct. - private SenderKeyStateStructure(com.google.protobuf.GeneratedMessage.Builder builder) { - super(builder); - this.unknownFields = builder.getUnknownFields(); - } - private SenderKeyStateStructure(boolean noInit) { this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); } - - private static final SenderKeyStateStructure defaultInstance; - public static SenderKeyStateStructure getDefaultInstance() { - return defaultInstance; - } - - public SenderKeyStateStructure getDefaultInstanceForType() { - return defaultInstance; - } - - private final com.google.protobuf.UnknownFieldSet unknownFields; - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return this.unknownFields; - } - private SenderKeyStateStructure( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - initFields(); - int mutable_bitField0_ = 0; - com.google.protobuf.UnknownFieldSet.Builder unknownFields = - com.google.protobuf.UnknownFieldSet.newBuilder(); - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: { - if (!parseUnknownField(input, unknownFields, - extensionRegistry, tag)) { - done = true; - } - break; - } - case 8: { - bitField0_ |= 0x00000001; - senderKeyId_ = input.readUInt32(); - break; - } - case 18: { - org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderChainKey.Builder subBuilder = null; - if (((bitField0_ & 0x00000002) == 0x00000002)) { - subBuilder = senderChainKey_.toBuilder(); - } - senderChainKey_ = input.readMessage(org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderChainKey.PARSER, extensionRegistry); - if (subBuilder != null) { - subBuilder.mergeFrom(senderChainKey_); - senderChainKey_ = subBuilder.buildPartial(); - } - bitField0_ |= 0x00000002; - break; - } - case 26: { - org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderSigningKey.Builder subBuilder = null; - if (((bitField0_ & 0x00000004) == 0x00000004)) { - subBuilder = senderSigningKey_.toBuilder(); - } - senderSigningKey_ = input.readMessage(org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderSigningKey.PARSER, extensionRegistry); - if (subBuilder != null) { - subBuilder.mergeFrom(senderSigningKey_); - senderSigningKey_ = subBuilder.buildPartial(); - } - bitField0_ |= 0x00000004; - break; - } - case 34: { - if (!((mutable_bitField0_ & 0x00000008) == 0x00000008)) { - senderMessageKeys_ = new java.util.ArrayList(); - mutable_bitField0_ |= 0x00000008; - } - senderMessageKeys_.add(input.readMessage(org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderMessageKey.PARSER, extensionRegistry)); - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(this); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException( - e.getMessage()).setUnfinishedMessage(this); - } finally { - if (((mutable_bitField0_ & 0x00000008) == 0x00000008)) { - senderMessageKeys_ = java.util.Collections.unmodifiableList(senderMessageKeys_); - } - this.unknownFields = unknownFields.build(); - makeExtensionsImmutable(); - } - } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return org.session.libsignal.libsignal.state.StorageProtos.internal_static_textsecure_SenderKeyStateStructure_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return org.session.libsignal.libsignal.state.StorageProtos.internal_static_textsecure_SenderKeyStateStructure_fieldAccessorTable - .ensureFieldAccessorsInitialized( - org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.class, org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.Builder.class); - } - - public static com.google.protobuf.Parser PARSER = - new com.google.protobuf.AbstractParser() { - public SenderKeyStateStructure parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return new SenderKeyStateStructure(input, extensionRegistry); - } - }; - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - public interface SenderChainKeyOrBuilder - extends com.google.protobuf.MessageOrBuilder { - - // optional uint32 iteration = 1; - /** - * optional uint32 iteration = 1; - */ - boolean hasIteration(); - /** - * optional uint32 iteration = 1; - */ - int getIteration(); - - // optional bytes seed = 2; - /** - * optional bytes seed = 2; - */ - boolean hasSeed(); - /** - * optional bytes seed = 2; - */ - com.google.protobuf.ByteString getSeed(); - } - /** - * Protobuf type {@code textsecure.SenderKeyStateStructure.SenderChainKey} - */ - public static final class SenderChainKey extends - com.google.protobuf.GeneratedMessage - implements SenderChainKeyOrBuilder { - // Use SenderChainKey.newBuilder() to construct. - private SenderChainKey(com.google.protobuf.GeneratedMessage.Builder builder) { - super(builder); - this.unknownFields = builder.getUnknownFields(); - } - private SenderChainKey(boolean noInit) { this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); } - - private static final SenderChainKey defaultInstance; - public static SenderChainKey getDefaultInstance() { - return defaultInstance; - } - - public SenderChainKey getDefaultInstanceForType() { - return defaultInstance; - } - - private final com.google.protobuf.UnknownFieldSet unknownFields; - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return this.unknownFields; - } - private SenderChainKey( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - initFields(); - int mutable_bitField0_ = 0; - com.google.protobuf.UnknownFieldSet.Builder unknownFields = - com.google.protobuf.UnknownFieldSet.newBuilder(); - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: { - if (!parseUnknownField(input, unknownFields, - extensionRegistry, tag)) { - done = true; - } - break; - } - case 8: { - bitField0_ |= 0x00000001; - iteration_ = input.readUInt32(); - break; - } - case 18: { - bitField0_ |= 0x00000002; - seed_ = input.readBytes(); - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(this); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException( - e.getMessage()).setUnfinishedMessage(this); - } finally { - this.unknownFields = unknownFields.build(); - makeExtensionsImmutable(); - } - } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return org.session.libsignal.libsignal.state.StorageProtos.internal_static_textsecure_SenderKeyStateStructure_SenderChainKey_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return org.session.libsignal.libsignal.state.StorageProtos.internal_static_textsecure_SenderKeyStateStructure_SenderChainKey_fieldAccessorTable - .ensureFieldAccessorsInitialized( - org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderChainKey.class, org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderChainKey.Builder.class); - } - - public static com.google.protobuf.Parser PARSER = - new com.google.protobuf.AbstractParser() { - public SenderChainKey parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return new SenderChainKey(input, extensionRegistry); - } - }; - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - private int bitField0_; - // optional uint32 iteration = 1; - public static final int ITERATION_FIELD_NUMBER = 1; - private int iteration_; - /** - * optional uint32 iteration = 1; - */ - public boolean hasIteration() { - return ((bitField0_ & 0x00000001) == 0x00000001); - } - /** - * optional uint32 iteration = 1; - */ - public int getIteration() { - return iteration_; - } - - // optional bytes seed = 2; - public static final int SEED_FIELD_NUMBER = 2; - private com.google.protobuf.ByteString seed_; - /** - * optional bytes seed = 2; - */ - public boolean hasSeed() { - return ((bitField0_ & 0x00000002) == 0x00000002); - } - /** - * optional bytes seed = 2; - */ - public com.google.protobuf.ByteString getSeed() { - return seed_; - } - - private void initFields() { - iteration_ = 0; - seed_ = com.google.protobuf.ByteString.EMPTY; - } - private byte memoizedIsInitialized = -1; - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized != -1) return isInitialized == 1; - - memoizedIsInitialized = 1; - return true; - } - - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - getSerializedSize(); - if (((bitField0_ & 0x00000001) == 0x00000001)) { - output.writeUInt32(1, iteration_); - } - if (((bitField0_ & 0x00000002) == 0x00000002)) { - output.writeBytes(2, seed_); - } - getUnknownFields().writeTo(output); - } - - private int memoizedSerializedSize = -1; - public int getSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (((bitField0_ & 0x00000001) == 0x00000001)) { - size += com.google.protobuf.CodedOutputStream - .computeUInt32Size(1, iteration_); - } - if (((bitField0_ & 0x00000002) == 0x00000002)) { - size += com.google.protobuf.CodedOutputStream - .computeBytesSize(2, seed_); - } - size += getUnknownFields().getSerializedSize(); - memoizedSerializedSize = size; - return size; - } - - private static final long serialVersionUID = 0L; - @java.lang.Override - protected java.lang.Object writeReplace() - throws java.io.ObjectStreamException { - return super.writeReplace(); - } - - public static org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderChainKey parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderChainKey parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderChainKey parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderChainKey parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderChainKey parseFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderChainKey parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - public static org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderChainKey parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input); - } - public static org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderChainKey parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input, extensionRegistry); - } - public static org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderChainKey parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderChainKey parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - - public static Builder newBuilder() { return Builder.create(); } - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder(org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderChainKey prototype) { - return newBuilder().mergeFrom(prototype); - } - public Builder toBuilder() { return newBuilder(this); } - - @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * Protobuf type {@code textsecure.SenderKeyStateStructure.SenderChainKey} - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessage.Builder - implements org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderChainKeyOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return org.session.libsignal.libsignal.state.StorageProtos.internal_static_textsecure_SenderKeyStateStructure_SenderChainKey_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return org.session.libsignal.libsignal.state.StorageProtos.internal_static_textsecure_SenderKeyStateStructure_SenderChainKey_fieldAccessorTable - .ensureFieldAccessorsInitialized( - org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderChainKey.class, org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderChainKey.Builder.class); - } - - // Construct using org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderChainKey.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { - } - } - private static Builder create() { - return new Builder(); - } - - public Builder clear() { - super.clear(); - iteration_ = 0; - bitField0_ = (bitField0_ & ~0x00000001); - seed_ = com.google.protobuf.ByteString.EMPTY; - bitField0_ = (bitField0_ & ~0x00000002); - return this; - } - - public Builder clone() { - return create().mergeFrom(buildPartial()); - } - - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return org.session.libsignal.libsignal.state.StorageProtos.internal_static_textsecure_SenderKeyStateStructure_SenderChainKey_descriptor; - } - - public org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderChainKey getDefaultInstanceForType() { - return org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderChainKey.getDefaultInstance(); - } - - public org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderChainKey build() { - org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderChainKey result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - public org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderChainKey buildPartial() { - org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderChainKey result = new org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderChainKey(this); - int from_bitField0_ = bitField0_; - int to_bitField0_ = 0; - if (((from_bitField0_ & 0x00000001) == 0x00000001)) { - to_bitField0_ |= 0x00000001; - } - result.iteration_ = iteration_; - if (((from_bitField0_ & 0x00000002) == 0x00000002)) { - to_bitField0_ |= 0x00000002; - } - result.seed_ = seed_; - result.bitField0_ = to_bitField0_; - onBuilt(); - return result; - } - - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderChainKey) { - return mergeFrom((org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderChainKey)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderChainKey other) { - if (other == org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderChainKey.getDefaultInstance()) return this; - if (other.hasIteration()) { - setIteration(other.getIteration()); - } - if (other.hasSeed()) { - setSeed(other.getSeed()); - } - this.mergeUnknownFields(other.getUnknownFields()); - return this; - } - - public final boolean isInitialized() { - return true; - } - - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderChainKey parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderChainKey) e.getUnfinishedMessage(); - throw e; - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - private int bitField0_; - - // optional uint32 iteration = 1; - private int iteration_ ; - /** - * optional uint32 iteration = 1; - */ - public boolean hasIteration() { - return ((bitField0_ & 0x00000001) == 0x00000001); - } - /** - * optional uint32 iteration = 1; - */ - public int getIteration() { - return iteration_; - } - /** - * optional uint32 iteration = 1; - */ - public Builder setIteration(int value) { - bitField0_ |= 0x00000001; - iteration_ = value; - onChanged(); - return this; - } - /** - * optional uint32 iteration = 1; - */ - public Builder clearIteration() { - bitField0_ = (bitField0_ & ~0x00000001); - iteration_ = 0; - onChanged(); - return this; - } - - // optional bytes seed = 2; - private com.google.protobuf.ByteString seed_ = com.google.protobuf.ByteString.EMPTY; - /** - * optional bytes seed = 2; - */ - public boolean hasSeed() { - return ((bitField0_ & 0x00000002) == 0x00000002); - } - /** - * optional bytes seed = 2; - */ - public com.google.protobuf.ByteString getSeed() { - return seed_; - } - /** - * optional bytes seed = 2; - */ - public Builder setSeed(com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - bitField0_ |= 0x00000002; - seed_ = value; - onChanged(); - return this; - } - /** - * optional bytes seed = 2; - */ - public Builder clearSeed() { - bitField0_ = (bitField0_ & ~0x00000002); - seed_ = getDefaultInstance().getSeed(); - onChanged(); - return this; - } - - // @@protoc_insertion_point(builder_scope:textsecure.SenderKeyStateStructure.SenderChainKey) - } - - static { - defaultInstance = new SenderChainKey(true); - defaultInstance.initFields(); - } - - // @@protoc_insertion_point(class_scope:textsecure.SenderKeyStateStructure.SenderChainKey) - } - - public interface SenderMessageKeyOrBuilder - extends com.google.protobuf.MessageOrBuilder { - - // optional uint32 iteration = 1; - /** - * optional uint32 iteration = 1; - */ - boolean hasIteration(); - /** - * optional uint32 iteration = 1; - */ - int getIteration(); - - // optional bytes seed = 2; - /** - * optional bytes seed = 2; - */ - boolean hasSeed(); - /** - * optional bytes seed = 2; - */ - com.google.protobuf.ByteString getSeed(); - } - /** - * Protobuf type {@code textsecure.SenderKeyStateStructure.SenderMessageKey} - */ - public static final class SenderMessageKey extends - com.google.protobuf.GeneratedMessage - implements SenderMessageKeyOrBuilder { - // Use SenderMessageKey.newBuilder() to construct. - private SenderMessageKey(com.google.protobuf.GeneratedMessage.Builder builder) { - super(builder); - this.unknownFields = builder.getUnknownFields(); - } - private SenderMessageKey(boolean noInit) { this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); } - - private static final SenderMessageKey defaultInstance; - public static SenderMessageKey getDefaultInstance() { - return defaultInstance; - } - - public SenderMessageKey getDefaultInstanceForType() { - return defaultInstance; - } - - private final com.google.protobuf.UnknownFieldSet unknownFields; - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return this.unknownFields; - } - private SenderMessageKey( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - initFields(); - int mutable_bitField0_ = 0; - com.google.protobuf.UnknownFieldSet.Builder unknownFields = - com.google.protobuf.UnknownFieldSet.newBuilder(); - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: { - if (!parseUnknownField(input, unknownFields, - extensionRegistry, tag)) { - done = true; - } - break; - } - case 8: { - bitField0_ |= 0x00000001; - iteration_ = input.readUInt32(); - break; - } - case 18: { - bitField0_ |= 0x00000002; - seed_ = input.readBytes(); - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(this); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException( - e.getMessage()).setUnfinishedMessage(this); - } finally { - this.unknownFields = unknownFields.build(); - makeExtensionsImmutable(); - } - } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return org.session.libsignal.libsignal.state.StorageProtos.internal_static_textsecure_SenderKeyStateStructure_SenderMessageKey_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return org.session.libsignal.libsignal.state.StorageProtos.internal_static_textsecure_SenderKeyStateStructure_SenderMessageKey_fieldAccessorTable - .ensureFieldAccessorsInitialized( - org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderMessageKey.class, org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderMessageKey.Builder.class); - } - - public static com.google.protobuf.Parser PARSER = - new com.google.protobuf.AbstractParser() { - public SenderMessageKey parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return new SenderMessageKey(input, extensionRegistry); - } - }; - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - private int bitField0_; - // optional uint32 iteration = 1; - public static final int ITERATION_FIELD_NUMBER = 1; - private int iteration_; - /** - * optional uint32 iteration = 1; - */ - public boolean hasIteration() { - return ((bitField0_ & 0x00000001) == 0x00000001); - } - /** - * optional uint32 iteration = 1; - */ - public int getIteration() { - return iteration_; - } - - // optional bytes seed = 2; - public static final int SEED_FIELD_NUMBER = 2; - private com.google.protobuf.ByteString seed_; - /** - * optional bytes seed = 2; - */ - public boolean hasSeed() { - return ((bitField0_ & 0x00000002) == 0x00000002); - } - /** - * optional bytes seed = 2; - */ - public com.google.protobuf.ByteString getSeed() { - return seed_; - } - - private void initFields() { - iteration_ = 0; - seed_ = com.google.protobuf.ByteString.EMPTY; - } - private byte memoizedIsInitialized = -1; - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized != -1) return isInitialized == 1; - - memoizedIsInitialized = 1; - return true; - } - - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - getSerializedSize(); - if (((bitField0_ & 0x00000001) == 0x00000001)) { - output.writeUInt32(1, iteration_); - } - if (((bitField0_ & 0x00000002) == 0x00000002)) { - output.writeBytes(2, seed_); - } - getUnknownFields().writeTo(output); - } - - private int memoizedSerializedSize = -1; - public int getSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (((bitField0_ & 0x00000001) == 0x00000001)) { - size += com.google.protobuf.CodedOutputStream - .computeUInt32Size(1, iteration_); - } - if (((bitField0_ & 0x00000002) == 0x00000002)) { - size += com.google.protobuf.CodedOutputStream - .computeBytesSize(2, seed_); - } - size += getUnknownFields().getSerializedSize(); - memoizedSerializedSize = size; - return size; - } - - private static final long serialVersionUID = 0L; - @java.lang.Override - protected java.lang.Object writeReplace() - throws java.io.ObjectStreamException { - return super.writeReplace(); - } - - public static org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderMessageKey parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderMessageKey parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderMessageKey parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderMessageKey parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderMessageKey parseFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderMessageKey parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - public static org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderMessageKey parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input); - } - public static org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderMessageKey parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input, extensionRegistry); - } - public static org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderMessageKey parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderMessageKey parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - - public static Builder newBuilder() { return Builder.create(); } - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder(org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderMessageKey prototype) { - return newBuilder().mergeFrom(prototype); - } - public Builder toBuilder() { return newBuilder(this); } - - @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * Protobuf type {@code textsecure.SenderKeyStateStructure.SenderMessageKey} - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessage.Builder - implements org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderMessageKeyOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return org.session.libsignal.libsignal.state.StorageProtos.internal_static_textsecure_SenderKeyStateStructure_SenderMessageKey_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return org.session.libsignal.libsignal.state.StorageProtos.internal_static_textsecure_SenderKeyStateStructure_SenderMessageKey_fieldAccessorTable - .ensureFieldAccessorsInitialized( - org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderMessageKey.class, org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderMessageKey.Builder.class); - } - - // Construct using org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderMessageKey.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { - } - } - private static Builder create() { - return new Builder(); - } - - public Builder clear() { - super.clear(); - iteration_ = 0; - bitField0_ = (bitField0_ & ~0x00000001); - seed_ = com.google.protobuf.ByteString.EMPTY; - bitField0_ = (bitField0_ & ~0x00000002); - return this; - } - - public Builder clone() { - return create().mergeFrom(buildPartial()); - } - - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return org.session.libsignal.libsignal.state.StorageProtos.internal_static_textsecure_SenderKeyStateStructure_SenderMessageKey_descriptor; - } - - public org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderMessageKey getDefaultInstanceForType() { - return org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderMessageKey.getDefaultInstance(); - } - - public org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderMessageKey build() { - org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderMessageKey result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - public org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderMessageKey buildPartial() { - org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderMessageKey result = new org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderMessageKey(this); - int from_bitField0_ = bitField0_; - int to_bitField0_ = 0; - if (((from_bitField0_ & 0x00000001) == 0x00000001)) { - to_bitField0_ |= 0x00000001; - } - result.iteration_ = iteration_; - if (((from_bitField0_ & 0x00000002) == 0x00000002)) { - to_bitField0_ |= 0x00000002; - } - result.seed_ = seed_; - result.bitField0_ = to_bitField0_; - onBuilt(); - return result; - } - - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderMessageKey) { - return mergeFrom((org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderMessageKey)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderMessageKey other) { - if (other == org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderMessageKey.getDefaultInstance()) return this; - if (other.hasIteration()) { - setIteration(other.getIteration()); - } - if (other.hasSeed()) { - setSeed(other.getSeed()); - } - this.mergeUnknownFields(other.getUnknownFields()); - return this; - } - - public final boolean isInitialized() { - return true; - } - - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderMessageKey parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderMessageKey) e.getUnfinishedMessage(); - throw e; - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - private int bitField0_; - - // optional uint32 iteration = 1; - private int iteration_ ; - /** - * optional uint32 iteration = 1; - */ - public boolean hasIteration() { - return ((bitField0_ & 0x00000001) == 0x00000001); - } - /** - * optional uint32 iteration = 1; - */ - public int getIteration() { - return iteration_; - } - /** - * optional uint32 iteration = 1; - */ - public Builder setIteration(int value) { - bitField0_ |= 0x00000001; - iteration_ = value; - onChanged(); - return this; - } - /** - * optional uint32 iteration = 1; - */ - public Builder clearIteration() { - bitField0_ = (bitField0_ & ~0x00000001); - iteration_ = 0; - onChanged(); - return this; - } - - // optional bytes seed = 2; - private com.google.protobuf.ByteString seed_ = com.google.protobuf.ByteString.EMPTY; - /** - * optional bytes seed = 2; - */ - public boolean hasSeed() { - return ((bitField0_ & 0x00000002) == 0x00000002); - } - /** - * optional bytes seed = 2; - */ - public com.google.protobuf.ByteString getSeed() { - return seed_; - } - /** - * optional bytes seed = 2; - */ - public Builder setSeed(com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - bitField0_ |= 0x00000002; - seed_ = value; - onChanged(); - return this; - } - /** - * optional bytes seed = 2; - */ - public Builder clearSeed() { - bitField0_ = (bitField0_ & ~0x00000002); - seed_ = getDefaultInstance().getSeed(); - onChanged(); - return this; - } - - // @@protoc_insertion_point(builder_scope:textsecure.SenderKeyStateStructure.SenderMessageKey) - } - - static { - defaultInstance = new SenderMessageKey(true); - defaultInstance.initFields(); - } - - // @@protoc_insertion_point(class_scope:textsecure.SenderKeyStateStructure.SenderMessageKey) - } - - public interface SenderSigningKeyOrBuilder - extends com.google.protobuf.MessageOrBuilder { - - // optional bytes public = 1; - /** - * optional bytes public = 1; - */ - boolean hasPublic(); - /** - * optional bytes public = 1; - */ - com.google.protobuf.ByteString getPublic(); - - // optional bytes private = 2; - /** - * optional bytes private = 2; - */ - boolean hasPrivate(); - /** - * optional bytes private = 2; - */ - com.google.protobuf.ByteString getPrivate(); - } - /** - * Protobuf type {@code textsecure.SenderKeyStateStructure.SenderSigningKey} - */ - public static final class SenderSigningKey extends - com.google.protobuf.GeneratedMessage - implements SenderSigningKeyOrBuilder { - // Use SenderSigningKey.newBuilder() to construct. - private SenderSigningKey(com.google.protobuf.GeneratedMessage.Builder builder) { - super(builder); - this.unknownFields = builder.getUnknownFields(); - } - private SenderSigningKey(boolean noInit) { this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); } - - private static final SenderSigningKey defaultInstance; - public static SenderSigningKey getDefaultInstance() { - return defaultInstance; - } - - public SenderSigningKey getDefaultInstanceForType() { - return defaultInstance; - } - - private final com.google.protobuf.UnknownFieldSet unknownFields; - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return this.unknownFields; - } - private SenderSigningKey( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - initFields(); - int mutable_bitField0_ = 0; - com.google.protobuf.UnknownFieldSet.Builder unknownFields = - com.google.protobuf.UnknownFieldSet.newBuilder(); - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: { - if (!parseUnknownField(input, unknownFields, - extensionRegistry, tag)) { - done = true; - } - break; - } - case 10: { - bitField0_ |= 0x00000001; - public_ = input.readBytes(); - break; - } - case 18: { - bitField0_ |= 0x00000002; - private_ = input.readBytes(); - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(this); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException( - e.getMessage()).setUnfinishedMessage(this); - } finally { - this.unknownFields = unknownFields.build(); - makeExtensionsImmutable(); - } - } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return org.session.libsignal.libsignal.state.StorageProtos.internal_static_textsecure_SenderKeyStateStructure_SenderSigningKey_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return org.session.libsignal.libsignal.state.StorageProtos.internal_static_textsecure_SenderKeyStateStructure_SenderSigningKey_fieldAccessorTable - .ensureFieldAccessorsInitialized( - org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderSigningKey.class, org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderSigningKey.Builder.class); - } - - public static com.google.protobuf.Parser PARSER = - new com.google.protobuf.AbstractParser() { - public SenderSigningKey parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return new SenderSigningKey(input, extensionRegistry); - } - }; - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - private int bitField0_; - // optional bytes public = 1; - public static final int PUBLIC_FIELD_NUMBER = 1; - private com.google.protobuf.ByteString public_; - /** - * optional bytes public = 1; - */ - public boolean hasPublic() { - return ((bitField0_ & 0x00000001) == 0x00000001); - } - /** - * optional bytes public = 1; - */ - public com.google.protobuf.ByteString getPublic() { - return public_; - } - - // optional bytes private = 2; - public static final int PRIVATE_FIELD_NUMBER = 2; - private com.google.protobuf.ByteString private_; - /** - * optional bytes private = 2; - */ - public boolean hasPrivate() { - return ((bitField0_ & 0x00000002) == 0x00000002); - } - /** - * optional bytes private = 2; - */ - public com.google.protobuf.ByteString getPrivate() { - return private_; - } - - private void initFields() { - public_ = com.google.protobuf.ByteString.EMPTY; - private_ = com.google.protobuf.ByteString.EMPTY; - } - private byte memoizedIsInitialized = -1; - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized != -1) return isInitialized == 1; - - memoizedIsInitialized = 1; - return true; - } - - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - getSerializedSize(); - if (((bitField0_ & 0x00000001) == 0x00000001)) { - output.writeBytes(1, public_); - } - if (((bitField0_ & 0x00000002) == 0x00000002)) { - output.writeBytes(2, private_); - } - getUnknownFields().writeTo(output); - } - - private int memoizedSerializedSize = -1; - public int getSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (((bitField0_ & 0x00000001) == 0x00000001)) { - size += com.google.protobuf.CodedOutputStream - .computeBytesSize(1, public_); - } - if (((bitField0_ & 0x00000002) == 0x00000002)) { - size += com.google.protobuf.CodedOutputStream - .computeBytesSize(2, private_); - } - size += getUnknownFields().getSerializedSize(); - memoizedSerializedSize = size; - return size; - } - - private static final long serialVersionUID = 0L; - @java.lang.Override - protected java.lang.Object writeReplace() - throws java.io.ObjectStreamException { - return super.writeReplace(); - } - - public static org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderSigningKey parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderSigningKey parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderSigningKey parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderSigningKey parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderSigningKey parseFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderSigningKey parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - public static org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderSigningKey parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input); - } - public static org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderSigningKey parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input, extensionRegistry); - } - public static org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderSigningKey parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderSigningKey parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - - public static Builder newBuilder() { return Builder.create(); } - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder(org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderSigningKey prototype) { - return newBuilder().mergeFrom(prototype); - } - public Builder toBuilder() { return newBuilder(this); } - - @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * Protobuf type {@code textsecure.SenderKeyStateStructure.SenderSigningKey} - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessage.Builder - implements org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderSigningKeyOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return org.session.libsignal.libsignal.state.StorageProtos.internal_static_textsecure_SenderKeyStateStructure_SenderSigningKey_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return org.session.libsignal.libsignal.state.StorageProtos.internal_static_textsecure_SenderKeyStateStructure_SenderSigningKey_fieldAccessorTable - .ensureFieldAccessorsInitialized( - org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderSigningKey.class, org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderSigningKey.Builder.class); - } - - // Construct using org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderSigningKey.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { - } - } - private static Builder create() { - return new Builder(); - } - - public Builder clear() { - super.clear(); - public_ = com.google.protobuf.ByteString.EMPTY; - bitField0_ = (bitField0_ & ~0x00000001); - private_ = com.google.protobuf.ByteString.EMPTY; - bitField0_ = (bitField0_ & ~0x00000002); - return this; - } - - public Builder clone() { - return create().mergeFrom(buildPartial()); - } - - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return org.session.libsignal.libsignal.state.StorageProtos.internal_static_textsecure_SenderKeyStateStructure_SenderSigningKey_descriptor; - } - - public org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderSigningKey getDefaultInstanceForType() { - return org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderSigningKey.getDefaultInstance(); - } - - public org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderSigningKey build() { - org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderSigningKey result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - public org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderSigningKey buildPartial() { - org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderSigningKey result = new org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderSigningKey(this); - int from_bitField0_ = bitField0_; - int to_bitField0_ = 0; - if (((from_bitField0_ & 0x00000001) == 0x00000001)) { - to_bitField0_ |= 0x00000001; - } - result.public_ = public_; - if (((from_bitField0_ & 0x00000002) == 0x00000002)) { - to_bitField0_ |= 0x00000002; - } - result.private_ = private_; - result.bitField0_ = to_bitField0_; - onBuilt(); - return result; - } - - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderSigningKey) { - return mergeFrom((org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderSigningKey)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderSigningKey other) { - if (other == org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderSigningKey.getDefaultInstance()) return this; - if (other.hasPublic()) { - setPublic(other.getPublic()); - } - if (other.hasPrivate()) { - setPrivate(other.getPrivate()); - } - this.mergeUnknownFields(other.getUnknownFields()); - return this; - } - - public final boolean isInitialized() { - return true; - } - - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderSigningKey parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderSigningKey) e.getUnfinishedMessage(); - throw e; - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - private int bitField0_; - - // optional bytes public = 1; - private com.google.protobuf.ByteString public_ = com.google.protobuf.ByteString.EMPTY; - /** - * optional bytes public = 1; - */ - public boolean hasPublic() { - return ((bitField0_ & 0x00000001) == 0x00000001); - } - /** - * optional bytes public = 1; - */ - public com.google.protobuf.ByteString getPublic() { - return public_; - } - /** - * optional bytes public = 1; - */ - public Builder setPublic(com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - bitField0_ |= 0x00000001; - public_ = value; - onChanged(); - return this; - } - /** - * optional bytes public = 1; - */ - public Builder clearPublic() { - bitField0_ = (bitField0_ & ~0x00000001); - public_ = getDefaultInstance().getPublic(); - onChanged(); - return this; - } - - // optional bytes private = 2; - private com.google.protobuf.ByteString private_ = com.google.protobuf.ByteString.EMPTY; - /** - * optional bytes private = 2; - */ - public boolean hasPrivate() { - return ((bitField0_ & 0x00000002) == 0x00000002); - } - /** - * optional bytes private = 2; - */ - public com.google.protobuf.ByteString getPrivate() { - return private_; - } - /** - * optional bytes private = 2; - */ - public Builder setPrivate(com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - bitField0_ |= 0x00000002; - private_ = value; - onChanged(); - return this; - } - /** - * optional bytes private = 2; - */ - public Builder clearPrivate() { - bitField0_ = (bitField0_ & ~0x00000002); - private_ = getDefaultInstance().getPrivate(); - onChanged(); - return this; - } - - // @@protoc_insertion_point(builder_scope:textsecure.SenderKeyStateStructure.SenderSigningKey) - } - - static { - defaultInstance = new SenderSigningKey(true); - defaultInstance.initFields(); - } - - // @@protoc_insertion_point(class_scope:textsecure.SenderKeyStateStructure.SenderSigningKey) - } - - private int bitField0_; - // optional uint32 senderKeyId = 1; - public static final int SENDERKEYID_FIELD_NUMBER = 1; - private int senderKeyId_; - /** - * optional uint32 senderKeyId = 1; - */ - public boolean hasSenderKeyId() { - return ((bitField0_ & 0x00000001) == 0x00000001); - } - /** - * optional uint32 senderKeyId = 1; - */ - public int getSenderKeyId() { - return senderKeyId_; - } - - // optional .textsecure.SenderKeyStateStructure.SenderChainKey senderChainKey = 2; - public static final int SENDERCHAINKEY_FIELD_NUMBER = 2; - private org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderChainKey senderChainKey_; - /** - * optional .textsecure.SenderKeyStateStructure.SenderChainKey senderChainKey = 2; - */ - public boolean hasSenderChainKey() { - return ((bitField0_ & 0x00000002) == 0x00000002); - } - /** - * optional .textsecure.SenderKeyStateStructure.SenderChainKey senderChainKey = 2; - */ - public org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderChainKey getSenderChainKey() { - return senderChainKey_; - } - /** - * optional .textsecure.SenderKeyStateStructure.SenderChainKey senderChainKey = 2; - */ - public org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderChainKeyOrBuilder getSenderChainKeyOrBuilder() { - return senderChainKey_; - } - - // optional .textsecure.SenderKeyStateStructure.SenderSigningKey senderSigningKey = 3; - public static final int SENDERSIGNINGKEY_FIELD_NUMBER = 3; - private org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderSigningKey senderSigningKey_; - /** - * optional .textsecure.SenderKeyStateStructure.SenderSigningKey senderSigningKey = 3; - */ - public boolean hasSenderSigningKey() { - return ((bitField0_ & 0x00000004) == 0x00000004); - } - /** - * optional .textsecure.SenderKeyStateStructure.SenderSigningKey senderSigningKey = 3; - */ - public org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderSigningKey getSenderSigningKey() { - return senderSigningKey_; - } - /** - * optional .textsecure.SenderKeyStateStructure.SenderSigningKey senderSigningKey = 3; - */ - public org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderSigningKeyOrBuilder getSenderSigningKeyOrBuilder() { - return senderSigningKey_; - } - - // repeated .textsecure.SenderKeyStateStructure.SenderMessageKey senderMessageKeys = 4; - public static final int SENDERMESSAGEKEYS_FIELD_NUMBER = 4; - private java.util.List senderMessageKeys_; - /** - * repeated .textsecure.SenderKeyStateStructure.SenderMessageKey senderMessageKeys = 4; - */ - public java.util.List getSenderMessageKeysList() { - return senderMessageKeys_; - } - /** - * repeated .textsecure.SenderKeyStateStructure.SenderMessageKey senderMessageKeys = 4; - */ - public java.util.List - getSenderMessageKeysOrBuilderList() { - return senderMessageKeys_; - } - /** - * repeated .textsecure.SenderKeyStateStructure.SenderMessageKey senderMessageKeys = 4; - */ - public int getSenderMessageKeysCount() { - return senderMessageKeys_.size(); - } - /** - * repeated .textsecure.SenderKeyStateStructure.SenderMessageKey senderMessageKeys = 4; - */ - public org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderMessageKey getSenderMessageKeys(int index) { - return senderMessageKeys_.get(index); - } - /** - * repeated .textsecure.SenderKeyStateStructure.SenderMessageKey senderMessageKeys = 4; - */ - public org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderMessageKeyOrBuilder getSenderMessageKeysOrBuilder( - int index) { - return senderMessageKeys_.get(index); - } - - private void initFields() { - senderKeyId_ = 0; - senderChainKey_ = org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderChainKey.getDefaultInstance(); - senderSigningKey_ = org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderSigningKey.getDefaultInstance(); - senderMessageKeys_ = java.util.Collections.emptyList(); - } - private byte memoizedIsInitialized = -1; - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized != -1) return isInitialized == 1; - - memoizedIsInitialized = 1; - return true; - } - - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - getSerializedSize(); - if (((bitField0_ & 0x00000001) == 0x00000001)) { - output.writeUInt32(1, senderKeyId_); - } - if (((bitField0_ & 0x00000002) == 0x00000002)) { - output.writeMessage(2, senderChainKey_); - } - if (((bitField0_ & 0x00000004) == 0x00000004)) { - output.writeMessage(3, senderSigningKey_); - } - for (int i = 0; i < senderMessageKeys_.size(); i++) { - output.writeMessage(4, senderMessageKeys_.get(i)); - } - getUnknownFields().writeTo(output); - } - - private int memoizedSerializedSize = -1; - public int getSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (((bitField0_ & 0x00000001) == 0x00000001)) { - size += com.google.protobuf.CodedOutputStream - .computeUInt32Size(1, senderKeyId_); - } - if (((bitField0_ & 0x00000002) == 0x00000002)) { - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(2, senderChainKey_); - } - if (((bitField0_ & 0x00000004) == 0x00000004)) { - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(3, senderSigningKey_); - } - for (int i = 0; i < senderMessageKeys_.size(); i++) { - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(4, senderMessageKeys_.get(i)); - } - size += getUnknownFields().getSerializedSize(); - memoizedSerializedSize = size; - return size; - } - - private static final long serialVersionUID = 0L; - @java.lang.Override - protected java.lang.Object writeReplace() - throws java.io.ObjectStreamException { - return super.writeReplace(); - } - - public static org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure parseFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - public static org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input); - } - public static org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input, extensionRegistry); - } - public static org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - - public static Builder newBuilder() { return Builder.create(); } - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder(org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure prototype) { - return newBuilder().mergeFrom(prototype); - } - public Builder toBuilder() { return newBuilder(this); } - - @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * Protobuf type {@code textsecure.SenderKeyStateStructure} - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessage.Builder - implements org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructureOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return org.session.libsignal.libsignal.state.StorageProtos.internal_static_textsecure_SenderKeyStateStructure_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return org.session.libsignal.libsignal.state.StorageProtos.internal_static_textsecure_SenderKeyStateStructure_fieldAccessorTable - .ensureFieldAccessorsInitialized( - org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.class, org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.Builder.class); - } - - // Construct using org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { - getSenderChainKeyFieldBuilder(); - getSenderSigningKeyFieldBuilder(); - getSenderMessageKeysFieldBuilder(); - } - } - private static Builder create() { - return new Builder(); - } - - public Builder clear() { - super.clear(); - senderKeyId_ = 0; - bitField0_ = (bitField0_ & ~0x00000001); - if (senderChainKeyBuilder_ == null) { - senderChainKey_ = org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderChainKey.getDefaultInstance(); - } else { - senderChainKeyBuilder_.clear(); - } - bitField0_ = (bitField0_ & ~0x00000002); - if (senderSigningKeyBuilder_ == null) { - senderSigningKey_ = org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderSigningKey.getDefaultInstance(); - } else { - senderSigningKeyBuilder_.clear(); - } - bitField0_ = (bitField0_ & ~0x00000004); - if (senderMessageKeysBuilder_ == null) { - senderMessageKeys_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000008); - } else { - senderMessageKeysBuilder_.clear(); - } - return this; - } - - public Builder clone() { - return create().mergeFrom(buildPartial()); - } - - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return org.session.libsignal.libsignal.state.StorageProtos.internal_static_textsecure_SenderKeyStateStructure_descriptor; - } - - public org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure getDefaultInstanceForType() { - return org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.getDefaultInstance(); - } - - public org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure build() { - org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - public org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure buildPartial() { - org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure result = new org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure(this); - int from_bitField0_ = bitField0_; - int to_bitField0_ = 0; - if (((from_bitField0_ & 0x00000001) == 0x00000001)) { - to_bitField0_ |= 0x00000001; - } - result.senderKeyId_ = senderKeyId_; - if (((from_bitField0_ & 0x00000002) == 0x00000002)) { - to_bitField0_ |= 0x00000002; - } - if (senderChainKeyBuilder_ == null) { - result.senderChainKey_ = senderChainKey_; - } else { - result.senderChainKey_ = senderChainKeyBuilder_.build(); - } - if (((from_bitField0_ & 0x00000004) == 0x00000004)) { - to_bitField0_ |= 0x00000004; - } - if (senderSigningKeyBuilder_ == null) { - result.senderSigningKey_ = senderSigningKey_; - } else { - result.senderSigningKey_ = senderSigningKeyBuilder_.build(); - } - if (senderMessageKeysBuilder_ == null) { - if (((bitField0_ & 0x00000008) == 0x00000008)) { - senderMessageKeys_ = java.util.Collections.unmodifiableList(senderMessageKeys_); - bitField0_ = (bitField0_ & ~0x00000008); - } - result.senderMessageKeys_ = senderMessageKeys_; - } else { - result.senderMessageKeys_ = senderMessageKeysBuilder_.build(); - } - result.bitField0_ = to_bitField0_; - onBuilt(); - return result; - } - - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure) { - return mergeFrom((org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure other) { - if (other == org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.getDefaultInstance()) return this; - if (other.hasSenderKeyId()) { - setSenderKeyId(other.getSenderKeyId()); - } - if (other.hasSenderChainKey()) { - mergeSenderChainKey(other.getSenderChainKey()); - } - if (other.hasSenderSigningKey()) { - mergeSenderSigningKey(other.getSenderSigningKey()); - } - if (senderMessageKeysBuilder_ == null) { - if (!other.senderMessageKeys_.isEmpty()) { - if (senderMessageKeys_.isEmpty()) { - senderMessageKeys_ = other.senderMessageKeys_; - bitField0_ = (bitField0_ & ~0x00000008); - } else { - ensureSenderMessageKeysIsMutable(); - senderMessageKeys_.addAll(other.senderMessageKeys_); - } - onChanged(); - } - } else { - if (!other.senderMessageKeys_.isEmpty()) { - if (senderMessageKeysBuilder_.isEmpty()) { - senderMessageKeysBuilder_.dispose(); - senderMessageKeysBuilder_ = null; - senderMessageKeys_ = other.senderMessageKeys_; - bitField0_ = (bitField0_ & ~0x00000008); - senderMessageKeysBuilder_ = - com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders ? - getSenderMessageKeysFieldBuilder() : null; - } else { - senderMessageKeysBuilder_.addAllMessages(other.senderMessageKeys_); - } - } - } - this.mergeUnknownFields(other.getUnknownFields()); - return this; - } - - public final boolean isInitialized() { - return true; - } - - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure) e.getUnfinishedMessage(); - throw e; - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - private int bitField0_; - - // optional uint32 senderKeyId = 1; - private int senderKeyId_ ; - /** - * optional uint32 senderKeyId = 1; - */ - public boolean hasSenderKeyId() { - return ((bitField0_ & 0x00000001) == 0x00000001); - } - /** - * optional uint32 senderKeyId = 1; - */ - public int getSenderKeyId() { - return senderKeyId_; - } - /** - * optional uint32 senderKeyId = 1; - */ - public Builder setSenderKeyId(int value) { - bitField0_ |= 0x00000001; - senderKeyId_ = value; - onChanged(); - return this; - } - /** - * optional uint32 senderKeyId = 1; - */ - public Builder clearSenderKeyId() { - bitField0_ = (bitField0_ & ~0x00000001); - senderKeyId_ = 0; - onChanged(); - return this; - } - - // optional .textsecure.SenderKeyStateStructure.SenderChainKey senderChainKey = 2; - private org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderChainKey senderChainKey_ = org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderChainKey.getDefaultInstance(); - private com.google.protobuf.SingleFieldBuilder< - org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderChainKey, org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderChainKey.Builder, org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderChainKeyOrBuilder> senderChainKeyBuilder_; - /** - * optional .textsecure.SenderKeyStateStructure.SenderChainKey senderChainKey = 2; - */ - public boolean hasSenderChainKey() { - return ((bitField0_ & 0x00000002) == 0x00000002); - } - /** - * optional .textsecure.SenderKeyStateStructure.SenderChainKey senderChainKey = 2; - */ - public org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderChainKey getSenderChainKey() { - if (senderChainKeyBuilder_ == null) { - return senderChainKey_; - } else { - return senderChainKeyBuilder_.getMessage(); - } - } - /** - * optional .textsecure.SenderKeyStateStructure.SenderChainKey senderChainKey = 2; - */ - public Builder setSenderChainKey(org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderChainKey value) { - if (senderChainKeyBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - senderChainKey_ = value; - onChanged(); - } else { - senderChainKeyBuilder_.setMessage(value); - } - bitField0_ |= 0x00000002; - return this; - } - /** - * optional .textsecure.SenderKeyStateStructure.SenderChainKey senderChainKey = 2; - */ - public Builder setSenderChainKey( - org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderChainKey.Builder builderForValue) { - if (senderChainKeyBuilder_ == null) { - senderChainKey_ = builderForValue.build(); - onChanged(); - } else { - senderChainKeyBuilder_.setMessage(builderForValue.build()); - } - bitField0_ |= 0x00000002; - return this; - } - /** - * optional .textsecure.SenderKeyStateStructure.SenderChainKey senderChainKey = 2; - */ - public Builder mergeSenderChainKey(org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderChainKey value) { - if (senderChainKeyBuilder_ == null) { - if (((bitField0_ & 0x00000002) == 0x00000002) && - senderChainKey_ != org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderChainKey.getDefaultInstance()) { - senderChainKey_ = - org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderChainKey.newBuilder(senderChainKey_).mergeFrom(value).buildPartial(); - } else { - senderChainKey_ = value; - } - onChanged(); - } else { - senderChainKeyBuilder_.mergeFrom(value); - } - bitField0_ |= 0x00000002; - return this; - } - /** - * optional .textsecure.SenderKeyStateStructure.SenderChainKey senderChainKey = 2; - */ - public Builder clearSenderChainKey() { - if (senderChainKeyBuilder_ == null) { - senderChainKey_ = org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderChainKey.getDefaultInstance(); - onChanged(); - } else { - senderChainKeyBuilder_.clear(); - } - bitField0_ = (bitField0_ & ~0x00000002); - return this; - } - /** - * optional .textsecure.SenderKeyStateStructure.SenderChainKey senderChainKey = 2; - */ - public org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderChainKey.Builder getSenderChainKeyBuilder() { - bitField0_ |= 0x00000002; - onChanged(); - return getSenderChainKeyFieldBuilder().getBuilder(); - } - /** - * optional .textsecure.SenderKeyStateStructure.SenderChainKey senderChainKey = 2; - */ - public org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderChainKeyOrBuilder getSenderChainKeyOrBuilder() { - if (senderChainKeyBuilder_ != null) { - return senderChainKeyBuilder_.getMessageOrBuilder(); - } else { - return senderChainKey_; - } - } - /** - * optional .textsecure.SenderKeyStateStructure.SenderChainKey senderChainKey = 2; - */ - private com.google.protobuf.SingleFieldBuilder< - org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderChainKey, org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderChainKey.Builder, org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderChainKeyOrBuilder> - getSenderChainKeyFieldBuilder() { - if (senderChainKeyBuilder_ == null) { - senderChainKeyBuilder_ = new com.google.protobuf.SingleFieldBuilder< - org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderChainKey, org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderChainKey.Builder, org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderChainKeyOrBuilder>( - senderChainKey_, - getParentForChildren(), - isClean()); - senderChainKey_ = null; - } - return senderChainKeyBuilder_; - } - - // optional .textsecure.SenderKeyStateStructure.SenderSigningKey senderSigningKey = 3; - private org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderSigningKey senderSigningKey_ = org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderSigningKey.getDefaultInstance(); - private com.google.protobuf.SingleFieldBuilder< - org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderSigningKey, org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderSigningKey.Builder, org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderSigningKeyOrBuilder> senderSigningKeyBuilder_; - /** - * optional .textsecure.SenderKeyStateStructure.SenderSigningKey senderSigningKey = 3; - */ - public boolean hasSenderSigningKey() { - return ((bitField0_ & 0x00000004) == 0x00000004); - } - /** - * optional .textsecure.SenderKeyStateStructure.SenderSigningKey senderSigningKey = 3; - */ - public org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderSigningKey getSenderSigningKey() { - if (senderSigningKeyBuilder_ == null) { - return senderSigningKey_; - } else { - return senderSigningKeyBuilder_.getMessage(); - } - } - /** - * optional .textsecure.SenderKeyStateStructure.SenderSigningKey senderSigningKey = 3; - */ - public Builder setSenderSigningKey(org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderSigningKey value) { - if (senderSigningKeyBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - senderSigningKey_ = value; - onChanged(); - } else { - senderSigningKeyBuilder_.setMessage(value); - } - bitField0_ |= 0x00000004; - return this; - } - /** - * optional .textsecure.SenderKeyStateStructure.SenderSigningKey senderSigningKey = 3; - */ - public Builder setSenderSigningKey( - org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderSigningKey.Builder builderForValue) { - if (senderSigningKeyBuilder_ == null) { - senderSigningKey_ = builderForValue.build(); - onChanged(); - } else { - senderSigningKeyBuilder_.setMessage(builderForValue.build()); - } - bitField0_ |= 0x00000004; - return this; - } - /** - * optional .textsecure.SenderKeyStateStructure.SenderSigningKey senderSigningKey = 3; - */ - public Builder mergeSenderSigningKey(org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderSigningKey value) { - if (senderSigningKeyBuilder_ == null) { - if (((bitField0_ & 0x00000004) == 0x00000004) && - senderSigningKey_ != org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderSigningKey.getDefaultInstance()) { - senderSigningKey_ = - org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderSigningKey.newBuilder(senderSigningKey_).mergeFrom(value).buildPartial(); - } else { - senderSigningKey_ = value; - } - onChanged(); - } else { - senderSigningKeyBuilder_.mergeFrom(value); - } - bitField0_ |= 0x00000004; - return this; - } - /** - * optional .textsecure.SenderKeyStateStructure.SenderSigningKey senderSigningKey = 3; - */ - public Builder clearSenderSigningKey() { - if (senderSigningKeyBuilder_ == null) { - senderSigningKey_ = org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderSigningKey.getDefaultInstance(); - onChanged(); - } else { - senderSigningKeyBuilder_.clear(); - } - bitField0_ = (bitField0_ & ~0x00000004); - return this; - } - /** - * optional .textsecure.SenderKeyStateStructure.SenderSigningKey senderSigningKey = 3; - */ - public org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderSigningKey.Builder getSenderSigningKeyBuilder() { - bitField0_ |= 0x00000004; - onChanged(); - return getSenderSigningKeyFieldBuilder().getBuilder(); - } - /** - * optional .textsecure.SenderKeyStateStructure.SenderSigningKey senderSigningKey = 3; - */ - public org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderSigningKeyOrBuilder getSenderSigningKeyOrBuilder() { - if (senderSigningKeyBuilder_ != null) { - return senderSigningKeyBuilder_.getMessageOrBuilder(); - } else { - return senderSigningKey_; - } - } - /** - * optional .textsecure.SenderKeyStateStructure.SenderSigningKey senderSigningKey = 3; - */ - private com.google.protobuf.SingleFieldBuilder< - org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderSigningKey, org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderSigningKey.Builder, org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderSigningKeyOrBuilder> - getSenderSigningKeyFieldBuilder() { - if (senderSigningKeyBuilder_ == null) { - senderSigningKeyBuilder_ = new com.google.protobuf.SingleFieldBuilder< - org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderSigningKey, org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderSigningKey.Builder, org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderSigningKeyOrBuilder>( - senderSigningKey_, - getParentForChildren(), - isClean()); - senderSigningKey_ = null; - } - return senderSigningKeyBuilder_; - } - - // repeated .textsecure.SenderKeyStateStructure.SenderMessageKey senderMessageKeys = 4; - private java.util.List senderMessageKeys_ = - java.util.Collections.emptyList(); - private void ensureSenderMessageKeysIsMutable() { - if (!((bitField0_ & 0x00000008) == 0x00000008)) { - senderMessageKeys_ = new java.util.ArrayList(senderMessageKeys_); - bitField0_ |= 0x00000008; - } - } - - private com.google.protobuf.RepeatedFieldBuilder< - org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderMessageKey, org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderMessageKey.Builder, org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderMessageKeyOrBuilder> senderMessageKeysBuilder_; - - /** - * repeated .textsecure.SenderKeyStateStructure.SenderMessageKey senderMessageKeys = 4; - */ - public java.util.List getSenderMessageKeysList() { - if (senderMessageKeysBuilder_ == null) { - return java.util.Collections.unmodifiableList(senderMessageKeys_); - } else { - return senderMessageKeysBuilder_.getMessageList(); - } - } - /** - * repeated .textsecure.SenderKeyStateStructure.SenderMessageKey senderMessageKeys = 4; - */ - public int getSenderMessageKeysCount() { - if (senderMessageKeysBuilder_ == null) { - return senderMessageKeys_.size(); - } else { - return senderMessageKeysBuilder_.getCount(); - } - } - /** - * repeated .textsecure.SenderKeyStateStructure.SenderMessageKey senderMessageKeys = 4; - */ - public org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderMessageKey getSenderMessageKeys(int index) { - if (senderMessageKeysBuilder_ == null) { - return senderMessageKeys_.get(index); - } else { - return senderMessageKeysBuilder_.getMessage(index); - } - } - /** - * repeated .textsecure.SenderKeyStateStructure.SenderMessageKey senderMessageKeys = 4; - */ - public Builder setSenderMessageKeys( - int index, org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderMessageKey value) { - if (senderMessageKeysBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureSenderMessageKeysIsMutable(); - senderMessageKeys_.set(index, value); - onChanged(); - } else { - senderMessageKeysBuilder_.setMessage(index, value); - } - return this; - } - /** - * repeated .textsecure.SenderKeyStateStructure.SenderMessageKey senderMessageKeys = 4; - */ - public Builder setSenderMessageKeys( - int index, org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderMessageKey.Builder builderForValue) { - if (senderMessageKeysBuilder_ == null) { - ensureSenderMessageKeysIsMutable(); - senderMessageKeys_.set(index, builderForValue.build()); - onChanged(); - } else { - senderMessageKeysBuilder_.setMessage(index, builderForValue.build()); - } - return this; - } - /** - * repeated .textsecure.SenderKeyStateStructure.SenderMessageKey senderMessageKeys = 4; - */ - public Builder addSenderMessageKeys(org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderMessageKey value) { - if (senderMessageKeysBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureSenderMessageKeysIsMutable(); - senderMessageKeys_.add(value); - onChanged(); - } else { - senderMessageKeysBuilder_.addMessage(value); - } - return this; - } - /** - * repeated .textsecure.SenderKeyStateStructure.SenderMessageKey senderMessageKeys = 4; - */ - public Builder addSenderMessageKeys( - int index, org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderMessageKey value) { - if (senderMessageKeysBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureSenderMessageKeysIsMutable(); - senderMessageKeys_.add(index, value); - onChanged(); - } else { - senderMessageKeysBuilder_.addMessage(index, value); - } - return this; - } - /** - * repeated .textsecure.SenderKeyStateStructure.SenderMessageKey senderMessageKeys = 4; - */ - public Builder addSenderMessageKeys( - org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderMessageKey.Builder builderForValue) { - if (senderMessageKeysBuilder_ == null) { - ensureSenderMessageKeysIsMutable(); - senderMessageKeys_.add(builderForValue.build()); - onChanged(); - } else { - senderMessageKeysBuilder_.addMessage(builderForValue.build()); - } - return this; - } - /** - * repeated .textsecure.SenderKeyStateStructure.SenderMessageKey senderMessageKeys = 4; - */ - public Builder addSenderMessageKeys( - int index, org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderMessageKey.Builder builderForValue) { - if (senderMessageKeysBuilder_ == null) { - ensureSenderMessageKeysIsMutable(); - senderMessageKeys_.add(index, builderForValue.build()); - onChanged(); - } else { - senderMessageKeysBuilder_.addMessage(index, builderForValue.build()); - } - return this; - } - /** - * repeated .textsecure.SenderKeyStateStructure.SenderMessageKey senderMessageKeys = 4; - */ - public Builder addAllSenderMessageKeys( - java.lang.Iterable values) { - if (senderMessageKeysBuilder_ == null) { - ensureSenderMessageKeysIsMutable(); - super.addAll(values, senderMessageKeys_); - onChanged(); - } else { - senderMessageKeysBuilder_.addAllMessages(values); - } - return this; - } - /** - * repeated .textsecure.SenderKeyStateStructure.SenderMessageKey senderMessageKeys = 4; - */ - public Builder clearSenderMessageKeys() { - if (senderMessageKeysBuilder_ == null) { - senderMessageKeys_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000008); - onChanged(); - } else { - senderMessageKeysBuilder_.clear(); - } - return this; - } - /** - * repeated .textsecure.SenderKeyStateStructure.SenderMessageKey senderMessageKeys = 4; - */ - public Builder removeSenderMessageKeys(int index) { - if (senderMessageKeysBuilder_ == null) { - ensureSenderMessageKeysIsMutable(); - senderMessageKeys_.remove(index); - onChanged(); - } else { - senderMessageKeysBuilder_.remove(index); - } - return this; - } - /** - * repeated .textsecure.SenderKeyStateStructure.SenderMessageKey senderMessageKeys = 4; - */ - public org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderMessageKey.Builder getSenderMessageKeysBuilder( - int index) { - return getSenderMessageKeysFieldBuilder().getBuilder(index); - } - /** - * repeated .textsecure.SenderKeyStateStructure.SenderMessageKey senderMessageKeys = 4; - */ - public org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderMessageKeyOrBuilder getSenderMessageKeysOrBuilder( - int index) { - if (senderMessageKeysBuilder_ == null) { - return senderMessageKeys_.get(index); } else { - return senderMessageKeysBuilder_.getMessageOrBuilder(index); - } - } - /** - * repeated .textsecure.SenderKeyStateStructure.SenderMessageKey senderMessageKeys = 4; - */ - public java.util.List - getSenderMessageKeysOrBuilderList() { - if (senderMessageKeysBuilder_ != null) { - return senderMessageKeysBuilder_.getMessageOrBuilderList(); - } else { - return java.util.Collections.unmodifiableList(senderMessageKeys_); - } - } - /** - * repeated .textsecure.SenderKeyStateStructure.SenderMessageKey senderMessageKeys = 4; - */ - public org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderMessageKey.Builder addSenderMessageKeysBuilder() { - return getSenderMessageKeysFieldBuilder().addBuilder( - org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderMessageKey.getDefaultInstance()); - } - /** - * repeated .textsecure.SenderKeyStateStructure.SenderMessageKey senderMessageKeys = 4; - */ - public org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderMessageKey.Builder addSenderMessageKeysBuilder( - int index) { - return getSenderMessageKeysFieldBuilder().addBuilder( - index, org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderMessageKey.getDefaultInstance()); - } - /** - * repeated .textsecure.SenderKeyStateStructure.SenderMessageKey senderMessageKeys = 4; - */ - public java.util.List - getSenderMessageKeysBuilderList() { - return getSenderMessageKeysFieldBuilder().getBuilderList(); - } - private com.google.protobuf.RepeatedFieldBuilder< - org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderMessageKey, org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderMessageKey.Builder, org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderMessageKeyOrBuilder> - getSenderMessageKeysFieldBuilder() { - if (senderMessageKeysBuilder_ == null) { - senderMessageKeysBuilder_ = new com.google.protobuf.RepeatedFieldBuilder< - org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderMessageKey, org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderMessageKey.Builder, org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.SenderMessageKeyOrBuilder>( - senderMessageKeys_, - ((bitField0_ & 0x00000008) == 0x00000008), - getParentForChildren(), - isClean()); - senderMessageKeys_ = null; - } - return senderMessageKeysBuilder_; - } - - // @@protoc_insertion_point(builder_scope:textsecure.SenderKeyStateStructure) - } - - static { - defaultInstance = new SenderKeyStateStructure(true); - defaultInstance.initFields(); - } - - // @@protoc_insertion_point(class_scope:textsecure.SenderKeyStateStructure) - } - - public interface SenderKeyRecordStructureOrBuilder - extends com.google.protobuf.MessageOrBuilder { - - // repeated .textsecure.SenderKeyStateStructure senderKeyStates = 1; - /** - * repeated .textsecure.SenderKeyStateStructure senderKeyStates = 1; - */ - java.util.List - getSenderKeyStatesList(); - /** - * repeated .textsecure.SenderKeyStateStructure senderKeyStates = 1; - */ - org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure getSenderKeyStates(int index); - /** - * repeated .textsecure.SenderKeyStateStructure senderKeyStates = 1; - */ - int getSenderKeyStatesCount(); - /** - * repeated .textsecure.SenderKeyStateStructure senderKeyStates = 1; - */ - java.util.List - getSenderKeyStatesOrBuilderList(); - /** - * repeated .textsecure.SenderKeyStateStructure senderKeyStates = 1; - */ - org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructureOrBuilder getSenderKeyStatesOrBuilder( - int index); - } - /** - * Protobuf type {@code textsecure.SenderKeyRecordStructure} - */ - public static final class SenderKeyRecordStructure extends - com.google.protobuf.GeneratedMessage - implements SenderKeyRecordStructureOrBuilder { - // Use SenderKeyRecordStructure.newBuilder() to construct. - private SenderKeyRecordStructure(com.google.protobuf.GeneratedMessage.Builder builder) { - super(builder); - this.unknownFields = builder.getUnknownFields(); - } - private SenderKeyRecordStructure(boolean noInit) { this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); } - - private static final SenderKeyRecordStructure defaultInstance; - public static SenderKeyRecordStructure getDefaultInstance() { - return defaultInstance; - } - - public SenderKeyRecordStructure getDefaultInstanceForType() { - return defaultInstance; - } - - private final com.google.protobuf.UnknownFieldSet unknownFields; - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return this.unknownFields; - } - private SenderKeyRecordStructure( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - initFields(); - int mutable_bitField0_ = 0; - com.google.protobuf.UnknownFieldSet.Builder unknownFields = - com.google.protobuf.UnknownFieldSet.newBuilder(); - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: { - if (!parseUnknownField(input, unknownFields, - extensionRegistry, tag)) { - done = true; - } - break; - } - case 10: { - if (!((mutable_bitField0_ & 0x00000001) == 0x00000001)) { - senderKeyStates_ = new java.util.ArrayList(); - mutable_bitField0_ |= 0x00000001; - } - senderKeyStates_.add(input.readMessage(org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.PARSER, extensionRegistry)); - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(this); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException( - e.getMessage()).setUnfinishedMessage(this); - } finally { - if (((mutable_bitField0_ & 0x00000001) == 0x00000001)) { - senderKeyStates_ = java.util.Collections.unmodifiableList(senderKeyStates_); - } - this.unknownFields = unknownFields.build(); - makeExtensionsImmutable(); - } - } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return org.session.libsignal.libsignal.state.StorageProtos.internal_static_textsecure_SenderKeyRecordStructure_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return org.session.libsignal.libsignal.state.StorageProtos.internal_static_textsecure_SenderKeyRecordStructure_fieldAccessorTable - .ensureFieldAccessorsInitialized( - org.session.libsignal.libsignal.state.StorageProtos.SenderKeyRecordStructure.class, org.session.libsignal.libsignal.state.StorageProtos.SenderKeyRecordStructure.Builder.class); - } - - public static com.google.protobuf.Parser PARSER = - new com.google.protobuf.AbstractParser() { - public SenderKeyRecordStructure parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return new SenderKeyRecordStructure(input, extensionRegistry); - } - }; - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - // repeated .textsecure.SenderKeyStateStructure senderKeyStates = 1; - public static final int SENDERKEYSTATES_FIELD_NUMBER = 1; - private java.util.List senderKeyStates_; - /** - * repeated .textsecure.SenderKeyStateStructure senderKeyStates = 1; - */ - public java.util.List getSenderKeyStatesList() { - return senderKeyStates_; - } - /** - * repeated .textsecure.SenderKeyStateStructure senderKeyStates = 1; - */ - public java.util.List - getSenderKeyStatesOrBuilderList() { - return senderKeyStates_; - } - /** - * repeated .textsecure.SenderKeyStateStructure senderKeyStates = 1; - */ - public int getSenderKeyStatesCount() { - return senderKeyStates_.size(); - } - /** - * repeated .textsecure.SenderKeyStateStructure senderKeyStates = 1; - */ - public org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure getSenderKeyStates(int index) { - return senderKeyStates_.get(index); - } - /** - * repeated .textsecure.SenderKeyStateStructure senderKeyStates = 1; - */ - public org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructureOrBuilder getSenderKeyStatesOrBuilder( - int index) { - return senderKeyStates_.get(index); - } - - private void initFields() { - senderKeyStates_ = java.util.Collections.emptyList(); - } - private byte memoizedIsInitialized = -1; - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized != -1) return isInitialized == 1; - - memoizedIsInitialized = 1; - return true; - } - - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - getSerializedSize(); - for (int i = 0; i < senderKeyStates_.size(); i++) { - output.writeMessage(1, senderKeyStates_.get(i)); - } - getUnknownFields().writeTo(output); - } - - private int memoizedSerializedSize = -1; - public int getSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - for (int i = 0; i < senderKeyStates_.size(); i++) { - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(1, senderKeyStates_.get(i)); - } - size += getUnknownFields().getSerializedSize(); - memoizedSerializedSize = size; - return size; - } - - private static final long serialVersionUID = 0L; - @java.lang.Override - protected java.lang.Object writeReplace() - throws java.io.ObjectStreamException { - return super.writeReplace(); - } - - public static org.session.libsignal.libsignal.state.StorageProtos.SenderKeyRecordStructure parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static org.session.libsignal.libsignal.state.StorageProtos.SenderKeyRecordStructure parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static org.session.libsignal.libsignal.state.StorageProtos.SenderKeyRecordStructure parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static org.session.libsignal.libsignal.state.StorageProtos.SenderKeyRecordStructure parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static org.session.libsignal.libsignal.state.StorageProtos.SenderKeyRecordStructure parseFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static org.session.libsignal.libsignal.state.StorageProtos.SenderKeyRecordStructure parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - public static org.session.libsignal.libsignal.state.StorageProtos.SenderKeyRecordStructure parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input); - } - public static org.session.libsignal.libsignal.state.StorageProtos.SenderKeyRecordStructure parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input, extensionRegistry); - } - public static org.session.libsignal.libsignal.state.StorageProtos.SenderKeyRecordStructure parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static org.session.libsignal.libsignal.state.StorageProtos.SenderKeyRecordStructure parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - - public static Builder newBuilder() { return Builder.create(); } - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder(org.session.libsignal.libsignal.state.StorageProtos.SenderKeyRecordStructure prototype) { - return newBuilder().mergeFrom(prototype); - } - public Builder toBuilder() { return newBuilder(this); } - - @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * Protobuf type {@code textsecure.SenderKeyRecordStructure} - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessage.Builder - implements org.session.libsignal.libsignal.state.StorageProtos.SenderKeyRecordStructureOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return org.session.libsignal.libsignal.state.StorageProtos.internal_static_textsecure_SenderKeyRecordStructure_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return org.session.libsignal.libsignal.state.StorageProtos.internal_static_textsecure_SenderKeyRecordStructure_fieldAccessorTable - .ensureFieldAccessorsInitialized( - org.session.libsignal.libsignal.state.StorageProtos.SenderKeyRecordStructure.class, org.session.libsignal.libsignal.state.StorageProtos.SenderKeyRecordStructure.Builder.class); - } - - // Construct using org.session.libsignal.libsignal.state.StorageProtos.SenderKeyRecordStructure.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { - getSenderKeyStatesFieldBuilder(); - } - } - private static Builder create() { - return new Builder(); - } - - public Builder clear() { - super.clear(); - if (senderKeyStatesBuilder_ == null) { - senderKeyStates_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000001); - } else { - senderKeyStatesBuilder_.clear(); - } - return this; - } - - public Builder clone() { - return create().mergeFrom(buildPartial()); - } - - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return org.session.libsignal.libsignal.state.StorageProtos.internal_static_textsecure_SenderKeyRecordStructure_descriptor; - } - - public org.session.libsignal.libsignal.state.StorageProtos.SenderKeyRecordStructure getDefaultInstanceForType() { - return org.session.libsignal.libsignal.state.StorageProtos.SenderKeyRecordStructure.getDefaultInstance(); - } - - public org.session.libsignal.libsignal.state.StorageProtos.SenderKeyRecordStructure build() { - org.session.libsignal.libsignal.state.StorageProtos.SenderKeyRecordStructure result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - public org.session.libsignal.libsignal.state.StorageProtos.SenderKeyRecordStructure buildPartial() { - org.session.libsignal.libsignal.state.StorageProtos.SenderKeyRecordStructure result = new org.session.libsignal.libsignal.state.StorageProtos.SenderKeyRecordStructure(this); - int from_bitField0_ = bitField0_; - if (senderKeyStatesBuilder_ == null) { - if (((bitField0_ & 0x00000001) == 0x00000001)) { - senderKeyStates_ = java.util.Collections.unmodifiableList(senderKeyStates_); - bitField0_ = (bitField0_ & ~0x00000001); - } - result.senderKeyStates_ = senderKeyStates_; - } else { - result.senderKeyStates_ = senderKeyStatesBuilder_.build(); - } - onBuilt(); - return result; - } - - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof org.session.libsignal.libsignal.state.StorageProtos.SenderKeyRecordStructure) { - return mergeFrom((org.session.libsignal.libsignal.state.StorageProtos.SenderKeyRecordStructure)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(org.session.libsignal.libsignal.state.StorageProtos.SenderKeyRecordStructure other) { - if (other == org.session.libsignal.libsignal.state.StorageProtos.SenderKeyRecordStructure.getDefaultInstance()) return this; - if (senderKeyStatesBuilder_ == null) { - if (!other.senderKeyStates_.isEmpty()) { - if (senderKeyStates_.isEmpty()) { - senderKeyStates_ = other.senderKeyStates_; - bitField0_ = (bitField0_ & ~0x00000001); - } else { - ensureSenderKeyStatesIsMutable(); - senderKeyStates_.addAll(other.senderKeyStates_); - } - onChanged(); - } - } else { - if (!other.senderKeyStates_.isEmpty()) { - if (senderKeyStatesBuilder_.isEmpty()) { - senderKeyStatesBuilder_.dispose(); - senderKeyStatesBuilder_ = null; - senderKeyStates_ = other.senderKeyStates_; - bitField0_ = (bitField0_ & ~0x00000001); - senderKeyStatesBuilder_ = - com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders ? - getSenderKeyStatesFieldBuilder() : null; - } else { - senderKeyStatesBuilder_.addAllMessages(other.senderKeyStates_); - } - } - } - this.mergeUnknownFields(other.getUnknownFields()); - return this; - } - - public final boolean isInitialized() { - return true; - } - - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - org.session.libsignal.libsignal.state.StorageProtos.SenderKeyRecordStructure parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (org.session.libsignal.libsignal.state.StorageProtos.SenderKeyRecordStructure) e.getUnfinishedMessage(); - throw e; - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - private int bitField0_; - - // repeated .textsecure.SenderKeyStateStructure senderKeyStates = 1; - private java.util.List senderKeyStates_ = - java.util.Collections.emptyList(); - private void ensureSenderKeyStatesIsMutable() { - if (!((bitField0_ & 0x00000001) == 0x00000001)) { - senderKeyStates_ = new java.util.ArrayList(senderKeyStates_); - bitField0_ |= 0x00000001; - } - } - - private com.google.protobuf.RepeatedFieldBuilder< - org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure, org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.Builder, org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructureOrBuilder> senderKeyStatesBuilder_; - - /** - * repeated .textsecure.SenderKeyStateStructure senderKeyStates = 1; - */ - public java.util.List getSenderKeyStatesList() { - if (senderKeyStatesBuilder_ == null) { - return java.util.Collections.unmodifiableList(senderKeyStates_); - } else { - return senderKeyStatesBuilder_.getMessageList(); - } - } - /** - * repeated .textsecure.SenderKeyStateStructure senderKeyStates = 1; - */ - public int getSenderKeyStatesCount() { - if (senderKeyStatesBuilder_ == null) { - return senderKeyStates_.size(); - } else { - return senderKeyStatesBuilder_.getCount(); - } - } - /** - * repeated .textsecure.SenderKeyStateStructure senderKeyStates = 1; - */ - public org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure getSenderKeyStates(int index) { - if (senderKeyStatesBuilder_ == null) { - return senderKeyStates_.get(index); - } else { - return senderKeyStatesBuilder_.getMessage(index); - } - } - /** - * repeated .textsecure.SenderKeyStateStructure senderKeyStates = 1; - */ - public Builder setSenderKeyStates( - int index, org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure value) { - if (senderKeyStatesBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureSenderKeyStatesIsMutable(); - senderKeyStates_.set(index, value); - onChanged(); - } else { - senderKeyStatesBuilder_.setMessage(index, value); - } - return this; - } - /** - * repeated .textsecure.SenderKeyStateStructure senderKeyStates = 1; - */ - public Builder setSenderKeyStates( - int index, org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.Builder builderForValue) { - if (senderKeyStatesBuilder_ == null) { - ensureSenderKeyStatesIsMutable(); - senderKeyStates_.set(index, builderForValue.build()); - onChanged(); - } else { - senderKeyStatesBuilder_.setMessage(index, builderForValue.build()); - } - return this; - } - /** - * repeated .textsecure.SenderKeyStateStructure senderKeyStates = 1; - */ - public Builder addSenderKeyStates(org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure value) { - if (senderKeyStatesBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureSenderKeyStatesIsMutable(); - senderKeyStates_.add(value); - onChanged(); - } else { - senderKeyStatesBuilder_.addMessage(value); - } - return this; - } - /** - * repeated .textsecure.SenderKeyStateStructure senderKeyStates = 1; - */ - public Builder addSenderKeyStates( - int index, org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure value) { - if (senderKeyStatesBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureSenderKeyStatesIsMutable(); - senderKeyStates_.add(index, value); - onChanged(); - } else { - senderKeyStatesBuilder_.addMessage(index, value); - } - return this; - } - /** - * repeated .textsecure.SenderKeyStateStructure senderKeyStates = 1; - */ - public Builder addSenderKeyStates( - org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.Builder builderForValue) { - if (senderKeyStatesBuilder_ == null) { - ensureSenderKeyStatesIsMutable(); - senderKeyStates_.add(builderForValue.build()); - onChanged(); - } else { - senderKeyStatesBuilder_.addMessage(builderForValue.build()); - } - return this; - } - /** - * repeated .textsecure.SenderKeyStateStructure senderKeyStates = 1; - */ - public Builder addSenderKeyStates( - int index, org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.Builder builderForValue) { - if (senderKeyStatesBuilder_ == null) { - ensureSenderKeyStatesIsMutable(); - senderKeyStates_.add(index, builderForValue.build()); - onChanged(); - } else { - senderKeyStatesBuilder_.addMessage(index, builderForValue.build()); - } - return this; - } - /** - * repeated .textsecure.SenderKeyStateStructure senderKeyStates = 1; - */ - public Builder addAllSenderKeyStates( - java.lang.Iterable values) { - if (senderKeyStatesBuilder_ == null) { - ensureSenderKeyStatesIsMutable(); - super.addAll(values, senderKeyStates_); - onChanged(); - } else { - senderKeyStatesBuilder_.addAllMessages(values); - } - return this; - } - /** - * repeated .textsecure.SenderKeyStateStructure senderKeyStates = 1; - */ - public Builder clearSenderKeyStates() { - if (senderKeyStatesBuilder_ == null) { - senderKeyStates_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000001); - onChanged(); - } else { - senderKeyStatesBuilder_.clear(); - } - return this; - } - /** - * repeated .textsecure.SenderKeyStateStructure senderKeyStates = 1; - */ - public Builder removeSenderKeyStates(int index) { - if (senderKeyStatesBuilder_ == null) { - ensureSenderKeyStatesIsMutable(); - senderKeyStates_.remove(index); - onChanged(); - } else { - senderKeyStatesBuilder_.remove(index); - } - return this; - } - /** - * repeated .textsecure.SenderKeyStateStructure senderKeyStates = 1; - */ - public org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.Builder getSenderKeyStatesBuilder( - int index) { - return getSenderKeyStatesFieldBuilder().getBuilder(index); - } - /** - * repeated .textsecure.SenderKeyStateStructure senderKeyStates = 1; - */ - public org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructureOrBuilder getSenderKeyStatesOrBuilder( - int index) { - if (senderKeyStatesBuilder_ == null) { - return senderKeyStates_.get(index); } else { - return senderKeyStatesBuilder_.getMessageOrBuilder(index); - } - } - /** - * repeated .textsecure.SenderKeyStateStructure senderKeyStates = 1; - */ - public java.util.List - getSenderKeyStatesOrBuilderList() { - if (senderKeyStatesBuilder_ != null) { - return senderKeyStatesBuilder_.getMessageOrBuilderList(); - } else { - return java.util.Collections.unmodifiableList(senderKeyStates_); - } - } - /** - * repeated .textsecure.SenderKeyStateStructure senderKeyStates = 1; - */ - public org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.Builder addSenderKeyStatesBuilder() { - return getSenderKeyStatesFieldBuilder().addBuilder( - org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.getDefaultInstance()); - } - /** - * repeated .textsecure.SenderKeyStateStructure senderKeyStates = 1; - */ - public org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.Builder addSenderKeyStatesBuilder( - int index) { - return getSenderKeyStatesFieldBuilder().addBuilder( - index, org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.getDefaultInstance()); - } - /** - * repeated .textsecure.SenderKeyStateStructure senderKeyStates = 1; - */ - public java.util.List - getSenderKeyStatesBuilderList() { - return getSenderKeyStatesFieldBuilder().getBuilderList(); - } - private com.google.protobuf.RepeatedFieldBuilder< - org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure, org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.Builder, org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructureOrBuilder> - getSenderKeyStatesFieldBuilder() { - if (senderKeyStatesBuilder_ == null) { - senderKeyStatesBuilder_ = new com.google.protobuf.RepeatedFieldBuilder< - org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure, org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructure.Builder, org.session.libsignal.libsignal.state.StorageProtos.SenderKeyStateStructureOrBuilder>( - senderKeyStates_, - ((bitField0_ & 0x00000001) == 0x00000001), - getParentForChildren(), - isClean()); - senderKeyStates_ = null; - } - return senderKeyStatesBuilder_; - } - - // @@protoc_insertion_point(builder_scope:textsecure.SenderKeyRecordStructure) - } - - static { - defaultInstance = new SenderKeyRecordStructure(true); - defaultInstance.initFields(); - } - - // @@protoc_insertion_point(class_scope:textsecure.SenderKeyRecordStructure) - } - - private static com.google.protobuf.Descriptors.Descriptor - internal_static_textsecure_SessionStructure_descriptor; - private static - com.google.protobuf.GeneratedMessage.FieldAccessorTable - internal_static_textsecure_SessionStructure_fieldAccessorTable; - private static com.google.protobuf.Descriptors.Descriptor - internal_static_textsecure_SessionStructure_Chain_descriptor; - private static - com.google.protobuf.GeneratedMessage.FieldAccessorTable - internal_static_textsecure_SessionStructure_Chain_fieldAccessorTable; - private static com.google.protobuf.Descriptors.Descriptor - internal_static_textsecure_SessionStructure_Chain_ChainKey_descriptor; - private static - com.google.protobuf.GeneratedMessage.FieldAccessorTable - internal_static_textsecure_SessionStructure_Chain_ChainKey_fieldAccessorTable; - private static com.google.protobuf.Descriptors.Descriptor - internal_static_textsecure_SessionStructure_Chain_MessageKey_descriptor; - private static - com.google.protobuf.GeneratedMessage.FieldAccessorTable - internal_static_textsecure_SessionStructure_Chain_MessageKey_fieldAccessorTable; - private static com.google.protobuf.Descriptors.Descriptor - internal_static_textsecure_SessionStructure_PendingKeyExchange_descriptor; - private static - com.google.protobuf.GeneratedMessage.FieldAccessorTable - internal_static_textsecure_SessionStructure_PendingKeyExchange_fieldAccessorTable; - private static com.google.protobuf.Descriptors.Descriptor - internal_static_textsecure_SessionStructure_PendingPreKey_descriptor; - private static - com.google.protobuf.GeneratedMessage.FieldAccessorTable - internal_static_textsecure_SessionStructure_PendingPreKey_fieldAccessorTable; - private static com.google.protobuf.Descriptors.Descriptor - internal_static_textsecure_RecordStructure_descriptor; - private static - com.google.protobuf.GeneratedMessage.FieldAccessorTable - internal_static_textsecure_RecordStructure_fieldAccessorTable; - private static com.google.protobuf.Descriptors.Descriptor - internal_static_textsecure_PreKeyRecordStructure_descriptor; - private static - com.google.protobuf.GeneratedMessage.FieldAccessorTable - internal_static_textsecure_PreKeyRecordStructure_fieldAccessorTable; - private static com.google.protobuf.Descriptors.Descriptor - internal_static_textsecure_SignedPreKeyRecordStructure_descriptor; - private static - com.google.protobuf.GeneratedMessage.FieldAccessorTable - internal_static_textsecure_SignedPreKeyRecordStructure_fieldAccessorTable; - private static com.google.protobuf.Descriptors.Descriptor - internal_static_textsecure_IdentityKeyPairStructure_descriptor; - private static - com.google.protobuf.GeneratedMessage.FieldAccessorTable - internal_static_textsecure_IdentityKeyPairStructure_fieldAccessorTable; - private static com.google.protobuf.Descriptors.Descriptor - internal_static_textsecure_SenderKeyStateStructure_descriptor; - private static - com.google.protobuf.GeneratedMessage.FieldAccessorTable - internal_static_textsecure_SenderKeyStateStructure_fieldAccessorTable; - private static com.google.protobuf.Descriptors.Descriptor - internal_static_textsecure_SenderKeyStateStructure_SenderChainKey_descriptor; - private static - com.google.protobuf.GeneratedMessage.FieldAccessorTable - internal_static_textsecure_SenderKeyStateStructure_SenderChainKey_fieldAccessorTable; - private static com.google.protobuf.Descriptors.Descriptor - internal_static_textsecure_SenderKeyStateStructure_SenderMessageKey_descriptor; - private static - com.google.protobuf.GeneratedMessage.FieldAccessorTable - internal_static_textsecure_SenderKeyStateStructure_SenderMessageKey_fieldAccessorTable; - private static com.google.protobuf.Descriptors.Descriptor - internal_static_textsecure_SenderKeyStateStructure_SenderSigningKey_descriptor; - private static - com.google.protobuf.GeneratedMessage.FieldAccessorTable - internal_static_textsecure_SenderKeyStateStructure_SenderSigningKey_fieldAccessorTable; - private static com.google.protobuf.Descriptors.Descriptor - internal_static_textsecure_SenderKeyRecordStructure_descriptor; - private static - com.google.protobuf.GeneratedMessage.FieldAccessorTable - internal_static_textsecure_SenderKeyRecordStructure_fieldAccessorTable; - - public static com.google.protobuf.Descriptors.FileDescriptor - getDescriptor() { - return descriptor; - } - private static com.google.protobuf.Descriptors.FileDescriptor - descriptor; - static { - java.lang.String[] descriptorData = { - "\n\032LocalStorageProtocol.proto\022\ntextsecure" + - "\"\323\010\n\020SessionStructure\022\026\n\016sessionVersion\030" + - "\001 \001(\r\022\033\n\023localIdentityPublic\030\002 \001(\014\022\034\n\024re" + - "moteIdentityPublic\030\003 \001(\014\022\017\n\007rootKey\030\004 \001(" + - "\014\022\027\n\017previousCounter\030\005 \001(\r\0227\n\013senderChai" + - "n\030\006 \001(\0132\".textsecure.SessionStructure.Ch" + - "ain\022:\n\016receiverChains\030\007 \003(\0132\".textsecure" + - ".SessionStructure.Chain\022K\n\022pendingKeyExc" + - "hange\030\010 \001(\0132/.textsecure.SessionStructur" + - "e.PendingKeyExchange\022A\n\rpendingPreKey\030\t ", - "\001(\0132*.textsecure.SessionStructure.Pendin" + - "gPreKey\022\034\n\024remoteRegistrationId\030\n \001(\r\022\033\n" + - "\023localRegistrationId\030\013 \001(\r\022\024\n\014needsRefre" + - "sh\030\014 \001(\010\022\024\n\014aliceBaseKey\030\r \001(\014\032\271\002\n\005Chain" + - "\022\030\n\020senderRatchetKey\030\001 \001(\014\022\037\n\027senderRatc" + - "hetKeyPrivate\030\002 \001(\014\022=\n\010chainKey\030\003 \001(\0132+." + - "textsecure.SessionStructure.Chain.ChainK" + - "ey\022B\n\013messageKeys\030\004 \003(\0132-.textsecure.Ses" + - "sionStructure.Chain.MessageKey\032&\n\010ChainK" + - "ey\022\r\n\005index\030\001 \001(\r\022\013\n\003key\030\002 \001(\014\032J\n\nMessag", - "eKey\022\r\n\005index\030\001 \001(\r\022\021\n\tcipherKey\030\002 \001(\014\022\016" + - "\n\006macKey\030\003 \001(\014\022\n\n\002iv\030\004 \001(\014\032\315\001\n\022PendingKe" + - "yExchange\022\020\n\010sequence\030\001 \001(\r\022\024\n\014localBase" + - "Key\030\002 \001(\014\022\033\n\023localBaseKeyPrivate\030\003 \001(\014\022\027" + - "\n\017localRatchetKey\030\004 \001(\014\022\036\n\026localRatchetK" + - "eyPrivate\030\005 \001(\014\022\030\n\020localIdentityKey\030\007 \001(" + - "\014\022\037\n\027localIdentityKeyPrivate\030\010 \001(\014\032J\n\rPe" + - "ndingPreKey\022\020\n\010preKeyId\030\001 \001(\r\022\026\n\016signedP" + - "reKeyId\030\003 \001(\005\022\017\n\007baseKey\030\002 \001(\014\"\177\n\017Record" + - "Structure\0224\n\016currentSession\030\001 \001(\0132\034.text", - "secure.SessionStructure\0226\n\020previousSessi" + - "ons\030\002 \003(\0132\034.textsecure.SessionStructure\"" + - "J\n\025PreKeyRecordStructure\022\n\n\002id\030\001 \001(\r\022\021\n\t" + - "publicKey\030\002 \001(\014\022\022\n\nprivateKey\030\003 \001(\014\"v\n\033S" + - "ignedPreKeyRecordStructure\022\n\n\002id\030\001 \001(\r\022\021" + - "\n\tpublicKey\030\002 \001(\014\022\022\n\nprivateKey\030\003 \001(\014\022\021\n" + - "\tsignature\030\004 \001(\014\022\021\n\ttimestamp\030\005 \001(\006\"A\n\030I" + - "dentityKeyPairStructure\022\021\n\tpublicKey\030\001 \001" + - "(\014\022\022\n\nprivateKey\030\002 \001(\014\"\270\003\n\027SenderKeyStat" + - "eStructure\022\023\n\013senderKeyId\030\001 \001(\r\022J\n\016sende", - "rChainKey\030\002 \001(\01322.textsecure.SenderKeySt" + - "ateStructure.SenderChainKey\022N\n\020senderSig" + - "ningKey\030\003 \001(\01324.textsecure.SenderKeyStat" + - "eStructure.SenderSigningKey\022O\n\021senderMes" + - "sageKeys\030\004 \003(\01324.textsecure.SenderKeySta" + - "teStructure.SenderMessageKey\0321\n\016SenderCh" + - "ainKey\022\021\n\titeration\030\001 \001(\r\022\014\n\004seed\030\002 \001(\014\032" + - "3\n\020SenderMessageKey\022\021\n\titeration\030\001 \001(\r\022\014" + - "\n\004seed\030\002 \001(\014\0323\n\020SenderSigningKey\022\016\n\006publ" + - "ic\030\001 \001(\014\022\017\n\007private\030\002 \001(\014\"X\n\030SenderKeyRe", - "cordStructure\022<\n\017senderKeyStates\030\001 \003(\0132#" + - ".textsecure.SenderKeyStateStructureB6\n%o" + - "rg.session.libsignal.libsignal.stateB\rSt" + - "orageProtos" - }; - com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = - new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() { - public com.google.protobuf.ExtensionRegistry assignDescriptors( - com.google.protobuf.Descriptors.FileDescriptor root) { - descriptor = root; - internal_static_textsecure_SessionStructure_descriptor = - getDescriptor().getMessageTypes().get(0); - internal_static_textsecure_SessionStructure_fieldAccessorTable = new - com.google.protobuf.GeneratedMessage.FieldAccessorTable( - internal_static_textsecure_SessionStructure_descriptor, - new java.lang.String[] { "SessionVersion", "LocalIdentityPublic", "RemoteIdentityPublic", "RootKey", "PreviousCounter", "SenderChain", "ReceiverChains", "PendingKeyExchange", "PendingPreKey", "RemoteRegistrationId", "LocalRegistrationId", "NeedsRefresh", "AliceBaseKey", }); - internal_static_textsecure_SessionStructure_Chain_descriptor = - internal_static_textsecure_SessionStructure_descriptor.getNestedTypes().get(0); - internal_static_textsecure_SessionStructure_Chain_fieldAccessorTable = new - com.google.protobuf.GeneratedMessage.FieldAccessorTable( - internal_static_textsecure_SessionStructure_Chain_descriptor, - new java.lang.String[] { "SenderRatchetKey", "SenderRatchetKeyPrivate", "ChainKey", "MessageKeys", }); - internal_static_textsecure_SessionStructure_Chain_ChainKey_descriptor = - internal_static_textsecure_SessionStructure_Chain_descriptor.getNestedTypes().get(0); - internal_static_textsecure_SessionStructure_Chain_ChainKey_fieldAccessorTable = new - com.google.protobuf.GeneratedMessage.FieldAccessorTable( - internal_static_textsecure_SessionStructure_Chain_ChainKey_descriptor, - new java.lang.String[] { "Index", "Key", }); - internal_static_textsecure_SessionStructure_Chain_MessageKey_descriptor = - internal_static_textsecure_SessionStructure_Chain_descriptor.getNestedTypes().get(1); - internal_static_textsecure_SessionStructure_Chain_MessageKey_fieldAccessorTable = new - com.google.protobuf.GeneratedMessage.FieldAccessorTable( - internal_static_textsecure_SessionStructure_Chain_MessageKey_descriptor, - new java.lang.String[] { "Index", "CipherKey", "MacKey", "Iv", }); - internal_static_textsecure_SessionStructure_PendingKeyExchange_descriptor = - internal_static_textsecure_SessionStructure_descriptor.getNestedTypes().get(1); - internal_static_textsecure_SessionStructure_PendingKeyExchange_fieldAccessorTable = new - com.google.protobuf.GeneratedMessage.FieldAccessorTable( - internal_static_textsecure_SessionStructure_PendingKeyExchange_descriptor, - new java.lang.String[] { "Sequence", "LocalBaseKey", "LocalBaseKeyPrivate", "LocalRatchetKey", "LocalRatchetKeyPrivate", "LocalIdentityKey", "LocalIdentityKeyPrivate", }); - internal_static_textsecure_SessionStructure_PendingPreKey_descriptor = - internal_static_textsecure_SessionStructure_descriptor.getNestedTypes().get(2); - internal_static_textsecure_SessionStructure_PendingPreKey_fieldAccessorTable = new - com.google.protobuf.GeneratedMessage.FieldAccessorTable( - internal_static_textsecure_SessionStructure_PendingPreKey_descriptor, - new java.lang.String[] { "PreKeyId", "SignedPreKeyId", "BaseKey", }); - internal_static_textsecure_RecordStructure_descriptor = - getDescriptor().getMessageTypes().get(1); - internal_static_textsecure_RecordStructure_fieldAccessorTable = new - com.google.protobuf.GeneratedMessage.FieldAccessorTable( - internal_static_textsecure_RecordStructure_descriptor, - new java.lang.String[] { "CurrentSession", "PreviousSessions", }); - internal_static_textsecure_PreKeyRecordStructure_descriptor = - getDescriptor().getMessageTypes().get(2); - internal_static_textsecure_PreKeyRecordStructure_fieldAccessorTable = new - com.google.protobuf.GeneratedMessage.FieldAccessorTable( - internal_static_textsecure_PreKeyRecordStructure_descriptor, - new java.lang.String[] { "Id", "PublicKey", "PrivateKey", }); - internal_static_textsecure_SignedPreKeyRecordStructure_descriptor = - getDescriptor().getMessageTypes().get(3); - internal_static_textsecure_SignedPreKeyRecordStructure_fieldAccessorTable = new - com.google.protobuf.GeneratedMessage.FieldAccessorTable( - internal_static_textsecure_SignedPreKeyRecordStructure_descriptor, - new java.lang.String[] { "Id", "PublicKey", "PrivateKey", "Signature", "Timestamp", }); - internal_static_textsecure_IdentityKeyPairStructure_descriptor = - getDescriptor().getMessageTypes().get(4); - internal_static_textsecure_IdentityKeyPairStructure_fieldAccessorTable = new - com.google.protobuf.GeneratedMessage.FieldAccessorTable( - internal_static_textsecure_IdentityKeyPairStructure_descriptor, - new java.lang.String[] { "PublicKey", "PrivateKey", }); - internal_static_textsecure_SenderKeyStateStructure_descriptor = - getDescriptor().getMessageTypes().get(5); - internal_static_textsecure_SenderKeyStateStructure_fieldAccessorTable = new - com.google.protobuf.GeneratedMessage.FieldAccessorTable( - internal_static_textsecure_SenderKeyStateStructure_descriptor, - new java.lang.String[] { "SenderKeyId", "SenderChainKey", "SenderSigningKey", "SenderMessageKeys", }); - internal_static_textsecure_SenderKeyStateStructure_SenderChainKey_descriptor = - internal_static_textsecure_SenderKeyStateStructure_descriptor.getNestedTypes().get(0); - internal_static_textsecure_SenderKeyStateStructure_SenderChainKey_fieldAccessorTable = new - com.google.protobuf.GeneratedMessage.FieldAccessorTable( - internal_static_textsecure_SenderKeyStateStructure_SenderChainKey_descriptor, - new java.lang.String[] { "Iteration", "Seed", }); - internal_static_textsecure_SenderKeyStateStructure_SenderMessageKey_descriptor = - internal_static_textsecure_SenderKeyStateStructure_descriptor.getNestedTypes().get(1); - internal_static_textsecure_SenderKeyStateStructure_SenderMessageKey_fieldAccessorTable = new - com.google.protobuf.GeneratedMessage.FieldAccessorTable( - internal_static_textsecure_SenderKeyStateStructure_SenderMessageKey_descriptor, - new java.lang.String[] { "Iteration", "Seed", }); - internal_static_textsecure_SenderKeyStateStructure_SenderSigningKey_descriptor = - internal_static_textsecure_SenderKeyStateStructure_descriptor.getNestedTypes().get(2); - internal_static_textsecure_SenderKeyStateStructure_SenderSigningKey_fieldAccessorTable = new - com.google.protobuf.GeneratedMessage.FieldAccessorTable( - internal_static_textsecure_SenderKeyStateStructure_SenderSigningKey_descriptor, - new java.lang.String[] { "Public", "Private", }); - internal_static_textsecure_SenderKeyRecordStructure_descriptor = - getDescriptor().getMessageTypes().get(6); - internal_static_textsecure_SenderKeyRecordStructure_fieldAccessorTable = new - com.google.protobuf.GeneratedMessage.FieldAccessorTable( - internal_static_textsecure_SenderKeyRecordStructure_descriptor, - new java.lang.String[] { "SenderKeyStates", }); - return null; - } - }; - com.google.protobuf.Descriptors.FileDescriptor - .internalBuildGeneratedFileFrom(descriptorData, - new com.google.protobuf.Descriptors.FileDescriptor[] { - }, assigner); - } - - // @@protoc_insertion_point(outer_class_scope) -} diff --git a/libsignal/src/main/java/org/session/libsignal/libsignal/state/impl/InMemoryIdentityKeyStore.java b/libsignal/src/main/java/org/session/libsignal/libsignal/state/impl/InMemoryIdentityKeyStore.java deleted file mode 100644 index 7e48eb121f..0000000000 --- a/libsignal/src/main/java/org/session/libsignal/libsignal/state/impl/InMemoryIdentityKeyStore.java +++ /dev/null @@ -1,60 +0,0 @@ -/** - * Copyright (C) 2014-2016 Open Whisper Systems - * - * Licensed according to the LICENSE file in this repository. - */ -package org.session.libsignal.libsignal.state.impl; - -import org.session.libsignal.libsignal.IdentityKey; -import org.session.libsignal.libsignal.IdentityKeyPair; -import org.session.libsignal.libsignal.SignalProtocolAddress; -import org.session.libsignal.libsignal.state.IdentityKeyStore; - -import java.util.HashMap; -import java.util.Map; - -public class InMemoryIdentityKeyStore implements IdentityKeyStore { - - private final Map trustedKeys = new HashMap(); - - private final IdentityKeyPair identityKeyPair; - private final int localRegistrationId; - - public InMemoryIdentityKeyStore(IdentityKeyPair identityKeyPair, int localRegistrationId) { - this.identityKeyPair = identityKeyPair; - this.localRegistrationId = localRegistrationId; - } - - @Override - public IdentityKeyPair getIdentityKeyPair() { - return identityKeyPair; - } - - @Override - public int getLocalRegistrationId() { - return localRegistrationId; - } - - @Override - public boolean saveIdentity(SignalProtocolAddress address, IdentityKey identityKey) { - IdentityKey existing = trustedKeys.get(address); - - if (!identityKey.equals(existing)) { - trustedKeys.put(address, identityKey); - return true; - } else { - return false; - } - } - - @Override - public boolean isTrustedIdentity(SignalProtocolAddress address, IdentityKey identityKey, Direction direction) { - IdentityKey trusted = trustedKeys.get(address); - return (trusted == null || trusted.equals(identityKey)); - } - - @Override - public IdentityKey getIdentity(SignalProtocolAddress address) { - return trustedKeys.get(address); - } -} diff --git a/libsignal/src/main/java/org/session/libsignal/libsignal/state/impl/InMemoryPreKeyStore.java b/libsignal/src/main/java/org/session/libsignal/libsignal/state/impl/InMemoryPreKeyStore.java deleted file mode 100644 index ed6b66c3c4..0000000000 --- a/libsignal/src/main/java/org/session/libsignal/libsignal/state/impl/InMemoryPreKeyStore.java +++ /dev/null @@ -1,47 +0,0 @@ -/** - * Copyright (C) 2014-2016 Open Whisper Systems - * - * Licensed according to the LICENSE file in this repository. - */ -package org.session.libsignal.libsignal.state.impl; - -import org.session.libsignal.libsignal.InvalidKeyIdException; -import org.session.libsignal.libsignal.state.PreKeyRecord; -import org.session.libsignal.libsignal.state.PreKeyStore; - -import java.io.IOException; -import java.util.HashMap; -import java.util.Map; - -public class InMemoryPreKeyStore implements PreKeyStore { - - private final Map store = new HashMap(); - - @Override - public PreKeyRecord loadPreKey(int preKeyId) throws InvalidKeyIdException { - try { - if (!store.containsKey(preKeyId)) { - throw new InvalidKeyIdException("No such prekeyrecord!"); - } - - return new PreKeyRecord(store.get(preKeyId)); - } catch (IOException e) { - throw new AssertionError(e); - } - } - - @Override - public void storePreKey(int preKeyId, PreKeyRecord record) { - store.put(preKeyId, record.serialize()); - } - - @Override - public boolean containsPreKey(int preKeyId) { - return store.containsKey(preKeyId); - } - - @Override - public void removePreKey(int preKeyId) { - store.remove(preKeyId); - } -} diff --git a/libsignal/src/main/java/org/session/libsignal/libsignal/state/impl/InMemorySessionStore.java b/libsignal/src/main/java/org/session/libsignal/libsignal/state/impl/InMemorySessionStore.java deleted file mode 100644 index 9bc734e5ee..0000000000 --- a/libsignal/src/main/java/org/session/libsignal/libsignal/state/impl/InMemorySessionStore.java +++ /dev/null @@ -1,75 +0,0 @@ -/** - * Copyright (C) 2014-2016 Open Whisper Systems - * - * Licensed according to the LICENSE file in this repository. - */ -package org.session.libsignal.libsignal.state.impl; - -import org.session.libsignal.libsignal.SignalProtocolAddress; -import org.session.libsignal.libsignal.state.SessionRecord; -import org.session.libsignal.libsignal.state.SessionStore; - -import java.io.IOException; -import java.util.HashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; - -public class InMemorySessionStore implements SessionStore { - - private Map sessions = new HashMap(); - - public InMemorySessionStore() {} - - @Override - public synchronized SessionRecord loadSession(SignalProtocolAddress remoteAddress) { - try { - if (containsSession(remoteAddress)) { - return new SessionRecord(sessions.get(remoteAddress)); - } else { - return new SessionRecord(); - } - } catch (IOException e) { - throw new AssertionError(e); - } - } - - @Override - public synchronized List getSubDeviceSessions(String name) { - List deviceIds = new LinkedList(); - - for (SignalProtocolAddress key : sessions.keySet()) { - if (key.getName().equals(name) && - key.getDeviceId() != 1) - { - deviceIds.add(key.getDeviceId()); - } - } - - return deviceIds; - } - - @Override - public synchronized void storeSession(SignalProtocolAddress address, SessionRecord record) { - sessions.put(address, record.serialize()); - } - - @Override - public synchronized boolean containsSession(SignalProtocolAddress address) { - return sessions.containsKey(address); - } - - @Override - public synchronized void deleteSession(SignalProtocolAddress address) { - sessions.remove(address); - } - - @Override - public synchronized void deleteAllSessions(String name) { - for (SignalProtocolAddress key : sessions.keySet()) { - if (key.getName().equals(name)) { - sessions.remove(key); - } - } - } -} diff --git a/libsignal/src/main/java/org/session/libsignal/libsignal/state/impl/InMemorySignalProtocolStore.java b/libsignal/src/main/java/org/session/libsignal/libsignal/state/impl/InMemorySignalProtocolStore.java deleted file mode 100644 index eb0129e0b1..0000000000 --- a/libsignal/src/main/java/org/session/libsignal/libsignal/state/impl/InMemorySignalProtocolStore.java +++ /dev/null @@ -1,130 +0,0 @@ -/** - * Copyright (C) 2014-2016 Open Whisper Systems - * - * Licensed according to the LICENSE file in this repository. - */ -package org.session.libsignal.libsignal.state.impl; - -import org.session.libsignal.libsignal.SignalProtocolAddress; -import org.session.libsignal.libsignal.IdentityKey; -import org.session.libsignal.libsignal.IdentityKeyPair; -import org.session.libsignal.libsignal.InvalidKeyIdException; -import org.session.libsignal.libsignal.state.SignalProtocolStore; -import org.session.libsignal.libsignal.state.PreKeyRecord; -import org.session.libsignal.libsignal.state.SessionRecord; -import org.session.libsignal.libsignal.state.SignedPreKeyRecord; - -import java.util.List; - -public class InMemorySignalProtocolStore implements SignalProtocolStore { - - private final InMemoryPreKeyStore preKeyStore = new InMemoryPreKeyStore(); - private final InMemorySessionStore sessionStore = new InMemorySessionStore(); - private final InMemorySignedPreKeyStore signedPreKeyStore = new InMemorySignedPreKeyStore(); - - private final InMemoryIdentityKeyStore identityKeyStore; - - public InMemorySignalProtocolStore(IdentityKeyPair identityKeyPair, int registrationId) { - this.identityKeyStore = new InMemoryIdentityKeyStore(identityKeyPair, registrationId); - } - - @Override - public IdentityKeyPair getIdentityKeyPair() { - return identityKeyStore.getIdentityKeyPair(); - } - - @Override - public int getLocalRegistrationId() { - return identityKeyStore.getLocalRegistrationId(); - } - - @Override - public boolean saveIdentity(SignalProtocolAddress address, IdentityKey identityKey) { - return identityKeyStore.saveIdentity(address, identityKey); - } - - @Override - public boolean isTrustedIdentity(SignalProtocolAddress address, IdentityKey identityKey, Direction direction) { - return identityKeyStore.isTrustedIdentity(address, identityKey, direction); - } - - @Override - public IdentityKey getIdentity(SignalProtocolAddress address) { - return identityKeyStore.getIdentity(address); - } - - @Override - public PreKeyRecord loadPreKey(int preKeyId) throws InvalidKeyIdException { - return preKeyStore.loadPreKey(preKeyId); - } - - @Override - public void storePreKey(int preKeyId, PreKeyRecord record) { - preKeyStore.storePreKey(preKeyId, record); - } - - @Override - public boolean containsPreKey(int preKeyId) { - return preKeyStore.containsPreKey(preKeyId); - } - - @Override - public void removePreKey(int preKeyId) { - preKeyStore.removePreKey(preKeyId); - } - - @Override - public SessionRecord loadSession(SignalProtocolAddress address) { - return sessionStore.loadSession(address); - } - - @Override - public List getSubDeviceSessions(String name) { - return sessionStore.getSubDeviceSessions(name); - } - - @Override - public void storeSession(SignalProtocolAddress address, SessionRecord record) { - sessionStore.storeSession(address, record); - } - - @Override - public boolean containsSession(SignalProtocolAddress address) { - return sessionStore.containsSession(address); - } - - @Override - public void deleteSession(SignalProtocolAddress address) { - sessionStore.deleteSession(address); - } - - @Override - public void deleteAllSessions(String name) { - sessionStore.deleteAllSessions(name); - } - - @Override - public SignedPreKeyRecord loadSignedPreKey(int signedPreKeyId) throws InvalidKeyIdException { - return signedPreKeyStore.loadSignedPreKey(signedPreKeyId); - } - - @Override - public List loadSignedPreKeys() { - return signedPreKeyStore.loadSignedPreKeys(); - } - - @Override - public void storeSignedPreKey(int signedPreKeyId, SignedPreKeyRecord record) { - signedPreKeyStore.storeSignedPreKey(signedPreKeyId, record); - } - - @Override - public boolean containsSignedPreKey(int signedPreKeyId) { - return signedPreKeyStore.containsSignedPreKey(signedPreKeyId); - } - - @Override - public void removeSignedPreKey(int signedPreKeyId) { - signedPreKeyStore.removeSignedPreKey(signedPreKeyId); - } -} diff --git a/libsignal/src/main/java/org/session/libsignal/libsignal/state/impl/InMemorySignedPreKeyStore.java b/libsignal/src/main/java/org/session/libsignal/libsignal/state/impl/InMemorySignedPreKeyStore.java deleted file mode 100644 index 80b15b979f..0000000000 --- a/libsignal/src/main/java/org/session/libsignal/libsignal/state/impl/InMemorySignedPreKeyStore.java +++ /dev/null @@ -1,64 +0,0 @@ -/** - * Copyright (C) 2014-2016 Open Whisper Systems - * - * Licensed according to the LICENSE file in this repository. - */ -package org.session.libsignal.libsignal.state.impl; - -import org.session.libsignal.libsignal.InvalidKeyIdException; -import org.session.libsignal.libsignal.state.SignedPreKeyRecord; -import org.session.libsignal.libsignal.state.SignedPreKeyStore; - -import java.io.IOException; -import java.util.HashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; - -public class InMemorySignedPreKeyStore implements SignedPreKeyStore { - - private final Map store = new HashMap(); - - @Override - public SignedPreKeyRecord loadSignedPreKey(int signedPreKeyId) throws InvalidKeyIdException { - try { - if (!store.containsKey(signedPreKeyId)) { - throw new InvalidKeyIdException("No such signedprekeyrecord! " + signedPreKeyId); - } - - return new SignedPreKeyRecord(store.get(signedPreKeyId)); - } catch (IOException e) { - throw new AssertionError(e); - } - } - - @Override - public List loadSignedPreKeys() { - try { - List results = new LinkedList(); - - for (byte[] serialized : store.values()) { - results.add(new SignedPreKeyRecord(serialized)); - } - - return results; - } catch (IOException e) { - throw new AssertionError(e); - } - } - - @Override - public void storeSignedPreKey(int signedPreKeyId, SignedPreKeyRecord record) { - store.put(signedPreKeyId, record.serialize()); - } - - @Override - public boolean containsSignedPreKey(int signedPreKeyId) { - return store.containsKey(signedPreKeyId); - } - - @Override - public void removeSignedPreKey(int signedPreKeyId) { - store.remove(signedPreKeyId); - } -} diff --git a/libsignal/src/main/java/org/session/libsignal/libsignal/util/KeyHelper.java b/libsignal/src/main/java/org/session/libsignal/libsignal/util/KeyHelper.java index 5d7ced75f5..2dccb1a0d6 100644 --- a/libsignal/src/main/java/org/session/libsignal/libsignal/util/KeyHelper.java +++ b/libsignal/src/main/java/org/session/libsignal/libsignal/util/KeyHelper.java @@ -10,13 +10,9 @@ import org.session.libsignal.libsignal.IdentityKeyPair; import org.session.libsignal.libsignal.InvalidKeyException; import org.session.libsignal.libsignal.ecc.Curve; import org.session.libsignal.libsignal.ecc.ECKeyPair; -import org.session.libsignal.libsignal.state.PreKeyRecord; -import org.session.libsignal.libsignal.state.SignedPreKeyRecord; import java.security.NoSuchAlgorithmException; import java.security.SecureRandom; -import java.util.LinkedList; -import java.util.List; /** * Helper class for generating keys of different types. @@ -26,19 +22,6 @@ import java.util.List; public class KeyHelper { private KeyHelper() {} - - /** - * Generate an identity key pair. Clients should only do this once, - * at install time. - * - * @return the generated IdentityKeyPair. - */ - public static IdentityKeyPair generateIdentityKeyPair() { - ECKeyPair keyPair = Curve.generateKeyPair(); - IdentityKey publicKey = new IdentityKey(keyPair.getPublicKey()); - return new IdentityKeyPair(publicKey, keyPair.getPrivateKey()); - } - /** * Generate a registration ID. Clients should only do this once, * at install time. @@ -59,79 +42,4 @@ public class KeyHelper { throw new AssertionError(e); } } - - public static int getRandomSequence(int max) { - try { - return SecureRandom.getInstance("SHA1PRNG").nextInt(max); - } catch (NoSuchAlgorithmException e) { - throw new AssertionError(e); - } - } - - /** - * Generate a list of PreKeys. Clients should do this at install time, and - * subsequently any time the list of PreKeys stored on the server runs low. - *

- * PreKey IDs are shorts, so they will eventually be repeated. Clients should - * store PreKeys in a circular buffer, so that they are repeated as infrequently - * as possible. - * - * @param start The starting PreKey ID, inclusive. - * @param count The number of PreKeys to generate. - * @return the list of generated PreKeyRecords. - */ - public static List generatePreKeys(int start, int count) { - List results = new LinkedList(); - - start--; - - for (int i=0;i CIPHERTEXT_VERSION) { - throw new InvalidMetadataVersionException("Unknown version: " + this.version); - } - - SignalProtos.UnidentifiedSenderMessage unidentifiedSenderMessage = SignalProtos.UnidentifiedSenderMessage.parseFrom(ByteString.copyFrom(serialized, 1, serialized.length - 1)); - - if (!unidentifiedSenderMessage.hasEphemeralPublic() || - !unidentifiedSenderMessage.hasEncryptedStatic() || - !unidentifiedSenderMessage.hasEncryptedMessage()) - { - throw new InvalidMetadataMessageException("Missing fields"); - } - - this.ephemeral = Curve.decodePoint(unidentifiedSenderMessage.getEphemeralPublic().toByteArray(), 0); - this.encryptedStatic = unidentifiedSenderMessage.getEncryptedStatic().toByteArray(); - this.encryptedMessage = unidentifiedSenderMessage.getEncryptedMessage().toByteArray(); - this.serialized = serialized; - } catch (InvalidProtocolBufferException e) { - throw new InvalidMetadataMessageException(e); - } catch (InvalidKeyException e) { - throw new InvalidMetadataMessageException(e); - } - } - - public UnidentifiedSenderMessage(ECPublicKey ephemeral, byte[] encryptedStatic, byte[] encryptedMessage) { - this.version = CIPHERTEXT_VERSION; - this.ephemeral = ephemeral; - this.encryptedStatic = encryptedStatic; - this.encryptedMessage = encryptedMessage; - - byte[] versionBytes = {ByteUtil.intsToByteHighAndLow(CIPHERTEXT_VERSION, CIPHERTEXT_VERSION)}; - byte[] messageBytes = SignalProtos.UnidentifiedSenderMessage.newBuilder() - .setEncryptedMessage(ByteString.copyFrom(encryptedMessage)) - .setEncryptedStatic(ByteString.copyFrom(encryptedStatic)) - .setEphemeralPublic(ByteString.copyFrom(ephemeral.serialize())) - .build() - .toByteArray(); - - this.serialized = ByteUtil.combine(versionBytes, messageBytes); - } - - public ECPublicKey getEphemeral() { - return ephemeral; - } - - public byte[] getEncryptedStatic() { - return encryptedStatic; - } - - public byte[] getEncryptedMessage() { - return encryptedMessage; - } - - public byte[] getSerialized() { - return serialized; - } -} diff --git a/libsignal/src/main/java/org/session/libsignal/metadata/protocol/UnidentifiedSenderMessageContent.java b/libsignal/src/main/java/org/session/libsignal/metadata/protocol/UnidentifiedSenderMessageContent.java deleted file mode 100644 index 650a05fc48..0000000000 --- a/libsignal/src/main/java/org/session/libsignal/metadata/protocol/UnidentifiedSenderMessageContent.java +++ /dev/null @@ -1,85 +0,0 @@ -package org.session.libsignal.metadata.protocol; - - -import com.google.protobuf.ByteString; -import com.google.protobuf.InvalidProtocolBufferException; - -import org.session.libsignal.metadata.InvalidMetadataMessageException; -import org.session.libsignal.metadata.SignalProtos; -import org.session.libsignal.metadata.certificate.InvalidCertificateException; -import org.session.libsignal.metadata.certificate.SenderCertificate; -import org.session.libsignal.libsignal.protocol.CiphertextMessage; - -public class UnidentifiedSenderMessageContent { - - private final int type; - private final SenderCertificate senderCertificate; - private final byte[] content; - private final byte[] serialized; - - public UnidentifiedSenderMessageContent(byte[] serialized) throws InvalidMetadataMessageException, InvalidCertificateException { - try { - SignalProtos.UnidentifiedSenderMessage.Message message = SignalProtos.UnidentifiedSenderMessage.Message.parseFrom(serialized); - - if (!message.hasType() || !message.hasSenderCertificate() || !message.hasContent()) { - throw new InvalidMetadataMessageException("Missing fields"); - } - - switch (message.getType()) { - case MESSAGE: this.type = CiphertextMessage.WHISPER_TYPE; break; - case PREKEY_MESSAGE: this.type = CiphertextMessage.PREKEY_TYPE; break; - case FALLBACK_MESSAGE: this.type = CiphertextMessage.FALLBACK_MESSAGE_TYPE; break; - default: throw new InvalidMetadataMessageException("Unknown type: " + message.getType().getNumber()); - } - - this.senderCertificate = new SenderCertificate(message.getSenderCertificate().toByteArray()); - this.content = message.getContent().toByteArray(); - this.serialized = serialized; - } catch (InvalidProtocolBufferException e) { - throw new InvalidMetadataMessageException(e); - } - } - - public UnidentifiedSenderMessageContent(int type, SenderCertificate senderCertificate, byte[] content) { - try { - this.serialized = SignalProtos.UnidentifiedSenderMessage.Message.newBuilder() - .setType(SignalProtos.UnidentifiedSenderMessage.Message.Type.valueOf(getProtoType(type))) - .setSenderCertificate(SignalProtos.SenderCertificate.parseFrom(senderCertificate.getSerialized())) - .setContent(ByteString.copyFrom(content)) - .build() - .toByteArray(); - - this.type = type; - this.senderCertificate = senderCertificate; - this.content = content; - } catch (InvalidProtocolBufferException e) { - throw new AssertionError(e); - } - } - - public int getType() { - return type; - } - - public SenderCertificate getSenderCertificate() { - return senderCertificate; - } - - public byte[] getContent() { - return content; - } - - public byte[] getSerialized() { - return serialized; - } - - private int getProtoType(int type) { - switch (type) { - case CiphertextMessage.WHISPER_TYPE: return SignalProtos.UnidentifiedSenderMessage.Message.Type.MESSAGE_VALUE; - case CiphertextMessage.PREKEY_TYPE: return SignalProtos.UnidentifiedSenderMessage.Message.Type.PREKEY_MESSAGE_VALUE; - case CiphertextMessage.FALLBACK_MESSAGE_TYPE: return SignalProtos.UnidentifiedSenderMessage.Message.Type.FALLBACK_MESSAGE_VALUE; - default: throw new AssertionError(type); - } - } - -} diff --git a/libsignal/src/main/java/org/session/libsignal/service/api/SignalServiceAccountManager.java b/libsignal/src/main/java/org/session/libsignal/service/api/SignalServiceAccountManager.java deleted file mode 100644 index b581c92af9..0000000000 --- a/libsignal/src/main/java/org/session/libsignal/service/api/SignalServiceAccountManager.java +++ /dev/null @@ -1,442 +0,0 @@ -/** - * Copyright (C) 2014-2016 Open Whisper Systems - * - * Licensed according to the LICENSE file in this repository. - */ - -package org.session.libsignal.service.api; - - -import com.google.protobuf.ByteString; - -import org.whispersystems.curve25519.Curve25519; -import org.whispersystems.curve25519.Curve25519KeyPair; -import org.session.libsignal.libsignal.IdentityKey; -import org.session.libsignal.libsignal.IdentityKeyPair; -import org.session.libsignal.libsignal.InvalidKeyException; -import org.session.libsignal.libsignal.ecc.ECPublicKey; -import org.session.libsignal.utilities.logging.Log; -import org.session.libsignal.libsignal.state.PreKeyRecord; -import org.session.libsignal.libsignal.state.SignedPreKeyRecord; -import org.session.libsignal.libsignal.util.Pair; -import org.session.libsignal.libsignal.util.guava.Optional; -import org.session.libsignal.service.api.crypto.InvalidCiphertextException; -import org.session.libsignal.service.api.crypto.ProfileCipher; -import org.session.libsignal.service.api.crypto.ProfileCipherOutputStream; -import org.session.libsignal.service.api.messages.calls.TurnServerInfo; -import org.session.libsignal.service.api.push.ContactTokenDetails; -import org.session.libsignal.service.api.push.SignedPreKeyEntity; -import org.session.libsignal.service.api.util.CredentialsProvider; -import org.session.libsignal.service.api.util.StreamDetails; -import org.session.libsignal.service.internal.configuration.SignalServiceConfiguration; -import org.session.libsignal.service.internal.contacts.crypto.ContactDiscoveryCipher; -import org.session.libsignal.service.internal.contacts.crypto.Quote; -import org.session.libsignal.service.internal.contacts.crypto.RemoteAttestation; -import org.session.libsignal.service.internal.contacts.crypto.RemoteAttestationKeys; -import org.session.libsignal.service.internal.contacts.crypto.UnauthenticatedQuoteException; -import org.session.libsignal.service.internal.contacts.crypto.UnauthenticatedResponseException; -import org.session.libsignal.service.internal.contacts.entities.DiscoveryRequest; -import org.session.libsignal.service.internal.contacts.entities.DiscoveryResponse; -import org.session.libsignal.service.internal.contacts.entities.RemoteAttestationRequest; -import org.session.libsignal.service.internal.contacts.entities.RemoteAttestationResponse; -import org.session.libsignal.service.internal.crypto.ProvisioningCipher; -import org.session.libsignal.service.internal.push.ProfileAvatarData; -import org.session.libsignal.service.internal.push.PushServiceSocket; -import org.session.libsignal.service.internal.push.http.ProfileCipherOutputStreamFactory; -import org.session.libsignal.utilities.Base64; -import org.session.libsignal.service.internal.util.StaticCredentialsProvider; -import org.session.libsignal.service.internal.util.Util; - -import java.io.IOException; -import java.security.KeyStore; -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; -import java.security.SignatureException; -import java.util.Collection; -import java.util.HashMap; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; -import java.util.Locale; -import java.util.Map; -import java.util.Set; - -import static org.session.libsignal.service.internal.push.ProvisioningProtos.ProvisionMessage; - -/** - * The main interface for creating, registering, and - * managing a Signal Service account. - * - * @author Moxie Marlinspike - */ -public class SignalServiceAccountManager { - - private static final String TAG = SignalServiceAccountManager.class.getSimpleName(); - - private final PushServiceSocket pushServiceSocket; - private final String user; - private final String userAgent; - - /** - * Construct a SignalServiceAccountManager. - * - * @param configuration The URL for the Signal Service. - * @param user A Signal Service phone number. - * @param password A Signal Service password. - * @param userAgent A string which identifies the client software. - */ - public SignalServiceAccountManager(SignalServiceConfiguration configuration, - String user, String password, - String userAgent) - { - this(configuration, new StaticCredentialsProvider(user, password, null), userAgent); - } - - public SignalServiceAccountManager(SignalServiceConfiguration configuration, - CredentialsProvider credentialsProvider, - String userAgent) - { - this.pushServiceSocket = new PushServiceSocket(configuration, credentialsProvider, userAgent); - this.user = credentialsProvider.getUser(); - this.userAgent = userAgent; - } - - public byte[] getSenderCertificate() throws IOException { - return this.pushServiceSocket.getSenderCertificate(); - } - - public void setPin(Optional pin) throws IOException { - if (pin.isPresent()) { - this.pushServiceSocket.setPin(pin.get()); - } else { - this.pushServiceSocket.removePin(); - } - } - - /** - * Register/Unregister a Google Cloud Messaging registration ID. - * - * @param gcmRegistrationId The GCM id to register. A call with an absent value will unregister. - * @throws IOException - */ - public void setGcmId(Optional gcmRegistrationId) throws IOException { - if (gcmRegistrationId.isPresent()) { - this.pushServiceSocket.registerGcmId(gcmRegistrationId.get()); - } else { - this.pushServiceSocket.unregisterGcmId(); - } - } - - /** - * Request an SMS verification code. On success, the server will send - * an SMS verification code to this Signal user. - * - * @throws IOException - */ - public void requestSmsVerificationCode(boolean androidSmsRetrieverSupported, Optional captchaToken) throws IOException { - this.pushServiceSocket.requestSmsVerificationCode(androidSmsRetrieverSupported, captchaToken); - } - - /** - * Request a Voice verification code. On success, the server will - * make a voice call to this Signal user. - * - * @throws IOException - */ - public void requestVoiceVerificationCode(Locale locale, Optional captchaToken) throws IOException { - this.pushServiceSocket.requestVoiceVerificationCode(locale, captchaToken); - } - - /** - * Verify a Signal Service account with a received SMS or voice verification code. - * - * @param verificationCode The verification code received via SMS or Voice - * (see {@link #requestSmsVerificationCode} and - * {@link #requestVoiceVerificationCode}). - * @param signalingKey 52 random bytes. A 32 byte AES key and a 20 byte Hmac256 key, - * concatenated. - * @param signalProtocolRegistrationId A random 14-bit number that identifies this Signal install. - * This value should remain consistent across registrations for the - * same install, but probabilistically differ across registrations - * for separate installs. - * - * @throws IOException - */ - public void verifyAccountWithCode(String verificationCode, String signalingKey, int signalProtocolRegistrationId, boolean fetchesMessages, String pin, - byte[] unidentifiedAccessKey, boolean unrestrictedUnidentifiedAccess) - throws IOException - { - this.pushServiceSocket.verifyAccountCode(verificationCode, signalingKey, - signalProtocolRegistrationId, - fetchesMessages, pin, - unidentifiedAccessKey, - unrestrictedUnidentifiedAccess); - } - - /** - * Refresh account attributes with server. - * - * @param signalingKey 52 random bytes. A 32 byte AES key and a 20 byte Hmac256 key, concatenated. - * @param signalProtocolRegistrationId A random 14-bit number that identifies this Signal install. - * This value should remain consistent across registrations for the same - * install, but probabilistically differ across registrations for - * separate installs. - * - * @throws IOException - */ - public void setAccountAttributes(String signalingKey, int signalProtocolRegistrationId, boolean fetchesMessages, String pin, - byte[] unidentifiedAccessKey, boolean unrestrictedUnidentifiedAccess) - throws IOException - { - this.pushServiceSocket.setAccountAttributes(signalingKey, signalProtocolRegistrationId, fetchesMessages, pin, - unidentifiedAccessKey, unrestrictedUnidentifiedAccess); - } - - /** - * Register an identity key, signed prekey, and list of one time prekeys - * with the server. - * - * @param identityKey The client's long-term identity keypair. - * @param signedPreKey The client's signed prekey. - * @param oneTimePreKeys The client's list of one-time prekeys. - * - * @throws IOException - */ - public void setPreKeys(IdentityKey identityKey, SignedPreKeyRecord signedPreKey, List oneTimePreKeys) - throws IOException - { - this.pushServiceSocket.registerPreKeys(identityKey, signedPreKey, oneTimePreKeys); - } - - /** - * @return The server's count of currently available (eg. unused) prekeys for this user. - * @throws IOException - */ - public int getPreKeysCount() throws IOException { - return this.pushServiceSocket.getAvailablePreKeys(); - } - - /** - * Set the client's signed prekey. - * - * @param signedPreKey The client's new signed prekey. - * @throws IOException - */ - public void setSignedPreKey(SignedPreKeyRecord signedPreKey) throws IOException { - this.pushServiceSocket.setCurrentSignedPreKey(signedPreKey); - } - - /** - * @return The server's view of the client's current signed prekey. - * @throws IOException - */ - public SignedPreKeyEntity getSignedPreKey() throws IOException { - return this.pushServiceSocket.getCurrentSignedPreKey(); - } - - /** - * Checks whether a contact is currently registered with the server. - * - * @param e164number The contact to check. - * @return An optional ContactTokenDetails, present if registered, absent if not. - * @throws IOException - */ - public Optional getContact(String e164number) throws IOException { - String contactToken = createDirectoryServerToken(e164number, true); - ContactTokenDetails contactTokenDetails = this.pushServiceSocket.getContactTokenDetails(contactToken); - - if (contactTokenDetails != null) { - contactTokenDetails.setNumber(e164number); - } - - return Optional.fromNullable(contactTokenDetails); - } - - /** - * Checks which contacts in a set are registered with the server. - * - * @param e164numbers The contacts to check. - * @return A list of ContactTokenDetails for the registered users. - * @throws IOException - */ - public List getContacts(Set e164numbers) - throws IOException - { - Map contactTokensMap = createDirectoryServerTokenMap(e164numbers); - List activeTokens = this.pushServiceSocket.retrieveDirectory(contactTokensMap.keySet()); - - for (ContactTokenDetails activeToken : activeTokens) { - activeToken.setNumber(contactTokensMap.get(activeToken.getToken())); - } - - return activeTokens; - } - - public List getRegisteredUsers(KeyStore iasKeyStore, Set e164numbers, String mrenclave) - throws IOException, Quote.InvalidQuoteFormatException, UnauthenticatedQuoteException, SignatureException, UnauthenticatedResponseException - { - try { - String authorization = this.pushServiceSocket.getContactDiscoveryAuthorization(); - Curve25519 curve = Curve25519.getInstance(Curve25519.BEST); - Curve25519KeyPair keyPair = curve.generateKeyPair(); - - ContactDiscoveryCipher cipher = new ContactDiscoveryCipher(); - RemoteAttestationRequest attestationRequest = new RemoteAttestationRequest(keyPair.getPublicKey()); - Pair> attestationResponse = this.pushServiceSocket.getContactDiscoveryRemoteAttestation(authorization, attestationRequest, mrenclave); - - RemoteAttestationKeys keys = new RemoteAttestationKeys(keyPair, attestationResponse.first().getServerEphemeralPublic(), attestationResponse.first().getServerStaticPublic()); - Quote quote = new Quote(attestationResponse.first().getQuote()); - byte[] requestId = cipher.getRequestId(keys, attestationResponse.first()); - - cipher.verifyServerQuote(quote, attestationResponse.first().getServerStaticPublic(), mrenclave); - cipher.verifyIasSignature(iasKeyStore, attestationResponse.first().getCertificates(), attestationResponse.first().getSignatureBody(), attestationResponse.first().getSignature(), quote); - - RemoteAttestation remoteAttestation = new RemoteAttestation(requestId, keys); - List addressBook = new LinkedList(); - - for (String e164number : e164numbers) { - addressBook.add(e164number.substring(1)); - } - - DiscoveryRequest request = cipher.createDiscoveryRequest(addressBook, remoteAttestation); - DiscoveryResponse response = this.pushServiceSocket.getContactDiscoveryRegisteredUsers(authorization, request, attestationResponse.second(), mrenclave); - byte[] data = cipher.getDiscoveryResponseData(response, remoteAttestation); - - Iterator addressBookIterator = addressBook.iterator(); - List results = new LinkedList(); - - for (byte aData : data) { - String candidate = addressBookIterator.next(); - - if (aData != 0) results.add('+' + candidate); - } - - return results; - } catch (InvalidCiphertextException e) { - throw new UnauthenticatedResponseException(e); - } - } - - public void reportContactDiscoveryServiceMatch() { - try { - this.pushServiceSocket.reportContactDiscoveryServiceMatch(); - } catch (IOException e) { - Log.w(TAG, "Request to indicate a contact discovery result match failed. Ignoring.", e); - } - } - - public void reportContactDiscoveryServiceMismatch() { - try { - this.pushServiceSocket.reportContactDiscoveryServiceMismatch(); - } catch (IOException e) { - Log.w(TAG, "Request to indicate a contact discovery result mismatch failed. Ignoring.", e); - } - } - - public void reportContactDiscoveryServiceAttestationError(String reason) { - try { - this.pushServiceSocket.reportContactDiscoveryServiceAttestationError(reason); - } catch (IOException e) { - Log.w(TAG, "Request to indicate a contact discovery attestation error failed. Ignoring.", e); - } - } - - public void reportContactDiscoveryServiceUnexpectedError(String reason) { - try { - this.pushServiceSocket.reportContactDiscoveryServiceUnexpectedError(reason); - } catch (IOException e) { - Log.w(TAG, "Request to indicate a contact discovery unexpected error failed. Ignoring.", e); - } - } - - public String getNewDeviceVerificationCode() throws IOException { - return this.pushServiceSocket.getNewDeviceVerificationCode(); - } - - public void addDevice(String deviceIdentifier, - ECPublicKey deviceKey, - IdentityKeyPair identityKeyPair, - Optional profileKey, - String code) - throws InvalidKeyException, IOException - { - ProvisioningCipher cipher = new ProvisioningCipher(deviceKey); - ProvisionMessage.Builder message = ProvisionMessage.newBuilder() - .setIdentityKeyPublic(ByteString.copyFrom(identityKeyPair.getPublicKey().serialize())) - .setIdentityKeyPrivate(ByteString.copyFrom(identityKeyPair.getPrivateKey().serialize())) - .setNumber(user) - .setProvisioningCode(code); - - if (profileKey.isPresent()) { - message.setProfileKey(ByteString.copyFrom(profileKey.get())); - } - - byte[] ciphertext = cipher.encrypt(message.build()); - this.pushServiceSocket.sendProvisioningMessage(deviceIdentifier, ciphertext); - } - - public void removeDevice(long deviceId) throws IOException { - this.pushServiceSocket.removeDevice(deviceId); - } - - public TurnServerInfo getTurnServerInfo() throws IOException { - return this.pushServiceSocket.getTurnServerInfo(); - } - - public void setProfileName(byte[] key, String name) - throws IOException - { - if (name == null) name = ""; - - String ciphertextName = Base64.encodeBytesWithoutPadding(new ProfileCipher(key).encryptName(name.getBytes("UTF-8"), ProfileCipher.NAME_PADDED_LENGTH)); - - this.pushServiceSocket.setProfileName(ciphertextName); - } - - public void setProfileAvatar(byte[] key, StreamDetails avatar) - throws IOException - { - ProfileAvatarData profileAvatarData = null; - - if (avatar != null) { - profileAvatarData = new ProfileAvatarData(avatar.getStream(), - ProfileCipherOutputStream.getCiphertextLength(avatar.getLength()), - avatar.getContentType(), - new ProfileCipherOutputStreamFactory(key)); - } - - this.pushServiceSocket.setProfileAvatar(profileAvatarData); - } - - public void setSoTimeoutMillis(long soTimeoutMillis) { - this.pushServiceSocket.setSoTimeoutMillis(soTimeoutMillis); - } - - public void cancelInFlightRequests() { - this.pushServiceSocket.cancelInFlightRequests(); - } - - private String createDirectoryServerToken(String e164number, boolean urlSafe) { - try { - MessageDigest digest = MessageDigest.getInstance("SHA1"); - byte[] token = Util.trim(digest.digest(e164number.getBytes()), 10); - String encoded = Base64.encodeBytesWithoutPadding(token); - - if (urlSafe) return encoded.replace('+', '-').replace('/', '_'); - else return encoded; - } catch (NoSuchAlgorithmException e) { - throw new AssertionError(e); - } - } - - private Map createDirectoryServerTokenMap(Collection e164numbers) { - Map tokenMap = new HashMap(e164numbers.size()); - - for (String number : e164numbers) { - tokenMap.put(createDirectoryServerToken(number, false), number); - } - - return tokenMap; - } - -} diff --git a/libsignal/src/main/java/org/session/libsignal/service/api/SignalServiceMessageReceiver.java b/libsignal/src/main/java/org/session/libsignal/service/api/SignalServiceMessageReceiver.java index 885d2212ca..e41e66fa94 100644 --- a/libsignal/src/main/java/org/session/libsignal/service/api/SignalServiceMessageReceiver.java +++ b/libsignal/src/main/java/org/session/libsignal/service/api/SignalServiceMessageReceiver.java @@ -108,12 +108,6 @@ public class SignalServiceMessageReceiver { return retrieveAttachment(pointer, destination, maxSizeBytes, null); } - public SignalServiceProfile retrieveProfile(SignalServiceAddress address, Optional unidentifiedAccess) - throws IOException - { - return socket.retrieveProfile(address, unidentifiedAccess); - } - public InputStream retrieveProfileAvatar(String path, File destination, byte[] profileKey, int maxSizeBytes) throws IOException { @@ -209,10 +203,6 @@ public class SignalServiceMessageReceiver { return new SignalServiceMessagePipe(webSocket, Optional.of(credentialsProvider)); } - public List retrieveMessages() throws IOException { - return retrieveMessages(new NullMessageReceivedCallback()); - } - public List retrieveMessages(MessageReceivedCallback callback) throws IOException { diff --git a/libsignal/src/main/java/org/session/libsignal/service/api/SignalServiceMessageSender.java b/libsignal/src/main/java/org/session/libsignal/service/api/SignalServiceMessageSender.java index aa0c47adfc..01cf302c87 100644 --- a/libsignal/src/main/java/org/session/libsignal/service/api/SignalServiceMessageSender.java +++ b/libsignal/src/main/java/org/session/libsignal/service/api/SignalServiceMessageSender.java @@ -9,8 +9,8 @@ import com.google.protobuf.ByteString; import org.jetbrains.annotations.Nullable; import org.session.libsignal.libsignal.ecc.ECKeyPair; +import org.session.libsignal.libsignal.state.IdentityKeyStore; import org.session.libsignal.utilities.logging.Log; -import org.session.libsignal.libsignal.state.SignalProtocolStore; import org.session.libsignal.libsignal.util.guava.Optional; import org.session.libsignal.service.api.crypto.AttachmentCipherOutputStream; import org.session.libsignal.service.api.crypto.UnidentifiedAccess; @@ -29,12 +29,10 @@ import org.session.libsignal.service.api.push.SignalServiceAddress; import org.session.libsignal.service.api.push.exceptions.PushNetworkException; import org.session.libsignal.service.api.push.exceptions.UnregisteredUserException; import org.session.libsignal.service.api.util.CredentialsProvider; -import org.session.libsignal.service.internal.configuration.SignalServiceConfiguration; import org.session.libsignal.service.internal.crypto.PaddingInputStream; import org.session.libsignal.service.internal.push.OutgoingPushMessage; import org.session.libsignal.service.internal.push.OutgoingPushMessageList; import org.session.libsignal.service.internal.push.PushAttachmentData; -import org.session.libsignal.service.internal.push.PushServiceSocket; import org.session.libsignal.service.internal.push.PushTransportDetails; import org.session.libsignal.service.internal.push.SignalServiceProtos; import org.session.libsignal.service.internal.push.SignalServiceProtos.AttachmentPointer; @@ -62,7 +60,6 @@ import org.session.libsignal.service.loki.api.opengroups.PublicChatMessage; import org.session.libsignal.service.loki.database.LokiAPIDatabaseProtocol; import org.session.libsignal.service.loki.database.LokiMessageDatabaseProtocol; import org.session.libsignal.service.loki.database.LokiOpenGroupDatabaseProtocol; -import org.session.libsignal.service.loki.database.LokiPreKeyBundleDatabaseProtocol; import org.session.libsignal.service.loki.database.LokiThreadDatabaseProtocol; import org.session.libsignal.service.loki.database.LokiUserDatabaseProtocol; import org.session.libsignal.service.loki.utilities.TTLUtilities; @@ -94,7 +91,7 @@ public class SignalServiceMessageSender { private static final String TAG = SignalServiceMessageSender.class.getSimpleName(); - private final SignalProtocolStore store; + private final IdentityKeyStore store; private final SignalServiceAddress localAddress; private final AtomicReference> pipe; @@ -118,7 +115,7 @@ public class SignalServiceMessageSender { * @param store The SignalProtocolStore. */ public SignalServiceMessageSender(String user, String password, - SignalProtocolStore store, + IdentityKeyStore store, Optional pipe, Optional unidentifiedPipe, String userPublicKey, @@ -134,7 +131,7 @@ public class SignalServiceMessageSender { } public SignalServiceMessageSender(CredentialsProvider credentialsProvider, - SignalProtocolStore store, + IdentityKeyStore store, Optional pipe, Optional unidentifiedPipe, String userPublicKey, diff --git a/libsignal/src/main/java/org/session/libsignal/service/api/messages/SignalServiceDataMessage.java b/libsignal/src/main/java/org/session/libsignal/service/api/messages/SignalServiceDataMessage.java index 758c49e1a9..c0d93f9b6e 100644 --- a/libsignal/src/main/java/org/session/libsignal/service/api/messages/SignalServiceDataMessage.java +++ b/libsignal/src/main/java/org/session/libsignal/service/api/messages/SignalServiceDataMessage.java @@ -6,7 +6,6 @@ package org.session.libsignal.service.api.messages; -import org.session.libsignal.libsignal.state.PreKeyBundle; import org.session.libsignal.libsignal.util.guava.Optional; import org.session.libsignal.service.api.messages.shared.SharedContact; import org.session.libsignal.service.api.push.SignalServiceAddress; @@ -259,14 +258,10 @@ public class SignalServiceDataMessage { private long timestamp; private SignalServiceGroup group; private String body; - private boolean endSession; private int expiresInSeconds; private boolean expirationUpdate; private byte[] profileKey; - private boolean profileKeyUpdate; private Quote quote; - private Sticker sticker; - private PreKeyBundle preKeyBundle; private String syncTarget; private Builder() {} @@ -301,15 +296,6 @@ public class SignalServiceDataMessage { return this; } - public Builder asEndSessionMessage() { - return asEndSessionMessage(true); - } - - public Builder asEndSessionMessage(boolean endSession) { - this.endSession = endSession; - return this; - } - public Builder asExpirationUpdate() { return asExpirationUpdate(true); } @@ -329,11 +315,6 @@ public class SignalServiceDataMessage { return this; } - public Builder asProfileKeyUpdate(boolean profileKeyUpdate) { - this.profileKeyUpdate = profileKeyUpdate; - return this; - } - public Builder withQuote(Quote quote) { this.quote = quote; return this; @@ -354,16 +335,6 @@ public class SignalServiceDataMessage { return this; } - public Builder withSticker(Sticker sticker) { - this.sticker = sticker; - return this; - } - - public Builder withPreKeyBundle(PreKeyBundle preKeyBundle) { - this.preKeyBundle = preKeyBundle; - return this; - } - public SignalServiceDataMessage build() { if (timestamp == 0) timestamp = System.currentTimeMillis(); // closedGroupUpdate is always null because we don't use SignalServiceDataMessage to send them (we use ClosedGroupUpdateMessageSendJob) diff --git a/libsignal/src/main/java/org/session/libsignal/service/api/messages/SignalServiceNullMessage.java b/libsignal/src/main/java/org/session/libsignal/service/api/messages/SignalServiceNullMessage.java deleted file mode 100644 index 234a644315..0000000000 --- a/libsignal/src/main/java/org/session/libsignal/service/api/messages/SignalServiceNullMessage.java +++ /dev/null @@ -1,8 +0,0 @@ -package org.session.libsignal.service.api.messages; - -import org.session.libsignal.service.loki.utilities.TTLUtilities; - -public class SignalServiceNullMessage { - - public int getTTL() { return TTLUtilities.getTTL(TTLUtilities.MessageType.Ephemeral); } -} diff --git a/libsignal/src/main/java/org/session/libsignal/service/api/messages/calls/AnswerMessage.java b/libsignal/src/main/java/org/session/libsignal/service/api/messages/calls/AnswerMessage.java deleted file mode 100644 index 693f9cd96b..0000000000 --- a/libsignal/src/main/java/org/session/libsignal/service/api/messages/calls/AnswerMessage.java +++ /dev/null @@ -1,21 +0,0 @@ -package org.session.libsignal.service.api.messages.calls; - - -public class AnswerMessage { - - private final long id; - private final String description; - - public AnswerMessage(long id, String description) { - this.id = id; - this.description = description; - } - - public String getDescription() { - return description; - } - - public long getId() { - return id; - } -} diff --git a/libsignal/src/main/java/org/session/libsignal/service/api/messages/calls/BusyMessage.java b/libsignal/src/main/java/org/session/libsignal/service/api/messages/calls/BusyMessage.java deleted file mode 100644 index c46aad066d..0000000000 --- a/libsignal/src/main/java/org/session/libsignal/service/api/messages/calls/BusyMessage.java +++ /dev/null @@ -1,15 +0,0 @@ -package org.session.libsignal.service.api.messages.calls; - - -public class BusyMessage { - - private final long id; - - public BusyMessage(long id) { - this.id = id; - } - - public long getId() { - return id; - } -} diff --git a/libsignal/src/main/java/org/session/libsignal/service/api/messages/calls/HangupMessage.java b/libsignal/src/main/java/org/session/libsignal/service/api/messages/calls/HangupMessage.java deleted file mode 100644 index d790116ba5..0000000000 --- a/libsignal/src/main/java/org/session/libsignal/service/api/messages/calls/HangupMessage.java +++ /dev/null @@ -1,15 +0,0 @@ -package org.session.libsignal.service.api.messages.calls; - - -public class HangupMessage { - - private final long id; - - public HangupMessage(long id) { - this.id = id; - } - - public long getId() { - return id; - } -} diff --git a/libsignal/src/main/java/org/session/libsignal/service/api/messages/calls/IceUpdateMessage.java b/libsignal/src/main/java/org/session/libsignal/service/api/messages/calls/IceUpdateMessage.java deleted file mode 100644 index 626840c727..0000000000 --- a/libsignal/src/main/java/org/session/libsignal/service/api/messages/calls/IceUpdateMessage.java +++ /dev/null @@ -1,33 +0,0 @@ -package org.session.libsignal.service.api.messages.calls; - - -public class IceUpdateMessage { - - private final long id; - private final String sdpMid; - private final int sdpMLineIndex; - private final String sdp; - - public IceUpdateMessage(long id, String sdpMid, int sdpMLineIndex, String sdp) { - this.id = id; - this.sdpMid = sdpMid; - this.sdpMLineIndex = sdpMLineIndex; - this.sdp = sdp; - } - - public String getSdpMid() { - return sdpMid; - } - - public int getSdpMLineIndex() { - return sdpMLineIndex; - } - - public String getSdp() { - return sdp; - } - - public long getId() { - return id; - } -} diff --git a/libsignal/src/main/java/org/session/libsignal/service/api/messages/calls/OfferMessage.java b/libsignal/src/main/java/org/session/libsignal/service/api/messages/calls/OfferMessage.java deleted file mode 100644 index 50ea445c8f..0000000000 --- a/libsignal/src/main/java/org/session/libsignal/service/api/messages/calls/OfferMessage.java +++ /dev/null @@ -1,21 +0,0 @@ -package org.session.libsignal.service.api.messages.calls; - - -public class OfferMessage { - - private final long id; - private final String description; - - public OfferMessage(long id, String description) { - this.id = id; - this.description = description; - } - - public String getDescription() { - return description; - } - - public long getId() { - return id; - } -} diff --git a/libsignal/src/main/java/org/session/libsignal/service/api/messages/calls/SignalServiceCallMessage.java b/libsignal/src/main/java/org/session/libsignal/service/api/messages/calls/SignalServiceCallMessage.java deleted file mode 100644 index ba0790dda0..0000000000 --- a/libsignal/src/main/java/org/session/libsignal/service/api/messages/calls/SignalServiceCallMessage.java +++ /dev/null @@ -1,111 +0,0 @@ -package org.session.libsignal.service.api.messages.calls; - -import org.session.libsignal.libsignal.util.guava.Optional; -import org.session.libsignal.service.loki.utilities.TTLUtilities; - -import java.util.LinkedList; -import java.util.List; - -public class SignalServiceCallMessage { - - private final Optional offerMessage; - private final Optional answerMessage; - private final Optional hangupMessage; - private final Optional busyMessage; - private final Optional> iceUpdateMessages; - - private SignalServiceCallMessage(Optional offerMessage, - Optional answerMessage, - Optional> iceUpdateMessages, - Optional hangupMessage, - Optional busyMessage) - { - this.offerMessage = offerMessage; - this.answerMessage = answerMessage; - this.iceUpdateMessages = iceUpdateMessages; - this.hangupMessage = hangupMessage; - this.busyMessage = busyMessage; - } - - public static SignalServiceCallMessage forOffer(OfferMessage offerMessage) { - return new SignalServiceCallMessage(Optional.of(offerMessage), - Optional.absent(), - Optional.>absent(), - Optional.absent(), - Optional.absent()); - } - - public static SignalServiceCallMessage forAnswer(AnswerMessage answerMessage) { - return new SignalServiceCallMessage(Optional.absent(), - Optional.of(answerMessage), - Optional.>absent(), - Optional.absent(), - Optional.absent()); - } - - public static SignalServiceCallMessage forIceUpdates(List iceUpdateMessages) { - return new SignalServiceCallMessage(Optional.absent(), - Optional.absent(), - Optional.of(iceUpdateMessages), - Optional.absent(), - Optional.absent()); - } - - public static SignalServiceCallMessage forIceUpdate(final IceUpdateMessage iceUpdateMessage) { - List iceUpdateMessages = new LinkedList(); - iceUpdateMessages.add(iceUpdateMessage); - - return new SignalServiceCallMessage(Optional.absent(), - Optional.absent(), - Optional.of(iceUpdateMessages), - Optional.absent(), - Optional.absent()); - } - - public static SignalServiceCallMessage forHangup(HangupMessage hangupMessage) { - return new SignalServiceCallMessage(Optional.absent(), - Optional.absent(), - Optional.>absent(), - Optional.of(hangupMessage), - Optional.absent()); - } - - public static SignalServiceCallMessage forBusy(BusyMessage busyMessage) { - return new SignalServiceCallMessage(Optional.absent(), - Optional.absent(), - Optional.>absent(), - Optional.absent(), - Optional.of(busyMessage)); - } - - - public static SignalServiceCallMessage empty() { - return new SignalServiceCallMessage(Optional.absent(), - Optional.absent(), - Optional.>absent(), - Optional.absent(), - Optional.absent()); - } - - public Optional> getIceUpdateMessages() { - return iceUpdateMessages; - } - - public Optional getAnswerMessage() { - return answerMessage; - } - - public Optional getOfferMessage() { - return offerMessage; - } - - public Optional getHangupMessage() { - return hangupMessage; - } - - public Optional getBusyMessage() { - return busyMessage; - } - - public int getTTL() { return TTLUtilities.getTTL(TTLUtilities.MessageType.Call); } -} diff --git a/libsignal/src/main/java/org/session/libsignal/service/api/messages/calls/TurnServerInfo.java b/libsignal/src/main/java/org/session/libsignal/service/api/messages/calls/TurnServerInfo.java deleted file mode 100644 index 33f1ec316e..0000000000 --- a/libsignal/src/main/java/org/session/libsignal/service/api/messages/calls/TurnServerInfo.java +++ /dev/null @@ -1,30 +0,0 @@ -package org.session.libsignal.service.api.messages.calls; - - -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.List; - -public class TurnServerInfo { - - @JsonProperty - private String username; - - @JsonProperty - private String password; - - @JsonProperty - private List urls; - - public String getUsername() { - return username; - } - - public String getPassword() { - return password; - } - - public List getUrls() { - return urls; - } -} diff --git a/libsignal/src/main/java/org/session/libsignal/service/internal/push/PushServiceSocket.java b/libsignal/src/main/java/org/session/libsignal/service/internal/push/PushServiceSocket.java index 1c3d0b4234..3d5272fe12 100644 --- a/libsignal/src/main/java/org/session/libsignal/service/internal/push/PushServiceSocket.java +++ b/libsignal/src/main/java/org/session/libsignal/service/internal/push/PushServiceSocket.java @@ -12,14 +12,10 @@ import com.fasterxml.jackson.core.JsonProcessingException; import org.session.libsignal.libsignal.IdentityKey; import org.session.libsignal.libsignal.ecc.ECPublicKey; import org.session.libsignal.utilities.logging.Log; -import org.session.libsignal.libsignal.state.PreKeyBundle; -import org.session.libsignal.libsignal.state.PreKeyRecord; -import org.session.libsignal.libsignal.state.SignedPreKeyRecord; import org.session.libsignal.libsignal.util.Pair; import org.session.libsignal.libsignal.util.guava.Optional; import org.session.libsignal.service.api.crypto.UnidentifiedAccess; import org.session.libsignal.service.api.messages.SignalServiceAttachment.ProgressListener; -import org.session.libsignal.service.api.messages.calls.TurnServerInfo; import org.session.libsignal.service.api.profiles.SignalServiceProfile; import org.session.libsignal.service.api.push.ContactTokenDetails; import org.session.libsignal.service.api.push.SignalServiceAddress; @@ -157,110 +153,6 @@ public class PushServiceSocket { this.random = new SecureRandom(); } - public void requestSmsVerificationCode(boolean androidSmsRetriever, Optional captchaToken) throws IOException { - String path = String.format(CREATE_ACCOUNT_SMS_PATH, credentialsProvider.getUser(), androidSmsRetriever ? "android-ng" : "android"); - - if (captchaToken.isPresent()) { - path += "&captcha=" + captchaToken.get(); - } - - makeServiceRequest(path, "GET", null, NO_HEADERS, new ResponseCodeHandler() { - @Override - public void handle(int responseCode) throws NonSuccessfulResponseCodeException { - if (responseCode == 402) { - throw new CaptchaRequiredException(); - } - } - }); - } - - public void requestVoiceVerificationCode(Locale locale, Optional captchaToken) throws IOException { - Map headers = locale != null ? Collections.singletonMap("Accept-Language", locale.getLanguage() + "-" + locale.getCountry()) : NO_HEADERS; - String path = String.format(CREATE_ACCOUNT_VOICE_PATH, credentialsProvider.getUser()); - - if (captchaToken.isPresent()) { - path += "?captcha=" + captchaToken.get(); - } - - makeServiceRequest(path, "GET", null, headers, new ResponseCodeHandler() { - @Override - public void handle(int responseCode) throws NonSuccessfulResponseCodeException { - if (responseCode == 402) { - throw new CaptchaRequiredException(); - } - } - }); - } - - public void verifyAccountCode(String verificationCode, String signalingKey, int registrationId, boolean fetchesMessages, String pin, - byte[] unidentifiedAccessKey, boolean unrestrictedUnidentifiedAccess) - throws IOException - { - AccountAttributes signalingKeyEntity = new AccountAttributes(signalingKey, registrationId, fetchesMessages, pin, - unidentifiedAccessKey, unrestrictedUnidentifiedAccess); - makeServiceRequest(String.format(VERIFY_ACCOUNT_CODE_PATH, verificationCode), - "PUT", JsonUtil.toJson(signalingKeyEntity)); - } - - public void setAccountAttributes(String signalingKey, int registrationId, boolean fetchesMessages, String pin, - byte[] unidentifiedAccessKey, boolean unrestrictedUnidentifiedAccess) - throws IOException - { - AccountAttributes accountAttributes = new AccountAttributes(signalingKey, registrationId, fetchesMessages, pin, - unidentifiedAccessKey, unrestrictedUnidentifiedAccess); - makeServiceRequest(SET_ACCOUNT_ATTRIBUTES, "PUT", JsonUtil.toJson(accountAttributes)); - } - - public String getNewDeviceVerificationCode() throws IOException { - String responseText = makeServiceRequest(PROVISIONING_CODE_PATH, "GET", null); - return JsonUtil.fromJson(responseText, DeviceCode.class).getVerificationCode(); - } - - public void removeDevice(long deviceId) throws IOException { - makeServiceRequest(String.format(DEVICE_PATH, String.valueOf(deviceId)), "DELETE", null); - } - - public void sendProvisioningMessage(String destination, byte[] body) throws IOException { - makeServiceRequest(String.format(PROVISIONING_MESSAGE_PATH, destination), "PUT", - JsonUtil.toJson(new ProvisioningMessage(Base64.encodeBytes(body)))); - } - - public void registerGcmId(String gcmRegistrationId) throws IOException { - GcmRegistrationId registration = new GcmRegistrationId(gcmRegistrationId, true); - makeServiceRequest(REGISTER_GCM_PATH, "PUT", JsonUtil.toJson(registration)); - } - - public void unregisterGcmId() throws IOException { - makeServiceRequest(REGISTER_GCM_PATH, "DELETE", null); - } - - public void setPin(String pin) throws IOException { - RegistrationLock accountLock = new RegistrationLock(pin); - makeServiceRequest(PIN_PATH, "PUT", JsonUtil.toJson(accountLock)); - } - - public void removePin() throws IOException { - makeServiceRequest(PIN_PATH, "DELETE", null); - } - - public byte[] getSenderCertificate() throws IOException { - String responseText = makeServiceRequest(SENDER_CERTIFICATE_PATH, "GET", null); - return JsonUtil.fromJson(responseText, SenderCertificate.class).getCertificate(); - } - - public SendMessageResponse sendMessage(OutgoingPushMessageList bundle, Optional unidentifiedAccess) - throws IOException - { - try { - String responseText = makeServiceRequest(String.format(MESSAGE_PATH, bundle.getDestination()), "PUT", JsonUtil.toJson(bundle), NO_HEADERS, unidentifiedAccess); - - if (responseText == null) return new SendMessageResponse(false); - else return JsonUtil.fromJson(responseText, SendMessageResponse.class); - } catch (NotFoundException nfe) { - throw new UnregisteredUserException(bundle.getDestination(), nfe); - } - } - public List getMessages() throws IOException { String responseText = makeServiceRequest(String.format(MESSAGE_PATH, ""), "GET", null); return JsonUtil.fromJson(responseText, SignalServiceEnvelopeEntityList.class).getMessages(); @@ -270,159 +162,6 @@ public class PushServiceSocket { makeServiceRequest(String.format(SENDER_ACK_MESSAGE_PATH, sender, timestamp), "DELETE", null); } - public void acknowledgeMessage(String uuid) throws IOException { - makeServiceRequest(String.format(UUID_ACK_MESSAGE_PATH, uuid), "DELETE", null); - } - - public void registerPreKeys(IdentityKey identityKey, - SignedPreKeyRecord signedPreKey, - List records) - throws IOException - { - List entities = new LinkedList(); - - for (PreKeyRecord record : records) { - PreKeyEntity entity = new PreKeyEntity(record.getId(), - record.getKeyPair().getPublicKey()); - - entities.add(entity); - } - - SignedPreKeyEntity signedPreKeyEntity = new SignedPreKeyEntity(signedPreKey.getId(), - signedPreKey.getKeyPair().getPublicKey(), - signedPreKey.getSignature()); - - makeServiceRequest(String.format(PREKEY_PATH, ""), "PUT", - JsonUtil.toJson(new PreKeyState(entities, signedPreKeyEntity, identityKey))); - } - - public int getAvailablePreKeys() throws IOException { - String responseText = makeServiceRequest(PREKEY_METADATA_PATH, "GET", null); - PreKeyStatus preKeyStatus = JsonUtil.fromJson(responseText, PreKeyStatus.class); - - return preKeyStatus.getCount(); - } - - public List getPreKeys(SignalServiceAddress destination, - Optional unidentifiedAccess, - int deviceIdInteger) - throws IOException - { - try { - String deviceId = String.valueOf(deviceIdInteger); - - if (deviceId.equals("1")) - deviceId = "*"; - - String path = String.format(PREKEY_DEVICE_PATH, destination.getNumber(), deviceId); - - if (destination.getRelay().isPresent()) { - path = path + "?relay=" + destination.getRelay().get(); - } - - String responseText = makeServiceRequest(path, "GET", null, NO_HEADERS, unidentifiedAccess); - PreKeyResponse response = JsonUtil.fromJson(responseText, PreKeyResponse.class); - List bundles = new LinkedList(); - - for (PreKeyResponseItem device : response.getDevices()) { - ECPublicKey preKey = null; - ECPublicKey signedPreKey = null; - byte[] signedPreKeySignature = null; - int preKeyId = -1; - int signedPreKeyId = -1; - - if (device.getSignedPreKey() != null) { - signedPreKey = device.getSignedPreKey().getPublicKey(); - signedPreKeyId = device.getSignedPreKey().getKeyId(); - signedPreKeySignature = device.getSignedPreKey().getSignature(); - } - - if (device.getPreKey() != null) { - preKeyId = device.getPreKey().getKeyId(); - preKey = device.getPreKey().getPublicKey(); - } - - bundles.add(new PreKeyBundle(device.getRegistrationId(), device.getDeviceId(), preKeyId, - preKey, signedPreKeyId, signedPreKey, signedPreKeySignature, - response.getIdentityKey())); - } - - return bundles; - } catch (NotFoundException nfe) { - throw new UnregisteredUserException(destination.getNumber(), nfe); - } - } - - public PreKeyBundle getPreKey(SignalServiceAddress destination, int deviceId) throws IOException { - try { - String path = String.format(PREKEY_DEVICE_PATH, destination.getNumber(), - String.valueOf(deviceId)); - - if (destination.getRelay().isPresent()) { - path = path + "?relay=" + destination.getRelay().get(); - } - - String responseText = makeServiceRequest(path, "GET", null); - PreKeyResponse response = JsonUtil.fromJson(responseText, PreKeyResponse.class); - - if (response.getDevices() == null || response.getDevices().size() < 1) - throw new IOException("Empty prekey list"); - - PreKeyResponseItem device = response.getDevices().get(0); - ECPublicKey preKey = null; - ECPublicKey signedPreKey = null; - byte[] signedPreKeySignature = null; - int preKeyId = -1; - int signedPreKeyId = -1; - - if (device.getPreKey() != null) { - preKeyId = device.getPreKey().getKeyId(); - preKey = device.getPreKey().getPublicKey(); - } - - if (device.getSignedPreKey() != null) { - signedPreKeyId = device.getSignedPreKey().getKeyId(); - signedPreKey = device.getSignedPreKey().getPublicKey(); - signedPreKeySignature = device.getSignedPreKey().getSignature(); - } - - return new PreKeyBundle(device.getRegistrationId(), device.getDeviceId(), preKeyId, preKey, - signedPreKeyId, signedPreKey, signedPreKeySignature, response.getIdentityKey()); - } catch (NotFoundException nfe) { - throw new UnregisteredUserException(destination.getNumber(), nfe); - } - } - - public SignedPreKeyEntity getCurrentSignedPreKey() throws IOException { - try { - String responseText = makeServiceRequest(SIGNED_PREKEY_PATH, "GET", null); - return JsonUtil.fromJson(responseText, SignedPreKeyEntity.class); - } catch (NotFoundException e) { - Log.w(TAG, e); - return null; - } - } - - public void setCurrentSignedPreKey(SignedPreKeyRecord signedPreKey) throws IOException { - SignedPreKeyEntity signedPreKeyEntity = new SignedPreKeyEntity(signedPreKey.getId(), - signedPreKey.getKeyPair().getPublicKey(), - signedPreKey.getSignature()); - makeServiceRequest(SIGNED_PREKEY_PATH, "PUT", JsonUtil.toJson(signedPreKeyEntity)); - } - - public void retrieveAttachment(long attachmentId, File destination, int maxSizeBytes, ProgressListener listener) - throws NonSuccessfulResponseCodeException, PushNetworkException - { - downloadFromCdn(destination, String.format(ATTACHMENT_DOWNLOAD_PATH, attachmentId), maxSizeBytes, listener); - } - - public void retrieveSticker(File destination, byte[] packId, int stickerId) - throws NonSuccessfulResponseCodeException, PushNetworkException - { - String hexPackId = Hex.toStringCondensed(packId); - downloadFromCdn(destination, String.format(STICKER_PATH, hexPackId, stickerId), 1024 * 1024, null); - } - public byte[] retrieveSticker(byte[] packId, int stickerId) throws NonSuccessfulResponseCodeException, PushNetworkException { @@ -457,172 +196,6 @@ public class PushServiceSocket { } } - public void retrieveProfileAvatar(String path, File destination, int maxSizeBytes) - throws NonSuccessfulResponseCodeException, PushNetworkException - { - downloadFromCdn(destination, path, maxSizeBytes, null); - } - - public void setProfileName(String name) throws NonSuccessfulResponseCodeException, PushNetworkException { - makeServiceRequest(String.format(PROFILE_PATH, "name/" + (name == null ? "" : URLEncoder.encode(name))), "PUT", ""); - } - - public void setProfileAvatar(ProfileAvatarData profileAvatar) - throws NonSuccessfulResponseCodeException, PushNetworkException - { - String response = makeServiceRequest(String.format(PROFILE_PATH, "form/avatar"), "GET", null); - ProfileAvatarUploadAttributes formAttributes; - - try { - formAttributes = JsonUtil.fromJson(response, ProfileAvatarUploadAttributes.class); - } catch (IOException e) { - Log.w(TAG, e); - throw new NonSuccessfulResponseCodeException("Unable to parse entity"); - } - - if (profileAvatar != null) { - uploadToCdn("", formAttributes.getAcl(), formAttributes.getKey(), - formAttributes.getPolicy(), formAttributes.getAlgorithm(), - formAttributes.getCredential(), formAttributes.getDate(), - formAttributes.getSignature(), profileAvatar.getData(), - profileAvatar.getContentType(), profileAvatar.getDataLength(), - profileAvatar.getOutputStreamFactory(), null); - } - } - - public List retrieveDirectory(Set contactTokens) - throws NonSuccessfulResponseCodeException, PushNetworkException - { - try { - ContactTokenList contactTokenList = new ContactTokenList(new LinkedList(contactTokens)); - String response = makeServiceRequest(DIRECTORY_TOKENS_PATH, "PUT", JsonUtil.toJson(contactTokenList)); - ContactTokenDetailsList activeTokens = JsonUtil.fromJson(response, ContactTokenDetailsList.class); - - return activeTokens.getContacts(); - } catch (IOException e) { - Log.w(TAG, e); - throw new NonSuccessfulResponseCodeException("Unable to parse entity"); - } - } - - public ContactTokenDetails getContactTokenDetails(String contactToken) throws IOException { - try { - String response = makeServiceRequest(String.format(DIRECTORY_VERIFY_PATH, contactToken), "GET", null); - return JsonUtil.fromJson(response, ContactTokenDetails.class); - } catch (NotFoundException nfe) { - return null; - } - } - - public String getContactDiscoveryAuthorization() throws IOException { - String response = makeServiceRequest(DIRECTORY_AUTH_PATH, "GET", null); - ContactDiscoveryCredentials token = JsonUtil.fromJson(response, ContactDiscoveryCredentials.class); - return Credentials.basic(token.getUsername(), token.getPassword()); - } - - public Pair> getContactDiscoveryRemoteAttestation(String authorization, RemoteAttestationRequest request, String mrenclave) - throws IOException - { - Response response = makeContactDiscoveryRequest(authorization, new LinkedList(), "/v1/attestation/" + mrenclave, "PUT", JsonUtil.toJson(request)); - ResponseBody body = response.body(); - List rawCookies = response.headers("Set-Cookie"); - List cookies = new LinkedList(); - - for (String cookie : rawCookies) { - cookies.add(cookie.split(";")[0]); - } - - if (body != null) { - return new Pair>(JsonUtil.fromJson(body.string(), RemoteAttestationResponse.class), cookies); - } else { - throw new NonSuccessfulResponseCodeException("Empty response!"); - } - } - - public DiscoveryResponse getContactDiscoveryRegisteredUsers(String authorizationToken, DiscoveryRequest request, List cookies, String mrenclave) - throws IOException - { - ResponseBody body = makeContactDiscoveryRequest(authorizationToken, cookies, "/v1/discovery/" + mrenclave, "PUT", JsonUtil.toJson(request)).body(); - - if (body != null) { - return JsonUtil.fromJson(body.string(), DiscoveryResponse.class); - } else { - throw new NonSuccessfulResponseCodeException("Empty response!"); - } - } - - public void reportContactDiscoveryServiceMatch() throws IOException { - makeServiceRequest(String.format(DIRECTORY_FEEDBACK_PATH, "ok"), "PUT", ""); - } - - public void reportContactDiscoveryServiceMismatch() throws IOException { - makeServiceRequest(String.format(DIRECTORY_FEEDBACK_PATH, "mismatch"), "PUT", ""); - } - - public void reportContactDiscoveryServiceAttestationError(String reason) throws IOException { - ContactDiscoveryFailureReason failureReason = new ContactDiscoveryFailureReason(reason); - makeServiceRequest(String.format(DIRECTORY_FEEDBACK_PATH, "attestation-error"), "PUT", JsonUtil.toJson(failureReason)); - } - - public void reportContactDiscoveryServiceUnexpectedError(String reason) throws IOException { - ContactDiscoveryFailureReason failureReason = new ContactDiscoveryFailureReason(reason); - makeServiceRequest(String.format(DIRECTORY_FEEDBACK_PATH, "unexpected-error"), "PUT", JsonUtil.toJson(failureReason)); - } - - public TurnServerInfo getTurnServerInfo() throws IOException { - String response = makeServiceRequest(TURN_SERVER_INFO, "GET", null); - return JsonUtil.fromJson(response, TurnServerInfo.class); - } - - public void setSoTimeoutMillis(long soTimeoutMillis) { - this.soTimeoutMillis = soTimeoutMillis; - } - - public void cancelInFlightRequests() { - synchronized (connections) { - Log.w(TAG, "Canceling: " + connections.size()); - for (Call connection : connections) { - Log.w(TAG, "Canceling: " + connection); - connection.cancel(); - } - } - } - - public AttachmentUploadAttributes getAttachmentUploadAttributes() throws NonSuccessfulResponseCodeException, PushNetworkException { - String response = makeServiceRequest(ATTACHMENT_PATH, "GET", null); - try { - return JsonUtil.fromJson(response, AttachmentUploadAttributes.class); - } catch (IOException e) { - Log.w(TAG, e); - throw new NonSuccessfulResponseCodeException("Unable to parse entity"); - } - } - - public Pair uploadAttachment(PushAttachmentData attachment, AttachmentUploadAttributes uploadAttributes) - throws PushNetworkException, NonSuccessfulResponseCodeException - { - long id = Long.parseLong(uploadAttributes.getAttachmentId()); - byte[] digest = uploadToCdn(ATTACHMENT_UPLOAD_PATH, uploadAttributes.getAcl(), uploadAttributes.getKey(), - uploadAttributes.getPolicy(), uploadAttributes.getAlgorithm(), - uploadAttributes.getCredential(), uploadAttributes.getDate(), - uploadAttributes.getSignature(), attachment.getData(), - "application/octet-stream", attachment.getDataSize(), - attachment.getOutputStreamFactory(), attachment.getListener()); - - return new Pair(id, digest); - } - - private void downloadFromCdn(File destination, String path, int maxSizeBytes, ProgressListener listener) - throws PushNetworkException, NonSuccessfulResponseCodeException - { - try { - FileOutputStream outputStream = new FileOutputStream(destination); - downloadFromCdn(outputStream, path, maxSizeBytes, listener); - } catch (IOException e) { - throw new PushNetworkException(e); - } - } - private void downloadFromCdn(OutputStream outputStream, String path, int maxSizeBytes, ProgressListener listener) throws PushNetworkException, NonSuccessfulResponseCodeException { @@ -683,66 +256,6 @@ public class PushServiceSocket { throw new NonSuccessfulResponseCodeException("Response: " + response); } - private byte[] uploadToCdn(String path, String acl, String key, String policy, String algorithm, - String credential, String date, String signature, - InputStream data, String contentType, long length, - OutputStreamFactory outputStreamFactory, ProgressListener progressListener) - throws PushNetworkException, NonSuccessfulResponseCodeException - { - ConnectionHolder connectionHolder = getRandom(cdnClients, random); - OkHttpClient okHttpClient = connectionHolder.getClient() - .newBuilder() - .connectTimeout(soTimeoutMillis, TimeUnit.MILLISECONDS) - .readTimeout(soTimeoutMillis, TimeUnit.MILLISECONDS) - .build(); - - DigestingRequestBody file = new DigestingRequestBody(data, outputStreamFactory, contentType, length, progressListener); - - RequestBody requestBody = new MultipartBody.Builder() - .setType(MultipartBody.FORM) - .addFormDataPart("acl", acl) - .addFormDataPart("key", key) - .addFormDataPart("policy", policy) - .addFormDataPart("Content-Type", contentType) - .addFormDataPart("x-amz-algorithm", algorithm) - .addFormDataPart("x-amz-credential", credential) - .addFormDataPart("x-amz-date", date) - .addFormDataPart("x-amz-signature", signature) - .addFormDataPart("file", "file", file) - .build(); - - Request.Builder request = new Request.Builder() - .url(connectionHolder.getUrl() + "/" + path) - .post(requestBody); - - if (connectionHolder.getHostHeader().isPresent()) { - request.addHeader("Host", connectionHolder.getHostHeader().get()); - } - - Call call = okHttpClient.newCall(request.build()); - - synchronized (connections) { - connections.add(call); - } - - try { - Response response; - - try { - response = call.execute(); - } catch (IOException e) { - throw new PushNetworkException(e); - } - - if (response.isSuccessful()) return file.getTransmittedDigest(); - else throw new NonSuccessfulResponseCodeException("Response: " + response); - } finally { - synchronized (connections) { - connections.remove(call); - } - } - } - private String makeServiceRequest(String urlFragment, String method, String body) throws NonSuccessfulResponseCodeException, PushNetworkException { diff --git a/libsignal/src/main/java/org/session/libsignal/service/loki/database/LokiPreKeyBundleDatabaseProtocol.kt b/libsignal/src/main/java/org/session/libsignal/service/loki/database/LokiPreKeyBundleDatabaseProtocol.kt deleted file mode 100644 index 66668a42ef..0000000000 --- a/libsignal/src/main/java/org/session/libsignal/service/loki/database/LokiPreKeyBundleDatabaseProtocol.kt +++ /dev/null @@ -1,9 +0,0 @@ -package org.session.libsignal.service.loki.database - -import org.session.libsignal.libsignal.state.PreKeyBundle - -interface LokiPreKeyBundleDatabaseProtocol { - - fun getPreKeyBundle(publicKey: String): PreKeyBundle? - fun removePreKeyBundle(publicKey: String) -} diff --git a/libsignal/src/main/java/org/session/libsignal/service/loki/database/LokiPreKeyRecordDatabaseProtocol.kt b/libsignal/src/main/java/org/session/libsignal/service/loki/database/LokiPreKeyRecordDatabaseProtocol.kt deleted file mode 100644 index c4e2e49ede..0000000000 --- a/libsignal/src/main/java/org/session/libsignal/service/loki/database/LokiPreKeyRecordDatabaseProtocol.kt +++ /dev/null @@ -1,8 +0,0 @@ -package org.session.libsignal.service.loki.database - -import org.session.libsignal.libsignal.state.PreKeyRecord - -interface LokiPreKeyRecordDatabaseProtocol { - - fun getPreKeyRecord(publicKey: String): PreKeyRecord? -}