From 4a8d628924bcf9fd4af2f39ca8477b33a9599196 Mon Sep 17 00:00:00 2001 From: Marvin W Date: Tue, 12 Feb 2019 15:27:58 -0600 Subject: Do not use signal_protocol_internal.h --- plugins/signal-protocol/src/context.vala | 2 +- plugins/signal-protocol/src/signal_helper.c | 6 ++++-- plugins/signal-protocol/src/signal_helper.h | 1 + plugins/signal-protocol/vapi/signal-protocol-native.vapi | 4 ++-- 4 files changed, 8 insertions(+), 5 deletions(-) (limited to 'plugins/signal-protocol') diff --git a/plugins/signal-protocol/src/context.vala b/plugins/signal-protocol/src/context.vala index c36bf010..87b51756 100644 --- a/plugins/signal-protocol/src/context.vala +++ b/plugins/signal-protocol/src/context.vala @@ -30,7 +30,7 @@ public class Context { } public void randomize(uint8[] data) throws Error { - throw_by_code(Signal.native_random(native_context, data)); + throw_by_code(Signal.native_random(data)); } public SignedPreKeyRecord generate_signed_pre_key(IdentityKeyPair identity_key_pair, int32 id, uint64 timestamp = 0) throws Error { diff --git a/plugins/signal-protocol/src/signal_helper.c b/plugins/signal-protocol/src/signal_helper.c index 3630d6d6..9f313475 100644 --- a/plugins/signal-protocol/src/signal_helper.c +++ b/plugins/signal-protocol/src/signal_helper.c @@ -1,5 +1,4 @@ #include -#include #include @@ -78,7 +77,10 @@ session_signed_pre_key* session_signed_pre_key_new(uint32_t id, uint64_t timesta return res; } - +int signal_vala_randomize(uint8_t *data, size_t len) { + gcry_randomize(data, len, GCRY_STRONG_RANDOM); + return SG_SUCCESS; +} int signal_vala_random_generator(uint8_t *data, size_t len, void *user_data) { gcry_randomize(data, len, GCRY_STRONG_RANDOM); diff --git a/plugins/signal-protocol/src/signal_helper.h b/plugins/signal-protocol/src/signal_helper.h index 819b399b..2c2c983f 100644 --- a/plugins/signal-protocol/src/signal_helper.h +++ b/plugins/signal-protocol/src/signal_helper.h @@ -20,6 +20,7 @@ int32_t signal_protocol_address_get_device_id(signal_protocol_address* self); session_pre_key* session_pre_key_new(uint32_t pre_key_id, ec_key_pair* pair, int* err); session_signed_pre_key* session_signed_pre_key_new(uint32_t id, uint64_t timestamp, ec_key_pair* pair, uint8_t* key, int key_len, int* err); +int signal_vala_randomize(uint8_t *data, size_t len); int signal_vala_random_generator(uint8_t *data, size_t len, void *user_data); int signal_vala_hmac_sha256_init(void **hmac_context, const uint8_t *key, size_t key_len, void *user_data); int signal_vala_hmac_sha256_update(void *hmac_context, const uint8_t *data, size_t data_len, void *user_data); diff --git a/plugins/signal-protocol/vapi/signal-protocol-native.vapi b/plugins/signal-protocol/vapi/signal-protocol-native.vapi index 9161a3ed..72ba1710 100644 --- a/plugins/signal-protocol/vapi/signal-protocol-native.vapi +++ b/plugins/signal-protocol/vapi/signal-protocol-native.vapi @@ -269,6 +269,6 @@ namespace Signal { [CCode (cname = "setup_signal_vala_crypto_provider", cheader_filename = "signal_helper.h")] public static void setup_crypto_provider(NativeContext context); - [CCode (cname = "signal_crypto_random", cheader_filename = "signal_protocol_internal.h")] - public static int native_random(NativeContext context, uint8[] data); + [CCode (cname = "signal_vala_randomize", cheader_filename = "signal_helper.h")] + public static int native_random(uint8[] data); } -- cgit v1.2.3-70-g09d2