Topic 0 Overview
C-I-A triad
Confidentiality |
Integrity |
Availability |
Anonymity, Privacy, Covert Channel |
Non-Repudiation, Authenticity |
People who need access to data can get it. |
Other
- Accountability
- Traitor-Tracing
- Plausible deniability
Topic 1 Encryption
Attack Model
Attackere's Goal |
Description |
Total Break |
The attacker wants to find the key. |
Partial Break |
The attacker may want to decrypt a ciphertext but not interested in knowing the secret key, or the attacker may simply want to extract some information about the plaintext. |
Distinguishability |
With some non-negligible probability more than , the attacker can correctly distinguish the ciphertexts of a given plaintext from the ciphertext of another given plaintext. |
- If attacker can ahieve total break, the attacker also can achieve partial break and disringuishability.
- We want to design a secure system that can prevent attacker from achieving the weakest goal (distinguishability).
Attacker's Capability |
Description |
Ciphertext only attack |
The attacker is given a collection of ciphertext. The attacker may know some properties of the plaintext. (The attacker can't choose the plaintext.) |
Known plaintext attack |
The attacker is given a collection of plaintext and their corresponding ciphertext. (The attacker can't choose the plaintext.) |
Chosen plaintext attack (CPA) |
The attacker has access to an oracle. The attacker can choose and feed any plaintext to the oracle and obtain the corresponding ciphertext (all encrypted with the same key). The attacker can access the oracle many times, as long as within the attacker's compute power. He can see the ciphertext and then choose the next input. We call this black-box an encryption oracle. |
Chosen ciphertext attack (CCA2) |
Same as chosen plaintext attack, but here, the attacker chooses the ciphertext and the black-box outputs the plaintext. We call the black-box a decryption oracle. |
- There are practical scenarios where the attacker has access to a weaker form of decryption oracle. Example: Padding Oracle
- If a cipher can defend against decryption oracle, then the cipher can defend against all other weaker forms.
Classical Ciphers
Substitution Cipher
Encryption
Plaintext |
Key |
Ciphertext |
|
(a substitution table, 1-1 onto function) |
|
Decryption:
Attack:
- Performing substitution twice using two tables does not increase difficulty of
attack. It simply reduces to one table.
Permutation Cipher
Encryption
Description: The plaintext is grouped into blocks of characters, then apply a secret permutation to each block by shuffling the characters.
Key: The key is the permutation and the block size . We can write which indicate the character at position is shifted to position .
Decryption
Attack
- Performing permutation twice using two permutations does not increase difficulty of attack. It simply reduces to one permutation.
- By using both Substitution and Permutation Ciphers, the attacks become more difficult.
One Time Pad
Encryption
Decryption
- The key cannot be re-used. That is, a key can only be used once. (For S and P, a same key is being used to encrypt multiple plaintexts.)
- So, a 1 GB plaintext requires a 1 GB key to encrypt.
- The long key renders one-time-pad impractical.
- Attacker can derive the key if given the ciphertext and corresponding plaintext, but such key is useless, since it will not be used any more.
- It is shown that one-time-pad leaks no information of the plaintext. (CS4236)
- It is unbreakable.
Modern Ciphers
Designs of modern ciphers take into considerations of known-plaintext-attack, frequency analysis and other known attacks (except CC2).
We can quantify the security of an encryption scheme by the length of the key.
Example:
- DES (Data Encryption Standard, 1977)
- The key length is 56 bits. Hence, the exhaustive search needs to loop for times in the worst case.
- Too short.
- RC4 (Rivest's Cipher 4, 1987)
- AES (Advanced Encryption Standard, 2001)
- The block length is 128 bits. The key length can be 128, 192 or 256 bits.
- Currently, no known attacks on AES.
Symmetric vs Asymmetric Key Cryptography
Block Cipher
- A block cipher has fixed size input and output.
- DES and AES are block cipher.
- AES is designed for 128 bits (16 bytes) input and output.
- For large plaintext, it will be divided into bloacks, then apply block cipher.
- The method of extending encryption from a single block to multiple blocks is called mode-of-operation.
- Mode of operation in this note: ECB, CBC, CTR, GCM
ECB (Electronic Code Book)
- Plaintext is divided into blocks.
- Block cipher is applied to each block, using same key.

- But ECB leaks information.
- Since blocks are encrypted using the same key, same blocks will be encrypted into same ciphertext.

CBC (Cipher Block Chaining)
- Plaintext is divided into blocks.
- The first block will XOR with the IV.
- Next block will XOR with the previous encrypted block.
- Encryption:

- Initialization Vector (IV) is an arbitrary value chosen during encryption, and is different in different encryption.
- IV will be included/sent with the ciphertext.
- , , ,
- CBC also leaks information, similar reason with ECB.
- Decryption:

CTR (Counter Mode)
- Similar to CBC.
- But, now IV is incrementing.
- Encryption:

GCM
- Details omitted in this course.
- An "Authenticated-Encryption".
- Ciphertext consists of an extra tag for authentication.
- It is secure in the presence of decryption oracle.
Stream Cipher

- Encryption:
- Given plaintext, and secret key, randomly generate IV.
- From secret key and IV, generate a long pseudorandom sequence, .
- Ciphertext will made up of IV and .
- Decryption:
- Given the key and the ciphertext with the IV.
- Extracts the IV from the ciphertext.
- From the key and IV, generates the long sequence.
- Performs xor to get the plaintext.
Examples of Attacks
Triple DES & Meet-in-the-middle
2DES
- If we want to improve DES, we can encrypt the plaintext twice or more, using different keys.
- Let's consider this double encryption under known plaintext attack. Then the attacker has a plaintext and the corresponding ciphertext, and wants to find the two secret keys.
- Using exhaustive search, loops required, so the key-strength seems to increased to 112.
- But it can be less with meet-in-the-middle attack.
Meet-in-the-middle Attack
- Known plaintext attack.
- Assume attacker has a pair of plaintext and the corresponding ciphertext. Note:
- Process:
- Take the plaintext , encrypt it using all possible keys.
- Let be the set of all possible ciphertexts.
- Take the corresponding ciphertext , decrypt it using all possible keys.
- Let be the set of all possible plaintext.
- Find common element in and .
- The key used to encrpyt that results in the common element , will be .
- The key used to decrypt that results in the common element , will be .
- For 2DES, the number of "guesses" are reduced to .
- In general, for -bit keys, it reduces the number of crypto operations to using approx units of storage space.
3DES
- a.k.a 3DES, TDES, TDEA, 2TDES, 3TDES
- Since DES and 2DES are not secure enough, we use 3DES.
- There are 2 versions:
- Both versions are believed to have same level of security.
- Version (b) can be more convenient.
Padding Oracle Attack
- The block size of AES is 128 bits (16 bytes).
- Suppose the length og the plaintext is 25 bytes, it will be fitted into two blocks.
- The remaining 7 bytes will be padded with some values.
- There are many ways to pad, but the number of padded bits must be encoded together, so the receiver will know the length of the plaintext.
PKCS#7
- PKCS#7 is a padding standard.
- Suppose the block size is 8 bytes, and the last block has 5 bytes, which mean 3 extra bytes needed.
- If the last block has 8 bytes, an extra bloack is added where each byte is
08
.
Padding Oracle Attack
- Attacker has: ciphertext , where is encrypted using key .
- Attacker's goal: obtain the plaintext.
- A padding oracle will accept any cipher text, and output whether the plaintext is in correct padding format.
- Assumption:
- Attacker has access to the padding oracle.
- Attacker knows how many bytes is padded.
- AES CBC mode is not secure against padding oracle attack.
- Process:
- Assume the block size is 8 bytes, is 1 block.
- Attacker wants to find out .
- Calculate from by xor with the last 4 bytes (see image), where is some value.

- Why choose for last 3 bits:
- Originally,
- Since we want and we know last 3 bits are
- We want to somehow make it
x1 x2 x3 x4 04 04 04 04
- We notice
- So choose
- Feeds the padding oracle with .
- If output YES, then must be , and we got the correct .
- Since we choose , must be
- Hence,
- If output NO, repeat steps 1-4 with different .
- We can easily extend the algorithm to find the full plaintext.
- It is easy to determine the initial padding length. (see tutorial question)
- CTR mode also vulnerable to padding oracle.
- Schemes that are secure against decryption oracle are also known as IND-CCA2 secure.
- GCM, or other βauthenticated encryptionβ, is believed to be IND-CCA2 secure, and thus secure against padding oracle attack.
Cryptography Pitfalls
- Wrong choices of IV
- Reusing one-time-pad
- Predictable secret generation
- Designing your own cipher
- Reliance on Obscurity: Kerckhoffsβs Principle
A system should be secure even if everything about the system, except the secret key, is public knowledge.
Topic 2 Authentication Credential
Topic 3 Autheticity (Data Origin)
Public Key Cryptography
- Public key scheme (PKS) uses different keys for encryption and decryption.

- There is no need to clearly indicate which key is for encryption, which key is for decryption.
- Both keys can be used to perform either encryption or decryption, but not both.
- Public key is shared with everyone, private key is kept secret by user.
- Public key can be used for encryption or decryption, depends on the context. (same goes for private key)
- Without PKS, every individual would need to keep a symmetric secret key pair with everyone else.
- Keys needed for symmetric-key setting:
- Keys needed for asymmetric-key setting:
- Example: RSA, ElGamal, Paillier
Classroom RSA
We call it βclassroomβ because the variant used in practice is different, with padding and special considerations in choosing the primes, etc. Also called βtextbookβ RSA.
Setup:
- Owner randomly chooses 2 large primes , and computes
- Owner randomly chooses an encryption exponent s.t.
- Owner finds the decryption exponent where
- Owner publishes as public key, and safe-keeps as the private key
Encryption:
- Public key:
- Given message , ciphertext
Decryption:
- Private key: , Decryption key:
- Given ciphertext , message

Remarks:
-
Note that for any positive , and any pair of public/private keys,
-
Can we compute and efficiently?
- To find random prime :
- Randomly pick a number
- If is a prime, output and halts. Otherwise, repeat step 1-2.
- The probability that the randomly chosen is prime is non-negligible. This is by the well-known "Prime Number Theorem". Probability of a randomly chosen 1024-bit number being a prime is around ln(21024)~ (1/710). So likely takes about 710 trials to get a 1024-bit prime number. Fast but too slow for real-time application.
- There is fast algorithm to determine whether a number is a prime.
- Choose a small so that encryption can be done very fast. It turns out that the value of wonβt affect the security. But it canβt be too small due to some attack. It is common to set .
- The value of can be efficiently computed from and using the extended Euclidean algorithm.
- Using Chinese Reminder Theorem, one can speedup decryption about 2x faster. Public key doesnβt need to be large (but not too small). To achieve speedup in encryption, some scheme choose a fixed small public key such as , which is
-
We can use the decryption key to encrypt, and encryption key to decrypt. In other words, we can swap the role of and , so that anyone in the public can decypt, but only the owner can encrypt. This property is useful in desgining signature scheme.
Issues:
- Security:
- Same as symmetric-key encryption, some forms of IV is required so that encryption of the same plaintext at different time would give different ciphertext.
- Classroom RSA has an interesting βhomomorphicβ property. These properties are useful in applications, but they also lead to attacks. Such properties can be destroyed using padding.
- The standard Public-Key Cryptography Standards (PKCS)#1, add βoptimal paddingβ. https://en.wikipedia.org/wiki/PKCS_1
- RSA and "discrete log based" PKC will be broken with Quantum computer.
- Performance:
- RSA is signigicantly slower than AES.
- A 128-bit AES has the same key strength as a 3072-bit RSA (NIST recommendation).
- If we want to encrypt a large file , it would be very slow to directly use RSA on . Instead, it is typically carried out in this way:
- Chooses a random AES 128-bit key
- Encrypts using PKC to get
- Encrypts using AES with as the key to get .
- The final ciphertext will be

Cryptographic Hash
A hash is a function that takes in an arbitrarily long message as input and outputs a fixed-size digest.

Security Requirements:
- Preimage resistant
- Given a digest , it is difficult to find a s.t.
- Second-preimage resistant
- Given , it is difficult to find a second preimage s.t.
- Collision-resistant
- It is difficult to find two different messages that "hashes" into the same digest, i.e.
Popular Hash:
- Broken: SHA-0, SHA-1, MD5
- Partially broken: SHA-2
- No known attack: SHA-3
Keyed Hash
A keyed-hash is a function that takes an arbitrarily long message and a secret key as input, and outputs a fixed-size MAC.

Security Requirements:
- Without knowing the key, it is difficult to forge the MAC
Popular Keyed-Hash (MAC):
CBC-MAC
Based on AES operated under CBC mode.

HMAC
Baed on SHA.

||
means concatenation
Application of Unkeyed Hash
How do we know if a file we downloaded is authentic?
Unkeyed Hash for Integrity Protection
- Let be the original file.
- We obtain the digest from the secure channel.
- We then obtain the file , whose origin claims that the file is .
- We can compute and compare the digests and :
- If , then (with high confidence)
- If , then the file integrity is compromised
Assumptions:
- There is a secure channel to send a short piece of information (digest).

Application of Keyed Hash
In the previous example of using unkeyed hash, we assume that there is a secure channel to send the digest. What if we don't have a secure channel to deliver the digest?
In such scenarios, we can protect the digest with the help of some secrets.
- In the symmetric key setting, it is called the mac.
- In the public key setting, it is called the digital signature.

- Note that there is no issue on confidentiality. In fact, the data F can be sent in clear.
- Typically, the mac is appended to F. Hence, mac is also called the authentication tag, or authentication code.
Signature
Asymmetric-key version of MAC.
Here, the owner uses the private key to generate the signature. The public can use the public key to verify the signature. So, anyone can verify the authenticity of the data, but only the person who know the private key can generate the signature.

Procedure:
- The original file is first hashed using a hash function.
- The hash value is then passed through the signature function together with the private/signature key to produce signature .
- is then appended to and sent to the recipient via an insecure channel.
- The receipient then passes the received signature and the public/verification key into the verification function.
- The verification function will produce a hash value.
- The file is then pass through a hash function to return a hash value.
- The hash values are compared to see if the file has been modified, or if the digital signature is valid.

Notice that in this setting, the private key is used to encrypt, while the public key is used to decrypt.
Signature scheme achieves Non-repudiation.
Why hash the file before signing?
- For greater efficiency.
- Since hash value is a unique representation of the data, it is sufficient to sign the hash instead of original file.
Popular Signature scheme:
- RSA based: RSASSA-PSS, RSASSA-PKCS1
- Discrete log based: Digital Signature Algorithm (DSA)
Example of Attacks
Birthday Attack
From Wikipedia:
The birthday paradox is a veridical paradox: it seems wrong at first glance but is, in fact, true. While it may seem surprising that only individuals are required to reach a probability of a shared birthday, this result is made more intuitive by considering that the birthday comparisons will be made between every possible pair of individuals. With individuals, there are β pairs to consider, far more than half the number of days in a year.
This can be applied to the hash function. Suppose we have messages, and each message is tagged with a value randomly chosen from .
Then the probability that there is a pair of messages tagged with the same value is approximately:
In particular, when , then .
Suppose the hash gives 128-bit digest. Then . By choosing , with probability more than 0.5, birthday attack succeed.
For the birthday attack variant, we are looking at calculating the probability of a random set of elements sharing at least one element with another set of distinct elements, with both sets being subsets of an even larger set. Below is an useful theorem:
Let be a set of distinct elements where each element is an bits binary string. Let us independently and randomly select -bit binary strings and put them in the set . The probability that has non-empty intersection with is more than
Straightforward method to find collision
|
Birthday attack
|
Suppose H() is a hash with k-bit digest.
Find collision:
- Randomly pick two messages m1, m2.
- If H(m1) = H(m2), then output m1, m2 and halt.
- Repeat step 1 to 3.
|
Suppose H() is a hash with k-bit digest.
- Constructs a set S of M = β‘1.17* 2k/2β€ unique randomly chosen messages.
- Compute the digest of each message m in S.
- Check whether there are two messages in S having the same digest. If so, output m1, m2. Otherwise, output βFailβ.
|
The expected number of rounds taken by the above algorithm is 2k and thus the expected number of hashes is more than 2k. If k = 128, as analyzed in tutorial one, this is computationally infeasible.
|
When k = 128, one round would take ~264 hashes, significantly lower than before. And this has >50% chance will succeeds.
|
Pitfalls
Using encryption for the purpose of authentication
Encryption is designed to provide confidentiality. It does not guarantee integrity and authenticity.
For example, a company that communicates instructions via SMS does not provide integrity and authenticity if it simply encrypts its message. A sucure design could use MAC instead of encryption.
Simply adding MAC to the instructions is not sufficiently secure. It is still vulnerable to "replay attack". For example, an adversary can intercept one of the messages, and simply repeatedly send the message to receiver, which result in some command or instruction being repeatedly executed. To prevent replay attack, a cryptographic "noice" is required, which is a random or preudo-random number issued that prevents old communication from being reused.
Topic 4 Part 1 Public Key infrastructure
Topic 4 Part 2 Channel Security
Topic 5 Network Security
Topic 6 Web Security
Topic 7 & 8 Secure Programming
Topic 9 Access Control
Access Control Model
-
Access control setup security perimeter/boundary. Design of the boudary is guided by:
- Principle of least privilege
- access rights that are not required to complete the role will not be assigned
- Compartmentalization
- limits the access to information to persons or other entities on a need-to-know basis to perform certain tasks
- Defense in depth / Swiss Cheese Model
- Segregation of duties
- breaks down processes so that no single person is responsible for every stage in a process
-
Separation between policy and mechanism:
- A principal (or subject) wants to access an object with some operation. The reference monitor either grants or denies the access.
- Principals: humas users
- Subjects: entity in the system the operate on behalf of the principals
-
Types of accesses:
- Observe
- Alter:
- writing a file
- deleting a file
- changing properties
- Action:
-
Access rights:
- Discretionary access control
- owner of the object decides the rights
- Mandatory access control
- system-wide policy decides the rights
- strict rules that everyone must follow
Specifying Access Rights
r: read, w: write, x: execute, s: execute as owner, o: owner
Access Control Matrix
Example:
|
my.c
|
mysh.sh
|
sudo
|
a.txt
|
root
|
{r,w}
|
{r,x}
|
{r,s,o}
|
{r,w}
|
Alice
|
{r,w}
|
{r,x,o}
|
{r,s}
|
{r,w,o}
|
Bob
|
{r,w,o}
|
{}
|
{r,s}
|
{}
|
- Pros: can specify the access right for all pairs of principals and objects
- Cons: the table would be very large, and thus different to manage
Access Control List
The access control list stores the access rights to an object as a list.
Example:
my.c |
-> (root, {r,w}) |
-> (Alice, {r,w}) |
-> (Bob, {r,w,o}) |
mysh.sh |
-> (root, {r,x}) |
-> (Alice, {r,x,o}) |
sudo |
-> (root, {r,s,o}) |
-> (Alice, {r,s}) |
-> (Bob, {r,s}) |
a.txt |
-> (root, {r,w}) |
-> (Alice, {r,w,o}) |
- Pros: easy to find out all subjects that can access an object
- Cons: difficult to find out all objects that a subject can access
Capabilities
A subject is given a list of capabilities, where each capability is the access rights to an object.
Example:
root |
-> (my.c, {r,w}) |
-> (mysh.sh, {r,x}) |
-> (sudo, {r,s,o}) |
-> (a.txt, {r,w}) |
Alice |
-> (my.c, {r,w}) |
-> (mysh.sh, {r,x,o}) |
-> (sudo, {r,s}) |
-> (a.txt, {r,w,o}) |
Bob |
-> (my.c, {r,w,o}) |
-> (sudo, {r,s}) |
- Pros: easy to find out all objects that a subject can access
- Cons: difficult to find out all subjects that can assess an object
Notes
- UNIX file system employs ACL
- The size of lists for ACL and Capabilities are still too large
- Another approach is to group the subjects and objects and define access rights on the defined groups. So, we need intermediate control
It is not practical for an owner to specific each single entries in the access control matrix. So, we need some ways to simplify the representation. One method is to "group" the subjects/objects and define the access rights on the group. This is called intermediate control.
Recalls that UNIX employs ACL, but instead of specifying all subjects, UNIX's ACL only specifies the rights for owner, group and world/others.
Role-based access control
The grouping can be determined by the "role" of the subject.
A role associates with a collection of procedures. In order to carry out these procedures, access rights to certain objects are required.
To design the access right of a role, we should follow the least privilege principle.
Privileges
The term privilege is sometime used to describe access right. Privilege can also be viewed as an intermediate control. It can be represented by a number, e.g. 1,2,3. if a subject can access an object, another subject with higher privilege can also access the object.
Protection rings
In OS, "privilege" is often called protection rings. They are the same but with different name.
Each object (data) and subject (process) is assigned a number. Whether a subject can access an object is determined by their respective assigned number.
Object with smaller number are more important. If a process is assigned a number , we say that the process runs in ring . We call processes with lower ring number as having "higher privilege".
Unix has only 2 rings, superuser and user.
Two well-known models:
- Bell-LaPadula: Confidentiality
- no read up
- A subject does not have read access to object in higher level. This prevent a lower level from getting info in the higher level.
- no write down
- A subject does not have append-right to object in lower level. This prevents a malicious insider from passing information to lower levels. (e.g. a clerk working in the highly classified department is forbidden to gossip with other staff)
- Biba: Integrity
- no write up
- A subject does not has βwriteβ access to objects in higher level. This prevent a malicious subject from poisoning upper level data, and thus ensure that a process will not get compromised by lower level subjects.
- no read down
- A subject does not has read access to objects lower level. This prevents a subject from reading data poisoned by lower level subjects.
Tutorial Terminologies
Terminologies |
Meaning |
Cryptology |
|
Cryptanalysis |
|
Cryptography |
|
NSA |
|
NIST |
|
cryptography backdoor |
|
Key Escrow |
|
Decryption order |
|
Graphical Passwords |
|
covert channel |
|
end-to-end encryption |
|
Single Sign-On |
|
retinal vs iris scan |
|
Forward Secrecy |
|
Insider threat |
|