Ver Fonte

app: use OsRng.gen() for generating darkirc secret, not rand::random();

darkfi há 3 semanas atrás
pai
commit
113b78289f
3 ficheiros alterados com 4 adições e 4 exclusões
  1. 2 1
      bin/app/src/db.rs
  2. 0 1
      bin/app/src/logger.rs
  3. 2 2
      bin/app/src/plugin/darkirc.rs

+ 2 - 1
bin/app/src/db.rs

@@ -18,6 +18,7 @@
 
 use std::{path::PathBuf, sync::Arc};
 
+use rand::{rngs::OsRng, Rng};
 use smol::lock::Mutex as AsyncMutex;
 use turso::{Connection, Value};
 
@@ -51,7 +52,7 @@ impl AppDb {
         conn.execute_batch(include_str!("../app.sql")).await?;
         // First run: generate the DM identity secret right away. On
         // subsequent runs the row exists and the insert is ignored.
-        let secret: [u8; 32] = rand::random();
+        let secret: [u8; 32] = OsRng.gen();
         conn.execute(
             "INSERT OR IGNORE INTO profiles (id, nick, dm_secret) VALUES (1, 'anon', ?1)",
             vec![Value::Blob(secret.to_vec())],

+ 0 - 1
bin/app/src/logger.rs

@@ -107,7 +107,6 @@ pub fn setup_logging() -> Option<WorkerGuard> {
             AppendCount::new(0),
             ContentLimit::BytesSurpassed(LOGFILE_MAXSIZE),
             Compression::None,
-            #[cfg(unix)]
             None,
         ));
 

+ 2 - 2
bin/app/src/plugin/darkirc.rs

@@ -745,8 +745,8 @@ impl DarkIrc {
                 let public = secret_key.public_key();
                 let saltbox = ChaChaBox::new(&public, &secret_key);
 
-                // Log the secret in base58 for debugging
-                let secret_b58 = bs58::encode(secret).into_string();
+                // The secret in base58 for debugging
+                //let secret_b58 = bs58::encode(secret).into_string();
                 irc_channel.saltbox = Some(Arc::new(saltbox));
             }