0
0
mirror of https://github.com/signalapp/libsignal.git synced 2024-09-20 03:52:17 +02:00

Merge pull request #45 from signalapp/jack/jni-fixes

Fixes for Android
This commit is contained in:
Jack Lloyd 2020-11-11 13:10:59 -05:00 committed by GitHub
commit 768c264d20
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 2 deletions

View File

@ -7,7 +7,6 @@
package org.whispersystems.libsignal.ecc; package org.whispersystems.libsignal.ecc;
import org.signal.client.internal.Native; import org.signal.client.internal.Native;
import java.math.BigInteger;
import java.util.Arrays; import java.util.Arrays;
public class ECPublicKey implements Comparable<ECPublicKey> { public class ECPublicKey implements Comparable<ECPublicKey> {
@ -24,6 +23,13 @@ public class ECPublicKey implements Comparable<ECPublicKey> {
this.handle = Native.ECPublicKey_Deserialize(serialized, 0); this.handle = Native.ECPublicKey_Deserialize(serialized, 0);
} }
static public ECPublicKey fromPublicKeyBytes(byte[] key) {
byte[] with_type = new byte[33];
with_type[0] = 0x05;
System.arraycopy(key, 0, with_type, 1, 32);
return new ECPublicKey(Native.ECPublicKey_Deserialize(with_type, 0));
}
public ECPublicKey(long nativeHandle) { public ECPublicKey(long nativeHandle) {
if (nativeHandle == 0) { if (nativeHandle == 0) {
throw new NullPointerException(); throw new NullPointerException();

View File

@ -266,7 +266,11 @@ pub unsafe extern "system" fn Java_org_signal_client_internal_Native_HKDF_1Deriv
Some(env.convert_byte_array(salt)?) Some(env.convert_byte_array(salt)?)
}; };
let info = env.convert_byte_array(info)?; let info = if info.is_null() {
vec![]
} else {
env.convert_byte_array(info)?
};
let hkdf = HKDF::new(version)?; let hkdf = HKDF::new(version)?;
let derived = if let Some(salt) = salt { let derived = if let Some(salt) = salt {