mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-19 09:00:54 +00:00
stub libsignal::generate_identity_key_pair()
This commit is contained in:
parent
96e1b49cb2
commit
8951a6d72f
2 changed files with 61 additions and 2 deletions
|
|
@ -1,4 +1,5 @@
|
||||||
mod group_permission;
|
mod group_permission;
|
||||||
|
mod libsignal; // stub
|
||||||
mod link_state;
|
mod link_state;
|
||||||
mod signal_ws;
|
mod signal_ws;
|
||||||
mod trust_mode;
|
mod trust_mode;
|
||||||
|
|
@ -155,10 +156,11 @@ impl Manager {
|
||||||
Ok(Message::Binary(uuid)) => {
|
Ok(Message::Binary(uuid)) => {
|
||||||
log::info!("raw uuid ProtoBuffer: {:?}", uuid);
|
log::info!("raw uuid ProtoBuffer: {:?}", uuid);
|
||||||
let uuid = "TODO decode uuid ProtoBuffer";
|
let uuid = "TODO decode uuid ProtoBuffer";
|
||||||
let pub_key = "TODO generateIdentityKeyPair()";
|
let identity_key_pair = libsignal::generate_identity_key_pair();
|
||||||
|
let pub_key = identity_key_pair.djb_identity_key.key.clone();
|
||||||
match url::Url::parse_with_params(
|
match url::Url::parse_with_params(
|
||||||
"sgnl://linkdevice",
|
"sgnl://linkdevice",
|
||||||
&[("uuid", &uuid), ("pub_key", &pub_key)],
|
&[("uuid", &uuid), ("pub_key", &pub_key.as_str())],
|
||||||
) {
|
) {
|
||||||
Ok(device_link_uri) => {
|
Ok(device_link_uri) => {
|
||||||
log::info!("device_link_uri: {device_link_uri}");
|
log::info!("device_link_uri: {device_link_uri}");
|
||||||
|
|
|
||||||
57
apps/sigchat/src/manager/libsignal.rs
Normal file
57
apps/sigchat/src/manager/libsignal.rs
Normal file
|
|
@ -0,0 +1,57 @@
|
||||||
|
// this is a stub for a wrapped libsignal
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// use org.signal.libsignal.protocol.IdentityKey;
|
||||||
|
pub struct IdentityKey {
|
||||||
|
pub key:String,
|
||||||
|
}
|
||||||
|
impl IdentityKey {
|
||||||
|
pub fn new(key: String) -> Self {
|
||||||
|
IdentityKey {key}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn clone(&self) -> IdentityKey {
|
||||||
|
IdentityKey::new(self.key.clone())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// use org.signal.libsignal.protocol.IdentityKeyPair;
|
||||||
|
pub struct IdentityKeyPair {
|
||||||
|
pub djb_identity_key: IdentityKey,
|
||||||
|
pub djb_private_key: IdentityKey,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// use org.signal.libsignal.protocol.ecc.Curve;
|
||||||
|
pub struct Curve {}
|
||||||
|
impl Curve {
|
||||||
|
pub fn generate_key_pair() -> DjbKeyPair {
|
||||||
|
DjbKeyPair {
|
||||||
|
djb_private_key: IdentityKey::new("STUB privateIdentityKey".to_string()),
|
||||||
|
djb_public_key: IdentityKey::new("STUB publicIdentityKey".to_string()),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct DjbKeyPair {
|
||||||
|
djb_private_key: IdentityKey,
|
||||||
|
djb_public_key: IdentityKey,
|
||||||
|
}
|
||||||
|
impl DjbKeyPair {
|
||||||
|
pub fn get_private_key(&self) -> IdentityKey {
|
||||||
|
self.djb_private_key.clone()
|
||||||
|
}
|
||||||
|
pub fn get_public_key(&self) -> IdentityKey {
|
||||||
|
self.djb_public_key.clone()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// https://github.com/AsamK/signal-cli/blob/375bdb79485ec90beb9a154112821a4657740b7a/lib/src/main/java/org/asamk/signal/manager/util/KeyUtils.java#L45-L51
|
||||||
|
pub fn generate_identity_key_pair() -> IdentityKeyPair {
|
||||||
|
let djb_key_pair = Curve::generate_key_pair();
|
||||||
|
let djb_identity_key = IdentityKey::new(djb_key_pair.get_public_key().key);
|
||||||
|
let djb_private_key = djb_key_pair.get_private_key();
|
||||||
|
IdentityKeyPair { djb_identity_key, djb_private_key }
|
||||||
|
}
|
||||||
Loading…
Reference in a new issue