{"id":380,"date":"2026-11-14T11:50:00","date_gmt":"2026-11-14T11:50:00","guid":{"rendered":"https:\/\/backendside.com\/blog\/?p=380"},"modified":"2026-11-21T12:13:30","modified_gmt":"2026-11-21T12:13:30","slug":"symmetric-vs-public-key-encryption-rsa-key-exchange","status":"publish","type":"post","link":"https:\/\/backendside.com\/blog\/2026\/11\/14\/symmetric-vs-public-key-encryption-rsa-key-exchange\/","title":{"rendered":"Symmetric vs Public-Key Encryption: How RSA and Key Exchange Fit Together"},"content":{"rendered":"<p class=\"lead\">Every encrypted connection and encrypted file you use relies on two very different kinds of cryptography working together. <strong>Symmetric<\/strong> encryption is fast and simple but needs both sides to already share a secret. <strong>Public-key<\/strong> (asymmetric) cryptography lets strangers communicate securely without a shared secret, but it is slow and awkward for bulk data. Understanding how they fit together &mdash; RSA, Diffie-Hellman, hybrid encryption, forward secrecy &mdash; explains what is actually happening when you see a padlock in your browser or encrypt a file for a colleague.<\/p>\n<h2>Symmetric encryption: one key, both directions<\/h2>\n<p>In symmetric encryption the same key encrypts and decrypts. Today that means <strong>AES<\/strong> (with 128- or 256-bit keys) or <strong>ChaCha20<\/strong> (256-bit keys), usually in an authenticated mode such as AES-GCM or ChaCha20-Poly1305 so tampering is detected. These ciphers are extremely fast &mdash; gigabytes per second on a modern CPU &mdash; and a 128-bit key is already far beyond brute force.<\/p>\n<p>The catch is the <strong>key distribution problem<\/strong>. If you want to send an encrypted file to someone, they need the key. How do you get it to them? Emailing it alongside the file defeats the purpose. Reading it over the phone works for two people, but not for a website with millions of visitors who have never met it before.<\/p>\n<p>There is one situation where this problem disappears: when the person encrypting and the person decrypting are <strong>the same person<\/strong>. Encrypting your own files on your own PC is a pure symmetric problem. The usual approach is to derive the key from a password with a slow, salted key-derivation function (PBKDF2, scrypt or Argon2), so the password itself never needs to be stored.<\/p>\n<div style=\"border:1px solid #c5d3f8;background:linear-gradient(135deg,#eef2fd 0%,#ffffff 72%);border-radius:14px;padding:1.5rem 1.65rem;margin:2rem 0;\">\n<div style=\"font-size:.7rem;font-weight:700;letter-spacing:.08em;text-transform:uppercase;color:#2d5be3;margin-bottom:.55rem;\">&#128295; BackendSide Tool<\/div>\n<h4 style=\"margin:0 0 .45rem;font-size:1.15rem;color:#1a1916;font-weight:700;\">SafeViewer &mdash; Symmetric Encryption, Done for You<\/h4>\n<p style=\"margin:0 0 1.05rem;color:#3d3c38;font-size:.92rem;line-height:1.65;\">When the only person who needs to open your files is you, there is no key-exchange problem to solve. <strong>SafeViewer<\/strong> protects every file with <strong>authenticated AES-256<\/strong> under a key derived from your session password, with unique encryption data per file. The key lives only in memory and is discarded when you close the app, and images, PDFs, Office documents and video open in built-in viewers without ever writing the readable content to disk.<\/p>\n<p>  <a href=\"https:\/\/backendside.com\/safeviewer.php\" style=\"display:inline-flex;align-items:center;gap:.4rem;background:#2d5be3;color:#ffffff;font-weight:600;font-size:.85rem;padding:.6rem 1.2rem;border-radius:6px;text-decoration:none;\">Explore SafeViewer &rarr;<\/a>\n<\/div>\n<h2>Public-key cryptography: two keys, two jobs<\/h2>\n<p>Public-key cryptography gives each party a <strong>key pair<\/strong>: a <em>public key<\/em> that can be published to the whole world, and a <em>private key<\/em> that never leaves its owner. The two are mathematically linked, but deriving the private key from the public key is computationally infeasible. That enables two separate operations:<\/p>\n<table>\n<thead>\n<tr>\n<th>Operation<\/th>\n<th>Uses<\/th>\n<th>Guarantees<\/th>\n<th>Modern schemes<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>Encryption \/ key transport<\/td>\n<td>Recipient&rsquo;s <strong>public<\/strong> key to encrypt, their <strong>private<\/strong> key to decrypt<\/td>\n<td>Only the recipient can read it<\/td>\n<td>RSA-OAEP, ECIES-style schemes, ML-KEM<\/td>\n<\/tr>\n<tr>\n<td>Digital signature<\/td>\n<td>Signer&rsquo;s <strong>private<\/strong> key to sign, their <strong>public<\/strong> key to verify<\/td>\n<td>It came from the key holder and was not altered<\/td>\n<td>RSA-PSS, ECDSA, Ed25519<\/td>\n<\/tr>\n<tr>\n<td>Key agreement<\/td>\n<td>Each side&rsquo;s private key + the other&rsquo;s public key<\/td>\n<td>Both derive the same shared secret<\/td>\n<td>ECDH with X25519 or P-256<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>RSA<\/h3>\n<p><strong>RSA<\/strong> rests on the difficulty of factoring the product of two large primes. To encrypt with RSA you must use a padding scheme; textbook RSA without padding is deterministic and malleable. The modern choice is <strong>RSA-OAEP<\/strong> for encryption and <strong>RSA-PSS<\/strong> for signatures. The older PKCS#1 v1.5 encryption padding is the source of the long-running family of Bleichenbacher padding-oracle attacks and should be avoided in new designs.<\/p>\n<p>RSA is slow, and it can only encrypt a message smaller than its key &mdash; a 3072-bit key with OAEP-SHA256 can carry at most a few hundred bytes. That is plenty for a symmetric key, and nowhere near enough for a file. Hold that thought.<\/p>\n<h3>Diffie-Hellman and X25519<\/h3>\n<p><strong>Diffie-Hellman<\/strong> key agreement works differently: neither side sends a secret at all. Each side generates a key pair, they swap public keys, and each combines its own private key with the other&rsquo;s public key. The maths guarantees both arrive at the same shared secret, while an eavesdropper who saw both public keys cannot compute it. The elliptic-curve version, <strong>ECDH<\/strong>, is fast and compact; <strong>X25519<\/strong> (Curve25519) is the most common curve today, used in TLS 1.3, SSH, Signal and WireGuard.<\/p>\n<p>You can watch this happen with OpenSSL (included with Git for Windows):<\/p>\n<pre style=\"background:#1e1d1b;color:#eceae6;padding:1rem 1.15rem;border-radius:8px;overflow-x:auto;font-size:.85rem;line-height:1.5;\"><code># Alice and Bob each make an X25519 key pair\nopenssl genpkey -algorithm X25519 -out alice.pem\nopenssl genpkey -algorithm X25519 -out bob.pem\nopenssl pkey -in alice.pem -pubout -out alice_pub.pem\nopenssl pkey -in bob.pem   -pubout -out bob_pub.pem\n\n# Each derives the shared secret from own private key + the other's public key\nopenssl pkeyutl -derive -inkey alice.pem -peerkey bob_pub.pem   -out alice_secret.bin\nopenssl pkeyutl -derive -inkey bob.pem   -peerkey alice_pub.pem -out bob_secret.bin\n\n# Compare (Command Prompt): identical, yet the secret never crossed the wire\nfc \/b alice_secret.bin bob_secret.bin<\/code><\/pre>\n<p>A raw shared secret like this is never used directly as an encryption key. It is fed through a key-derivation function such as HKDF to produce properly formatted symmetric keys.<\/p>\n<h2>Hybrid encryption: how the two fit together<\/h2>\n<p>Real systems almost never encrypt data with RSA or ECC directly. They use <strong>hybrid encryption<\/strong>: public-key cryptography moves a small random symmetric key, and the symmetric cipher does the heavy lifting.<\/p>\n<pre style=\"background:#1e1d1b;color:#eceae6;padding:1rem 1.15rem;border-radius:8px;overflow-x:auto;font-size:.85rem;line-height:1.5;\"><code>Sender                                         Recipient\n------                                         ---------\nfile_key = 32 random bytes\nciphertext = AES-256-GCM(file_key, file)\nwrapped   = RSA-OAEP(recipient_public, file_key)\nsend: wrapped || ciphertext   ------------&gt;    file_key = RSA-OAEP-Decrypt(private, wrapped)\n                                               file = AES-256-GCM-Decrypt(file_key, ciphertext)<\/code><\/pre>\n<p>You get the best of both: any-size files at symmetric speed, with no shared secret arranged in advance. Sending to several people is cheap &mdash; encrypt the file once, then wrap the same file key separately for each recipient&rsquo;s public key. This is the pattern behind PGP and S\/MIME email encryption, and it is how most &ldquo;encrypt for a contact&rdquo; features in file-encryption tools work. With ECC instead of RSA, the sender generates a throwaway key pair, runs ECDH against the recipient&rsquo;s public key, and derives the file key from the result.<\/p>\n<div style=\"border:1px solid #c5d3f8;background:linear-gradient(135deg,#eef2fd 0%,#ffffff 72%);border-radius:14px;padding:1.5rem 1.65rem;margin:2rem 0;\">\n<div style=\"font-size:.7rem;font-weight:700;letter-spacing:.08em;text-transform:uppercase;color:#2d5be3;margin-bottom:.55rem;\">&#128295; Also from BackendSide<\/div>\n<h4 style=\"margin:0 0 .45rem;font-size:1.15rem;color:#1a1916;font-weight:700;\">EncryptEngine &mdash; When You Need to Send a File to Someone Else<\/h4>\n<p style=\"margin:0 0 1.05rem;color:#3d3c38;font-size:.92rem;line-height:1.65;\">For the sharing case, <strong>EncryptEngine<\/strong> is a free, offline Windows tool built on the same ideas covered here. It creates a personal <strong>RSA-3072 identity<\/strong> automatically, keeps the public keys of people you trust in a contacts book &mdash; with each contact&rsquo;s <strong>key fingerprint<\/strong> shown before you encrypt &mdash; and protects content with authenticated <strong>AES-256-GCM or ChaCha20-Poly1305<\/strong>. Password mode uses salted PBKDF2-SHA256, and your private key is sealed to your Windows account at rest.<\/p>\n<p>  <a href=\"https:\/\/backendside.com\/encryptengine.php\" style=\"display:inline-flex;align-items:center;gap:.4rem;background:#2d5be3;color:#ffffff;font-weight:600;font-size:.85rem;padding:.6rem 1.2rem;border-radius:6px;text-decoration:none;\">Explore EncryptEngine &rarr;<\/a>\n<\/div>\n<h2>Forward secrecy: why TLS 1.3 dropped RSA key transport<\/h2>\n<p>Older TLS versions let the browser pick a session key and encrypt it with the server&rsquo;s long-term RSA public key. It works, but it has a nasty property: anyone who records today&rsquo;s traffic and steals the server&rsquo;s private key years later can unwrap every recorded session key and decrypt everything.<\/p>\n<p><strong>Forward secrecy<\/strong> fixes that. In TLS 1.3, every connection performs a fresh <em>ephemeral<\/em> ECDH exchange (ECDHE); the key pairs are thrown away when the handshake ends. The server&rsquo;s long-term key is used only to <strong>sign<\/strong> the handshake, proving the server is genuine. Steal that key later and you can impersonate the server going forward, but you cannot decrypt past sessions, because the ephemeral secrets no longer exist anywhere. TLS 1.3 removed static RSA key transport entirely for this reason.<\/p>\n<p>The same thinking is now extending to quantum resistance. Browsers and servers are rolling out <strong>hybrid post-quantum key exchange<\/strong> that combines X25519 with ML-KEM (standardised by NIST in 2024), so that recorded traffic stays safe even if large quantum computers eventually break elliptic curves.<\/p>\n<h2>Key sizes: comparing apples to apples<\/h2>\n<p>Symmetric and public-key sizes are not comparable number-for-number. Roughly equivalent classical security levels, following NIST guidance:<\/p>\n<table>\n<thead>\n<tr>\n<th>Security level<\/th>\n<th>Symmetric<\/th>\n<th>RSA<\/th>\n<th>Elliptic curve<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>112-bit (legacy minimum)<\/td>\n<td>&mdash;<\/td>\n<td>2048-bit<\/td>\n<td>224-bit<\/td>\n<\/tr>\n<tr>\n<td>128-bit<\/td>\n<td>AES-128<\/td>\n<td>3072-bit<\/td>\n<td>256-bit (X25519, P-256)<\/td>\n<\/tr>\n<tr>\n<td>192-bit<\/td>\n<td>AES-192<\/td>\n<td>7680-bit<\/td>\n<td>384-bit<\/td>\n<\/tr>\n<tr>\n<td>256-bit<\/td>\n<td>AES-256<\/td>\n<td>15360-bit<\/td>\n<td>512-bit class<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>This is why ECC has taken over new designs: a 32-byte X25519 key gives the same strength as a 384-byte RSA-3072 key, with far faster operations.<\/p>\n<h2>The part people forget: trusting the public key<\/h2>\n<p>Public-key encryption only helps if the public key really belongs to the person you think it does. An attacker who swaps their own key in &mdash; a <strong>man-in-the-middle<\/strong> &mdash; can read everything and re-encrypt it onward. Systems solve this in different ways: certificate authorities vouch for website keys, SSH warns you when a host key changes, and messaging and file tools show a <strong>fingerprint<\/strong> (a short hash of the key) that you can compare with the other person over a separate channel. If you want to dig into how those fingerprints are built, see <a href=\"https:\/\/backendside.com\/blog\/2026\/06\/12\/understanding-sha256-why-it-matters\/\">Understanding SHA-256 and why it matters<\/a>.<\/p>\n<h2>Which do you need?<\/h2>\n<ul>\n<li><strong>Protecting your own files on your own machine:<\/strong> symmetric encryption with a strong, password-derived key. No key pairs required.<\/li>\n<li><strong>Sending a file to a specific person:<\/strong> hybrid encryption to their verified public key.<\/li>\n<li><strong>Secure connections:<\/strong> ephemeral ECDH for forward secrecy, signatures for authentication, AEAD for the data.<\/li>\n<\/ul>\n<p>For the first case, a tool that handles the whole lifecycle locally is the simplest answer. <strong>SafeViewer<\/strong> encrypts files in place or into the folder you are browsing, detects tampering when you open them, and opens them in built-in in-memory viewers &mdash; and with no password recovery, your password truly is the only key.<\/p>\n<div style=\"border:1px solid #c5d3f8;background:linear-gradient(135deg,#eef2fd 0%,#ffffff 72%);border-radius:14px;padding:1.5rem 1.65rem;margin:2rem 0;\">\n<div style=\"font-size:.7rem;font-weight:700;letter-spacing:.08em;text-transform:uppercase;color:#2d5be3;margin-bottom:.55rem;\">&#128295; BackendSide Tool<\/div>\n<h4 style=\"margin:0 0 .45rem;font-size:1.15rem;color:#1a1916;font-weight:700;\">SafeViewer &mdash; Symmetric Encryption, Done for You<\/h4>\n<p style=\"margin:0 0 1.05rem;color:#3d3c38;font-size:.92rem;line-height:1.65;\">When the only person who needs to open your files is you, there is no key-exchange problem to solve. <strong>SafeViewer<\/strong> protects every file with <strong>authenticated AES-256<\/strong> under a key derived from your session password, with unique encryption data per file. The key lives only in memory and is discarded when you close the app, and images, PDFs, Office documents and video open in built-in viewers without ever writing the readable content to disk.<\/p>\n<p>  <a href=\"https:\/\/backendside.com\/safeviewer.php\" style=\"display:inline-flex;align-items:center;gap:.4rem;background:#2d5be3;color:#ffffff;font-weight:600;font-size:.85rem;padding:.6rem 1.2rem;border-radius:6px;text-decoration:none;\">Explore SafeViewer &rarr;<\/a>\n<\/div>\n<h2>Key takeaways<\/h2>\n<ul>\n<li><strong>Symmetric<\/strong> ciphers (AES, ChaCha20) are fast and secure but need a shared secret; perfect when you are encrypting for yourself.<\/li>\n<li><strong>Public-key<\/strong> cryptography splits roles: encryption and key agreement to a public key, signatures with a private key.<\/li>\n<li>Use <strong>RSA-OAEP<\/strong> and <strong>RSA-PSS<\/strong>, never textbook RSA or PKCS#1 v1.5 encryption in new designs; prefer <strong>X25519<\/strong> and Ed25519 for new systems.<\/li>\n<li><strong>Hybrid encryption<\/strong> wraps a random symmetric key with the recipient&rsquo;s public key &mdash; the pattern behind almost every &ldquo;encrypt for a contact&rdquo; feature.<\/li>\n<li><strong>Forward secrecy<\/strong> comes from ephemeral ECDH; TLS 1.3 requires it, and post-quantum hybrids are being added on top.<\/li>\n<li>RSA-3072 &asymp; 256-bit ECC &asymp; AES-128 in strength, and a public key is only as good as your <strong>fingerprint check<\/strong>.<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Symmetric ciphers are fast but need a shared secret; public-key cryptography solves the sharing problem but is slow. Real systems use both. A clear walkthrough of AES and ChaCha20, RSA-OAEP, Diffie-Hellman and X25519, hybrid encryption, forward secrecy and key sizes, with commands you can try yourself.<\/p>\n","protected":false},"author":1,"featured_media":446,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,8],"tags":[45,73,72,71,67],"class_list":["post-380","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-security","category-tutorials","tag-encryption","tag-key-exchange","tag-public-key-cryptography","tag-rsa","tag-safeviewer"],"_links":{"self":[{"href":"https:\/\/backendside.com\/blog\/wp-json\/wp\/v2\/posts\/380","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/backendside.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/backendside.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/backendside.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/backendside.com\/blog\/wp-json\/wp\/v2\/comments?post=380"}],"version-history":[{"count":1,"href":"https:\/\/backendside.com\/blog\/wp-json\/wp\/v2\/posts\/380\/revisions"}],"predecessor-version":[{"id":447,"href":"https:\/\/backendside.com\/blog\/wp-json\/wp\/v2\/posts\/380\/revisions\/447"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/backendside.com\/blog\/wp-json\/wp\/v2\/media\/446"}],"wp:attachment":[{"href":"https:\/\/backendside.com\/blog\/wp-json\/wp\/v2\/media?parent=380"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/backendside.com\/blog\/wp-json\/wp\/v2\/categories?post=380"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/backendside.com\/blog\/wp-json\/wp\/v2\/tags?post=380"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}