From 7e439d030c4f4ac3239dabd86ccfcd4bdc1e5a8a Mon Sep 17 00:00:00 2001 From: Ola Bini Date: Wed, 3 Oct 2018 19:43:39 -0500 Subject: [PATCH] [#163] - The shared prekey pair is optional --- src/prekey_profile.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/prekey_profile.c b/src/prekey_profile.c index 9376af31..a76ed1d0 100644 --- a/src/prekey_profile.c +++ b/src/prekey_profile.c @@ -59,9 +59,14 @@ INTERNAL void otrng_prekey_profile_copy(otrng_prekey_profile_s *destination, otrng_ec_point_copy(destination->shared_prekey, source->shared_prekey); if (destination->keys != NULL) { otrng_shared_prekey_pair_free(destination->keys); + destination->keys = NULL; } - destination->keys = otrng_secure_alloc(sizeof(otrng_shared_prekey_pair_s)); - memcpy(destination->keys, source->keys, sizeof(otrng_shared_prekey_pair_s)); + + if (source->keys != NULL) { + destination->keys = otrng_secure_alloc(sizeof(otrng_shared_prekey_pair_s)); + memcpy(destination->keys, source->keys, sizeof(otrng_shared_prekey_pair_s)); + } + memcpy(destination->signature, source->signature, ED448_SIGNATURE_BYTES); destination->should_publish = source->should_publish;