Symmetric-key cryptography (source code)

= Symmetric-key cryptography

<Symmetric-key cryptography> uses shared secret key material for cryptographic operations, including <encryption> and authentication. In a symmetric <encryption> scheme, a recipient holding the secret key can recover the <plaintext> from a <ciphertext>. Keeping the <algorithm> public does not prevent security: the secret is the key, not the procedure.

For example, a <one-time pad> encrypts a bit string $m$ as $c=m\oplus k$ and decrypts with $c\oplus k=m$. Perfect secrecy requires an independently uniform secret key as long as the message and never reused. Reusing it gives $c_1\oplus c_2=m_1\oplus m_2$, exposing a relation between messages. Ordinary efficient symmetric ciphers instead offer computational guarantees under stated assumptions. Confidentiality alone does not ensure message integrity; <authenticated encryption> addresses both.<Handbook of Applied Cryptography by Alfred J. Menezes, Paul C. van Oorschot and Scott A. Vanstone>[§1.5, symmetric-key encryption; §6.1, stream ciphers and one-time pad]{ref}