IS-CryptoBasics SKC
IS-CryptoBasics SKC
Symmetric encryption
Symmetric encryption
Stream ciphers
Block ciphers and modes of operation
Hash functions
Message integrity
Authenticated encryption
Symmetric cryptography
Symmetric encryption;
Hash functions;
Authenticated encryption.
Prof.dr. F.L. Ţiplea, UAIC, RO Lectures on Information Security Cryptography Basics: Symmetric Key Cryptography Fall 2022 2 / 50
Symmetric encryption
Symmetric encryption
1. Secure communication
protects data in motion;
IPsec and SSL&TLS use it;
2. File protection
protects data at rest;
cloud storage tools use it.
Prof.dr. F.L. Ţiplea, UAIC, RO Lectures on Information Security Cryptography Basics: Symmetric Key Cryptography Fall 2022 3 / 50
Symmetric cipher: S = (G, E, D)
m c = E(K , m) m = D(K , c)
message Alice Bob
ciphertext
key distribution
Key distribution:
Prof.dr. F.L. Ţiplea, UAIC, RO Lectures on Information Security Cryptography Basics: Symmetric Key Cryptography Fall 2022 4 / 50
Security models for symmetric encryption
Prof.dr. F.L. Ţiplea, UAIC, RO Lectures on Information Security Cryptography Basics: Symmetric Key Cryptography Fall 2022 5 / 50
Security goals
1. Semantic security
1.1 Proposed by Goldwasser and Micali (1984), it was the first definition
of security for encryption;
1.2 It formalizes the fact that no adversary can obtain any partial
information about the message of a given ciphertext (whatever can
efficiently be computed about a message from its ciphertext can also
be computed without the ciphertext);
1.3 It is a “polynomially bounded” version of the concept of perfect
secrecy introduced by Shannon (1949);
1.4 It is complex and difficult to work with;
1. Passive attacks:
1.1 Cipher-only attack (COA): A has access to the ciphertext;
1.2 Known plaintext attack (KPA): A knows pairs (plaintext,ciphertext);
2. Active attacks:
2.1 Chosen plaintext attack (CPA): A has access to the encryption
oracle (this is for free for PKE);
2.2 Non-adaptive chosen ciphertext attack (CCA1): A has, in addition
to the ability of a CPA adversary, access to a decryption oracle
before the challenge phase;
2.3 Adaptive chosen ciphertext attack (CCA2): A has, in addition to the
ability of a CCA1 adversary, access to a decryption oracle after the
challenge phase. However, no decryption query is allowed involving
the challenge ciphertext.
Prof.dr. F.L. Ţiplea, UAIC, RO Lectures on Information Security Cryptography Basics: Symmetric Key Cryptography Fall 2022 7 / 50
Proving security by indistinguishability
Prof.dr. F.L. Ţiplea, UAIC, RO Lectures on Information Security Cryptography Basics: Symmetric Key Cryptography Fall 2022 9 / 50
Stream ciphers
Prof.dr. F.L. Ţiplea, UAIC, RO Lectures on Information Security Cryptography Basics: Symmetric Key Cryptography Fall 2022 10 / 50
Stream ciphers
K keystream
generator G
key
0
0
keystream G (K )
0
1
1
01011 m ⊕ G (K )
encryptor
message m ciphertext
Theorem 1
The SKE scheme above is IND-COA, provided that G is a PRG.
Prof.dr. F.L. Ţiplea, UAIC, RO Lectures on Information Security Cryptography Basics: Symmetric Key Cryptography Fall 2022 11 / 50
Stream ciphers: using the same key twice
If c1 = m1 ⊕ G (K ) and c2 = m2 ⊕ G (K ), then c1 ⊕ c2 = m1 ⊕ m2 ;
Natural language text contains enough redundancy to allow the
adversary to recover m1 and m2 from c1 ⊕ c2 .
Real scenarios:
Never use the same key to encrypt more than one message with stream
ciphers !
Prof.dr. F.L. Ţiplea, UAIC, RO Lectures on Information Security Cryptography Basics: Symmetric Key Cryptography Fall 2022 12 / 50
Stream ciphers: malleability
Malleability:
Real scenarios:
Prof.dr. F.L. Ţiplea, UAIC, RO Lectures on Information Security Cryptography Basics: Symmetric Key Cryptography Fall 2022 13 / 50
The stream cipher RC4
Prof.dr. F.L. Ţiplea, UAIC, RO Lectures on Information Security Cryptography Basics: Symmetric Key Cryptography Fall 2022 14 / 50
Other practical stream ciphers
Prof.dr. F.L. Ţiplea, UAIC, RO Lectures on Information Security Cryptography Basics: Symmetric Key Cryptography Fall 2022 15 / 50
Block ciphers
Remark 2
1. The encryption of a message block by another block is done by
families of permutations (i.e., block ciphers) or families of functions;
Prof.dr. F.L. Ţiplea, UAIC, RO Lectures on Information Security Cryptography Basics: Symmetric Key Cryptography Fall 2022 16 / 50
Block ciphers
K1 K2 ··· Kn
Prof.dr. F.L. Ţiplea, UAIC, RO Lectures on Information Security Cryptography Basics: Symmetric Key Cryptography Fall 2022 17 / 50
DES and AES block cipher
1. DES:
M = C = {0, 1}64 ;
K = {0, 1}56 ;
The number of rounds is 16;
2. AES:
M = C = M4×m (Z82 ), where m ∈ {4, 6, 8};
K = M4×k (Z82 ), where k ∈ {4, 6, 8};
The number of rounds varies on the key and message block length
Prof.dr. F.L. Ţiplea, UAIC, RO Lectures on Information Security Cryptography Basics: Symmetric Key Cryptography Fall 2022 18 / 50
Pseudo-random functions
Prof.dr. F.L. Ţiplea, UAIC, RO Lectures on Information Security Cryptography Basics: Symmetric Key Cryptography Fall 2022 19 / 50
Pseudo-random permutations
Remark 3
1. Strong PRP are simply referred to as PRP;
Prof.dr. F.L. Ţiplea, UAIC, RO Lectures on Information Security Cryptography Basics: Symmetric Key Cryptography Fall 2022 20 / 50
PRP candidates
Prof.dr. F.L. Ţiplea, UAIC, RO Lectures on Information Security Cryptography Basics: Symmetric Key Cryptography Fall 2022 21 / 50
Electronic Code Block (ECB)
F = (FK )K is a PRP
message: m1 m2 ··· mℓ
FK FK FK
ciphertext: c1 c2 ··· cℓ
Theorem 4
ECB is not IND-KPA.
Prof.dr. F.L. Ţiplea, UAIC, RO Lectures on Information Security Cryptography Basics: Symmetric Key Cryptography Fall 2022 22 / 50
ECB illustrated
Prof.dr. F.L. Ţiplea, UAIC, RO Lectures on Information Security Cryptography Basics: Symmetric Key Cryptography Fall 2022 23 / 50
Cipher Block Chaining (CBC)
F = (FK )K is a PRP
message: m1 m2 ··· mℓ
IV ← {0, 1}n ⊕ ⊕ ⊕
FK FK FK
ciphertext: IV c1 c2 ··· cℓ
Theorem 5
If F = (FK )K is a PRP, then CBC with F is IND-CPA.
Prof.dr. F.L. Ţiplea, UAIC, RO Lectures on Information Security Cryptography Basics: Symmetric Key Cryptography Fall 2022 24 / 50
CBC versus ECB
Prof.dr. F.L. Ţiplea, UAIC, RO Lectures on Information Security Cryptography Basics: Symmetric Key Cryptography Fall 2022 25 / 50
Deterministic counter mode (DCTR)
F = (FK )K is a PRF
message: m1 m2 ··· mℓ
⊕ ⊕ ⊕
r = 1 FK (r ) FK (r +1) ··· FK (r +ℓ-1)
ciphertext: c1 c2 ··· cℓ
The scheme works like a stream cipher with the PRG G given by
Theorem 6
If F = (FK )K is a PRF, then DCTR with F is IND-KPA but not
IND-CPA.
Prof.dr. F.L. Ţiplea, UAIC, RO Lectures on Information Security Cryptography Basics: Symmetric Key Cryptography Fall 2022 26 / 50
Counter mode (CTR)
F = (FK )K is a PRF
message: m1 m2 ··· mℓ
⊕ ⊕ ⊕
r ← {0, 1}n FK (r ) FK (r +1) ··· FK (r +ℓ-1)
ciphertext: r c1 c2 ··· cℓ
The scheme works like a stream cipher with the PRG G given by
G (K ) = FK (r ) ∥ FK (r + 1) ∥ · · · ∥ FK (r + ℓ − 1)
Theorem 7
If F = (FK )K is a PRF, then CTR with F is IND-CPA.
Prof.dr. F.L. Ţiplea, UAIC, RO Lectures on Information Security Cryptography Basics: Symmetric Key Cryptography Fall 2022 27 / 50
Output feedback (OFB) and cipher feedback (CFB)
FK (r ) ∥ FK (r + 1) ∥ FK (r + 2) ∥ · · ·
FK (r ) ∥ FK (c1 ) ∥ FK (c2 ) ∥ · · ·
Prof.dr. F.L. Ţiplea, UAIC, RO Lectures on Information Security Cryptography Basics: Symmetric Key Cryptography Fall 2022 29 / 50
Hash functions
m H c = H(K , m)
message (DPT) message digest
Prof.dr. F.L. Ţiplea, UAIC, RO Lectures on Information Security Cryptography Basics: Symmetric Key Cryptography Fall 2022 30 / 50
Collision-resistant hash functions
m0
H
If m0 ̸= m1 then
G(λ) → K H(K , m0 ) = H(K , m1 ) (m0 , m1 ) is a collision
m1
H
Prof.dr. F.L. Ţiplea, UAIC, RO Lectures on Information Security Cryptography Basics: Symmetric Key Cryptography Fall 2022 31 / 50
One-way hash functions
m0
H −1
(K , c) .. c
. H
mℓ
G(λ) → K
?
Prof.dr. F.L. Ţiplea, UAIC, RO Lectures on Information Security Cryptography Basics: Symmetric Key Cryptography Fall 2022 32 / 50
Looking for collisions
Theorem 9
Let m be the number of possible message digests of a hash function H
under some key K . If we compute message digests for r messages
chosen uniformly at random and
√
⌊ 2cm⌋ < r < m
for some real constant c > 0, then the probability to get a collision is
higher than 1 − e −c (e is Euler’s number, e = 2.71828 · · · ).
Example 10
√
Let m = 240 and r such that 1.200.000 ≈ ⌊220 2 ln 2⌋ < r < 240 .
The probability of getting a collision is greater than 1/2. Therefore,
40-bit message digests do not ensure security.
Prof.dr. F.L. Ţiplea, UAIC, RO Lectures on Information Security Cryptography Basics: Symmetric Key Cryptography Fall 2022 33 / 50
Construction of CRHFs
Prof.dr. F.L. Ţiplea, UAIC, RO Lectures on Information Security Cryptography Basics: Symmetric Key Cryptography Fall 2022 34 / 50
The MD transform
ℓ
Use an MD-complaint padding pad : {0, 1}<2 → nℓ
S
n≥1 {0, 1}
with the following properties:
1. m is a prefix of pad(m)
2. if |m1 | = |m2 | then |pad(m1 )| = |pad(m2 )|;
3. if m1 ̸= m2 , then the last block of pad(m1 ); is different than the last
block of pad(m2 );
Prof.dr. F.L. Ţiplea, UAIC, RO Lectures on Information Security Cryptography Basics: Symmetric Key Cryptography Fall 2022 35 / 50
The MD transform
m1 m2 mn
···
message digest
IV hK hK ··· hK
Theorem 11
If h is collision-resistant, then the MD-transform based on h is so.
Prof.dr. F.L. Ţiplea, UAIC, RO Lectures on Information Security Cryptography Basics: Symmetric Key Cryptography Fall 2022 36 / 50
The MD transform in practice
MD4 – developed by Rivest in 1990. It was the starting point for the
development of a series of similar hash functions;
Prof.dr. F.L. Ţiplea, UAIC, RO Lectures on Information Security Cryptography Basics: Symmetric Key Cryptography Fall 2022 37 / 50
The sponge construction
Absorbing phase .
m1 m2 ··· mn
m1 ∥ 0c m2 ∥ 0c ··· mn ∥ 0c
0ℓ ⊕ ⊕ ⊕
···
π π π V
Prof.dr. F.L. Ţiplea, UAIC, RO Lectures on Information Security Cryptography Basics: Symmetric Key Cryptography Fall 2022 38 / 50
The sponge construction
Squeezing phase
π π ··· π
V
z1 z2 zi each of size r
z1 z2 ··· zi
message digest
Theorem 12
If π is a random permutation and 2ℓ and 2c are super-poly, then the
sponge construction yields a CRHF.
Prof.dr. F.L. Ţiplea, UAIC, RO Lectures on Information Security Cryptography Basics: Symmetric Key Cryptography Fall 2022 39 / 50
Message integrity
Message authentication codes
Alice
Dear Tom,
Tg tag tag
G(λ) → K
Prof.dr. F.L. Ţiplea, UAIC, RO Lectures on Information Security Cryptography Basics: Symmetric Key Cryptography Fall 2022 40 / 50
MACs
1. PRFs;
2. Hash functions.
Prof.dr. F.L. Ţiplea, UAIC, RO Lectures on Information Security Cryptography Basics: Symmetric Key Cryptography Fall 2022 41 / 50
MACs from PRFs: CMAC
4. Apply F with K0 in the CBC mode and output only the last block
as the message tag.
Prof.dr. F.L. Ţiplea, UAIC, RO Lectures on Information Security Cryptography Basics: Symmetric Key Cryptography Fall 2022 42 / 50
MACs from PRFs: CMAC
m1 m2 ··· mk−1 mk
0ℓ ⊕ ⊕ ⊕ ⊕
F K0 F K0 ··· F K0 FK0
Theorem 13
CMAC is secure, provided that F is a PRF.
Prof.dr. F.L. Ţiplea, UAIC, RO Lectures on Information Security Cryptography Basics: Symmetric Key Cryptography Fall 2022 43 / 50
MACs from CRHFs: HMAC
Theorem 14
If h and h′ given by h′ (K , m) = h(m, K ) are PRFs, then FH is a PRF.
For a proof of this theorem please see Boneh and Shoup (2020).
The HMAC construction uses one single key K from which two keys are
derived: K1 = K ⊕ ipad and K2 = K ⊕ opad.
Prof.dr. F.L. Ţiplea, UAIC, RO Lectures on Information Security Cryptography Basics: Symmetric Key Cryptography Fall 2022 44 / 50
Authenticated encryption
The need for authenticated encryption
Theorem 16
If S is AE secure then it is IND-CCA secure.
Prof.dr. F.L. Ţiplea, UAIC, RO Lectures on Information Security Cryptography Basics: Symmetric Key Cryptography Fall 2022 45 / 50
Constructing AE secure ciphers
1. Encrypt-then-MAC (EtM)
1.1 c ← E(K , m), t ← Tg (K ′ , c), output (c, t);
1.2 Used in IPsec, TLS 1.2 and later versions, and in the NIST standard
GCM;
2. MAC-then-Encrypt (MtE)
2.1 t ← Tg (K ′ , m), c ← E(K , (m, t)), output c;
2.2 Used in SSL 3.0, TLS 1.0, and in 802.11i WiFi encryption protocol.
Prof.dr. F.L. Ţiplea, UAIC, RO Lectures on Information Security Cryptography Basics: Symmetric Key Cryptography Fall 2022 46 / 50
Encrypt-then-MAC
Theorem 17
If S is an IND-CPA secure cipher and S ′ is a secure MAC, then the
EtM construction is a secure AE.
1. Use the same key for the cipher and the MAC;
2. Apply the MAC only to part of the ciphertext (we may loose
ciphertext integrity) – discovered in 2013 at RNCryptor facility in
Apple’s iOS.
Prof.dr. F.L. Ţiplea, UAIC, RO Lectures on Information Security Cryptography Basics: Symmetric Key Cryptography Fall 2022 47 / 50
MAC-then-Encrypt
Prof.dr. F.L. Ţiplea, UAIC, RO Lectures on Information Security Cryptography Basics: Symmetric Key Cryptography Fall 2022 48 / 50
References
References
AlFardan, N., Bernstein, D. J., Paterson, K. G., Poettering, B., and Schuldt, J. C. N. (2013). On
the security of rc4 in TLS. In 22nd USENIX Security Symposium (USENIX Security 13), pages
305–320, Washington, D.C. USENIX Association.
Barkan, E., Biham, E., and Keller, N. (2003). Instant ciphertext-only cryptanalysis of gsm
encrypted communication. In Boneh, D., editor, Advances in Cryptology - CRYPTO 2003,
pages 600–616, Berlin, Heidelberg. Springer Berlin Heidelberg.
Bernstein, D. J. (2008a). ChaCha, a variant of Salsa20. Technical report, The University of Illinois
at Chicago.
Bernstein, D. J. (2008b). The salsa20 family of stream ciphers. In Robshaw, M. and Billet, O.,
editors, New Stream Cipher Designs: The eSTREAM Finalists, pages 84–97, Berlin, Heidelberg.
Springer Berlin Heidelberg.
Bernstein, D. J. (2013). Failures of secret-key cryptography. Invited talk to the 20th International
Workshop on Fast Software Encryption 2013.
Boneh, D. and Shoup, V. (2020). A Graduate Course in Applied Cryptography. Authors’ website,
Version 0.5.
Prof.dr. F.L. Ţiplea, UAIC, RO Lectures on Information Security Cryptography Basics: Symmetric Key Cryptography Fall 2022 49 / 50
References (cont.)
Dworkin, M. (2005). Recommendation for block cipher modes of operation: The CMAC mode for
authentication. NIST Pubs 800-30B, NIST. Updated, 2016.
Goldwasser, S. and Micali, S. (1984). Probabilistic encryption. Journal of Computer and System
Sciences, 28:270–299.
Krawczyk, H. (2001). The order of encryption and authentication for protecting communications
(or: How secure is SSL?). In Kilian, J., editor, Advances in Cryptology — CRYPTO 2001,
pages 310–331, Berlin, Heidelberg. Springer Berlin Heidelberg.
Lu, Y., Meier, W., and Vaudenay, S. (2005). The conditional correlation attack: A practical attack
on bluetooth encryption. In Shoup, V., editor, Advances in Cryptology – CRYPTO 2005, pages
97–117, Berlin, Heidelberg. Springer Berlin Heidelberg.
Shannon, C. E. (1949). Communication theory of secrecy systems. The Bell System Technical
Journal, 28(4):656–715.
Prof.dr. F.L. Ţiplea, UAIC, RO Lectures on Information Security Cryptography Basics: Symmetric Key Cryptography Fall 2022 50 / 50