Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Email Attachment Encryption - RSA or AES?

I'm developing an email server from scratch for a custom project. I understand RSA and AES but where I am lost is in handling attachments. I want to send Alice a signed message and I also want to send her an encrypted file attachment. How are attachments typically handled in this scenario?

Thanks in advance!

like image 390
mikelovestar Avatar asked Dec 21 '25 22:12

mikelovestar


1 Answers

Attachments are big files and asymmetric encryption is really slow (i.e. RSA) so it is best to generate an AES key and encrypt it with the RSA public key and then encrypt the attachment with a lot faster AES. Then send both the encrypted key & attachment to the recipient. As only she got the private key, only she can decrypt the AES key thus can decrypt the attachment.

like image 106
Teoman Soygul Avatar answered Dec 24 '25 04:12

Teoman Soygul



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!