[SEC] Cryptography II
Cryptography II
Content
- Symmetric Encryption
- Block Ciphers
- SP-Networks
- The advanced Encryption Standard
- Modes of Operation
- Hash Functions
- The Birthday Paradox
- Message Authentication Codes
Symmetric Ciphers
Symmetric ciphers are divided into two categories:
- Stream cipher: each plaintext corresponds to one ciphertext
- Block cipher
Block Ciphers
- Block ciphers use a key to encrypt a fixed-size block of plaintext into a fixed-size block of ciphertext
- If you’re careful, you can convert between block and stream ciphers using modes of operation
SP-Networks
- Claude Shannon suggested that all that was required for a strong cipher was repeated substitution and permutation
- SP-Networks combine a substitution process with a permutation into a single round
- Rounds are then repeated enough times to ensure the algorithm is secure
What does it mean by “permutation”?
It means that the ciphertext can be translated back to plaintext
- Substitution Boxes - Add confusion by replacing values with other values using a lookup table
- Permutation Boxes - Add diffusion by moving values around from input to output
A simple 8-bits SP-Network
- This is a single round! One round isn’t enough!
- Careful analysis of input changes and output changes can reveal the contents of the S-boxes
- More rounds produces more diffusion
- Replacing permutation with linear transformation is more effective
- Each bit is the XOR combination of multiple S-box outputs
- Large block size
- An 8-bit block would be vulnerable to dictionary attacks, just pre-compute all possible blocks
- Typically we see 128-bit and 256-bit block sizes
- S-box design
- “Psuedorandomness” of the result is compromised with poor S-box design
Key Mixing
- The previous SP-Network didn’t use a key, we can add one using XOR:
Advanced Encryption Standard
- Superseded DES as a standard in 2002
- A standard built around the Rijndael Algorithm
- Rijndael is an SP-network with a 128-bit block size, and a key length of 128, 192 or 256-bits
- Round count depends on key length
- 10,12 or 14 cycles
- AES is vastly superior to DES, which had a 64-bit block and 56 bit key
AES Security
- Is currently the standard algorithm for symmetric encryption, and is likely to remain that way
- How good is it?
- \(2^{128}\) keys, let’s say we get lucky and crack it at \(2^{127}\)
- Long time, almost impossible
Block Cipher Modes
- Most message don’t come in convenient 128-block lengths
- We’ll need to run a block cipher repeatedly on consecutive blocks
- Why not just use a stream cipher?
- Historically stream ciphers have proven harder to implement
- ChaCha20 is pretty good
Electronic Code Book(ECB)
- Just encrypt each block one after another
- Weak to redundant data divulging patterns
Cipher Block Chaining(CBC)
- XOR the output of each cipher block with the next input
- Not totally immune to the insertion of malicious blocks
- Not totally immune to the insertion of malicious blocks
Counter Mode(CTR)
- Encrypting a counter to produce a stream cipher
- Can be parallelized
- Can be parallelized
Galois Counter Mode(GCM)
- Extends counter mode to add authenticity
- The sender definitely sent that message, and it hasn’t changed
- Very similar to counter mode, but adds an authentication tag
- The tag is calculated using multiplication in a Galois Finite field GF
- Extremely parallelisable
- Robust to message alteration
Hash Functions
Strong Hash Functions
- The output must be indistinguishable from random noise
- Bit changes must diffused through the entire output
- Usually hash functions iteratively jumble blocks of a message after another
- Once all the message is gone, we read the current hash
- The initial hash is usually defined in the spec
- For a hash function to be useful, we need it to have some important properties
- One-way: Given h(M), we can’t calculate M easily
- Weak collision resistance: Given M and h(M), we cannot find some M’ such that h(M) = h(M’)
- Strong collision resistanceL We can’t find some message pair M \(\neq\) M’, such that h(M) = h(M’)
The birthday paradox
- The output of the hash must be long enough to avoid a birthday attack
- Given a hash function outputs n bit hashes
- You will find a collision after about \(2^{n/2}\) random attempts
Some notable examples
Message Authentication Codes
- Provide integrity and authenticity, not confidentiality
- Protecting system files
- Ensuring message haven’t been altered
- Calculate a keyed hash of the message, then append this to the end of the message
评论
发表评论