import org.whispersystems.signalservice.api.crypto.UnidentifiedAccess;
import org.whispersystems.signalservice.api.kbs.MasterKey;
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
+import org.whispersystems.signalservice.api.storage.StorageKey;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
private String password;
private String registrationLockPin;
private MasterKey pinMasterKey;
+ private StorageKey storageKey;
private String signalingKey;
private ProfileKey profileKey;
private int preKeyIdOffset;
pinMasterKey = pinMasterKeyNode == null || pinMasterKeyNode.isNull()
? null
: new MasterKey(Base64.getDecoder().decode(pinMasterKeyNode.asText()));
+ JsonNode storageKeyNode = rootNode.get("storageKey");
+ storageKey = storageKeyNode == null || storageKeyNode.isNull()
+ ? null
+ : new StorageKey(Base64.getDecoder().decode(storageKeyNode.asText()));
if (rootNode.has("signalingKey")) {
signalingKey = Utils.getNotNullNode(rootNode, "signalingKey").asText();
}
.put("registrationLockPin", registrationLockPin)
.put("pinMasterKey",
pinMasterKey == null ? null : Base64.getEncoder().encodeToString(pinMasterKey.serialize()))
+ .put("storageKey",
+ storageKey == null ? null : Base64.getEncoder().encodeToString(storageKey.serialize()))
.put("signalingKey", signalingKey)
.put("preKeyIdOffset", preKeyIdOffset)
.put("nextSignedPreKeyId", nextSignedPreKeyId)
this.pinMasterKey = pinMasterKey;
}
+ public StorageKey getStorageKey() {
+ if (pinMasterKey != null) {
+ return pinMasterKey.deriveStorageServiceKey();
+ }
+ return storageKey;
+ }
+
+ public void setStorageKey(final StorageKey storageKey) {
+ this.storageKey = storageKey;
+ }
+
public String getSignalingKey() {
return signalingKey;
}