# THE CIA Triad
![[Pasted image 20250107142948.png]]

 The **CIA Triad** is a widely recognized framework for cybersecurity that focuses on three core principles essential for protecting information systems. These principles are:

### 1. **Confidentiality**

- Ensures that information is not disclosed to unauthorized individuals, entities, or processes.
- Protects sensitive data from being accessed by unauthorized users.
- Techniques used include:
    - Encryption
    - Access controls
    - Authentication mechanisms
    - Data masking

### 2. **Integrity**

- Ensures that information remains accurate, consistent, and unaltered during storage, transmission, and processing unless modified by authorized personnel.
- Protects against data tampering, accidental or intentional.
- Techniques used include:
    - Checksums
    - Hash functions
    - Digital signatures
    - Version control

### 3. **Availability**

- Ensures that authorized users have reliable and timely access to information and systems when needed.
- Protects against disruptions caused by hardware failures, cyberattacks, or natural disasters.
- Techniques used include:
    - Redundancy (e.g., backup systems, failover mechanisms)
    - Distributed Denial of Service (DDoS) protection
    - Regular maintenance and updates
    - Disaster recovery planning


# Cryptography

Cryptography = the science (art) of encryption

Cryptanalysis = the science (art) of breaking encryption

Cryptology = cryptography + cryptanalysis

There are bad guys (and girls) out
there!

### What can a “bad guy/girl” do?

![[Pasted image 20250107174112.png]]

- eavesdrop: intercept messages
- actively insert messages into connection
	
- impersonation: can fake (spoof) source address in
	packet (or any field in packet)
	
- hijacking: “take over” ongoing connection by removing
	sender or receiver, inserting himself in place

- denial of service: prevent service from being used by
	others (e.g., by overloading resources) – DOS Attacks

Symmetric key crypto: sender, receiver keys identical

public-key crypto: encryption key public, decryption key secret (private)

# Types of ciphers

## Transposition Cipher

The **Rail Fence Cipher** is a type of **Transposition Cipher** that rearranges the order of characters without altering them. Here's how it works and its limitation: 
How It Works: 
1. Write the plaintext alternately across two rows (like a zigzag). - **Example**: `"HELLOWORLD"` - 
	Row 1: `H L O O L` 
	Row 2: `E L W R D` 

2. Generate the ciphertext by reading row-by-row: - **Ciphertext**: `HLOOLELWRD` 
3. Problem: - The cipher does **not change the frequency of individual symbols** (e.g., `E` and `L` are still as frequent in the ciphertext as in the plaintext). - This makes it vulnerable to **frequency analysis**, as attackers can use letter frequencies to infer the original plaintext. **Summary**: The Rail Fence Cipher only obscures the order of characters, offering weak security.

## Substitution Cipher 
### Overview  
Involves **substituting one thing for another**. - The simplest form is the **monoalphabetic cipher**: - Substitutes one letter for another. - 
### Caesar Cipher
Plaintext alphabet:                         `A B C D E F G H I J K L M N O P Q R S T U V W X Y Z` - 
Ciphertext alphabet (shifted by 3): `D E F G H I J K L M N O P Q R S T U V W X Y Z A B C` 
#### Problem with the Simple Substitution Cipher 
##### **1. Key Space** - For the English alphabet, the key space is **26! ≈ 4 x 10²⁶** (all possible permutations of 26 letters). - Large key space suggests high security. 
##### **2. Vulnerability** 

Despite the large key space, it is **not secure** due to **frequency analysis**: - **Example**: - English texts have a statistical structure: - The letter **“e”** is the most common. - By performing a **frequency count** on the ciphertext: - The most frequent letter in the cipher can be assumed to be **“e”**. - This pattern allows attackers to guess mappings, reducing the effective key space significantly. 

**Summary**: While the key space is theoretically large, the **statistical patterns** in the English language make the cipher vulnerable to frequency analysis, compromising its security.


### Vigenere Cipher

#### Idea
- Uses **Caesar's cipher** with different shifts for each letter, making it harder to detect letter distribution.
- A **key** defines the shift for each letter in the text.
- The **key word** is repeated to match the length of the plaintext.

#### Example:
- **Plaintext**:    `I a t t a c k`
- **Key**:            `2 3 4 2 3 4 2` (key is `"234"`)
- **Ciphertext**: `K d x v d g m`

---

#### Problem of Vigenere Cipher

The Vigenere cipher is **easy to break** due to the work of **Kasiski (1863)**:

#### Breaking the Cipher:
1. **Assume key length is known**:
   - Arrange the ciphertext into rows, each with the same length as the key.
   - Each column can be treated as a separate Caesar cipher.

2. **Finding the Key Length**:
   - **Brute force**: Try lengths 1, 2, 3, etc.
   - **Repeated Strings**:
     - Look for repeated strings in the ciphertext.
     - The distance between them is likely a multiple of the key length.
     - Compute the **GCD** of most distances to find the key length.
   - **Index of Coincidence**:
     - A statistical measure used to estimate the key length by comparing letter frequencies.

---

**Summary**: The Vigenere cipher hides letter frequencies better than Caesar's cipher but is still vulnerable to cryptanalysis if the key length or repeated patterns are identified.

