Cryptography Flashcards
Kerchoffs’ Principle
if:
* the encryption algorithm was well designed
* the N bit long keys are kept secret
* the algorithm is executed by a trusted party
then:
the only possible attack us the brute force attack which requires a number of trials equal to T = 2^{Bit}
Symmetric cryptography: formulas, characteristics, related problems
- a.k.a secret key crypto
- K1 = K2
- C = enc(K, P)
- P = enc^-1(K, C)
- low computational load -> used for data encryption
- problem: how to share the secret key among sender and receiver
Symmetric cryptography for blocks: algorithms list
DES, 3-DES, IDEA, AES
DES and variants
Symmetric cryptography for blocks
- Data Encryption Standard
- it requires: XOR, shift, permutation -> designed to be efficient in hardware
DES
* key length: 56 + 8
* block length: 64
* time T
3-DES
* key length: 112 + 16 or 168 + 24 -> 112 bit strength
* block length: 64
* time 3T
* it is DES applied three times using 2 or 3 keys of 56 bit
* usually applied in the EDE mode: encryption with K1, decryption with K2, encryption with K3 or K1
* if 2 keys: if the attacker has 2^59B of memory available the strength is of 56 bit, otherwise it is of 112 bit
* if 3 keys: if the attacker has 2^59B of memory available the strength is of 112 bit, otherwise it is of 168 bit
IDEA
Symmetric cryptography for blocks, famous for PGP
AES
Symmetric cryptography for blocks
- Advanced Encryption Standard
- key length: 128 - 192- 256
- block length: 128
Important things about the XOR operation
- it is the inverse of itself
- it is the confusion operator because P(0) = P(1) = 50%
- primitive function available on all CPU
Why 2DES is not used?
Double application of encryption algorithms s subject to a known-plaintext attack named MITM which permits to decrypt data with at most 2^{N+1} attempts if the key is N bit long. This means that only the encryption time is doubled while the effective key length increases by just one bit
Demonstration
How can we apply a block algorithm?
There are different application modes:
* if data to encrypt > algorithm block size: ECB, CBC
* otherwise: padding, CTR, CTS (not sure CTS is a mode)
These are not algorithms but modes of application!!!!
ECB: extended name, formula, characteristics and problems
- Electronic Code Block
- D > B
- C_i = enc(K, P_i) where P_i’s length is the block size length
- P_i = enc^-1(K, C_i)
Advantages
* no propagation of errors: an error in transmission causes an error in the decryption of a single block without propagating to the other blocks;
* CPU parallelization: it is possible to work on several blocks at the same time.
Disadvantages
* swapping attacks: encryption does not depend on the position of the block) it is possible to swap two blocks, or move any block, without this being discovered;
* known-plaintext attacks: identical blocks are encrypted in the same way; an attacker can build a database containing the encryption outputs with all the possible keys of a recurring block (eg header of a Word document), and then find the key by comparing each block of ciphertext for the recurring block (pattern).
CBC: extended name, formula, characteristics and problems
- Cypher Block Chaining
- D > B
- C_i = enc(K, P_i XOR C_{i-1})
- C_0 = IV, random value that has to be known by the receiver -> there are two opposite approaches: IV in clear, IV encrypted
- P_i = enc^-1(K, C_i) XOR C_{i-1} -> XOR is the inverse of itself
characteristics:
- it tries to solve ECB’s problems
- no undetected swapping permitted
- one error in transmission generates an error at the decryption of two block
Padding: characteristics and problems
Bits are added to the last block (derived from the division) till the block length is reached
Characteristics:
* some offer minimal integrity control
* if data length is minor then the ad hoc techniques are preferred such as CTR
* EVEN IF THE PLAINTEXT IS AN EXACT MULTIPLE OF THE BLOCK PADDING MUST BE ADDED TO AVOID ERROR IN THE INTERPRETAZION OF THE LAST BLOCK -> 1≤ L ≤ B -> the biggest padding has to be done when no padding is needed
* attacks also depend from the padding type chosen
Problems:
* the sent/stored data are bigger than the original ones -> a solution could be using CTS
* which value have the padding bits? There are different padding TECHNIQUES
CTR: extended name, formula, characteristics and problems
- Counter Mode
- D < B -> data are small themselves so they are made of N bits -> variable length, a group
characteristics/formula:
- a nonce, a counter and a function are required
- at the sender and at the receiver there is a synchronized register in which a computation f(nonce, counter) is performed. the result is the key and the leftmost bits are taken
- the key is XORed with the plaintext
- no error propagation
- direct access to each block
Example: if we assume that f is the concatenation…
at the sender:
for (x = 0; x < data_size; x++) {
ctext[x] = ptext[x]
XOR
MSB( enc(K, nonce || x) )
}
If CTR is byte-oriented it can be considered a stream algorithm
CTS: extended name, formula, characteristics and problems
Cyphertext Stealing
- it is a technique used when we cannot have encrypted data bigger than the original data or when we cannot use padding
- very important for storage encryption
- the computation time slightly increases
Execution:
- the last block is filled with bytes taken from the second to last block -> the second to last block becomes a partial one
- blocks are encrypted
- the last block and the second to last block positions are exchanged
Which padding techniques are there?
- … 0x00 0x00 0x00 -> if the message length is known
- original DES -> one 1 followed by many 0, …1000000
- one byte with value 128 followed by null bytes, … 0x80 0x00 0x00
- techniques depending explicitly from the data length (L):
- Schneier: … 0x00 0x00 0xL
- SSL/TLS: … 0xL 0xL 0xL
- SSH2: random bytes, … r r 0xL -> equal data give different cypher texts
- IPsec/ESP: progressive number, … 0xL-2 0xL-1 0xL
- bytes with value L-1: … 0xL-1 0xL-1 0xL-1
CTS - example with CBC
slide
Symmetric Stream Encryption Algorithms: characteristics, problems, difference between an ideal and a real algorithm, main algorithm list
They work on a data stream without requiring the split in block, typically they work on a bit or on a byte at a time
- ideal algorithm: one-time pad, that means that a key as long as the message is required
- real algorithms: they use a key that is generated by pseudo-random key generators that are synchronized at the sender and at the receiver. The generators use a shared seed to generate the key. This seed is the main secret shared between sender and receiver.
characteristics and problems:
- very fast
- operations are not complex
- subject to cancellation attack and others
Algorithms: RC4 (old), Salsa20, ChaCha20
Salsa20 and ChaCha20
Symmetric Stream Encryption Algorithms
ChaCha20 is an improvement of Salsa20: more diffusion of bits, faster on some architectures
They are both based on:
- key: 128 or 256
- + nonce + counter
- base operation: ARX (Add, Rotate, XOR). Rotate is not available on all CPUs so if you do not have it by default and you have to implement it it will be slower
Salsa20:
- base function: f(key256, Nonce64, Counter64) = 512-bit kystream block
- O(1) decryption of any block at random
- Salsa20 perfora 20 mixing rounds of the input
ChaCha20:
- 96 bit nonce
- 32 bit block counter -> limit of 2^32 = 256GB 64 bit block
- used by Google and OpenSSH
Minimum secure key length for symmetric and asymmetric algorithms
symm: 256 to have high security, ok 128
asymm (FFC, IFC): 4096 (2048)
asymm (ECC): 512 (256)
Key distribution for symmetric cryptography
- OOB
- by means of key exchange algorithms
Asymmetric cryptography: characteristics, main algorithms
- a.k.a public key crypto
- two different keys, they form a key-pair and they are dependent one from the other -> SK + PK
- one of the keys is used for encryption, the other one for decryption -> they are keys with inverse functionality
- high computational load
- used to encrypt little data such as keys to distribute or to create digital signatures
- main algorithms: DH, RSA, DSA
- encryption with SK -> digital signature
- encryption with PK -> confidentiality
Digital Signature: how is it reached and which security properties does it have
It is reached via asymmetric encryption by using the private key to encrypt the data. Usually the encryption is done on the data summary and not directly on data.
PROVIDES DATA AUTHENTICATION AND INTEGRITY + NON-REPUDIATION
DSA
Digital Signature Algorithm (public key algorithm)
- The security challenge is the discrete logarithm problem, where the attacker sees the result of exponentiation but does not know the base.
- DSA is used exclusively for digital signatures. It employs a one-way lossy compression function, meaning the original plaintext cannot be recovered from the signature
RSA
Rivest - Shamir - Adleman public key algorithm
- Its security is based on the mathematical difficulty of factorizing large numbers, specifically the product of two large prime numbers -> There is no known polynomial-time solution for factorizing very large numbers,
- can be used for both digital signatures and encryption (confidentiality)