Deprecate old signaling key concept
This commit is contained in:
parent
05087a833c
commit
c2f2146872
|
@ -1,4 +1,4 @@
|
||||||
/**
|
/*
|
||||||
* Copyright (C) 2013 Open WhisperSystems
|
* Copyright (C) 2013 Open WhisperSystems
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
@ -42,7 +42,6 @@ public class EncryptedOutgoingMessage {
|
||||||
private static final int MAC_SIZE = 10;
|
private static final int MAC_SIZE = 10;
|
||||||
|
|
||||||
private final byte[] serialized;
|
private final byte[] serialized;
|
||||||
private final String serializedAndEncoded;
|
|
||||||
|
|
||||||
public EncryptedOutgoingMessage(Envelope outgoingMessage, String signalingKey)
|
public EncryptedOutgoingMessage(Envelope outgoingMessage, String signalingKey)
|
||||||
throws CryptoEncodingException
|
throws CryptoEncodingException
|
||||||
|
@ -52,11 +51,6 @@ public class EncryptedOutgoingMessage {
|
||||||
SecretKeySpec macKey = getMacKey(signalingKey);
|
SecretKeySpec macKey = getMacKey(signalingKey);
|
||||||
|
|
||||||
this.serialized = getCiphertext(plaintext, cipherKey, macKey);
|
this.serialized = getCiphertext(plaintext, cipherKey, macKey);
|
||||||
this.serializedAndEncoded = Base64.encodeBytes(this.serialized);
|
|
||||||
}
|
|
||||||
|
|
||||||
public String toEncodedString() {
|
|
||||||
return serializedAndEncoded;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte[] toByteArray() {
|
public byte[] toByteArray() {
|
||||||
|
|
|
@ -31,6 +31,7 @@ import org.whispersystems.websocket.messages.WebSocketResponseMessage;
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import javax.ws.rs.WebApplicationException;
|
import javax.ws.rs.WebApplicationException;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
|
@ -111,9 +112,18 @@ public class WebSocketConnection implements DispatchChannel {
|
||||||
final boolean requery)
|
final boolean requery)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
EncryptedOutgoingMessage encryptedMessage = new EncryptedOutgoingMessage(message, device.getSignalingKey());
|
String header;
|
||||||
Optional<byte[]> body = Optional.ofNullable(encryptedMessage.toByteArray());
|
Optional<byte[]> body;
|
||||||
ListenableFuture<WebSocketResponseMessage> response = client.sendRequest("PUT", "/api/v1/message", null, body);
|
|
||||||
|
if (Util.isEmpty(device.getSignalingKey())) {
|
||||||
|
header = "X-Signal-Key: false";
|
||||||
|
body = Optional.ofNullable(message.toByteArray());
|
||||||
|
} else {
|
||||||
|
header = "X-Signal-Key: true";
|
||||||
|
body = Optional.ofNullable(new EncryptedOutgoingMessage(message, device.getSignalingKey()).toByteArray());
|
||||||
|
}
|
||||||
|
|
||||||
|
ListenableFuture<WebSocketResponseMessage> response = client.sendRequest("PUT", "/api/v1/message", Collections.singletonList(header), body);
|
||||||
|
|
||||||
Futures.addCallback(response, new FutureCallback<WebSocketResponseMessage>() {
|
Futures.addCallback(response, new FutureCallback<WebSocketResponseMessage>() {
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in New Issue