Device Sender Utilities - Generate Key + Self-Signed Certificate

This commit is contained in:
Jack Lloyd
2021-03-03 17:23:22 -05:00
parent 5f5687ed74
commit 1944d16dec
23 changed files with 686 additions and 44 deletions

View File

@@ -74,6 +74,9 @@ public final class Native {
public static native byte[] Aes256GcmSiv_Encrypt(long aesGcmSiv, byte[] ptext, byte[] nonce, byte[] associatedData);
public static native long Aes256GcmSiv_New(byte[] key);
public static native byte[] DeviceTransfer_GenerateCertificate(byte[] privateKey, String name, int daysToExpire);
public static native byte[] DeviceTransfer_GeneratePrivateKey();
public static native byte[] ECPrivateKey_Agree(long privateKey, long publicKey);
public static native long ECPrivateKey_Deserialize(byte[] data);
public static native void ECPrivateKey_Destroy(long handle);

View File

@@ -0,0 +1,20 @@
//
// Copyright 2021 Signal Messenger, LLC.
// SPDX-License-Identifier: AGPL-3.0-only
//
package org.signal.libsignal.devicetransfer;
import org.signal.client.internal.Native;
class DeviceTransferKey {
byte[] keyMaterial;
DeviceTransferKey() {
this.keyMaterial = Native.DeviceTransfer_GeneratePrivateKey();
}
byte[] generateCertificate(String name, int daysTilExpires) {
return Native.DeviceTransfer_GenerateCertificate(this.keyMaterial, name, daysTilExpires);
}
}