|
|
@ -22,6 +22,7 @@ public class TextSecurePreKeyStore implements PreKeyStore {
|
|
|
|
|
|
|
|
|
|
|
|
public static final String PREKEY_DIRECTORY = "prekeys";
|
|
|
|
public static final String PREKEY_DIRECTORY = "prekeys";
|
|
|
|
private static final int CURRENT_VERSION_MARKER = 1;
|
|
|
|
private static final int CURRENT_VERSION_MARKER = 1;
|
|
|
|
|
|
|
|
private static final Object FILE_LOCK = new Object();
|
|
|
|
private static final String TAG = TextSecurePreKeyStore.class.getSimpleName();
|
|
|
|
private static final String TAG = TextSecurePreKeyStore.class.getSimpleName();
|
|
|
|
|
|
|
|
|
|
|
|
private final Context context;
|
|
|
|
private final Context context;
|
|
|
@ -34,6 +35,7 @@ public class TextSecurePreKeyStore implements PreKeyStore {
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public PreKeyRecord load(int preKeyId) throws InvalidKeyIdException {
|
|
|
|
public PreKeyRecord load(int preKeyId) throws InvalidKeyIdException {
|
|
|
|
|
|
|
|
synchronized (FILE_LOCK) {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
MasterCipher masterCipher = new MasterCipher(masterSecret);
|
|
|
|
MasterCipher masterCipher = new MasterCipher(masterSecret);
|
|
|
|
FileInputStream fin = new FileInputStream(getPreKeyFile(preKeyId));
|
|
|
|
FileInputStream fin = new FileInputStream(getPreKeyFile(preKeyId));
|
|
|
@ -51,9 +53,11 @@ public class TextSecurePreKeyStore implements PreKeyStore {
|
|
|
|
throw new InvalidKeyIdException(e);
|
|
|
|
throw new InvalidKeyIdException(e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void store(int preKeyId, PreKeyRecord record) {
|
|
|
|
public void store(int preKeyId, PreKeyRecord record) {
|
|
|
|
|
|
|
|
synchronized (FILE_LOCK) {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
MasterCipher masterCipher = new MasterCipher(masterSecret);
|
|
|
|
MasterCipher masterCipher = new MasterCipher(masterSecret);
|
|
|
|
RandomAccessFile recordFile = new RandomAccessFile(getPreKeyFile(preKeyId), "rw");
|
|
|
|
RandomAccessFile recordFile = new RandomAccessFile(getPreKeyFile(preKeyId), "rw");
|
|
|
@ -69,6 +73,7 @@ public class TextSecurePreKeyStore implements PreKeyStore {
|
|
|
|
throw new AssertionError(e);
|
|
|
|
throw new AssertionError(e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public boolean contains(int preKeyId) {
|
|
|
|
public boolean contains(int preKeyId) {
|
|
|
|