mirror of
https://github.com/oxen-io/session-android.git
synced 2025-05-08 05:27:02 +00:00
43 lines
1.4 KiB
Java
43 lines
1.4 KiB
Java
package org.thoughtcrime.securesms.crypto;
|
|
|
|
import android.content.Context;
|
|
|
|
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
|
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
|
import org.whispersystems.libaxolotl.IdentityKey;
|
|
import org.whispersystems.libaxolotl.IdentityKeyPair;
|
|
import org.whispersystems.libaxolotl.state.IdentityKeyStore;
|
|
import org.whispersystems.textsecure.crypto.MasterSecret;
|
|
|
|
public class TextSecureIdentityKeyStore implements IdentityKeyStore {
|
|
|
|
private final Context context;
|
|
private final MasterSecret masterSecret;
|
|
|
|
public TextSecureIdentityKeyStore(Context context, MasterSecret masterSecret) {
|
|
this.context = context;
|
|
this.masterSecret = masterSecret;
|
|
}
|
|
|
|
@Override
|
|
public IdentityKeyPair getIdentityKeyPair() {
|
|
return IdentityKeyUtil.getIdentityKeyPair(context, masterSecret);
|
|
}
|
|
|
|
@Override
|
|
public int getLocalRegistrationId() {
|
|
return TextSecurePreferences.getLocalRegistrationId(context);
|
|
}
|
|
|
|
@Override
|
|
public void saveIdentity(long recipientId, IdentityKey identityKey) {
|
|
DatabaseFactory.getIdentityDatabase(context).saveIdentity(masterSecret, recipientId, identityKey);
|
|
}
|
|
|
|
@Override
|
|
public boolean isTrustedIdentity(long recipientId, IdentityKey identityKey) {
|
|
return DatabaseFactory.getIdentityDatabase(context)
|
|
.isValidIdentity(masterSecret, recipientId, identityKey);
|
|
}
|
|
}
|