Comp. Sec. Fund. Lec Notes
Comp. Sec. Fund. Lec Notes
• Confidentiality:
● Data integrity: Assures that information and programs are changed only in a specified
and authorized manner.
● System integrity: Assures that a system performs its intended function in an unimpaired
manner, free from deliberate or inadvertent unauthorized manipulation of the system.
• Availability: Assures that systems work promptly and service is not denied to authorized
users.
Definitions:
● Availability: Ensuring timely and reliable access to and use of information. A loss of
availability is the disruption of access to or use of information or an information system.
● Accountability: The security goal that generates the requirement for actions of an entity
to be traced uniquely to that entity. This supports nonrepudiation, deterrence, fault
isolation, intrusion detection and prevention, and after-action recovery and legal action.
Because truly secure systems are not yet an achievable goal, we must be able to trace a
security breach to a responsible party. Systems must keep records of their activities to
permit later forensic analysis to trace security breaches or to aid in transaction disputes.
Adversary(Threat agent): is individual or group, conduct or intent to conduct detrimental
Activity
Risk refers to the potential for loss, damage, or harm that can occur when a vulnerability is
exploited by a threat
Security Policy: is a set of rules that defines how an organization manages and protect its
information and system\
Threat: is any potential danger that exploits vulnerability to harm the system.
Vulnerability: is weakness or flaw In the system or process that can exploit system security
privacy.
Active Attack: where the attacker actively disrupt, modifies, and harms sys resources(causing
real damage )
Passive attack: is a security attack where the attacker monitors or intercepts data without
altering or disrupting it.
Insider attack: an attack launched or implemented by an insider.
Outsider attack:an attack launched by an individual or group from outside of the organization.
Benign is something harmless and does not pose a risk. Ex. Pop Ups (ads without links)
Mitigation → Identification for the attack occurring → Stop the attack → Recover
- Secure.
- Inconvenient.
- For Big Projects & Corporations.
Encapsulation & Isolation (same way we understood it in OOP, principle is applied here but for
sake of security not just modularity)
Separation of Privileges/Clusters: It’s where we decompose the task to smaller tasks and assign
the smaller tasks to separate people with privileges over that specific task only instead of the
whole process being done by one person.
Attack Surface: Includes the attack, and everything related to the attack and consequences of it
and actors involved and environment the attack happened in.
Everything from open and closed ports, to what scripts were running to conduct the attack and
happening in parallel to the attack, employees that were present during the attack etc.
Defense of Depth:
Cryptography deals with scrambling the message, making the message unreadable.
Auth DrDrift Edit: Encryption used for dealing with scrambling the message, making the
message unreadable.
DES ( Data Encryption Standard): Deprecated cuz of Brute forcing techniques can break the
algorithm cuz short key length. Block size is 64 bits
Triple DES/3DES: Repeats the DES 3 times, Key length being 168 bit overcomes brute force
attacks. Since no cryptanalysis technique was found for DES it’s safe for now. Uses block size
of 64 bit
AES (Advanced Encryption Standard): We use because 3DES is not suitable for long term use
It has a block size of 128
Practical security issues with the 3DES/DES/AES: Since they are applied on a unit of data
larger than 64/128 bit they use ECB (electronic codebook) method where plaintext is handled b
bits at a time and each block encrypted at a time by dividing all of the plaintext into n blocks.
Cryptanalysts exploit regularities (if they know certain type of msgs start with a certain phrase,
etc) in the plaintext to decrypt. This issue is solved by modes of operation (not covered yet)
Stream Ciphers: Unlike block ciphers, they process the input continuously (one byte or bit a
time) rather than splitting everything up to blocks.
It works by using pseudorandom that has a key which generates random 8 bit nums. This output
is called a keystream. It is then used to combine one byte at a time with the plaintext using
XOR operation.
Steam Ciphers are always faster and use less code than block ciphers typically used for
data communication channel/browser/web link anything with continuous stream of data
Block ciphers are used with blocks of data with fixed length, such as file transfer, emails,
database applications.
Encryption doesn't help with authentication or integrity (manipulation with blocks of text can
happen, where they are re-ordered)
Plaintext ————————>Encrypted
(convert to)
Cryptanalysis: Knowing the plaintext from the ciphertext without knowing the key
Auth DrDrift Edit: BruteForce: attack method where an attacker tries all possible keys or
combinations to crack an encrypted message, password, or system
Caesar Cipher:
Encryption Algorithim made up of all 26 alphabets (starting from 0 to 25)
Method of Encryption using caesar cipher:
for ex: plaintext → “I want to go” and shift 5 letters using caesar cipher.
plaintext: I WANT TO GO
CipherText: N BFSY YT LT
(Encrypted)
Block Cipher: Takes it block by block where it encrypts it then sends it and then receiver
deciphers it and its used by most systems
Ex: Such as Caesar Cipher with a block of one [as in we take it letter by letter])
Stream Cipher: Used for Real time systems that require encryption in real time such as nuclear
weapons activation systems.
Encryption has three kinds:
- Symmetrical Encryption
They use same encryption key
O O
| <—————> |
/\ /\
Alice Bob
Key:K Key:K
- Asymmetric Encryption
They use different encryption keys
O O
| <—————> |
/\ /\
Alice Bob
Key:Z Key:F
—---------------------------------------------------
9/18
Caesar Cipher
→ Substitution Cipher
→ Monoalphabetic AKA Block Size = 1 letter (Each letter is a block for a cipher)
→ Shifting is by key
Caesar Cipher isn’t used because u can cryptanalyze it easily (Break the code easily meaning)
Auth DrDrift: Any Encryption Algorithm (Cipher) uses two types of operations
- Substitution (aka caesar cipher)
- Permutation/Transposition (DES, SDES)
- Cartesian Product (Substitution AND Permutation )
(one step is substitution next is permutations, as in a mixture of both such as DES, AES
algorithms and so on)
Ex.) You are given a ciphertext encrypted using a mono alphabetically cipher.
Solve the problem (Usually an assignment question)
- Perform Textual Analysis (Frequency Analysis) [conduct it for each letter in the alphabet]
1.1.) Calculate the frequency of each letter in the ciphertext
1.2.) Divide by the total number of letters in the alphabet (whichever it maybe) and let that be
the function
1.3.) Create the function of each letter
3.) Relative Comparison between list of sorted frequencies and the table/figure of frequencies
of english letters (or other alphabets)
[You can google the letter frequency for each language]
4) Find the letter that has the most frequencies in the cipher & correlate it to the letter in
frequency table of the language, (it is likely to be correct not necessarily correct)
5.) Replace each letter in the ciphertext with the most likely letter to match the frequency from
high to low (based on step 4)
For ex: ik doesn't make sense so we try what makes sense (such as if, it, is) but the letter we
changed we have to apply to all the “k” and turn them into “f” or “t” or “s” to see what fits best
and makes most sense for all the ciphertext to decrypt (cryptanalyze it) to plaintext.
Note: you can use this not just mono, but bi tables to attempt to keep track of different
permutations after you fixed the error and resulted in a meaningful decrypting (which we call
cryptanalysis)
Playfair Cipher has two dimensions and is bi-block cypher (meaning encryption block = 2, we
take two letters at a time)
(a table with dimensions of 5 x 5), resulting in a table of 25 squares.
1.) Start with the key’s letters filling it in the table 1 by 1, each letter in each cell of the table.
(Make sure not to repeat the letter twice for example letter S do not repeat it)
Note: the point is to fill in alphabets but we start with the key then we try to fill alphabetically
without repeating
2.) Whenever you run into i put the j right next to it in the same cell (I/J)
W I/J R E L
S A B C D
F G H K M
N O P Q I
U V X Y Z
4.1) If the two letters occur in the same row in the plaintext then replace each letter with the
letter to the right. (decryption to the left of the letter)
For example AC → BD
SD → AS
To get the S we wrap to the beginning of the row.
4.2) If the two letters are in the plaintext fall in the same column then replace each letter with the
one below it.
WS → SF
FU → NW
And wrap from if it is the last letter in the column to the first one at the top.
4.3.) If they are not in the same column or row. (Ex. LX)
4.3.1) Find the intersection between them starting with the first letter in the sequence (L in this
case)
4.3.2) Then move in the row till you find the intersection with the column that the letter is in (X in
this case) and then drop down the intersection.
or (we go left/right on the row of the first one then up/down to reach the second letter)
Then repeat with the other letter but this time, repeat in that letter’s (X in this case) row to get
the cipher
W I/J R E L
S A B C D
F G H K M
N O P Q I
U V X Y Z
LX → RZ
(you can use this tool for practice Online calculator: Playfair cipher (planetcalc.com) )
Adding Filler to the playfair cipher is useful as it allows you to avoid repeated letters in the block
which can help the encryption process and not make it obvious that some letters are repeated.
It is also used when you are left with one letter at the end so you add the filler
Here double L’s in hello and all, thus you add the filler to each block to avoid repetition and on
the last letter.
He lx lo on ea nd al lx
HE → CF
LX → SU
LO → PM
ON → NA
EA → IM
NO → RY
AL → MS
LX → SU
Ciphertext: CFSUPMNAIMRYMSSU
Decryption for the playfair cipher is in the exam Online calculator: Playfair cipher
(planetcalc.com)
The one symmetric key has 16 round key keys where each key is an iteration of the
original/primary key
- Block Cipher
- Block Size = 64-Bits
- Key Size = 64-Bits
- Ciphertext block size = 64-Bits
K → Key-64 bits
C → 64 bits
Ex Question.)
Suppose that plaintext is 517 bits, in order to run it through the DES encryption algorithm.
We split the 517 into 64 bit blocks and we end up with 8 blocks and 5 bits remaining.
The remainder we create a block for them alone and we fill the rest of the bits with either 0’s or
1’s making sure that they are all are 0’s or 1’s (which is called padding)
So the 64 bit block would contain the remaining 5 bits and the rest of the block with padding (1’s
or 0’s).
How to generate a 16 iteration round key from the original symmetrical key ?
Look this up, I don't get the details however there are lookup tables that are fixed that we use as
is.
DES (EXPLANATION, KEY GENERATION, ETC) SDES AND EVERYTHING RELATED TO IT
(MISSED CLASSES REVISE)
1. There are a number of applications in which the same message is broadcast to a number of
destinations. Two examples are notification to users that the network is now unavailable and an
alarm signal in a control center. It is cheaper and more reliable to have only one destination
responsible for monitoring authenticity. Thus, the message must be broadcast in plaintext with
an associated message authentication tag. The responsible system performs authentication. If a
violation occurs, the other destination systems are alerted by a general alarm.
2. Another possible scenario is an exchange in which one side has a heavy load and cannot
afford the time to decrypt all incoming messages. Authentication is carried out on a selective
basis, with messages being chosen at random for checking.
MAC (Message Authentication Code): A Small block of data generated by a secret key that is
attached to the message used for authentication.
1.
Symmetric Keys would be used by both sender and receiver thus guaranteeing the authenticity
and the hash function guarantees integrity since any modification to the hash function would
result in a different output.
2.
In the next section using asymmetric encryption.
3.
This method bypasses encryption entirely by combining MAC & Hashing, Why?
Because its computationally expensive, doesn’t work efficiently on small chunks of data,
creates load on networks.
HMAC uses integrity (since algo is not reversible and any modifications would ruin the msg)
and Authenticity since the secret key is shared by both
3. H(x) is relatively easy to compute for any given x, making both hardware and software
implementations practical.
4. For any given code h, it is computationally infeasible to find x such that H(x) = h. A hash
function with this property is referred to as one-way or preimage resistant.
5. For any given block x, it is computationally infeasible to find y≠x. with H (y) = H
(x). A hash function with this property is referred to as second preimage resistant.
This is sometimes referred to as weak collision resistant.
6. It is computationally infeasible to find any pair (x, y) such that H (y) = H (x). A hash function
with this property is referred to as collision resistant. This is sometimes referred to as strong
collision resistant.
4th Property is what makes it one way since u can’t generate a msg from the output.
5th Property makes it impossible to find an alternative msg with the same hash value
If FIRST 5 are satisfied its a weak hash, if all 6 are satisfied its strong hash
- Passwords are stored as a hash in the Operating system rather than as plaintext
- Intrusion detection: Stores a hash value for a file and then save the values, you can
check later if it has been modified by recomputing the hash value of the file and see if it
has been modified.
Asymmetric Encryption: Usage of Two Different Keys.
Public keys make symmetric encryption obsolete ? no, because of the computational overhead
needed for public keys it’s not feasible to use them all the time.
CA: Certificate Authority that generates the public keys and holds everyone’s public keys and
it’s tables are referenced whenever anyone wants to use another’s public keys
Public keys have certificates from the CA and they consist of public key + user ID of the owner
and it is signed by a trusted 3rd party, guaranteeing their authenticity and integrity.
1. User software (client) creates a pair of keys: one public and one private.
2. Client prepares an unsigned certificate that includes the user ID and user’s public key.
3. User provides the unsigned certificate to a CA in some secure manner. This might require a
face-to-face meeting, require the use of registered e-mail, or happen via a Web form with e-mail
verification.
b. CA generates a digital signature using the CA’s private key and a signature
generation algorithm.
b. User verifies digital signature using CA’s public key and the signature verification
algorithm. The algorithm returns a result of either signature valid or invalid.
- Public Keys: Everyone in the CA can view it
- Private Keys: Only the owner has it
- Both private keys and private keys can encrypt and decrypt
O O
| <—————> |
/\ /\
Alice Bob
Public Key:eA Public Key:eB
Private Key:dA Private Key:dB
1.Each user generates a pair of keys to be used for the encryption and decryption of messages.
2. Each user places one of the two keys in a public register or other accessible file. This is the
public key. The companion key is kept private. each user maintains a collection of public keys
obtained from others.
3. If Bob wishes to send a private message to Alice, he encrypts the message using Alice’s
public key.
4. When Alice receives the message, she decrypts it using her private key. No other recipient
can decrypt the message because only Alice knows her private key.
Public Key is public to the certificate authority table’s & is used as an identifier for the user
[Bonus Point Not Important: Assume Alice is CA1 certified & Bob is CA2 Certified, they cannot
contact each other unless both certificates are compatible with each other and engage in chain
certification where they hit an intersection(??).
If Encryption is done using a key then a decryption will be using the other key to decrypt for the
other user. (if alice uses public key to encrypt, bob uses private key),
2.E(M)dA [feasible]
3.E(M)eB [feasible]
E(M)dA=C
1.) A —------—---—---—---> B
D(C)eA=M
(This method is for confidentiality since it relies on alice’s private key meaning only she can
access the msg)
Using Alice’s private key to encrypt would mean the decryption would be using the public
key (Which is available for everyone) meaning there is a confidentiality issue but there is
authenticity (because private key is known by only alice and she’s encrypting using it
only)
E(M)eB=C
2.) A —------—---—---—---> B
D(C)dB=M
This method guarantees authenticity and data/msg integrity because only bob could
have encrypted the msg but anyone can open the msg since his key is public to
everyone in the CA
Best Practice to maintain confidentiality is to use the other’s public key to encrypt it so that he
will have to use his own private key.
E(E(M)dA)eB
1. ) A ————————>B (Correct)
E(E(M)eB)dA
2. ) A ————————>B (Incorrect)
Translation: Encryption using bob public key then with encryption using alice private key
Everyone knows that alice sent the message which is unnecessary information
Quiz: Chp1 (Basics, definition etc) Caesar Cipher, Playfair, DES (ex. If u have 6 bits do
the conversions or steps), encryption/decryption msgs.
Midterm: Mon 9:30 AM E101 & E109 → 28/10/2024
Digital Signatures: It’s defined as a cryptographic transformation of data that provides a
mechanism for authentication, data integrity, and signatory non-repudiation.
Bob wants to send a digital envelope to alice. The steps are as follows:
1. Prepare a message.
2. Generate a random symmetric key that will be used this one time only.
3. Encrypt the message using symmetric encryption and the one-time key.
4. Encrypt the one-time key using public-key encryption with Alice’s public key.
5. Attach the encrypted one-time key to the encrypted message and send it to Alice.
(Only Alice can decrypt the msg since it was encrypted with her public key)
Quantum Computing may be able to break public key cryptography in the future.
(LECTURE NOTES)
Encryption done by the sender’s private key and receiver’s public key.
Sender A has the msg hashed and then encrypts it using his private key hash value generated
by the encryption algorithm. And it attaches it to the msg and it’s called digital signature.
(encrypted hash value is known as digital signature)
Digital signature are used for authenticity, the drawings are used to illustrate the process of
which everything is done
Public Certificates:
Authored by the CA (Certificate Authority, a trusted 3rd Party)
Bob’s Info
CA’s Info
Hashed
How do they make sure that data is not tampered with ? They hash it using a hash value
and a checksum is performed then an encryption using the public key of the certificate.
Once the encrypted hash value is done it is added to the user’s (bob in this case) table
of info and then it is sent to the receiver (alice in this case)
Afterwards the receiver performs hashing and generates a hash value and it compares
the encrypted hash value received from bob by decrpyting it using the public key of the
certificate and then doing the comparison, if they match they can begin communicating.
Symmetric Encryption is mostly aimed at confidentiality (that doesn’t mean it’s only
limited)
Digital Envelope
Sender → Send a message to Bob that includes a symmetric key to use for a new
future communication between sender and receiver.
Steps in order:
Alice is sender, Bob is receiver.
Chapter 4:
Access Control is defined as a process in which use of system resources is regulated by a
security policy that permits only authorized entities according to that policy.
Access Control Implements a security policy that specifies who or what may have access to
each specific system's resource and the type of access that is permitted in each instance.
● Authentication: Verification that the credentials of a user or other system entity are valid.
● Audit: An independent review and examination of system records and activities in order
to test for adequacy of system controls, to ensure compliance with established policy
and operational procedures, to detect breaches in security, and to recommend any
indicated changes in control, policy, and procedures.
Security administrator maintains an authorization database that specifies what type of access to
which resource is allowed for the user.
Types of Access Control Policies: (From Book)
Discretionary access control (DAC): Controls access based on the identity of the requestor
and on access rules (authorizations) stating what requestors are (or are not) allowed to do. This
policy is termed discretionary because an entity might have access rights that permit the entity,
by its own volition, to enable another entity to access some resource.
Mandatory access control (MAC): Controls access based on comparing security labels (which
indicate how sensitive or critical system resources are) with security clearances (which indicate
that system entities are eligible to access certain resources). This policy is termed mandatory
because an entity that has clearance to access a resource may not, just by its own volition,
enable another entity to access that resource.
Role-based access control (RBAC): Controls access based on the roles that users have
within the system and on rules stating what accesses are allowed to users in given roles.
Attribute-based access control (ABAC): Controls access based on attributes of the user, the
resource to be accessed, and current environmental conditions.
If the subject uses a process to access an object, that process takes on the attributes of the
user thus having the same access rights.
Access Control Mon 10/14/2024
Access Control List/Matrix (ACL/ACM) is what determines what privileges the user gets when
he accesses the system.
It’s a process of either granting or denying access privileges according to a predefined policy
ACL/ACM’s Mechanisms:
1. ACL/ACM’s can operate by DAC (Discriminatory Access Control): Rights are granted
based on the user’s discretion/identity, as long as the system policy allows that.
2. Mandatory Access Control (MAC): Privileges/Rights are granted based on system policy
MAC has a set of classifications & clearances.
Users are considered clearances & Objects are considered a set of classifications
(think of military documents as objects with classifications (secret, top secret, confidential) and
the military rankings with clearances that allow you to view the classifications.)
3. Role Based Access Control (RBAC): Rights are granted based on the user role
4. Attribute Based Access Control (ARAC): Rights are given based on attributes & subject
& object & relation
2 Types of Systems:
1. Military Systems
They are security focused systems.
2. Commercial Systems
Focused on customer satisfaction.
Access Capability List: For users’ actions on the files
Where User A has access to F1 file and with specific privileges and then what behaves as a
linked list linking F3 together as capabilities he can perform on F3
(o = own, r=read, w=write)
Access Control List: It’s for the files on the system and who has privileges for them.
Example Question: Write the set of Access Control Lists (meaning work on the files and
who has access to them and what is their privileges on each file)
Access Control List & Capability Control List Performed on the matrix as solved example
ALSO: No Transitive property for control, meaning that S3 does NOT have control over
S1 bec he controls S2.
HOWEVER: For owner classes it has transitive property, where the owner OWNs the
subclasses or child classes. (basically inheritance applied)
r* [read it as (read star)]
S1 —---------------------------------------->F1
The star is called the copy flag, Meaning the capability of delegating the rights to another user,
however without the full control over the file. Meaning it can delegate to S2 or S3 to read the file
F1. AND they can TRANSFER the delegation right (copy flag) and let them delegate as well but
the original owner of that right loses it along with their original privilege and they can revoke it
even if they give read only without read start.
5. Create Object add a new column to ACM and assign an owner to this new object
New Object → A[S1,F1] = 0 → Given that S1 created F1 (idfk what that
means)
8. Destroy Subject, deletes a row and a column of the subject from the ACM who needs
Own
● S1 —(Deletes)—>S2 → A[S1,S2] = 0
● The Rights that the deleted subject has over the files will be transferred as per
the system policy. (If there is no system policy They will go to the owner of the
subject]
Access Control Graph:
System Policy:
Example Questions:
Is it allowed to grant cindy (C) the write right on F3 and why ?
No, Because Bob owns Cindy, and as such he has her rights, if she is granted that right then
using transitivity Bob will get her rights and he will be able to write F2 and F3 violating system
policy
No, Because if eve has the write and bob has the own right on eve, that means bob has the
write on f1 and f2 violating system policy
Is it allowed for eve to transfer the read (R*) star of cindy to bob and why ?
Yes, because Eve owns Cindy and as such Eve can transfer it to bob and it does not violate the
system policies.
RBAC (Role Based Access Control):