mirror of
https://github.com/profanity-im/profanity.git
synced 2025-01-03 14:57:42 -05:00
Create signal session
This commit is contained in:
parent
f9216fddb1
commit
b1ae220aa4
@ -249,15 +249,30 @@ omemo_set_device_list(const char *const jid, GList * device_list)
|
||||
}
|
||||
|
||||
void
|
||||
omemo_start_device_session(const char *const jid, uint32_t device_id, const unsigned char *const prekey, size_t prekey_len)
|
||||
omemo_start_device_session(const char *const jid, uint32_t device_id,
|
||||
uint32_t prekey_id, const unsigned char *const prekey_raw, size_t prekey_len,
|
||||
uint32_t signed_prekey_id, const unsigned char *const signed_prekey_raw,
|
||||
size_t signed_prekey_len, const unsigned char *const signature,
|
||||
size_t signature_len, const unsigned char *const identity_key_raw,
|
||||
size_t identity_key_len)
|
||||
{
|
||||
session_pre_key_bundle *bundle;
|
||||
signal_protocol_address address = {
|
||||
jid, strlen(jid), device_id
|
||||
};
|
||||
|
||||
session_builder *builder;
|
||||
session_builder_create(&builder, omemo_ctx.store, &address, omemo_ctx.signal);
|
||||
//session_builder_process_pre_key_bundle(builder, prekey);
|
||||
|
||||
ec_public_key *prekey;
|
||||
curve_decode_point(&prekey, prekey_raw, prekey_len, omemo_ctx.signal);
|
||||
ec_public_key *signed_prekey;
|
||||
curve_decode_point(&signed_prekey, signed_prekey_raw, signed_prekey_len, omemo_ctx.signal);
|
||||
ec_public_key *identity_key;
|
||||
curve_decode_point(&identity_key, identity_key_raw, identity_key_len, omemo_ctx.signal);
|
||||
|
||||
session_pre_key_bundle_create(&bundle, 0, device_id, prekey_id, prekey, signed_prekey_id, signed_prekey, signature, signature_len, identity_key);
|
||||
session_builder_process_pre_key_bundle(builder, bundle);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -15,6 +15,6 @@ void omemo_prekeys(GList **prekeys, GList **ids, GList **lengths);
|
||||
void omemo_set_device_list(const char *const jid, GList * device_list);
|
||||
|
||||
void omemo_start_session(const char *const barejid);
|
||||
void omemo_start_device_session(const char *const jid, uint32_t device_id, const unsigned char *const prekey, size_t prekey_len);
|
||||
void omemo_start_device_session(const char *const jid, uint32_t device_id, uint32_t prekey_id, const unsigned char *const prekey, size_t prekey_len, uint32_t signed_prekey_id, const unsigned char *const signed_prekey, size_t signed_prekey_len, const unsigned char *const signature, size_t signature_len, const unsigned char *const identity_key, size_t identity_key_len);
|
||||
|
||||
gboolean omemo_loaded(void);
|
||||
|
@ -134,16 +134,60 @@ omemo_start_device_session_handle_bundle(xmpp_stanza_t *const stanza, void *cons
|
||||
if (!prekey) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
const char *prekey_id_text = xmpp_stanza_get_attribute(prekey, "preKeyId");
|
||||
if (!prekey_id_text) {
|
||||
return 1;
|
||||
}
|
||||
uint32_t prekey_id = strtoul(prekey_id_text, NULL, 10);
|
||||
xmpp_stanza_t *prekey_text = xmpp_stanza_get_children(prekey);
|
||||
if (!prekey_text) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
size_t prekey_len;
|
||||
unsigned char *prekey_raw = g_base64_decode(xmpp_stanza_get_text(prekey_text), &prekey_len);
|
||||
|
||||
omemo_start_device_session(from, device_id, prekey_raw, prekey_len);
|
||||
xmpp_stanza_t *signed_prekey = xmpp_stanza_get_child_by_name(bundle, "signedPreKeyPublic");
|
||||
if (!signed_prekey) {
|
||||
return 1;
|
||||
}
|
||||
const char *signed_prekey_id_text = xmpp_stanza_get_attribute(signed_prekey, "signedPreKeyId");
|
||||
if (!signed_prekey_id_text) {
|
||||
return 1;
|
||||
}
|
||||
uint32_t signed_prekey_id = strtoul(signed_prekey_id_text, NULL, 10);
|
||||
xmpp_stanza_t *signed_prekey_text = xmpp_stanza_get_children(signed_prekey);
|
||||
if (!signed_prekey_text) {
|
||||
return 1;
|
||||
}
|
||||
size_t signed_prekey_len;
|
||||
unsigned char *signed_prekey_raw = g_base64_decode(xmpp_stanza_get_text(signed_prekey_text), &signed_prekey_len);
|
||||
|
||||
xmpp_stanza_t *signed_prekey_signature = xmpp_stanza_get_child_by_name(bundle, "signedPreKeySignature");
|
||||
if (!signed_prekey_signature) {
|
||||
return 1;
|
||||
}
|
||||
xmpp_stanza_t *signed_prekey_signature_text = xmpp_stanza_get_children(signed_prekey_signature);
|
||||
if (!signed_prekey_signature_text) {
|
||||
return 1;
|
||||
}
|
||||
size_t signed_prekey_signature_len;
|
||||
unsigned char *signed_prekey_signature_raw = g_base64_decode(xmpp_stanza_get_text(signed_prekey_signature_text), &signed_prekey_signature_len);
|
||||
|
||||
xmpp_stanza_t *identity_key = xmpp_stanza_get_child_by_name(bundle, "identityKey");
|
||||
if (!identity_key) {
|
||||
return 1;
|
||||
}
|
||||
xmpp_stanza_t *identity_key_text = xmpp_stanza_get_children(identity_key);
|
||||
if (!identity_key_text) {
|
||||
return 1;
|
||||
}
|
||||
size_t identity_key_len;
|
||||
unsigned char *identity_key_raw = g_base64_decode(xmpp_stanza_get_text(identity_key_text), &identity_key_len);
|
||||
|
||||
omemo_start_device_session(from, device_id, prekey_id, prekey_raw,
|
||||
prekey_len, signed_prekey_id, signed_prekey_raw, signed_prekey_len,
|
||||
signed_prekey_signature_raw, signed_prekey_signature_len,
|
||||
identity_key_raw, identity_key_len);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user