mirror of
https://github.com/signalapp/libsignal.git
synced 2026-05-10 09:02:05 +02:00
Remove the SenderKey protobufs from Java wrapper
This commit is contained in:
@@ -204,10 +204,10 @@ public final class Native {
|
||||
public static native int SenderKeyName_GetSenderDeviceId(long handle);
|
||||
public static native String SenderKeyName_GetGroupId(long handle);
|
||||
|
||||
public static native long SenderKeyState_New(int id, int iteration, byte[] chainKey, long signaturePublicHandle, long signaturePrivateHandle);
|
||||
public static native void SenderKeyState_Destroy(long handle);
|
||||
public static native long SenderKeyState_Deserialize(byte[] serialized);
|
||||
public static native byte[] SenderKeyState_GetSerialized(long handle);
|
||||
public static native long SenderKeyRecord_New();
|
||||
public static native long SenderKeyRecord_Deserialize(byte[] serialized);
|
||||
public static native void SenderKeyRecord_Destroy(long handle);
|
||||
public static native byte[] SenderKeyRecord_GetSerialized(long handle);
|
||||
|
||||
public static native long SenderKeyMessage_Deserialize(byte[] serialized);
|
||||
public static native long SenderKeyMessage_New(int keyId, int iteration, byte[] ciphertext, long pkHandle);
|
||||
|
||||
@@ -6,13 +6,8 @@
|
||||
package org.whispersystems.libsignal.groups;
|
||||
|
||||
import org.signal.client.internal.Native;
|
||||
import org.whispersystems.libsignal.InvalidKeyException;
|
||||
import org.whispersystems.libsignal.InvalidKeyIdException;
|
||||
import org.whispersystems.libsignal.groups.state.SenderKeyRecord;
|
||||
import org.whispersystems.libsignal.groups.state.SenderKeyState;
|
||||
import org.whispersystems.libsignal.groups.state.SenderKeyStore;
|
||||
import org.whispersystems.libsignal.protocol.SenderKeyDistributionMessage;
|
||||
import org.whispersystems.libsignal.util.KeyHelper;
|
||||
|
||||
/**
|
||||
* GroupSessionBuilder is responsible for setting up group SenderKey encrypted sessions.
|
||||
|
||||
@@ -5,13 +5,8 @@
|
||||
*/
|
||||
package org.whispersystems.libsignal.groups.state;
|
||||
|
||||
import org.whispersystems.libsignal.InvalidKeyIdException;
|
||||
|
||||
import org.signal.client.internal.Native;
|
||||
import java.io.IOException;
|
||||
import java.util.LinkedList;
|
||||
|
||||
import static org.whispersystems.libsignal.state.StorageProtos.SenderKeyRecordStructure;
|
||||
import static org.whispersystems.libsignal.state.StorageProtos.SenderKeyStateStructure;
|
||||
|
||||
/**
|
||||
* A durable representation of a set of SenderKeyStates for a specific
|
||||
@@ -20,26 +15,30 @@ import static org.whispersystems.libsignal.state.StorageProtos.SenderKeyStateStr
|
||||
* @author Moxie Marlinspike
|
||||
*/
|
||||
public class SenderKeyRecord {
|
||||
private long handle;
|
||||
|
||||
private LinkedList<SenderKeyState> senderKeyStates = new LinkedList<>();
|
||||
@Override
|
||||
protected void finalize() {
|
||||
Native.SenderKeyRecord_Destroy(this.handle);
|
||||
}
|
||||
|
||||
public SenderKeyRecord() {}
|
||||
public SenderKeyRecord() {
|
||||
handle = Native.SenderKeyRecord_New();
|
||||
}
|
||||
|
||||
public SenderKeyRecord(long handle) {
|
||||
this.handle = handle;
|
||||
}
|
||||
|
||||
public SenderKeyRecord(byte[] serialized) throws IOException {
|
||||
SenderKeyRecordStructure senderKeyRecordStructure = SenderKeyRecordStructure.parseFrom(serialized);
|
||||
|
||||
for (SenderKeyStateStructure structure : senderKeyRecordStructure.getSenderKeyStatesList()) {
|
||||
this.senderKeyStates.add(new SenderKeyState(structure));
|
||||
}
|
||||
handle = Native.SenderKeyRecord_Deserialize(serialized);
|
||||
}
|
||||
|
||||
public byte[] serialize() {
|
||||
SenderKeyRecordStructure.Builder recordStructure = SenderKeyRecordStructure.newBuilder();
|
||||
return Native.SenderKeyRecord_GetSerialized(this.handle);
|
||||
}
|
||||
|
||||
for (SenderKeyState senderKeyState : senderKeyStates) {
|
||||
recordStructure.addSenderKeyStates(senderKeyState.getStructure());
|
||||
}
|
||||
|
||||
return recordStructure.build().toByteArray();
|
||||
public long nativeHandle() {
|
||||
return this.handle;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,56 +0,0 @@
|
||||
/**
|
||||
* Copyright (C) 2014-2016 Open Whisper Systems
|
||||
*
|
||||
* Licensed according to the LICENSE file in this repository.
|
||||
*/
|
||||
package org.whispersystems.libsignal.groups.state;
|
||||
|
||||
import org.signal.client.internal.Native;
|
||||
import org.whispersystems.libsignal.InvalidKeyException;
|
||||
import org.whispersystems.libsignal.ecc.ECKeyPair;
|
||||
import org.whispersystems.libsignal.ecc.ECPrivateKey;
|
||||
import org.whispersystems.libsignal.ecc.ECPublicKey;
|
||||
import org.whispersystems.libsignal.util.guava.Optional;
|
||||
|
||||
import com.google.protobuf.InvalidProtocolBufferException;
|
||||
|
||||
import static org.whispersystems.libsignal.state.StorageProtos.SenderKeyStateStructure;
|
||||
|
||||
/**
|
||||
* Represents the state of an individual SenderKey ratchet.
|
||||
*
|
||||
* @author Moxie Marlinspike
|
||||
*/
|
||||
public class SenderKeyState {
|
||||
private long handle;
|
||||
|
||||
public SenderKeyState(int id, int iteration, byte[] chainKey, ECPublicKey signatureKey) {
|
||||
this(id, iteration, chainKey, signatureKey, Optional.<ECPrivateKey>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<ECPrivateKey> signatureKeyPrivate)
|
||||
{
|
||||
long signatureKeyPrivateHandle = signatureKeyPrivate.isPresent() ? signatureKeyPrivate.get().nativeHandle() : 0;
|
||||
|
||||
this.handle = Native.SenderKeyState_New(id, iteration, chainKey, signatureKeyPublic.nativeHandle(),
|
||||
signatureKeyPrivateHandle);
|
||||
}
|
||||
|
||||
public SenderKeyState(SenderKeyStateStructure senderKeyStateStructure) {
|
||||
this.handle = Native.SenderKeyState_Deserialize(senderKeyStateStructure.toByteArray());
|
||||
}
|
||||
|
||||
public SenderKeyStateStructure getStructure() {
|
||||
try {
|
||||
return SenderKeyStateStructure.parseFrom(Native.SenderKeyState_GetSerialized(this.handle));
|
||||
} catch (InvalidProtocolBufferException e) {
|
||||
throw new AssertionError(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user