wireguard-control: {generate => get}_public()
parent
80a070baae
commit
c4c34d5c10
|
@ -535,7 +535,7 @@ async fn serve(
|
|||
num_candidates
|
||||
);
|
||||
|
||||
let public_key = wireguard_control::Key::from_base64(&config.private_key)?.generate_public();
|
||||
let public_key = wireguard_control::Key::from_base64(&config.private_key)?.get_public();
|
||||
let db = Arc::new(Mutex::new(conn));
|
||||
let endpoints = spawn_endpoint_refresher(interface, network);
|
||||
spawn_expired_invite_sweeper(db.clone());
|
||||
|
@ -720,7 +720,7 @@ mod tests {
|
|||
async fn test_incorrect_public_key() -> Result<(), Error> {
|
||||
let server = test::Server::new()?;
|
||||
|
||||
let key = Key::generate_private().generate_public();
|
||||
let key = Key::generate_private().get_public();
|
||||
|
||||
let path = if cfg!(feature = "v6-test") {
|
||||
format!("http://[{}]/v1/admin/peers", test::WG_MANAGE_PEER_IP)
|
||||
|
|
|
@ -83,7 +83,7 @@ impl Server {
|
|||
let test_dir = tempfile::tempdir()?;
|
||||
let test_dir_path = test_dir.path();
|
||||
|
||||
let public_key = Key::generate_private().generate_public();
|
||||
let public_key = Key::generate_private().get_public();
|
||||
// Run the init wizard to initialize the database and create basic
|
||||
// cidrs and peers.
|
||||
let interface = "test".to_string();
|
||||
|
|
|
@ -139,7 +139,7 @@ impl InterfaceConfig {
|
|||
impl InterfaceInfo {
|
||||
pub fn public_key(&self) -> Result<String, Error> {
|
||||
Ok(wireguard_control::Key::from_base64(&self.private_key)?
|
||||
.generate_public()
|
||||
.get_public()
|
||||
.to_base64())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -149,7 +149,7 @@ impl ConfigParser {
|
|||
.device_info
|
||||
.private_key
|
||||
.as_ref()
|
||||
.map(|k| k.generate_public());
|
||||
.map(|k| k.get_public());
|
||||
},
|
||||
"listen_port" => {
|
||||
self.device_info.listen_port = Some(value.parse().map_err(|_| InvalidData)?)
|
||||
|
|
|
@ -56,7 +56,7 @@ impl Key {
|
|||
|
||||
/// Generates a public key for this private key.
|
||||
#[must_use]
|
||||
pub fn generate_public(&self) -> Self {
|
||||
pub fn get_public(&self) -> Self {
|
||||
use curve25519_dalek::scalar::Scalar;
|
||||
|
||||
use curve25519_dalek::constants::ED25519_BASEPOINT_TABLE;
|
||||
|
@ -115,7 +115,7 @@ mod test {
|
|||
let pubkey = "DD5yKRfzExcV5+kDnTroDgCU15latdMjiQ59j1hEuk8=";
|
||||
|
||||
let private = Key::from_base64(privkey).unwrap();
|
||||
let public = Key::generate_public(&private);
|
||||
let public = Key::get_public(&private);
|
||||
|
||||
assert_eq!(public.to_base64(), pubkey);
|
||||
}
|
||||
|
@ -164,12 +164,12 @@ impl fmt::Debug for Key {
|
|||
impl KeyPair {
|
||||
pub fn generate() -> Self {
|
||||
let private = Key::generate_private();
|
||||
let public = private.generate_public();
|
||||
let public = private.get_public();
|
||||
KeyPair { private, public }
|
||||
}
|
||||
|
||||
pub fn from_private(key: Key) -> Self {
|
||||
let public = key.generate_public();
|
||||
let public = key.get_public();
|
||||
KeyPair {
|
||||
private: key,
|
||||
public,
|
||||
|
@ -216,7 +216,7 @@ mod tests {
|
|||
use crate::key::Key;
|
||||
|
||||
let privkey = Key::generate_private();
|
||||
let pubkey = privkey.generate_public();
|
||||
let pubkey = privkey.get_public();
|
||||
|
||||
assert_ne!(privkey, pubkey);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue