Introduction to Computer Security | Prof. Bart Jacobs, prof. Joan Daemen
@lecture @security @Jacobs @Daemen @cryptography @bitcoin @hashing @key @RSA @ECC @attacks
Slide set 1: Introduction
Definitions
Def: Computer Security is about regulating access to (digital) assets
Assets: the valuables that need protection
Regulating access:
- Identification: who are you / what are your attributes?
- Authentication: how do you prove your identity?
- Authorisation: What are you allowed to do?
In this course, these security issues are investigated from the perspective of an attacker model.
Security is not only digital, but also organizational. Jacobs gave the example of KPMG Amsterdam and the "Trojaanse Schimmel" attack, where attackers gained access to the facility dressed up as Sinterklaas. However strong digital security is, mistakes are often made by humans nevertheless.
Security management can thus be visualized as a triangle of asserts, threats, and controls.
This course requires professional paranoia.
Threats
The internet has changed from an opportunity to a liability. Similarly, big data has become a liability due to significant penalties and reputation damage in case of data loss, and strict regulations on data protection, especially via GDPR.
How do you protect from an attacker that is:
- Deliberate
- Well-motivated
- Malicious
- Resourceful
- Technically competent
- Intelligent
- Creative
- Socially skilful
- Patient
Given a protection, how do you test / verify the protection.
- Formalize the attacker
Limitations:
- How do you incorporate out-of-the-box and geeky sick minds into your validation methods?
- Formalization makes your assumptions explicit, but there is no guarantee the attacker fits the assumptions
Controls
Technical measures:
- Cryptography, mathematical basis
- Computers running and breaking cryptographic algorithms
- Physical security (e.g. tamper-resistancy)
Organisational measures:
- E.g. for the OV-chip card: monitoring of difference between travel costs and money put on cards
- Against three B's: Burglary, blackmail, bribery
Legal measures:
- Criminal law, in particular computer criminality laws
- Civil law, e.g. in user agreements for bank and travel cards
Civil vs. criminal law
Example: you are asked to test a company's security by hacking them. You sign a contract so that they do not sue you.
This excludes civil liabilities, but not criminal liabilities. Hacking is still illegal, and the state could in principle prosecute you.
Computer science for law vs law for computer science
Former: knowledge representation, formal reasoning, AI flavoured.
Latter: laws governing computers, European origin, related to cyber crime, criminal penal law. Example: hacking allowed by police?
Dutch computer crime laws
- art. 138a, Sr: computervredebreuk
- No computer intrusion
- art. 139a, Sr: afluisteren
- No eavesdropping (confidentiality)
- art 161sexies, Sr: stoornis
- No computer disruption (hardware, software integrity & availability)
- art. 350a, Sr: wijzingen of vernietigen opgeslagen gegevens
- No data corruption (data integrity)
DICE: Disruption, Intrusion, corruption, eavesdropping.
Aspects of intrusion
- Passive eavesdropping
- Active intervention
- Material nature of connections influences possibilities of interception:
- Tempest: emission security (electromagnetic emanations might reveal information)
- Covert channels of information: increase of pizza deliveries to Pentagon reveal that there is a crisis
Traffic analysis
- Who is communicating with whom?
- NSA calls this "meta data"
- former CIA & NSA chief Hayden: "We kill based on meta data"
- Meta data are already privacy sensitive
- Your location
- E.g. have you called an abortion clinic?
Main security goals [PIVOTAL]
- Confidentiality
- Eve cannot read content of communication
- Integrity
- Eva cannot alter the content of communication
- Authenticity
- Alice and Bob are certain of each other's identities
- Availability
- Eve cannot prevent the communication between Alice and Bob
- Non-repudiation
- Past communication cannot be denied/revoked
- Accountability
- Reliable logging of communication history (including Eve)
N.B. integrity is sometimes called "message authentication"
N.B. an integrity breach can potentially be fixed, a confidentiality breach cannot.
Security and safety
Dutch: beveiliging versus veiligheid
German: Schutz versus Sicherheit
def Security: protection against active, malicious attack on a (computer) system.
def Safety: protection against unintended accidents or errors.
Security and privacy
Part of 1) Computer security, protection of personal data (data protection laws, General Data Protection Regulation (GDPR) ). 2) as important for personal security, including identity fraud.
Security and autonomy
Information is power, and access to power determined power relations in the world.
Range of philosophical questions:
How autonomous are people still when Google determines what they get to see?
One way to define computer security:
Computer security is about regulating access to data
Relevance of computer security
Public ICT projects make or break based on security:
- E-ticketing
- Electronic Health Care
- Road pricing
- E-voting
For companies:
- Protection of assets (intellectual, stock-related info, strategy information)
- Protection of e-commerce transactions (banks)
- Privacy & data protection regulation (GDPR)
- Profiling and behavioral targeting of customers ("CRM": Customer relationship management)
Stakeholders and concerns
- Banks / financial institutions
- Main concern: integrity of transactions, not confidentiality.
- Non-repudiation is crucial for e-banking
- Telecom / internet operators
- Concerns ...
- I would say mainly availability, integrity
- Health care
- Confidentiality / privacy
- Integrity & availability of patient files
- Citizens
- privacy protection, against ransomware etc.
- Intelligence / Military / Diplomats
- Confidentiality, integrity
Intelligence services
General division in three types:
- Internal (intra-national, sometimes power to make arrests)
- External (international intelligence gathering)
- Sigint (Signal Intelligence, intercepting and deciphering signals, traffic analysis)
Per country
- USA
- Internal: FBI
- External: CIA
- NSA (larger in size than FBI and CIA combined)
- UK
- Internal: MI5 (MI -> Military Intelligence)
- External: MI6 (or SIS -> Secret Intelligence Service)
- Sigint: GCHQ (Government Communications Headquarters, larger than MI5&6 combined)
- NL
- General: AIVD (Algemene Inlichtingen- en Veiligheidsdienst, both internal, external and sigint, but focus on internal)
- Military: MIVD (focus on international threats)
- JSCU (Joint Sigint Cyber Unit, joint effort of AIVD and MIVD)
General lesson: working in secrecy "carries the risk to be av cover-up for failure and incompetence"
But there are some independent oversight instances (e.g. CTIVD in NL)
Security Protocol Example: Car Keys
1) $CK \rightarrow C : IdNr$
Everything unencrypted, unsafe.
2) $CK \rightarrow C : K{IdNr}$
Still unsafe. Easy replay attack: record K{IdNr} and resend it to the car to open it.
3) $CK \rightarrow C : K{N+1}$
Still unsafe. If you intercept K{N+1} you can still use it, but only once.
4) Challenge response:
$$CK \rightarrow C : "open"$$ $$C \rightarrow CK: K{N}$$ $$CK \rightarrow C : K {N+1}$$
More secure! But still vulnerable to a man-in-the-middle attack. Eve intercepts the challenge.
$$C \rightarrow E(CK) : K{N}$$ $$E(C) \rightarrow CK : K{N}$$ $$CK \rightarrow E(C) : K{N+1}$$ $$E(CK) \rightarrow C : K{N+1}$$
Slide set 2a: Symmetric Cryptography
Historical Crypto Systems
- Scytala
- Breaking Zimmerman telegram WWI by British brought US into the war (telegram incited war between Mexico and US)
- German Enigma WWII (breaking shortened the war)
- Breaking of Japanese JN25 code (WWII) by US provided intel for Midway battle ('42) and for ambushing Marshal Yamamoto ('42)
- http://cryptomuseum.com/
Terminology
Cryptography: encryption from plaintext ciphertext
Cryptanalysis: decryption from ciphertext to original plaintext
Cryptology: cryptography + cryptanalysis
N.B. Cryptography is often used sloppily to refer to cryptology.
What is a crypto system? And some notation.
Crypto system $/approx$ encryption scheme $approx$ cipher =
... algorithm + key (algorithm parameter)
Crypto systems map plain text onto ciphertext and vice versa, which both are fundamentallly mappings from words onto words. A word is a finite sequence of letters of an alphabet $A$.
$A^*$ is the set of all possible words over alphabet $A$.
$a_1|a_2$ is the concatenation of two words $a_1$ and $a_2$.
$\oplus$ is a bitwise XOR on binary words of the same length.
Kerckhoffs principle
"The strength of the crypto system must rely solely on the secrecy of the key; the algorithm must be (assumed to be) public."
Modern interpretation:
1) Algorithm must result from public scrutiny, e.g. via competition 2) Non-public algorithms must be distrusted, as they often turn out to be broken, e.g. Mifare.
Types of crypto systems
| #Keys | Name | Key names | Notation |
|---|---|---|---|
| 0 | hash functions | N.A. | h(m) |
| 1 | symmetric crypto | shared, secret | K{m} |
| 2 | asymmetric (public key) crypto | public-private keypair | ${m}_k$ |
Symmetric crypto: three basic techniques
We have m and want K{m}. Three basic techniques:
1) Substitution: exchange alphabet characters. * Key: character substitution/exchange function 2) Transposition: exchange position of characters * Key: position exchange function 3) One-time-pad: take bitwise XOR with keystream (binary messages only!) * Key: keystream with at least same length of message
Ciphers often combine 1 and 2 repeatedly, e.g. DES and AES.
Substitution
Key: function $K : A \rightarrow A$ with inverse function $K^{-1} : A \rightarrow A$.
Defined on characters, but extends to words.
This function needs to be bijective, i.e. it needs to have an inverse, otherwise decryption is not possible. That is: $K^{-1} \dot K = I$.
Example: Caesar's Cipher.
E.g. rotation 4 specifies substitution function with C(a) = d, C(b) = e, ..., C(z) = c. Rotation 4 has as inverse function rotation -4 or 26-4=22, so that e.g. C(d) = a.
Rot 13 therefore has itself as its inverse.
Example: Polyalphabetic substitution Vigenère (16th century)
Applied substitution function depends on the letters of a keyword.
Edwin: subsequent rotations of 5-4-22 etc.
Weakness
- Frequency analysis.
Most common letters in a given natural language probably correspond to the most common characters in the cyphertext. This can be exploited to find the used rotation quite easily.
Transposition
- Choose a blocksize N. Usually some power of 2.
- Padding is applied to fill the last block. Padding must be chosen carefully.
- Key: exchange bijective function of positions within a block, $K : {1,2,...,N} \rightarrow {1,2,...,N}$
- So also needs to have an inverse for decryption.
Examples
Regular transposition on blocks
m = "ikbengek". N = 3. Transposition function $K: {1,2,3} \rightarrow {1,2,3}$ is specified by K(1) = 3, K(2) = 1, K(3) = 2. Use 'x' for padding.
K{ikbengek} = K{ikb eng ekx} = bik gen xek = bikgenxek.
K(1) = 3 should be read from right to left for encryption. It says that the character that is now at position 3, will be at position 1 in the cyphertext.
K{$i_1k_2b_3$} = $i_{K(2)} k_{K(3)} b_{K(1)}$ = b i k
Columnar transposition cipher
- Take a word as key
- Write plaint text under key, wraps rows around so that columns are formed.
- Read cipher text as columns using the alphabetical order of the keys.
Weakness
- Letter frequencies are not changed, indication of transposition
- Frequent 2-letter combinations can be exploited to see the structure of transpositions
Product cipher
By Claude Shannon. A product cipher combines multiple ciphers to create a more secure cipher whose security is a "product" of the element ciphers that by themselves are not necessarily very secure.
An SP-network is a product cipher that alternates substitutions and transpositions (permutations)
Underlies the idea of block ciphers.
Block ciphers: mini encryption schemes
Encryption and decryption of text under secret K, which describes a unvarying transformation on each block.
Relevant parameters are block size N and the key length.
It is required that input and output are the same length, otherwise the process will not be invertible. Padding is thus often required.
If message m is longer than the block size N
- split up message in blocks, encrypt separately
- different modes of use
Block cipher modes of use
For longer and shorter messages:
Either use regular block encryption mode, and apply padding. Apply block cypher in some complicated way on the blocks.
Or: build a stream cipher with a block cipher as a building block. Cf. a pure stream cipher produces a key stream bit by bit, not block by block.
1) Electronic CodeBook mode (ECB)
Apply block cipher parallel and independently on all blocks.
Limitation: equal plaintext blocks will result in equal ciphertext blocks, leaking information.
2) Cipher Block Chaining (CBC)
- Initial Value / Initialization Vector (IV)
- XOR with plain text.
- Block cipher on that with the key
- This returns a ciphertext
- This result is reused to randomize the next block cipher (XOR with next plain text input)
Security depends on randomness of IV and management of IV.
Serial encryption, but parallel decryption.
3) Stream encryption by using block cipher in counter mode (Frequently used)
Good IV management is critical for security
Fully parallelizable
IV = D || i, with diversifier D, and i the sequence number of the block.
Keystream $z_0$ = K{IV}, $z_1$ = KV{IV+1}, .. $z_i$ = K{IV+i}
Example: DES
Block cipher with N=64 bits and 56-bit key. NSA-involvement. 56-bit key on the low site due to NSA requirements.
Federal Information Processing Standard (FIPS).
Keys prone to exhaustive search by the end of the 80s.
Triple-DES: patch to counteract short key-length. Use three keys. Encrypt with K1, decrypt with K2, encrypt with K3. Backwards compatibility by using the same key for all steps.
Slow in software.
Example: AES
Block length N = 128, with variable key length 128, 192, 256 bits.
FIPS standard. Replacement of triples-DES. Also works efficiently on software with dedicated CPU instructions.
Using Cipher Block Chaining for creating a MAC mode (CBC-MAC)
- Pad message
- Run CBC without IV on the whole message, split up in blocks
- Only keep the last block and its cyphertext
- Throwing away the others is essential for security, prevents reconstruction of original message. In that case... the MAC wouldn't do anything useful.
One-time pads
Encrypt and decrypt with the same key K via bitwise addition i.e. XOR.
XOR properties:
$$0 \oplus 0$$ $$1 \oplus 1$$ $$k \oplus k$$
Proof using basic XOR properties:
$$(b \oplus k) \oplus k$$ $$=b \oplus (k \oplus k)$$ $$=b \oplus 0$$ $$=b.$$
Limitations
Shannon proved perfect secrecy if:
1) the key is never re-used. 2) key K is completely random 3) every bit of K is used for a single message bit
Re-use is catastrophic:
Encrypt $M_1$ and $M_2$ with the same key K.
$C_1 = M_1 \oplus K$ and $C_2 = M_2 \oplus K$ $$C_1 \oplus C_2 = M_1 \oplus K \oplus M_2 \oplus K = M_1 \oplus M_2$$
This means that knowledge of $M_1$ reveals information about $M_2$, because for whatever partial bit of $M_1$ it holds that $M_1 \oplus (M_1 \oplus M_2) = M_2$
Key-reuse does occur in practice. The latter reveals key stream because it is know that the message is "abort", so XOR with the encrypted command will reveal key stream bits.
- Mifare CLASSIC re-uses part of the key stream, and sends the "abort" command encrypted.
- The Venona project revealed Russian spies.
LFSR One-time pad key stream generation
Linear Feedback Shift Register.
Register of binary bits. On the "left" side a bit is outputted. A new bit is inserted on the right side with a simple procedure.
The quality of this procedure depends on whether it can produce all $2^n$ words.
E.g. for a register of 8 bits, the new value $x_7 = x_0 XOR x_4 XOR x_5$ (calculate before outputting, i.e. it can depend on all bits in the register).
In this example, for state 11001010, the next state will be 10010100, because 1 XOR 1 XOR 0 = 0.
Example of broken LFSR: The Mifare CLASSIC (e.g. in OV-chip)
Stream ciphers
Generalization of LSFR with one-time pad is a stream cipher, that produces a key stream of arbitrary length to be used with a one-time pad.
A key stream Z is defined as Z = F(K,D).
Where F is the stream cipher, that takes as input:
- K: a short secret key
- D: a short diversifier that is public
The stream cipher is secure if its output looks random for anyone that does not know the secret key K. F(K, -) behaves as a pseudorandom function (PRF).
(N.B. the Diversifier is public).
The diversifier allows the generation of multiple different key streams per key K.
- The key can be the initial content of the register
- The function F captures the register cycles
Slide set 2b: Symmetric Crypto Security Protocols
Each protocol has a specific security goal. For different goals, different protocols are required.
Between protocol steps Alice and Bob perform actions. Also their beliefs might change. Alice and Bob may decide to abort a protocol during execution if a check fails.
Attacker Model: "Dolev-Yao" (strong)
Strong attacker model where the attacker can:
- Read ...
- Delete ...
- Copy ...
- Store for indefinite time ...
- Rebuild message.
But cannot:
- Break the crypto / break the cryptogram*
- Or find hash collisions or pre-images.
Such problems would be problems in the crypto itself, rather than a communication protocol.
*Cryptogram is the result of the abstract black box K{m}, which assumes a secure cipher.
Long term secrecy
In the Dolev-Yao attacker model, the attacker can store all messages indefinitely.
Forward security: Some applications are so sensitive that they require security into the future, taking into account technological advances in computing power and techniques.
Protocol basis for confidentiality
This protocol is the basis for confidentiality.
1) $A \rightarrow B : K_{AB}{m}$
With a stream cipher a sequence number i is required as a diversifier to ensure the key stream is never the same.
2) $A \rightarrow B: c_i = m_i \oplus F(K_{AB}, i), i$
Alice has to increment the diversifier every time:
The diversifier is public, so it can be sent along in cleartext. This helps reconstructing the communication when messages are out of order.
The sequence number may never overflow as this could potentially allow a cyphertext to be repeated.
TLDR; confidentiality can be achieved by appropriate encryption.
Protocol basis for integrity
Goal: Alice and Bob need to be certain that Bob receives exactly what Alice sent.
The previous protocol for confidentiality however does not guarantee integrity.
Attack: If one cyphertext bit is flipped, the message bit after decryption will also be flipped.
So despite confidentiality not being broken (message m is never read by Eve), the message has been altered.
Take-away: Encryption does not imply integrity.
For a stream cipher Z=F(K,D), integrity can be achieved by including the message as diversifier. So:
$$A \rightarrow B: m, T$$ $$T=F(K_{AB},m)$$
T is called a "Tag" or Message Authentication Code (MAC)
This way, if Eve changes m, Bob does not have access to the diversifier and cannot decrypt the message. This failure to decrypt will show him the message has been altered, and integrity violated.
However, confidentiality is clearly broken, as the message is sent along in the clear.
In this scenario, a stream cipher is used as a MAC code. However, the diversifier in stream cipher has a limited fixed length, e.g. 96 bits, whereas messages are often way longer. At the same time, stream ciphers produce an output that is as long as the message itself, which can be very long. For a MAC function 128 or so bits would suffice.
A dedicated MAC function T=F(K,m) fixed this by having a:
- arbitrary length input message m
- but short fixed length output T
Informal definition of MAC is similar to that of a stream cipher: secure if output T looks random to someone who does not have access to secret key K (whereas the message m is public).
But so far:
- No confidentiality yet
- Vulnerable to replay attack
Integrity resistant against replay attack
Solution: Include a sequence counter in the MAC computation (Where "||" means concatenation)
$$A \rightarrow B: i, m, T$$ with $$T=F(K_{AB}, i||m)$$
In this case it is the receiver Bob that needs to make sure the sequence number i does not repeat. Sequence number i is included in the MAC so that Bob can check the integrity of the sequence number itself.
vs. confidentiality: before we saw that a sequence number was also used for confidentiality. But there it was used to ensure uniqueness of the key stream. In the case of confidentiality it was the responsibility of the sender, Alice to ensure uniqueness of the sequence number.
Key separation for both confidentiality and integrity
Key separation: use different keys for different security goals.
So $K_{conf}$ and $K_{int}$
Achieve both confidentiality and integrity with:
$$A \rightarrow B: i,c,T$$ with $$c_i = m_i \oplus F(K_{conf}, i)$$ and with $$T=F(K_{int}, c_i || i)$$
So sequence number i is used for two purposes: key stream diversification and anti-replay
Upon receiving:
1) Check MAC T, which in this protocol does not have the plaintext message $m$ but the cyphertext $c$ as parameter. * If it fails, no point in proceeding. In that case the cyphertext has been changed. 2) Use $K_{conf}$ and $i$ to produce the keystream and perform XOR on the cyphertext to get the original message.
Authentication: by something you know
Via shared secret: password / PIN
- Vulnerable to phishing
- Password file may be hacked
Passwords can also involve authentication by skill: pronounce "Scheveningen"
ATMs and pin payments use PIN, very insecure protocol.
Authentication with crypto: challenge-response
Idea: it is better to not send the shared secret, but to use it. How? By sending a fresh "riddle" that can only be solved efficiently by someone having the shared key.
This riddle must be fresh to avoid replay-attacks. This is achieved by incorporating an unpredictable number from a large range of numbers (e.g. $2^{128})$
This number is called a nonce.
Examples for block ciphers (no diversifier/stream cipher used)
Where $N_A$ is an unpredictable nonce:
$$ A \rightarrow B: A, N_A$$ $$B \rightarrow A:K_AB{N_A}$$
Here Alice sends her identity and a nonce to Bob. Bob then replies to Alice with the nonce encrypted with their shared secret key.
Here only Bob authenticates to Alice by using their shared key. Bob has not authenticated Alice yet, so only one-way authentication at this point.
Variations:
The challenge is to decrypt and return the nonce, instead of to encrypt it.
$$A \rightarrow B: A, K_{AB}{N_A}$$ $$B \rightarrow A: N_A$$
Or Alice sends the encrypted nonce, and Bob needs to decrypt it, increment it, and send it back encrypted again.
$$A \rightarrow B: A, K_{AB}{N_A}$$ $$B \rightarrow A: K_{AB}{N_A+1}$$
REVIEW: what problems are left?
- Man-in-the-middle
- Reflection
Examples of challenge-response with a MAC function
Naive solution: Alice sends Bob her identity and nonce. Bob uses that nonce as a diversifier in a stream cipher together with their shared key. This proves his identity. Now he sends a challenge back to Alice in the exact same way.
$$A \oplus B: A, N_A$$ $$B \oplus A: F(K_{AB}, N_A), N_B$$ $$A \oplus B: F(K_{AB},N_B)$$
So in this scenario Bob authenticates first. In a client-server setup, that would be the server.
Similarly, you can use a timestamp. Alice encrypts a nonce and a timestamp. Bob authenticates by decrypting the nonce.
Q: How does Bob now the timestamp Alice used? Well... that makes using timestamps very hard.
$$A \rightarrow B: K_{AB}{N_A, timestamp}$$ $$B \rightarrow A: N_A$$
Again: the "server"-side (Bob) authenticates first. This is vulnerable against reflection attacks.
Nonces, random numbers, timestamps: definitions and relations
- Sequence number: increments with each message stepwise
- Nonce: number used strictly once
- Random number: unpredictable number
- Pseudo-random number: unpredictable by someone not knowing a secret (i.e. a seed)
- Timestamp (very accurate (e.g. in ms) encoding of date and time)
Sequence number is a special nonce (if it doesn't wrap around after overflow)
Timestamp is a nonce if the clock is reliable and accurate enough.
Random number is a nonce is it is long enough for the key, and has a sufficiently uniform distribution.
Pseudo-random can be a nonce. There are non-crypto examples that are not usable (e.g. middle-square method).
Orthogonal properties:
- To ensure one time use, requires a keeping state (Weird terminology to me)
- Requires some magic to be unpredictable
When nonce, when random number?
Nonce:
- Stream encryption of multiple messages
- Anti-replay
Random number:
- Ensure freshness of messages
- Generation of cryptographic keys
Timestamp:
- Freshness without random number
Pseudo-random numbers are cryptographic primitives, which means they are low-level crypo-algorithms, like for example hash functions, that are often used for building cryptographic protocols.
Reflection Attack
def Reflection Attack: attack on the protocol using two or more sessions.
Cf. A man-in-the-middle attack is within one session.
This was the protocol for authentication using a stream cipher with nonces.
$$A \oplus B: A, N_A$$ $$B \oplus A: F(K_{AB}, N_A), N_B$$ $$A \oplus B: F(K_{AB},N_B)$$
But because Alice can send a request without having to authenticate the first, this protocol is vulnerable against a reflection attack, using two sessions.
$$(a) E \rightarrow B: A, N_A$$ $$(a) B \rightarrow E: F(K_{AB},N_A),N_B$$ $$(b) E \rightarrow B: A, N_B$$ $$(b) B \rightarrow E: F(K_{AB}, N_B),N$$ $$(a) E \rightarrow B: F(K_{AB},N_B)$$
So:
1) Eve can initiate the attack, as Bob authenticates first 2) By sending the identity A again in step 3, Bob uses the shared key $K_{AB}$ again. 3) In step 5, Eve replays Bob's own message. 4) As a result, Bob solves his own challenge
Fix one: Key separation
Due to both directions of authentication using the same key, the previous attack (see point 2) is possible.
Separating keys, such that $K_{AB} \neq K_{BA}$ would solve this issue.
Fix two: initiator must authenticate first
Good design rule in general, with downside that more messages are required in the protocol.
Let Bob send the challenge first, terminate protocol if initiator does not authenticate.
Fix three: combine it all, also against replay attack
The principle of key separation can be combined with nonces in MAC functions, through domain separation.
You need to ensure that a MAC-challenge for Alice is always different than a challenge for Bob, to avoid these being replayed.
E.g. append 1 to nonce for Alice, 0 to nonce for Bob, giving:
$$A \oplus B: A, N_A$$ $$B \oplus A: F(K_{AB}, N_A || 1), N_B$$ $$A \oplus B: F(K_{AB},N_B || 0)$$
Imagine the same attack:
$$(a) E \rightarrow B: A, N_A$$ $$(a) B \rightarrow E: F(K_{AB},N_A || 1),N_B$$ $$(b) E \rightarrow B: A, N_B$$ $$(b) B \rightarrow E: F(K_{AB}, N_B || 1),N$$ $$(a) E \rightarrow B: F(K_{AB},N_B || 0)$$
At step 4, Eve sends the identity of Alice together with the nonce for Bob. For the attack to succeed, Eve needs the challenge to be encoded for Bob. But since he sent the identity, the challenge he gets at step 4 now is encrypted for Alice. So he cannot reuse it in the last step.
Man-in-the-middle attack
All protocols so far are vulnerable to man-in-the-middle. Consider the basic protocol we discussed a few times now:
$$A \rightarrow E(B): A, N_A$$ $$E(A) \rightarrow B: A, N_A$$ $$B \rightarrow E(A): F(K_{AB}, N_A), N_B$$ $$E(B) \rightarrow A: F(K_{AB}, N_A), N_B$$ $$A \rightarrow E(B): F(K_{AB}, N_B)$$ $$E(A) \rightarrow B: F(K_{AB}, N_B)$$
A thinks E is B, and B thinks E is A.
Eve cannot take initiative. This is a classic man-in-the-middle attack.
However, if the attacker takes initiative, and from there on simply relays messages between two parties, we speak of a relay attack, which is a variety on man-in-the-middle and can be an extension of replay attacks as messages do not necessarily need to be read.
Intriguing remark in syllabus: "any router performs a relay attack, in a strict sense".
Examples
- Car key relay attack
- "Man-in-the-browser"
- Iranian forget certificates of DigiNotar for MITM on Iranian Gmail users
Slide set 2c: Active Attack Overview
Replay attacks
- Eavesdropping and resending message
- Counter: include nonce, verify it
- Reflection attack:
- Typical attack for two-way challenge-response protocols for authentication
- Counter: key separation, or domain separation.
Man-in-the-middle attacks
- Relay attack
- Passive, without any modification
- Lunch-break attack
- Delayed passive MITM
- Get response from prover and use them later
- Typical for physical access: car keys, access badges etc.
- Counter: random challenge from verifier to ensure freshness
- Active version
- Breaking crypto
- Out of scope
Slide set 2d: Symmetric Key Management
Per pair of people a symmetric key (at least) is required.
For N people, $\binom{N}{2}$ secret keys required, is $\frac{N(N-1)}{2}$.
Trusted Third Party (TTP)
Every user has a key with the TTP. They then ask the TTP to set up a shared key with someone else.
$$B \rightarrow TTP: key \; request \; for \; B \; to \; A$$ $$TTP \rightarrow B: K_B{K_{AB}} \; and \; ticket= K_A{K_{AB}}$$ $$B \rightarrow A: ticket, \; traffic \; secured \; with K_{AB}$$
The TTP sends whoever requests it a shared key, and also creates a ticket. This ticket contains the very same key encrypted for the recipient of the intended communication, so that that person can decrypt the message.
TTP offer additional services, such as guaranteeing freshnes of all keys, the ticket, key requests and expiration of the shared key etc.
Key Derivation / Diversified Keys
For payment and transport smart cards, for n cards and m terminals, nm keys are required.
Solution: Use a super secret master key, together with the ID of the card, in a crypto function to produce a card key. Often implemented in terminal hardware. Only online in a central system.
Terminal T checks whether ID is valid, and computer the key for communication with the card $K_C$.
$$C \rightarrow T: ID_C$$ $$T \rightarrow C: N$$ $$C \rightarrow T: F(K_C, N)$$
The process can be repeated to produce session keys.
Slide set 2e: Passport example
Basis of passport security: the consent of the user is required to read the passport.
Passports protected by:
1) Basic Access Control (BAC) * Picture, name, after user consent 2) Extended Access Control(EAC) * Fingerprint only after terminal authentication - Not currently rolled out, fingerprints not actually used...
BAC
Passport has Machine Readable Zone (MRZ) with unique info (data, BSN etc).
Two 3DES keys for chip communication derived from MRZ: one for confidentiality, one mac key for integrity.
Idea of consent here is that the passport needs to be handed over so that the MRZ can be read.
Particular BAC passport protocol used skipped.
Possible attack: Level below attack
Exploit differences in how cards react to different events, without having to know secret keys. E.g. timing of error messages might show info about the procedure used. Information given in error messages as well.
Example: Fingerprint e-passports
Passports from different countries send different error messages for out-of-protocol messages. This can identify the nationality of the passport holder, which might be sensitive information.
Timing attack
Assume you are checking a PIN code. If you give an error message as soon as a PIN digit is wrong, the attacker knows what digit to adapt.
On the e-passport:
Many implementations check integrity/MAC before a nonce check. So an error in the former will appear sooner.
Given that you have eavesdropped on communication of an e-passport.
You can request a nonce to communicate with that passport, that check will always fail. But if it fails later you know that the MAC check actually passed, linking the passport to the observed communication, proving someone's identity.
Slide set 3: Hashing
Definition and properties
Input: arbitrary length message. Output: fixed length digest.
$$h: {0,1}* \rightarrow {0,1}^N$$
h(m): hash value, message digest, cryptographic fingerprint
Properties:
- For same message m, always same h(m)
- h(m) and h(m') look completely random and unrelated when $m \neq m'$.
Security:
- Secure when every bit of h(m) depends on all bits of m.
- Secure when hash results h(m) look random with no apparent relation to input m
Example use of hash for a secure coin toss bet
C are coin toss results.
Commitment phase, using domain separation:
$$A \rightarrow B: Z_A = h(C_A || N_A || 1)$$ $$B \rightarrow A: Z_B = h(C_B || N_B || 0)$$
Revealing phase:
$$A \rightarrow B: C_A, N_A$$ $$B \rightarrow A: C_B, N_B$$
B checks honesty of A by hashing C, N and 1 to see if it matches the hash that was sent before. A does the same.
Example hash for signing
Hash a contract, then sign the hash. This was a notary can sign without having to see the contract itself. Only the original contract should be able to result in this hash. In case of conflict, the notary can hash the contract and compare with the hash to check its validity.
Requirements
Preimage resistance: h(m) does not help in any way to find m.
Second preimage resistance: if you already have m, then finding m' with $m \neq m'$ and h(m)=h(m') shall be infeasible.
Collision-resistance: it is not computationally feasible to find two messages m and m' with $m' \neq m$ such that h(m)=h(m'). In this scenario, m is not given yet, any collision will do.
N.B. Collision resistance implies second preimage resistance.
Attacks
Alice is selling a house to Bob, and they signed a hash of the contract.
Outsider attack (counter: second preimage resistance): Bob builds a second pre-image for the existing m (e.g. the contract) that results in the same hash. This new contract may contain a new (lower) price for the house. Bob can use this to sue Alice, if she will not sell for the lower price.
Insider attack (counter: collision-resistance): now it is Alice that tries to cheat on Bob. Before signing the contract, Alice made sure to find a collision such that both m and m' (two contracts, where one lists a higher price) produces the same hash value h(m). Bob signs the contract to pay 300K. Later, Alice reveals a contract that states that Bob agreed to pay 500K, showing that indeed this contract produces h(m).
Hashing passwords
Assumes preimage resistance: password cannot be retrieved from the hash.
(Multi-target) Dictionary attack
- simply try common names, or brute force character combinations and hash them.
- The more entries, the more chance that you will find at least one hit (and more bad passwords)
- Counter: original passwords with sufficient length
Diversification
- User-name based
Include unique username in hash, of form h(username;passwd). This prevent multi-target attack, because now passwords need to be guessed per user.
- Include servername/URL to prevent collisions with username-passwords on other servers
- Include password serial number to counteract reuse of passwords within the server
- Salting: random value used for diversification
- If it is unique per user, then it has the same resistance against multi-target attacks as user-name based diversification.
Salting is domain separation.
An important property is that when a hash function is ideal, any derived hash function that applied domain separation is also ideal.
From h(m) we can build h(m||0) and h(m||1) etc.
For h(m||a) with binary string a with length n you can build $2^n$ hash functions.
Key stretching
To counteract increase in computational power, hashing is artificially slowed down. This is called key stretching.
Application: Integrity Check
Hashes are used to verify the integrity of software, evidence, blockchain, etc.
This requires second preimage resistance, otherwise a different message could produce the same hash as the message you want to check.
Does not necessarily require collision resistance, because you already have m locally, so you are guarding yourself against outsider attacks, not insider attacks.
A subtle difference: in this case the message m is more or less public, i.e. it is not necessary to have preimage resistance (although this will be the case in practice) for this type of integrity check against someone fiddling with your files.
If you need the message to remain secret, while still proving you are the author/owner, then you also need preimage resistance.
E.g. blocked publication, so m is secret, but you do want to prove authorship at a particular date. So you publish the hash. You will get sued for publishing the actual paper, so it is very important that there is preimage resistance.
Expected Costs of an ideal hash function
1) preimage resistance: given h(m), finding m is expected to cost $2^n$ hash computations. 2) second preimage resistance: given m, finding h(m)=h(m') with $h(m)\neq h(m')$ is expected to cost $2^n$ computations. 3) collision-resistance: expected cost is $2^(n/2)$ due to birthday bound.
For 3 any collision will do.
Birthday collision in a group of people:
For first person: 0. 2nd person: 1/365. 3rd person: 2/365. So for i people the chance of a clash is:
$\frac{1+2+3..+i-1}{365}=\frac{(1+i-1)+(2+i-2) ...}{365}=\frac{365i(i-1)}{365}$
Resulting in: $p(clash) = \frac{i(i-1)}{2*365}$.
For hashes, the domain size is $2^n$ instead of 365.
$$\frac{2^ni(i-1)}{2^n}=\frac{2^ni^2-2^n}{2^n}$$
MATH DOESNT CHECK OUT, REVIEW LATER
Merkle-Damgard hash design
Split up hash function into a series of functions f applied on fixed length inputs.
- Split up message in blocks, apply padding if needed
- first function takes IV and $M_i$, others take partial result $CV_i$ and $M_{i+1}$ (chaining value)
This setup is collision-resistance preserving, i.e. that if function f is collision resistant, the whole hash function also is. This implies that a collision in the overall hash function implies a collision in function f.
Examples, MD5, SHA-1, SHA-2.
Slide set 4a: Public Key (asymmetric) cryptography
For symmetric cryptography, a shared secret needs to be established, and stay secret. This is a hard problem. Public key cryptography makes this problem a bit easier. (But moves the problem to another level: is the public key authentic?)
With public key crypto:
- Authentication of a message without sharing of a secret key
- Electronic signatures without writer's secret key
- Set up a key remotely without secret channel.
Notation:
PrK: private key.
PK: publick key
In principle, the private key can be computed from the public key, but this is computationally infeasible.
Types of public key use
1) Signature schemes - Use private key for signing a messsage - Use public key for verifying (anyone can do that, it's public!) 2) Encryption schemes (in theory) * Encrypt message with someone's public key (anyone can do that) * only who has the corresponding private key can decrypt. 3) Key-establishment (of symmetric keys), e.g. Diffie-Hellman * Use your own private key and the public key of another to establish a symmetric key
Examples / history
- Idea of public key crypto: Merkle, Diffie, Hellman
- Rivest, Shamir, Adleman (RSA) publish first key signature and encryption scheme
- Elliptic Curve Cryptography by Koblitz and Miller: dominant today.
Slide set 4b: Math behind public key cryptography
Full notes on paper.
The computational hardness of prime number factorization of numbers is the basis for public key crypto.
Selected relevant definitions
$Z_N$ numbers modulo N: {0,1,2,..,N-1}.
$Z_N$ contains the equivalence classes of numbers $0 \leq k \leq N$ given modulo N.
E.g. equivalence class for modulo 10 and k=3, { 3, 13, 23, 33 etc. }
Addition and multiplication are defined with the modulo operator.
$a \dot b$ is reserved for the usual product, whereas $a x b$ is here taken to imply a modulo N.
Some products modulo N are 1, e.g. $4x4 \equiv 1$ (mod 15). This has a multiplicative inverse, with a confusing notation (note the equivalence sign, not equals sign):
$$ \frac{1}{4} \equiv 4$$
Or:
$$4^{-1} \equiv 4$$
Some relevant properties / terminology w.r.t. additive groups.
Closed under addition, adding two elements of $Z_N$ modulo N will again be an element of $Z_N$.
For all $a$ in $(Z_N,+)$, if you take that a and keep adding it to itself modulo N, you will find a number of possible elements before you are in a loop.
#a (order of a) is the length of this group. #smallest number such that $na=0$.
Cyclic groups can be used as a generator
Take $Z_12$, with {0,1,2,..,11}.
Element 3 as generator <3>: {3,6,9,0}
Inverse of any number in that group is the order minus the index i, times the generator. Inverse of 3 is (4-1)3=9. Check: 3 + 9 (mod 12) = 0.
Shortcut for finding the order of an element in $(Z_N, +)$ (additive groups for elements {0,...,11}): smallest i such that ix is a multiple of n.
$$#x = N / gcd(N,x)$$
Lagrange theorem on $Z_n$: #a divides the order of the group, which is N.
Lagrange theorem (rephrased): the order of an element divides the order of the group.
Example:
Take $Z_{21}$. Order of this group is 21.
$#3 \in Z_{21} = 21/gcd(21,3) = 21/3 = 7$ $#5 \in Z_{21} = 21/gcd(21,5) = 21$
Multiplicative Groups
You can visualize $(Z_N, X)$ with a multiplication table of all elements in $Z_N = {0,1,...,6}$ with each other.
Each row, or column are themselves an additive group.
When do all elements in ($Z_N \ {0}, x)$ have inverses? A: for N = prime p.
Relative primes lemma: m has multiplicative inverse modulo N iff gcd(N,m)=1.
But when N is a prime, then of course any number lower than itself will not divide it, i.e. gcd(N,x)=1 always when N is a prime and x < N. (The latter holds due to mod N)
In $Z_p$ where p is a prime, each element is coprime to N and thus has an inverse.
In $Z_n$ where n is not a prime, only some elements have a multiplicative inverse, because not everything will be coprime to N.
Euclidean Algorithm
For $n > m > 0$
gcd(n,m)=gcd(m,n mod m). Iterate until one element is 0, which results gcd(x,0)=0.
Find multiplicative inverses: Extended Euclidean Algorithm
Used to find the inverse of m modulo N if gcd(N,m)=1, i.e. if element m is co-prime to N.
(That is to say, according to the relative prime lemma, that is has an inverse. You will not find an inverse if it does not have one).
Practice on paper. Review the handy table way.
Square-and-multiply
Practice
Slide set 4b: RSA cryptosystem
Trapdoor function: factorize n into primes p * q. Why trapdoor? Works easy one way not the other. Given the primes, n is really easy to compute (multiplication), whereas factorizing n into primes is very hard.
Encryption of message with public key PK=(n,e):
${m}_{PK} = m^e mod n$
Decryption with private key PrK=(n,d):
$[c]_{PrK}=c^d mod n$
For decryption the same modulus n is used, which is a factorization of large primes.
So in order to get the original message, we require $m=c^d=m^e$.
Def $Z^*_n$ is defined as the numbers m < n that have an inverse modulo n (i.e. are coprime to N).
If N is a prime, then all elements in that group are coprime to N. This implies that N is a prime, the order of the set is N-1.
See further: totient function.
This is just a particular definition. So far we have worked with $Z_n$ which is simply {0,1,..,n-1}. $Z*_n$ is the subset of that set that contains only primes.
Now, based on this new set, we can again define a multiplicative group ($Z^*_n, x)$.
Mathematical details written out on paper.
Partial result: $m^{#Z^_n}=1$ and desired result $m^{ed}=m$, gives $m^{edmod #Z^*_n} = m$.
This requires $edmod #Z^*_n=1$.
This means that for $mod #Z^*_n$ the public exponent e is the multiplicative inverse of private component d.
This is what is meant when it was said that in public key crypto in principle the private key can be derived form the public key. However, we do need to know the order $#Z^*_n$
This however, is the step that is computationally hard and requires refactoring N. WHY?
What is the order of the multiplicative group of $Z^*_n$ (contains only primes)?
By definition the order of that group is the totient function of N, because the totient function is:
def Totient function $\phi(N)$: the number of integers smaller than and coprime to N.
But $Z^*_n$ itself was defined as the group of integers modulo N (so < N) coprime to N!
As said before, if N is a prime, then all numbers from 1 to p-1 are coprime to N (0 is excluded), so the totient/group order is N-1.
In RSA $N$ (coming from mod N) is picked in such a way that $N=p \dot q$.
So to know the totient, all multiples of p and q should be removed from that set, and 0 is also excluded.
Formula for that solution: $\phi(pq)=(p-1)(q-1)$.
Requires factoring into p and q!
In other words, computing the order of this group with the totient is computationally as hard as factoring N into primes!
Oversight RSA
- PK: (e, n)
- PrK: (d, n)
- where $n = p \dot q$ with p and q large primes.
Public exponent:
- Public exponent e kept small, e.g. $2^{16}+1$ for easy computation.
- (p-1) and (q-1) must be coprime to e.
- WHY? Do they mean their product, because then I get it.
Private exponent:
- Private exponent d is inverse of e modulo $\phi(pq) \equiv #Z^*_n$
- d is also very large, close to n.
Security RSA:
- If n is given, then the totient of n helps finding p and q (right?)
- From the factorization of n you can compute private exponent d from (e,n) (how?)
- p and q must be large and unpredictable.
Generate a key pair
1) Generate a public exponent e (small, "imposed by the context"?) 2) Generate random prime p with length |n|/2 - then p-1 will be coprime to e. (Why?) 3) Generate random q such that $p \dot q$ has length |n| (?Where does this come from?) 4) Compute private exponent d as $e_{-1}$ mod (p-1)(q-1).
RSA efficiency
- Private exponentiation with square and multiply (grows with third power of modulus length)
- Public exponent: efficient do to small public exponent
- Key generation: very expensive, about 15 to 40 times more expensive than private exponentiation.
Using RSA
1) Encryption - Encrypt with public key of recipient - Decrypt with recipients own private key 2) Key establishment - Same procedure, but the message is a symmetric key for further communication 3) Signature scheme - Sign S with private key - Everyone can verify with the corresponding public key.
Attention points for encryption with RSA
Advice: do not encrypt data with RSA.
- The message needs to have enough entropy, otherwise one can potentially find m and easily check it with computation.
- Confidentiality: add random string r: m=PIN||r
- In symmetric encryption a nonce is sufficient for confidentiality
- Freshness: include a new challenge N, m = PIN||r||N.
Hybrid solutions:
1) encrypt symmetric key K and continue with symmetric cryptography. 2) KEM: RSA Key Establishment Method - Encrypt a random value with RSA - Recipient decrypts it - Both parties use the random value in a hash function to establish a symmetric key. - In this method the key is never directly exposed in communication, unlike previous option.
Attention points for signatures
- A third signature can be created by multiplying (mod n) the other signatures, for a third message $m_3=m_1 \dot m_2 mod n$.
- Hard limitation on message length
These two problems are solved by signing h(m) instead of m, where h(m) is an ideal hash function with output in $Z_n$. (The question is whether such a hash function can successfully be built).
Slide set 5a: Public Key Authentication
When using public key cryptography properly, you have confidentiality. But the public key authentication problem is that you need to be sure that the public key you are using to encrypt a message from someone, is in fact from the person you are trying to reach.
Cryptography does not solve problems, but reduces them to another problem: the authentication of keys, in this case.
Three approaches
1) Not institutionalized * Manual validation, bottom-up, crowd style * Or web of trust 2) Institutionalized: Public Key Infrastructure (PKI) - Phone-book style, trust in authority - Authority in this case: Certificate Authority (CA) 3) TOFU: Trust on First Use * If first communication is successful (without checking), assume it is correct thereafter.
Not institutionalized
Manual validation:
- Often of hash of the key $h(PK_B, Id_B)$, called a fingerprint
- This hash needs to be 2nd preimage resistant
- Otherwise someone can construct another key with the same fingerprint.
- Which would destroy the whole signing mechanism.
Web-of-trust:
- Alice wants to communicate with Bob
- Edwin authenticated Bob's PK
- And Alice already authenticated Edwin.
- So Alice asks Edwin to send Bob's key and identity and sign it with Edwin's PrK.
- By extension, Bob's key is also trusted.
- Only works if Edwin is trustworthy: Edwin can pretend to send another public key that he has the private key of.
- But Edwin can be caught with manual validation.
- Solution: ask multiple friends to sign.
Institutionalized: PKI
A public key certificate is a signed statement linking keys to identities.
The CA signs a statement with their own private key, stating:
"Trustee (the CA) declares that PKx is the public key of X."
Good certificates have a start and end date, and serial number.
- Certification Authority (CA)
- Generation of public key certificates
- Revocation
- Multiple levels: root CA, intermediate CAs.
- Registration Authority:
- Verification of identity of user
- Laboursome, expensive.
- Various levels of thoroughness
E.g. VeriSign three assurance levels:
1) Class 1: user has a unique name with the CA and a registered email address 2) Class 2: verification of applicant information "against identity proofing sources". 3) Class 3: requires physical presence and government ID.
Usage examples
- Server-side certificates with TLS and https: confidentiality + authenticity
- Code signing: integrity and authenticity of code
- Client-side certificates for secure remote logic, e.g. in VPNs.
- National ID cards, passports.
Revocation
- Local, offline
- Maintain a list
- Attack: overflow the list
- Online Certificate Status Protocol(OCSP)
- Send an OCSP request with serial number of certificate
- CA replies with signed OCSP response
- Privacy: with who and when you communicate is known to CA.
OCSP style does not require long-term certificates. They are less secure anyways.
PKI continued: Certificate Chains
Review more complex exercises on this
- Bob signs the key of Alice, with his private key
- Charley signs the key of Bob, with his private key.
We have the public key of Charley. If we trust Charley, we by extension also trust Bob and Alice.
How does this look like in practice? Consider e-passports for automated checks.
An NL passport (let's say of Alice) contains:
- Embedded private key
- Alice's certificate signed by producer Morpho.
- The certificate of Morpho, signed by the Dutch state.
The gate has the NL root CA public key, that can be used to verify the signature on Morpho's certificate on the card. Authentication as follows:
1) Read and validate Morpho's certificate with $PK_{NL}$ 2) Read and validate Alice's cert. with $PK_{NL}$
Through this chain, the gate trusts the public key of Alice, which it used to verify challenges signed by the e-passport in the following protocol.
PKI Issues
There is a tension between the idea of public key crypto and PKI-based crypto. The idea was to have authentication and confidentiality without need for pre-shared keys or TTP, but CAs are nothing more than a TTP. Moreover, they are companies in it for the money, and not always trustworthy.
At the end of every chain is a root key that by definition cannot have a certificate. It sometimes has a self-signed certificate, which is completely useless security-wise.
N.B. there is no such thing as a "root certificate", but this name is often used for root keys.
There are some free certificate services (CAcert, Let's encrypt) that do not provide robust accountability.
But in the philosophy of opportunistic encryption, hindering mass surveillance and impersonation, their use still makes some sense.
TOFU: Trust on first use
Trust the public key you receive is authentic without any validation. It thus promises security but without the effort of key management and validation that is required.
Very vulnerable to man-in-the-middle attack.
Used in:
- Signal
- de facto uses of PGP/GPG
But WhatsApp does offer manual validation.
DigiNotar case study
DigiNotar CA hacked by Iranian hacker. Claiming that it was political repercussion for Srebrenica.
Via OCSP calls the use of the rogue certificates could be traced back.
Turned out the rogue certificates were not used as an attack on NL, but on Iran's own citizens to intercept gmail traffic.
Hacker could have put all DigiNotar root CA keys on blacklist: this would have crippled the Dutch government. Would this have been an act of war? A problem with this question is that in an act of war, the perpetrator is usually identifiable.
DigiNotar was hacked due to neglect:
- All CA servers in one Windows domain, no compartmentalisation.
- No antivirus
- 3 years of updates behind on CMS
- Malware used was detectable.
Lessons:
- Know your system
- Use multiple certificates for crucial connection as a fallback
- Require security audit, not only management audit
- Security companies themselves can be used by bigger players: i.e. the attacker is a state.
Slide set 5b: Discrete-log based cryptography
Again we have a trapdoor function, e.g.:
$$y=3^x \; mod \; 17$$
Given, x, y is easily computed with exponentiation.
However, due to the modulo, given y it is extremely hard to find x with a logarithm.
Take multiplicative prime group $(Z^*_p, x)$ as a cyclic group with order p-1 (because N=p is a prime).
Find a generator in that group, e.g. 3. For p=5 that group will look like:
<3> = {1,3,4,2}. Note, order of this group is p-1=4.
where 3x3 mod 5 = 4, 3x3x3 mod 5 = 2, 3x3x3x3 mod 5 = 1, $3^5 mod 5$ = 3, $3^6 mod 5 = 4$, $3^7 mod 5 = 2$ etc.
In other words, a generator can be rewritten in terms of exponentation: $G^i$.
For any chosen generator in that group, multiplication of $g^a$ and $g^b$ is the same as raising that generator g to the power (a + b mod (p-1)). In other words, multiplying in $Z^*_p$ is the same as addition of the used components in the group $Z^(p-1)$, so modulo (p-1).
Central property
E.g. in $Z^*_5$ with generator 3, $3^1 x 3^2 = 3 x 4(9) mod 5 = 2$ equals $3^{1+2 mod 4} mod 5 =3^3 mod 5 = 2$.
This property is abused by log-based crypto.
See illustration in slides of two cyclic groups. The outer group is the multiplicative prime group for a chosen generator, i.e. exponentations of that generator.
The inner group is the equivalent group in the additive group of p-1.
Choosing G: choose G such that #G is the greatest prime divisor of p-1. Jeez Louise!
Example:
- We take $Z^*_p$ with prime p = 103.
- To choose a suitable generator, we first find the greatest prime divisor of p-1=102.
- Factorize 102 into $2x3x17$. So 17 is the largest prime divisor.
- What generator in $Z^*_{103}$ has order 17?
- Reminder: these elements do not have to be prime, only coprime to 103. But since 103 is a prime, all elements < 103 {0} will be coprime.
- I assume this step is not required for the exam, but that the generator will be given to us.
- $8 \in Z^*_{103}$ and #8=17.
- So 8 is our generator within the multiplicative prime group with p=103.
- We know that #8=17, in other words, the exponents of the outer (multiplicative) ring with generator 8, will be {0,1,..,16}. Write those down on the inside of the ring.
Final result / central property applied:
From the central property we know that multiplication in the outer ring, is the same as exponentiating the generator with the sum of the exponents.
E.g. $8^1 \times 8^3 = 8 \times 512 mod 103 = 8^4 mod 103 = 4096 mod 103 = 8^(1+3 mod 102) mod 103$
N.B. to do these calculations we need to know domain parameters: g and modulus N.
Uses of Discrete-log based crypto
The movement from the inside to the outside of the circle represents a trapdoor function.
I.e. if you know the inside (the exponent), getting to the outside is easy through exponentiation. E.g. $8^i mod N$ where i is the inside value, N is the known modulus of the multiplicative prime group (of which the used generator is an element).
However, the other way around is extremely hard. Given the 'outside value', e.g. '9', what exponent was used on the generator modulo N to get 9? In this scenario: for what i $8^i mod 103=9$?
This is useful for:
1) Key-establishment with (Merkle-)Diffie-Hellman 2) Encryption of messages (El Gamal) 3) Signature schemes (Schnorr, DSA)
(Merkle-)Diffie-Hellman key generation
Both Alice and Bob have a public and a private key, where the private key corresponds to the "inner circle", i.e. the used exponent on the generator, and where the public key corresponds to the "outer value" which is the result of exponentiation modulo N.
Note that from private key a it is easy to compute public key A because $PrK_{Alice}=a$ and $PK_{Alice}=A=G^a$. But not easy to compute the other way around!
To compute shared secret $K_{AB}$, both parties take their the public key of the other party and exponentiate that with their private key. So:
$$K_{AB}=A^b=B^a$$
This holds because $A^b = (G^a)^b=G^{a \dot b}=(G^b)^a=B^a.$
To do this, Alice and Bob only need to exchange their public keys. Computation of a symmetric key is done offline, and the key as such is not exposed in any communication.
Diffie-Hellman Attention points
Security:
- Either a or b will result in compromise of the symmetric key.
-
Having
, A, and B, it should be prohibitive to compute K_{AB} - But this has not been proven! (decisional Diffie-Hellman hardness assumption)
-
Domain parameters need to be known and shared
Public key authentication:
- If the public key of the other party is validated, you know for sure the other party only has the shared key.
Entity authentication? (UNCLEAR TO ME)
- with symmetric crypto challenge-response using the shared key
- along with encryption, message authentication...
- $h(K_{AB})$ can be used for deriving symmetric keys from the established key.
Diffie-Hellman key exchange cases
1) Mutual authentication: both parties authenticate each other's public keys. 2) Unilateral authentication: Alice authenticates Bob's public key, not vice versa. * Bob is still the only person with $K_{AB}$, (but Bob does not know the same of Alice) * Confidentiality: only Bob can read what she sends - Only Bob can use the shared key to generate MACS for integrity checks. - E.g. used in browsers, TLS. 3) Static Diffie-Hellman: Key established once, used for long term * Leakage of $K_{AB}$ or a or b allows decryption of all past cryptograms. - No no forward secrecy with this static method.
Diffie-Hellman key exchange with forward secrecy
Ephemeral key pair: Generate a new key pair per session.
Unilateral case:
If, like in browsers, Bob does not validate Alice's key (Bob is the website), then Alice can generate a new key pair for herself for each new session without problem.
She needs B to encode her session only for Bob, but only Bob can decrypt her message using the fresh public key A and his own (static) private key.
Now, if the shared key or a is leaked, only one session is compromised.
Leaking b is still catastrophic, as this key is still static.
Dynamic Diffie-Hellman
For better forward security, both parties can generate ephemeral key pairs.
Crux: a static/long-term key pair is only used for signing/authentication, not for encryption. - Alice signs (Alice, A, N) with her long term private key. - Assuming an authenticated public key $PK_A$, Bob verifies the signature of Alice. - Now Bob knows that indeed Alice sent him A and N for session communication. - Vice versa for mutual authentication. - Ephemeral keypairs used for setting up symmetric key for session - Leakage of the shared session key, a or b, only affects one session only. * Because the longer-term keys are never used for encryption. - Obviously, the session keys need to be deleted after the session to have forward security.
N.B. this works in theory for RSA, but in RSA key generation is very expensive.
El Gamal: Discrete-log based encryption
Using the same math, but then for encryption and decryption.
Encryption using public key (ephemeral key pairs)
Bob is sending a message to Alice.
Alice needs a large prime number p to determine the group. And Alice needs g. This is public information / domain parameters, that Bob needs to encrypt the message for Alice. Alice computes her ephemeral key pair based on this. Her public key is needed for encryption.
$A=g^a$
1) When encrypting a message, you need a mechanism for converting that cleartext into an element of
Decryption by Alice with private key a
Required by Alice for decryption:
- private key a
- #G the order of chosen generator G. (How does Alice know this?)
- The encrypted tuple C=$(C_1,C_2)$ that comes from $(R=G^r, M x A^r)$.
To decrypt according to the slides:
1) $C_2 \times C_1^{#G-a}$ * FAST method: $(c_1^{-1})^a = c_1^{-a}$ * Inverse rule: $c_1^{#G-a}$ * Compute #G quickly with Euclidean algorithm with p-1 * i.e. #G $= (p-1)/gcd(G,p-1)$ * You use p-1 because multiplication in prime group is the same as addition in the additive group of p-1. 2) Result is $M'$
I do not think the math behind this is intuitive, just ... learn the formulas I guess.
To decrypt according to another paper:
1) $x \equiv c^a_1 (mod p)$ 2) Then Alice also computer $x^{-1} (mod p)$. * This is the multiplicative inverse 3) Multiply $c_2$ with $x^{-1}$ 4) Result is m!
Slide set 5c: Elliptic Curve Cryptography (ECC)
Koblitz and Miller.
General properties:
- Shorter keys
- Shorter signatures
- Shorter cryptograms
- Faster key establishment ...
- ... signing ...
- ... and key pair generation
- but slower signature verification
So far group operations have been multiplication and addition in circular groups with modulos.
ECC's group operatoin is given by addition of points on an elliptic curve with formula $y^2=x^3+ax+b$.
Choose generator G as a point on the EC with #G being a prime.
All discrete log math so far can be applie to EC: EC Diffie-Hellman, EC Elgamal, EC Schnorr, ECDSA.
Private key: integer a in the group of generator G, just like before.
Public key: a point on the elliptic curve A = [n]G.
Where [n]G is scalar multiplication of that point on the curve with itself. This produces highly irregular results, and from the results [n] cannot be easily reconstructed.
Slide set 5d: Bitcoin - Security for financial transactions
1) Confidentiality: should bank and authorities know of transaction? 2) Integrity: No money creation, no messing with amount and receiver * The latter I would easily confuse with authenticity... * No minting * No double-spending 3) Availability: Transaction carried out when intended 4) Authenticity: Only the owner of the money can transfer 5) Non-repudiation: You cannot deny your transactions later on.
Normally, bank is a TTP. Can we do without?
Bitcoin is decentralized cryptocurrency, which means it uses crypto for securing transactions and the control of money creation.
Some main points:
Inputs of transaction are more than outputs due to transaction fee for the miner.
Bitcoin address is hash of public key (multiple actually)
To claim incoming transaction, show your public key as the pre-image of the address. You use your private key for signing outgoing transactions.
TBC