Page MenuHomePhabricator

D3156.id9553.diff
No OneTemporary

D3156.id9553.diff

diff --git a/native/cpp/CommonCpp/CryptoTools/opaque-ke-cxx/src/lib.rs b/native/cpp/CommonCpp/CryptoTools/opaque-ke-cxx/src/lib.rs
--- a/native/cpp/CommonCpp/CryptoTools/opaque-ke-cxx/src/lib.rs
+++ b/native/cpp/CommonCpp/CryptoTools/opaque-ke-cxx/src/lib.rs
@@ -12,6 +12,7 @@
RegistrationResponse,
};
use rand::rngs::OsRng;
+use std::ops::Deref;
struct Cipher;
@@ -51,6 +52,11 @@
session: Vec<u8>,
}
+ struct ServerKeyPair {
+ public: Vec<u8>,
+ private: Vec<u8>,
+ }
+
extern "Rust" {
fn client_register_cxx(password: String) -> Result<MessageState>;
fn client_register_finish_cxx(
@@ -62,6 +68,7 @@
client_login_state: Vec<u8>,
server_message: Vec<u8>,
) -> Result<MessageSession>;
+ fn server_kp() -> ServerKeyPair;
}
}
@@ -155,6 +162,17 @@
client_login_state.finish(server_message, ClientLoginFinishParameters::default())
}
+fn server_kp() -> ffi::ServerKeyPair {
+ let mut rng = OsRng;
+ let keypair = Cipher::generate_random_keypair(&mut rng);
+ let public_key = keypair.public().deref().to_vec();
+ let private_key = keypair.private().deref().to_vec();
+ ffi::ServerKeyPair {
+ public: public_key,
+ private: private_key,
+ }
+}
+
#[cfg(test)]
mod tests {
use super::*;
@@ -364,4 +382,11 @@
Err(ProtocolError::VerificationError(_))
);
}
+
+ #[test]
+ fn test_server_kp_ok() {
+ let keys = server_kp();
+ assert_eq!(keys.public.len(), 32);
+ assert_eq!(keys.private.len(), 32);
+ }
}

File Metadata

Mime Type
text/plain
Expires
Mon, Nov 18, 10:23 PM (21 h, 52 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2536003
Default Alt Text
D3156.id9553.diff (1 KB)

Event Timeline