mirror of
https://github.com/oxen-io/session-android.git
synced 2025-06-09 11:38:33 +00:00
Add type to KBS json.
This commit is contained in:
parent
1d9fff3c98
commit
ba6e1ab15a
@ -46,7 +46,7 @@ public final class KeyBackupCipher {
|
|||||||
|
|
||||||
Request requestData = Request.newBuilder().setBackup(backupRequest).build();
|
Request requestData = Request.newBuilder().setBackup(backupRequest).build();
|
||||||
|
|
||||||
return createKeyBackupRequest(requestData, remoteAttestation);
|
return createKeyBackupRequest(requestData, remoteAttestation, "backup");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static KeyBackupRequest createKeyRestoreRequest(byte[] kbsAccessKey,
|
public static KeyBackupRequest createKeyRestoreRequest(byte[] kbsAccessKey,
|
||||||
@ -66,7 +66,7 @@ public final class KeyBackupCipher {
|
|||||||
|
|
||||||
Request request = Request.newBuilder().setRestore(restoreRequest).build();
|
Request request = Request.newBuilder().setRestore(restoreRequest).build();
|
||||||
|
|
||||||
return createKeyBackupRequest(request, remoteAttestation);
|
return createKeyBackupRequest(request, remoteAttestation, "restore");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static KeyBackupRequest createKeyDeleteRequest(TokenResponse token,
|
public static KeyBackupRequest createKeyDeleteRequest(TokenResponse token,
|
||||||
@ -80,7 +80,7 @@ public final class KeyBackupCipher {
|
|||||||
|
|
||||||
Request request = Request.newBuilder().setDelete(deleteRequest).build();
|
Request request = Request.newBuilder().setDelete(deleteRequest).build();
|
||||||
|
|
||||||
return createKeyBackupRequest(request, remoteAttestation);
|
return createKeyBackupRequest(request, remoteAttestation, "delete");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static BackupResponse getKeyBackupResponse(KeyBackupResponse response, RemoteAttestation remoteAttestation)
|
public static BackupResponse getKeyBackupResponse(KeyBackupResponse response, RemoteAttestation remoteAttestation)
|
||||||
@ -109,13 +109,13 @@ public final class KeyBackupCipher {
|
|||||||
return DeleteResponse.parseFrom(data);
|
return DeleteResponse.parseFrom(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static KeyBackupRequest createKeyBackupRequest(Request requestData, RemoteAttestation remoteAttestation) {
|
private static KeyBackupRequest createKeyBackupRequest(Request requestData, RemoteAttestation remoteAttestation, String type) {
|
||||||
byte[] clientKey = remoteAttestation.getKeys().getClientKey();
|
byte[] clientKey = remoteAttestation.getKeys().getClientKey();
|
||||||
byte[] aad = remoteAttestation.getRequestId();
|
byte[] aad = remoteAttestation.getRequestId();
|
||||||
|
|
||||||
AESCipher.AESEncryptedResult aesEncryptedResult = AESCipher.encrypt(clientKey, aad, requestData.toByteArray());
|
AESCipher.AESEncryptedResult aesEncryptedResult = AESCipher.encrypt(clientKey, aad, requestData.toByteArray());
|
||||||
|
|
||||||
return new KeyBackupRequest(aesEncryptedResult.aad, aesEncryptedResult.iv, aesEncryptedResult.data, aesEncryptedResult.mac);
|
return new KeyBackupRequest(aesEncryptedResult.aad, aesEncryptedResult.iv, aesEncryptedResult.data, aesEncryptedResult.mac, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static byte[] decryptData(KeyBackupResponse response, RemoteAttestation remoteAttestation) throws InvalidCiphertextException {
|
private static byte[] decryptData(KeyBackupResponse response, RemoteAttestation remoteAttestation) throws InvalidCiphertextException {
|
||||||
|
@ -18,14 +18,18 @@ public class KeyBackupRequest {
|
|||||||
@JsonProperty
|
@JsonProperty
|
||||||
private byte[] mac;
|
private byte[] mac;
|
||||||
|
|
||||||
|
@JsonProperty
|
||||||
|
private String type;
|
||||||
|
|
||||||
public KeyBackupRequest() {
|
public KeyBackupRequest() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public KeyBackupRequest(byte[] requestId, byte[] iv, byte[] data, byte[] mac) {
|
public KeyBackupRequest(byte[] requestId, byte[] iv, byte[] data, byte[] mac, String type) {
|
||||||
this.requestId = requestId;
|
this.requestId = requestId;
|
||||||
this.iv = iv;
|
this.iv = iv;
|
||||||
this.data = data;
|
this.data = data;
|
||||||
this.mac = mac;
|
this.mac = mac;
|
||||||
|
this.type = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte[] getRequestId() {
|
public byte[] getRequestId() {
|
||||||
@ -44,8 +48,12 @@ public class KeyBackupRequest {
|
|||||||
return mac;
|
return mac;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "{ requestId: " + Hex.toString(requestId) + ", iv: " + Hex.toString(iv) + ", data: " + Hex.toString(data) + ", mac: " + Hex.toString(mac) + "}";
|
return "{ type:" + type + ", requestId: " + Hex.toString(requestId) + ", iv: " + Hex.toString(iv) + ", data: " + Hex.toString(data) + ", mac: " + Hex.toString(mac) + "}";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user