[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:

  1. Stream cipher: each plaintext corresponds to one ciphertext
  2. 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
    enter image description here
  • Permutation Boxes - Add diffusion by moving values around from input to output
    enter image description here

A simple 8-bits SP-Network

enter image description here
enter image description here

  • 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:
    enter image description here

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
    enter image description here

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
      enter image description here

Counter Mode(CTR)

  • Encrypting a counter to produce a stream cipher
    • Can be parallelized
      enter image description here

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

enter image description here

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

enter image description here

  • 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

enter image description here

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

HMAC

enter image description here

评论

此博客中的热门博文

[MLE] W2 Multivariate linear regression

[MLE] W1 Introduction

[AIM] MetaHeuristics