Topics in this domain
- Security Governance and Roles
- Data Classification and Ownership
- Security Policies
- Privacy Principles and GDPR
- Identity Management
- Authentication Factors
- Biometrics
- Access Models: DAC, MAC, RBAC
- Logical and Privileged Access
- Cryptography Basics
- Symmetric Encryption
- Asymmetric Encryption
- Hashing and Integrity
- Digital Signatures
- PKI and Certificates
- Firewalls
- IDS/IPS
- VPN, SSL/TLS, IPsec
- Wireless Security
- Endpoint and Mobile (BYOD)
- Cloud and Virtualization Security
- Physical Access Controls
- Environmental Controls: Fire, Power, HVAC
- Social Engineering
- Malware
- Network Attacks: DoS, Spoofing, Sniffing
- Application Attacks: SQLi, XSS
- Vulnerability Management and Pen Testing
- Incident Response
- Digital Forensics and Chain of Custody
- Security Awareness Training
- Logging, SIEM, and Auditing Security
Hashing and Integrity
A fingerprint for data
A fingerprint is tiny, unique to you, and you can’t rebuild a person from it. But if someone claims to be you, comparing fingerprints settles the question.
A cryptographic hash function does the same for data. Input of any size goes in; a fixed-size output (the digest, or message digest) comes out.
A good hash function is:
- one-way: you can’t work back from the digest to the input
- collision-resistant: it’s infeasible to find two different inputs with the same digest
- sensitive: change one bit of input and the digest changes completely (the avalanche effect)
Hashing gives integrity. It doesn’t hide the data, so it gives no confidentiality, and it isn’t encryption.
Algorithms
| Algorithm | Digest size | Status |
|---|---|---|
| MD5 | 128 bits | Broken (collisions found); not for security |
| SHA-1 | 160 bits | Broken for collision resistance; being retired |
| SHA-2 (SHA-256, SHA-512) | 256 / 512 bits | Current standard |
| SHA-3 | Variable | Current standard, different design |
Stopping deliberate tampering
A plain hash catches accidental changes. But an attacker who changes a message can just compute a new hash for it.
- An HMAC (hash-based message authentication code) mixes in a shared secret key. Only someone with the key can produce a valid HMAC, so it gives integrity and authentication between the two parties. Because both hold the key, it can’t give non-repudiation.
- A digital signature encrypts the hash with the sender’s private key, giving integrity, authentication and non-repudiation.
Storing passwords
Passwords must never be stored in clear text or with reversible encryption.
- Salt: a unique random value added to each password before hashing. Identical passwords then get different hashes, which defeats precomputed rainbow tables. Salts don’t need to be secret.
- Slow algorithms built for passwords (bcrypt, scrypt, Argon2, PBKDF2) make mass guessing expensive. Fast hashes like plain SHA-256 make guessing fast, which is the wrong goal for passwords.
- Optionally a pepper: a secret value stored separately from the database.
Example. A breached database stores passwords as unsalted SHA-1 hashes. Attackers crack most of them within hours using precomputed tables. With per-user salts and Argon2, the same attack would take years per password.
Hashes in audit work
- File integrity monitoring compares the current hashes of system files with known-good values.
- Forensics: the hash of a forensic image is compared with the original’s to prove the copy is exact.
- Software downloads: published hashes let users check what they downloaded.
- Deduplication and blockchains use hashes as identifiers.
How the exam asks about it
| If the question asks… | The answer is usually… |
|---|---|
| Purpose of hashing | Integrity (detect changes) |
| Does hashing provide confidentiality | No |
| Technique combining a hash with a secret key | HMAC |
| Defence against rainbow table attacks | Salting |
| How a forensic copy is proven identical | Matching hash values |
| Weak hash algorithms | MD5, SHA-1 |
In short
- A hash function turns any input into a fixed-length digest; it's one-way and should be collision-resistant.
- Any change to the input, even one bit, produces a very different hash, so hashes detect alteration.
- Hashing provides integrity, not confidentiality: the original data isn't hidden or encrypted.
- A plain hash doesn't prove who created it; an HMAC (hash with a secret key) or a digital signature adds authentication.
- Passwords are stored as salted hashes using deliberately slow algorithms (bcrypt, scrypt, Argon2, PBKDF2).
- MD5 and SHA-1 are broken for collision resistance; use SHA-2 or SHA-3.
Exam traps
- Hashing is not encryption and can't be reversed to recover data.
- An attacker who alters a message can recompute a plain hash; integrity against attackers needs an HMAC or signature.
- Salts defeat precomputed (rainbow table) attacks; they don't need to be secret.
- Fast hashes like SHA-256 alone are poor for passwords because they make guessing fast.
- Forensic images are verified by comparing hashes of the original and the copy.
Slides
Click the slide and use the arrow keys. F toggles full screen.