From 2fb6dd7c14a6cf8d75485a519e2b7e7f651229ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rodolphe=20Br=C3=A9ard?= Date: Sat, 15 Apr 2023 20:06:15 +0200 Subject: [PATCH] Add the key type in the header --- src/algorithm.rs | 7 +++++++ src/signature.rs | 3 ++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/algorithm.rs b/src/algorithm.rs index 6bd8873..0fd63ab 100644 --- a/src/algorithm.rs +++ b/src/algorithm.rs @@ -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(), diff --git a/src/signature.rs b/src/signature.rs index 13fc5d6..ea96ebc 100644 --- a/src/signature.rs +++ b/src/signature.rs @@ -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,