فهرست منبع

darkirc: Implement --gen-secret

parazyd 3 سال پیش
والد
کامیت
5b21ae1c4a
3فایلهای تغییر یافته به همراه13 افزوده شده و 0 حذف شده
  1. 2 0
      bin/darkirc/darkirc_config.toml
  2. 7 0
      bin/darkirc/src/main.rs
  3. 4 0
      bin/darkirc/src/settings.rs

+ 2 - 0
bin/darkirc/darkirc_config.toml

@@ -45,6 +45,8 @@ transport_mixing = false
 ## ====================
 ##
 ## You can create a shared secret with `darkirc --gen-secret`.
+## Never share this secret over unencrypted channels or with someone
+## who you do not want to be able to read all the channel messages.
 ## Use it like this example:
 #[channel."#foo"]
 #secret = "7CkVuFgwTUpJn5Sv67Q3fyEDpa28yrSeL5Hg2GqQ4jfM"

+ 7 - 0
bin/darkirc/src/main.rs

@@ -85,6 +85,13 @@ async fn realmain(settings: Args, executor: Arc<smol::Executor<'_>>) -> Result<(
         return Ok(())
     }
 
+    if settings.gen_secret {
+        let secret_key = crypto_box::SecretKey::generate(&mut OsRng);
+        let encoded = bs58::encode(secret_key.to_bytes());
+        println!("{}", encoded.into_string());
+        return Ok(())
+    }
+
     ////////////////////
     // Initialize the base structures
     ////////////////////

+ 4 - 0
bin/darkirc/src/settings.rs

@@ -71,6 +71,10 @@ pub struct Args {
     #[structopt(long)]
     pub gen_keypair: bool,
 
+    /// Generate a new NaCl secret for an encrypted channel and exit
+    #[structopt(long)]
+    pub gen_secret: bool,
+
     /// Path to save keypair in
     #[structopt(short)]
     pub output: Option<String>,