BIT6163_Weeks1-3_Notes
BIT6163_Weeks1-3_Notes
These notes cover Part 1 of BIT 6163, providing a comprehensive foundation in cryptography and network
security principles. Students will explore encryption methods, authentication protocols, and common cyber
threats essential for building secure web applications.
BIT 6163 – Cryptography & Network Security
Lincoln University College
TABLE OF CONTENTS
BIT 6163 | Cryptography & Network Security | Lecture Notes (Weeks 1–3) Page 2 of 29
BIT 6163 – Cryptography & Network Security
Lincoln University College
Cryptography Fundamentals
WEEK 1 Encryption · Hashing · Digital
Signatures
Learning Objectives
The word "cryptography" comes from the Greek words kryptos (hidden) and graphein (to write).
Modern cryptography is a branch of mathematics and computer science concerned with protocols
that prevent third parties from reading private messages.
Core Terminology
Before diving into specific cryptographic techniques, it is essential to understand the precise
vocabulary used throughout this course. The following terms form the foundation of all
cryptographic discussion. Each term is explained with a definition, context, and a real-world
analogy to reinforce understanding.
1. Plaintext
Definition: Plaintext (also called cleartext) is the original, human-readable data or message
before any cryptographic transformation has been applied. It is the information in its natural,
unprotected form.
Examples: A typed email ("Dear John, please find attached the contract..."), a password entered
in a login form ("P@ssword123"), a credit card number ("4111 1111 1111 1111"), or a medical
record stored in a database.
BIT 6163 | Cryptography & Network Security | Lecture Notes (Weeks 1–3) Page 3 of 29
BIT 6163 – Cryptography & Network Security
Lincoln University College
Why it matters: Plaintext must never be stored or transmitted without protection. Any attacker
who intercepts plaintext data immediately has full access to the sensitive information. Network
sniffers, database breaches, and server logs that accidentally capture plaintext are among the
most common sources of data leaks.
2. Ciphertext
Definition: Ciphertext is the output produced after applying a cryptographic algorithm to plaintext.
It is an unreadable, scrambled representation of the original data. Without the correct key and
algorithm, ciphertext appears as random, meaningless data.
Example: The plaintext message "HELLO" encrypted using AES-256 with a specific key might
produce the ciphertext: 3d4f9a2b1c8e7f0a5b6c... — a sequence of bytes that reveals
nothing about the original message to an observer.
Key property: Good ciphertext should be computationally indistinguishable from random data.
This means an attacker cannot even determine the length or structure of the original plaintext by
examining the ciphertext alone — this property is called semantic security.
3. Encryption
Definition: Encryption is the process of applying a mathematical algorithm (cipher) to plaintext
using a cryptographic key to produce ciphertext. It is the fundamental mechanism by which data is
protected from unauthorized access. Encryption does NOT destroy the original data — it
transforms it in a reversible way, so that the authorized recipient can recover it.
Types of encryption: Encryption can be applied to data at rest (stored data, such as files on a
hard drive or records in a database) and data in transit (data travelling across a network, such as
HTTPS web traffic or encrypted email). Both forms are equally important in a complete security
strategy.
4. Decryption
BIT 6163 | Cryptography & Network Security | Lecture Notes (Weeks 1–3) Page 4 of 29
BIT 6163 – Cryptography & Network Security
Lincoln University College
Definition: Decryption is the reverse process of encryption — it converts ciphertext back into the
original plaintext using a key. Only a party in possession of the correct decryption key can
successfully perform this operation.
Symmetric vs Asymmetric decryption: In symmetric systems, the same key is used for both
encryption and decryption. In asymmetric systems, a different but mathematically related key is
used — the public key encrypts, and the private key decrypts (for confidentiality use), or the
private key signs, and the public key verifies (for authentication use).
5. Cryptographic Key
Definition: A cryptographic key is a piece of information (a sequence of bits) that is fed into an
encryption or decryption algorithm to control how it transforms the data. The key is what makes
the same algorithm produce different ciphertext from the same plaintext for different users.
Crucially, the security of a cryptographic system lies in the secrecy of the key, not the
algorithm — this is known as Kerckhoffs's principle.
Key sizes: Key size is measured in bits. Larger keys provide exponentially more security. A
128-bit key has 2¹²■ possible values (~3.4 × 10³■). Even if an attacker could check one trillion
keys per second, it would take longer than the age of the universe to try them all. AES-256
(256-bit key) is currently considered quantum-resistant for practical purposes.
192-bit AES-192 Very Strong Used in some government and military contexts
2048-bit RSA-2048 Strong Minimum recommended for RSA; much larger keys
(asymmetric) needed vs symmetric
6. Cipher
Definition: A cipher is the specific algorithm or set of rules used to perform encryption and
decryption. The cipher defines the mathematical operations that scramble the data. Different
ciphers offer different trade-offs between speed, security, and computational resource
requirements.
Block ciphers vs Stream ciphers: A block cipher divides plaintext into fixed-size blocks (e.g.,
128 bits for AES) and encrypts each block as a whole unit. A stream cipher encrypts data one bit
or byte at a time, producing a keystream that is XORed with the plaintext. Block ciphers are
generally used for stored data; stream ciphers are often preferred for real-time communication
(e.g., TLS record encryption).
BIT 6163 | Cryptography & Network Security | Lecture Notes (Weeks 1–3) Page 5 of 29
BIT 6163 – Cryptography & Network Security
Lincoln University College
Block Cipher Encrypts fixed-size data blocks (e.g., Moderate AES, DES, 3DES, Blowfish
128 bits at a time)
Stream Cipher Encrypts data one bit/byte at a time Very Fast ChaCha20, RC4 (obsolete)
using a pseudorandom keystream
Substitution Replaces each character with another N/A Caesar cipher, ROT13
Cipher (classical, not modern)
7. Cryptanalysis
Definition: Cryptanalysis is the scientific study of breaking cryptographic systems — recovering
plaintext from ciphertext without access to the key, or finding weaknesses in cryptographic
algorithms. It is the offensive counterpart to cryptography. Security researchers use cryptanalysis
to test and validate new cryptographic designs before they are deployed.
Common cryptanalytic attacks include: Brute force (trying all possible keys), dictionary attacks
(trying likely passwords from a list), rainbow table attacks (precomputed hash lookups), differential
cryptanalysis (analysing how differences in plaintext affect the ciphertext), and side-channel
attacks (exploiting implementation details like timing or power consumption rather than the
algorithm itself).
8. Salt
Definition: A salt is a random value added to a password (or other data) before hashing. It
ensures that two users with the same password will have different hashes stored in the database.
Salts defeat rainbow table attacks and precomputed hash lookups because attackers would need
to precompute a separate rainbow table for every possible salt value.
9. Protocol
Definition: A cryptographic protocol is a defined sequence of steps that governs how
cryptographic operations are carried out between two or more parties. Protocols specify how keys
are exchanged, how messages are authenticated, and how sessions are established and
terminated. Examples include TLS (Transport Layer Security), SSH (Secure Shell), and PGP
(Pretty Good Privacy).
BIT 6163 | Cryptography & Network Security | Lecture Notes (Weeks 1–3) Page 6 of 29
BIT 6163 – Cryptography & Network Security
Lincoln University College
SYMMETRIC ENCRYPTION
ASYMMETRIC ENCRYPTION
Both parties share the same secret key in symmetric encryption, while asymmetric encryption uses a mathematically
linked key pair.
AES 128/192/256 Block Very High File encryption, TLS, VPNs, disk encryption
bit
3DES 168 bit Block Moderate Banking legacy (being phased out)
ChaCha20 256 bit Stream Very High Mobile, TLS 1.3, Google services
BIT 6163 | Cryptography & Network Security | Lecture Notes (Weeks 1–3) Page 7 of 29
BIT 6163 – Cryptography & Network Security
Lincoln University College
How it works: AES is a block cipher that operates on fixed 128-bit (16-byte) blocks of data. It
applies a series of mathematical transformations — called rounds — to mix and substitute the bits
in the block. The number of rounds depends on the key size: 10 rounds for 128-bit keys, 12 for
192-bit keys, and 14 for 256-bit keys. Each round involves four operations: SubBytes
(substitution), ShiftRows (permutation), MixColumns (diffusion), and AddRoundKey (key mixing).
Operating modes: AES alone is a block cipher — to encrypt data longer than 128 bits, it must be
used in an operating mode. Common modes include: CBC (Cipher Block Chaining) — each block
is XORed with the previous ciphertext block; GCM (Galois/Counter Mode) — provides both
encryption and authentication (authenticated encryption); and CTR (Counter Mode) — converts
AES into a stream cipher, suitable for parallel processing.
Real-world deployment: AES is used in HTTPS/TLS (securing all web traffic), WPA2/WPA3
(Wi-Fi security), BitLocker (Windows disk encryption), FileVault (macOS disk encryption),
WhatsApp and Signal (end-to-end message encryption), and government and military classified
communications.
How it works: DES is a Feistel cipher that processes 64-bit blocks using a 56-bit key through 16
rounds of substitution and permutation operations. In each round, the block is split in half; the right
half is expanded, XORed with a subkey, passed through 8 S-boxes (substitution tables), and
permuted before being XORed with the left half. The halves are then swapped.
Why DES is obsolete: In 1998, the Electronic Frontier Foundation (EFF) built "Deep Crack", a
specialized computer costing only $250,000 that broke a DES-encrypted message in 22 hours
and 15 minutes. Today, the same task could be accomplished in minutes using modern cloud
computing. DES should never be used in any new system.
BIT 6163 | Cryptography & Network Security | Lecture Notes (Weeks 1–3) Page 8 of 29
BIT 6163 – Cryptography & Network Security
Lincoln University College
How it works: 3DES applies the DES cipher three times to each data block using three different
keys (K1, K2, K3) in an Encrypt–Decrypt–Encrypt (EDE) sequence: first encrypt with K1, then
decrypt with K2, then encrypt again with K3. When all three keys are unique (3-key 3DES), the
effective key length is 168 bits, though due to a meet-in-the-middle attack the actual security level
is closer to 112 bits.
Current status: NIST deprecated 3DES in 2017 and officially disallowed its use for new
applications from 2023. It is still found in older banking systems, payment terminals, and legacy
enterprise software. It is significantly slower than AES (roughly 3x slower, processing only about
16 MB/s vs AES's 700+ MB/s on modern hardware).
Algorithm 4 — ChaCha20
Background: ChaCha20 is a stream cipher designed by cryptographer Daniel J. Bernstein in
2008 as an evolution of his earlier Salsa20 cipher. It was designed to be fast in software without
requiring hardware acceleration — making it ideal for resource-constrained environments like
mobile devices and embedded systems.
ChaCha20-Poly1305: In practice, ChaCha20 is almost always paired with the Poly1305 message
authentication code to produce an AEAD (Authenticated Encryption with Associated Data)
scheme. This combination simultaneously encrypts and authenticates the data. It is the default
cipher suite in TLS 1.3 for devices without AES hardware acceleration, and is used by Google,
Cloudflare, OpenSSH, and WireGuard VPN.
Algorithm 5 — Blowfish
Background: Blowfish was designed by cryptographer Bruce Schneier in 1993 as a fast, free
alternative to DES and the then-proprietary IDEA cipher. It was one of the first widely available
BIT 6163 | Cryptography & Network Security | Lecture Notes (Weeks 1–3) Page 9 of 29
BIT 6163 – Cryptography & Network Security
Lincoln University College
ciphers with a variable key length and became popular in the late 1990s and 2000s. While
Blowfish itself is rarely used for direct data encryption today, its legacy lives on through bcrypt —
the password hashing function that uses a Blowfish variant called "Eksblowfish" (expensive key
schedule Blowfish).
How it works: Blowfish is a 64-bit block cipher with a key size from 32 to 448 bits. It uses a
Feistel network structure with 16 rounds. A notable feature is its key expansion phase, which
takes any key and expands it into several subkey arrays totalling 4,168 bytes. This expensive
setup is intentional — it makes brute-force key searches slow, which is exploited by bcrypt to
make password cracking impractical.
bcrypt connection: The bcrypt password hashing function was designed to use Blowfish's key
setup algorithm because it is computationally expensive. The "cost factor" in bcrypt controls how
many times the key expansion is performed — higher cost means more work per hash, making
brute-force attacks proportionally slower. This is covered in detail in Section 1.5.
Why RC4 is broken: Multiple serious vulnerabilities have been discovered in RC4. The first few
bytes of the keystream are statistically biased — they are not truly random, which allows statistical
attacks. The BEAST, POODLE, and RC4 biases attacks exploited these weaknesses to decrypt
TLS traffic. RFC 7465 (2015) formally prohibits RC4 in all TLS connections. WEP (which used
RC4) was completely broken and WPA with RC4 (TKIP) has also been deprecated. RC4 must
never be used.
BIT 6163 | Cryptography & Network Security | Lecture Notes (Weeks 1–3) Page 10 of 29
BIT 6163 – Cryptography & Network Security
Lincoln University College
5. Confidentiality of Data Symmetric encryption excels at protecting data both when stored
at Rest and in Transit (encryption at rest) and when being transmitted (encryption in
transit). A database administrator can encrypt individual columns
containing sensitive fields (e.g., Social Security numbers, medical
records) using AES-256 without affecting query performance
significantly, thanks to the algorithm's speed.
BIT 6163 | Cryptography & Network Security | Lecture Notes (Weeks 1–3) Page 11 of 29
BIT 6163 – Cryptography & Network Security
Lincoln University College
2. Total Compromise if In a symmetric system, the key is the entire security mechanism. If a
the Key is Exposed single key is compromised — through theft, interception, insider
threat, or poor key management — ALL data encrypted with that key
is immediately exposed, including historical data. This is known as
catastrophic key compromise. Good practice requires regular key
rotation, generating new keys periodically, and using different keys
for different data classification levels. Forward secrecy (using new
keys per session) mitigates this risk but requires key exchange
protocols.
BIT 6163 | Cryptography & Network Security | Lecture Notes (Weeks 1–3) Page 12 of 29
BIT 6163 – Cryptography & Network Security
Lincoln University College
5. No Non-Repudiation Because both parties share the same key, either party could have
created any given encrypted message. This means symmetric
encryption alone cannot provide non-repudiation — the property that
prevents a sender from falsely denying they sent a message. In legal
and contractual contexts (e-signatures, financial transactions, audit
trails), non-repudiation is essential. It requires digital signatures,
which use asymmetric cryptography where only the private key
holder can create a valid signature.
This elegant mathematical relationship solves the key distribution problem that plagued symmetric
encryption. You can freely publish your public key — anyone can use it to send you encrypted
messages — but only you, holding the private key, can decrypt them.
Confidential Message Recipient's Public Key Recipient's Private Key Only recipient reads it
Digital Signature Sender's Private Key Sender's Public Key Proves sender's identity
BIT 6163 | Cryptography & Network Security | Lecture Notes (Weeks 1–3) Page 13 of 29
BIT 6163 – Cryptography & Network Security
Lincoln University College
1. Solves the Key The most significant advantage of asymmetric cryptography is that it
Distribution Problem eliminates the need to share a secret key over a secure channel.
Your public key can be published openly — on a website, in an email
signature, or in a public key directory. Anyone can use it to send you
an encrypted message. Only you, holding the private key, can
decrypt it. This fundamentally transforms how secure communication
is established across untrusted networks.
3. Scalability Across In a network of n users, each user only needs ONE key pair
Large Networks regardless of how many other users they need to communicate with.
This is dramatically more scalable than symmetric systems. Every
HTTPS website uses the same infrastructure: one key pair per
server, and millions of clients can securely connect to it without any
pre-shared secret.
4. Enables Public Key Asymmetric cryptography is the foundation of PKI — the system of
Infrastructure (PKI) certificates and certificate authorities that makes HTTPS trustworthy.
A certificate binds an entity's identity to their public key, signed by a
trusted Certificate Authority. Your browser trusts thousands of
websites securely because of this system, without needing to
pre-configure any secret keys.
1. Much Slower Than Asymmetric operations (particularly RSA key operations) involve
Symmetric Encryption modular exponentiation with very large numbers — mathematically
intensive operations that are 1,000–10,000 times slower than AES.
RSA-2048 encryption might process just a few kilobytes per second,
compared to AES-256's gigabytes per second. This makes
asymmetric encryption completely impractical for encrypting large
files or real-time data streams. In practice, it is only used to encrypt
small pieces of data, typically symmetric session keys.
BIT 6163 | Cryptography & Network Security | Lecture Notes (Weeks 1–3) Page 14 of 29
BIT 6163 – Cryptography & Network Security
Lincoln University College
2. Larger Key Sizes To achieve equivalent security to symmetric keys, asymmetric keys
Required must be dramatically larger. A 256-bit AES key provides roughly the
same security as a 3,072-bit RSA key. This means longer
computation times, more storage, and larger certificate sizes.
Modern ECC (Elliptic Curve Cryptography) partially addresses this —
a 256-bit ECC key provides security comparable to 3,072-bit RSA —
but ECC operations are still slower than symmetric operations.
4. Private Key Security is While public keys can be freely shared, the security of the entire
Critical asymmetric system depends on the absolute secrecy of the private
key. If a private key is stolen, compromised, or generated with
insufficient entropy, all communications and signatures are
immediately compromised. Private key management — secure
generation, encrypted storage, backup procedures, and revocation
— is operationally complex and a common source of real-world
security failures.
✗ Cannot reverse
ONE-WAY (Irreversible)
No matter how large the input, SHA-256 always produces a 256-bit (64-character hex) output. Changing even one
character in the input produces a completely different hash.
BIT 6163 | Cryptography & Network Security | Lecture Notes (Weeks 1–3) Page 15 of 29
BIT 6163 – Cryptography & Network Security
Lincoln University College
Pre-image Cannot reverse the hash to find the Passwords cannot be recovered from their
Resistance original input. hash.
Fast Computation Hash can be computed quickly. Efficient verification of large files.
SHA-256 a591a6d40bf420404a011733cfb7b190d62c65bf0bcda32b57b277d9ad9f14
(standard) 6e 256 bit
Variable
bcrypt (password) $2b$10$N9qo8uLOickgx2ZMRZoMyeIjZAgcfl7p972OR8... (salted)
Digital Signatures
A digital signature is a cryptographic mechanism that proves the authenticity and integrity of a
message. It answers two critical questions: (1) Did this message really come from the claimed
sender? (2) Has the message been tampered with in transit?
Digital signatures combine hashing with asymmetric cryptography. The sender hashes the
message and then encrypts the hash with their private key — this encrypted hash is the
signature. The receiver decrypts the signature using the sender's public key, then independently
hashes the received message. If both hashes match, the signature is valid.
Ste
p Action By Whom
BIT 6163 | Cryptography & Network Security | Lecture Notes (Weeks 1–3) Page 16 of 29
BIT 6163 – Cryptography & Network Security
Lincoln University College
// Install bcrypt npm install bcrypt // Import the library const bcrypt =
require('bcrypt'); // Define the salt rounds (cost factor) // Higher = slower &
more secure (10-12 is standard) const saltRounds = 10; // ■■ HASHING a password
■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ const plainPassword =
"MySecretPassword123"; [Link](plainPassword, saltRounds, (err, hash) => {
if (err) throw err; [Link]("Hashed password:", hash); // Output:
$2b$10$N9qo8uLOickgx2ZMRZoMyeIjZAgcfl7p972OR8... // Store THIS hash in your
database — NEVER the plaintext! storeInDatabase(hash); }); // ■■ VERIFYING a
password ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ const userInput =
"MySecretPassword123"; // from login form const storedHash = getFromDatabase();
// the hash stored earlier [Link](userInput, storedHash, (err, result)
=> { if (err) throw err; if (result) { [Link]("Password is correct! Login
successful."); } else { [Link]("Incorrect password. Access denied."); } });
BIT 6163 | Cryptography & Network Security | Lecture Notes (Weeks 1–3) Page 17 of 29
BIT 6163 – Cryptography & Network Security
Lincoln University College
Learning Objectives
Question Asked "Who are you?" "What are you allowed to do?"
Example Login with username & password Can this user delete records?
Failure Result Login rejected (401 Unauthorized) Access denied (403 Forbidden)
Real-World Analogy:
BIT 6163 | Cryptography & Network Security | Lecture Notes (Weeks 1–3) Page 18 of 29
BIT 6163 – Cryptography & Network Security
Lincoln University College
4. Validate
JWT STRUCTURE:
Header Payload Signature
(alg, typ) (claims, exp, iat) (HMAC/RSA)
. (dot separator) . (dot separator)
The client presents credentials once and receives a JWT. All subsequent API requests carry this token in the
Authorization header — no session storage needed on the server.
BIT 6163 | Cryptography & Network Security | Lecture Notes (Weeks 1–3) Page 19 of 29
BIT 6163 – Cryptography & Network Security
Lincoln University College
HMAC or
Signatur HMACSHA256(base64(header)+"."+bas Proves the token has not
RSA
e e64(payload), secret) been tampered with
signature
BIT 6163 | Cryptography & Network Security | Lecture Notes (Weeks 1–3) Page 20 of 29
BIT 6163 – Cryptography & Network Security
Lincoln University College
Client■(Browser) Server
ChangeCipherSpec + Finished
ChangeCipherSpec + Finished
The TLS handshake establishes a shared secret between client and server before any application data is transmitted,
ensuring all subsequent communication is encrypted.
Recommende
TLS 1.3 2018 d Fastest and most secure — use this
1. In User enters username and password HTTPS must be active; no credentials over HTTP
put in the browser
2. T Credentials sent to server via POST TLS 1.2/1.3 encrypts data in transit
rans request
port
3. V Server checks username exists in Prevent timing attacks — same response time for valid/invalid users
alid database
atio
n
BIT 6163 | Cryptography & Network Security | Lecture Notes (Weeks 1–3) Page 21 of 29
BIT 6163 – Cryptography & Network Security
Lincoln University College
5. R Server checks login attempt count Lock account after 5 failed attempts; CAPTCHA after 3
ate
Limi
ting
6. J Server generates JWT with user Short expiry (1h); signed with strong secret
WT claims
Issu
e
7. T JWT sent to client in httpOnly cookie httpOnly prevents JavaScript access; Secure flag enforces HTTPS
oke only
n St
ora
ge
9. L Client clears token; server adds to Token revocation list or short expiry
ogo blacklist if needed
ut
BIT 6163 | Cryptography & Network Security | Lecture Notes (Weeks 1–3) Page 22 of 29
BIT 6163 – Cryptography & Network Security
Lincoln University College
Learning Objectives
• Understand how XSS, CSRF, and SQL Injection attacks work mechanically
1. Injects <script> into comment/input Vulnerable 2. Server stores & serves malicious script Victim
Attacker
Web Server (Browser)
The attacker injects a script that the server unknowingly serves to victims. The victim's browser executes the script,
sending sensitive data back to the attacker.
Stored XSS Malicious script saved in the Permanent Injecting script in a forum post that
(Persistent) database (e.g., in a comment field) until removed all readers see
and served to all users
BIT 6163 | Cryptography & Network Security | Lecture Notes (Weeks 1–3) Page 23 of 29
BIT 6163 – Cryptography & Network Security
Lincoln University College
Reflected Script embedded in URL Temporary — Phishing email with crafted URL
XSS (Non-Per parameters; victim clicks a only when link containing the payload
sistent) malicious link is clicked
DOM-Based Script manipulates the DOM directly Temporary URL hash or query params
XSS using client-side JavaScript processed insecurely by JS on the
page
CSRF Prevention:
Prevention Description Implementation
Method
BIT 6163 | Cryptography & Network Security | Lecture Notes (Weeks 1–3) Page 24 of 29
BIT 6163 – Cryptography & Network Security
Lincoln University College
CSRF Tokens Server generates a unique token per Include hidden input field
session/form. Token must be submitted
with every state-changing request.
SameSite Cookie Prevents cookies from being sent with Set-Cookie: session=abc;
Attribute cross-site requests. SameSite=Strict; Secure; HttpOnly
Double Submit CSRF token stored in cookie AND sent in Both values must match for request to
Cookie request body. Server compares both. proceed
Custom Request AJAX requests with custom headers (e.g., Check header presence on server-side
Headers X-Requested-With) cannot be forged by
simple forms.
Referer/Origin Server checks that request origin matches Reject requests from unexpected
Validation expected domain. origins
Classic/In-band SQLi Error messages or UNION queries reveal Full database dump, authentication
data directly bypass
Blind Boolean SQLi Ask TRUE/FALSE questions to infer data Slow but can extract all data
Blind Time-Based Use SLEEP() to infer data based on Works even when no output is shown
SQLi response time
Out-of-Band SQLi Use database features to send data to Data exfiltration even with no visible
attacker (DNS, HTTP) errors
BIT 6163 | Cryptography & Network Security | Lecture Notes (Weeks 1–3) Page 25 of 29
BIT 6163 – Cryptography & Network Security
Lincoln University College
Second-Order SQLi Payload stored then executed later in a Hard to detect in code review
different context
Input Validation Never trust user input — validate type, Check that an email field contains "@" and a
length, format, and range on the valid domain before processing.
SERVER side.
Output Encoding Encode data before inserting into Use htmlspecialchars() in PHP or React's
HTML, JS, CSS, or SQL to prevent built-in escaping.
injection attacks.
Least Privilege Grant only the minimum permissions DB user for a login page needs SELECT only
necessary to complete a task. — not DROP TABLE.
Error Handling Show generic errors to users; log Display "Login failed" — never "User not
detailed errors only on the server. found" or stack traces.
Dependency Keep all libraries and frameworks Run npm audit regularly; use Snyk or
Management updated; scan for known vulnerabilities. Dependabot.
Secure Defaults Applications should be secure "out of Default to HTTPS; require strong passwords;
the box" with no extra configuration disable debug mode in production.
needed.
Cryptographic Use well-vetted, current cryptographic Use AES-256 for encryption, bcrypt for
Standards algorithms. Never invent your own passwords, SHA-256 for hashing.
crypto.
Authentication Multi-factor authentication, account Require OTP after password; lock after 5
Controls lockout, secure password reset. failed logins.
BIT 6163 | Cryptography & Network Security | Lecture Notes (Weeks 1–3) Page 26 of 29
BIT 6163 – Cryptography & Network Security
Lincoln University College
Alert! Suspicious
Firewall: blocks based on rules IDS: detects threats IPS: blocks threats
Traffic flows from the untrusted internet through the firewall (which blocks unauthorized packets), then through the
IDS/IPS (which monitors for suspicious patterns), before reaching internal systems.
Firewall Controls traffic based on IP, Block/Allow Network pfSense, Cisco ASA,
port, protocol rules packets (L3/L4) Windows Defender
Firewall
IDS (Intrusion Monitors and analyzes traffic ALERT only — Network/Ho Snort, Zeek (Bro),
Detection for known attack signatures or does not block st OSSEC
System) anomalies
IPS (Intrusion Like IDS but sits inline in the BLOCK malicious Network/Ho Snort in inline mode,
Prevention traffic path traffic in real time st Suricata, Cisco
System) Firepower
WAF (Web Filters HTTP traffic; blocks Block malicious Application Cloudflare WAF, AWS
Application web-layer attacks (XSS, SQLi) HTTP requests (L7) WAF, ModSecurity
Firewall)
SIEM Aggregates and analyzes logs Alert and correlate Manageme Splunk, IBM QRadar,
from all security devices events nt Microsoft Sentinel
Types of Firewalls:
Type How It Works Strengths
Packet Filter Inspects packet headers (IP, port, protocol) Fast; low overhead; good for simple
against static rules rules
Stateful Inspection Tracks connection state; ensures packets More intelligent than packet filter;
belong to a valid session catches spoofed packets
Application Inspects application-layer data; acts as Deep inspection; can filter HTTP
Gateway (Proxy) intermediary content
Next-Gen Firewall Combines all above + DPI, IPS, SSL Most comprehensive; industry
(NGFW) inspection, identity awareness standard today
BIT 6163 | Cryptography & Network Security | Lecture Notes (Weeks 1–3) Page 27 of 29
BIT 6163 – Cryptography & Network Security
Lincoln University College
Symmetric 1 Same key encrypts & decrypts; fast but key Protects bulk data (files, database
Encryption distribution is a challenge fields, network streams)
Asymmetric 1 Key pair (public+private); solves key Secures key exchange, enables digital
Encryption distribution problem signatures and certificates
Hashing 1 One-way function; fixed output; irreversible Password storage, data integrity
verification, digital signatures
bcrypt 1 Slow, salted password hashing; cost factor The industry standard for secure
is adjustable password storage
Authentication 2 Proving identity ("Who are you?") using First line of defense; ensures only valid
credentials users enter the system
JWT 2 Stateless signed token carrying user claims; Enables scalable, server-side
three-part structure sessionless API authentication
XSS 3 Injecting malicious scripts into pages viewed Can steal sessions, credentials,
by other users deface sites; very common
vulnerability
CSRF 3 Tricking authenticated users into unintended Can transfer funds, change settings,
actions delete data without user knowledge
SQL Injection 3 Inserting SQL code into database queries Bypasses authentication, exposes
via user input entire database, can destroy data
Firewall / IDS / IPS 3 Network perimeter defense: filter, detect, Essential for enterprise network
and prevent threats security; forms the outer defense layer
BIT 6163 | Cryptography & Network Security | Lecture Notes (Weeks 1–3) Page 28 of 29
BIT 6163 – Cryptography & Network Security
Lincoln University College
Note to Students: These three weeks lay the essential security foundation for the entire
course. The concepts covered here — encryption, authentication, and web security threats —
will be applied directly when you build and secure your ReactJS applications in Weeks 4
through 15. Review these notes before each ReactJS security lab.
BIT 6163 | Cryptography & Network Security | Lecture Notes (Weeks 1–3) Page 29 of 29