From e1113f0052753de659979c071c42ca2f3771cf37 Mon Sep 17 00:00:00 2001 From: Florian Brandes Date: Sat, 6 Jul 2024 08:17:22 +0200 Subject: [PATCH] use aes_256 instead of des Signed-off-by: Florian Brandes --- smtprd_ng/smtprd.py | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/smtprd_ng/smtprd.py b/smtprd_ng/smtprd.py index 0d21337..61f7736 100644 --- a/smtprd_ng/smtprd.py +++ b/smtprd_ng/smtprd.py @@ -172,13 +172,7 @@ class SMTPClient(SMTP): Returns: bytes: Encrypted message """ - # Make a MemoryBuffer of the message. buf = BIO.MemoryBuffer(message) - - # Seed the PRNG. - # Rand.load_file('randpool.dat', -1) - - # Instantiate an SMIME object. s = SMIME.SMIME() # Load target cert to encrypt to. @@ -187,9 +181,7 @@ class SMTPClient(SMTP): sk.push(x509) s.set_x509_stack(sk) - # Set cipher: 3-key triple-DES in CBC mode. - # TODO: Evaluate later - s.set_cipher(SMIME.Cipher("des_ede3_cbc")) + s.set_cipher(SMIME.Cipher("aes_256_cbc")) # Encrypt the buffer. p7 = s.encrypt(buf) @@ -197,16 +189,12 @@ class SMTPClient(SMTP): # Output p7 in mail-friendly format. out = BIO.MemoryBuffer() + # Add header out.write("From: " + self._config.sender + "\r\n") out.write("To: " + ", ".join(self._config.recipients) + "\r\n") out.write("Subject: " + subject + "\r\n") s.write(out, p7) - # print(out.read().decode()) - - # Save the PRNG's state. - # Rand.save_file('randpool.dat') - return out.read() def _sign(self, message: Message) -> bytes: