Add message signing

All messages are now signed by default with a randomly generated key.
TODO still is keyserver stuff, locking down the config file potentially
(or telling users to do it in the readme?), and doing any sort of
verification
This commit is contained in:
2026-05-31 11:09:15 -07:00
parent 1e67b80d10
commit 0f36ee454e
5 changed files with 277 additions and 10 deletions
+9 -1
View File
@@ -1,4 +1,5 @@
use clap::{Parser,Subcommand,ArgAction};
use ed25519_dalek::SigningKey;
use fedichat::client::{ClientMessage,SignedClientMessage,AuthMethod};
use fedichat::ServerAddr;
use fedichat::state::StatePath;
@@ -181,7 +182,7 @@ impl Command {
}
// If a command needs multiple messages, like an auth message first
// then call this
pub fn generate_messages(self,username: String,token: Option<String>)
pub fn generate_messages(self,username: String,token: Option<String>, key: SigningKey)
-> Result<Vec<SignedClientMessage>,MessageError>
{
let mut messages = Vec::with_capacity(2);
@@ -211,6 +212,11 @@ impl Command {
signature: Box::new([0])});
}
// sign all the messages
for message in messages.iter_mut() {
message.sign(key.clone())?;
}
Ok(messages)
}
}
@@ -223,6 +229,8 @@ pub enum MessageError {
UuidError(#[from] uuid::Error),
#[error("Error during file IO: {0}")]
IoError(#[from] std::io::Error),
#[error("Error while processing signature: {0}")]
Signature(#[from] fedichat::client::SignatureError)
}