Add the key type in the header

This commit is contained in:
Rodolphe Bréard 2023-04-15 20:06:15 +02:00
parent cd55e5cb83
commit 2fb6dd7c14
2 changed files with 9 additions and 1 deletions

View file

@ -28,6 +28,13 @@ impl Algorithm {
}
}
pub fn key_type(&self) -> String {
match self {
Self::Ed25519Sha256 => String::from("ed25519"),
Self::Rsa2048Sha256 | Self::Rsa3072Sha256 | Self::Rsa4096Sha256 => String::from("rsa"),
}
}
pub fn gen_keys(&self) -> (String, String) {
match self {
Self::Ed25519Sha256 => gen_ed25519_kp(),

View file

@ -43,8 +43,9 @@ impl Signature {
pub fn get_header(&self) -> String {
format!(
"DKIM-Signature: v=1; a={algorithm}; c={canonicalization}; d={sdid};\r\n\tt={timestamp}; s={selector};\r\n\th={headers};\r\n\tbh={body_hash};\r\n\tb={signature}",
"DKIM-Signature: v=1; a={algorithm}; c={canonicalization}; k={key_type};\r\n\tt={timestamp}; d={sdid};\r\n\ts={selector};\r\n\th={headers};\r\n\tbh={body_hash};\r\n\tb={signature}",
algorithm=self.algorithm.display(),
key_type=self.algorithm.key_type(),
canonicalization=self.canonicalization.to_string(),
selector=self.selector,
sdid=self.sdid,