TryHackMe — Cryptography Basics | Cyber Security 101 (THM)
Importance of Cryptography
Cryptography ensures secure communication, maintaining data confidentiality, integrity, and authenticity in the presence of adversaries. You rely on cryptography daily:
- Login: Your credentials are encrypted, preventing unauthorized access.
- SSH: Encrypted tunnels protect your session from eavesdropping.
- Online Banking: Cryptography verifies the server’s authenticity.
- Downloads: Hash functions check file integrity.
Cryptography is fundamental for standards like PCI DSS for credit card data and HIPAA/GDPR for medical records, establishing necessary security without direct user interaction.
Questions and Answers
- What is the standard required for handling credit card information?
- PCI DSS
Plaintext to Ciphertext
Plaintext is readable data, like text or images, before encryption. Using a cipher (encryption algorithm) and a key, plaintext is transformed into ciphertext, the unreadable, scrambled output. To revert it back to plaintext, we pass the ciphertext and key through the decryption process.
Key terms:
- Plaintext: Original, readable data.
- Ciphertext: Encrypted, unreadable data.
- Cipher: Algorithm for encryption and decryption.
- Key: Secret bit sequence used with the cipher.
- Encryption: Turning plaintext into ciphertext.
- Decryption: Turning ciphertext back into plaintext.
Questions and Answers
- What do you call the encrypted plaintext?
- ciphertext
- What do you call the process that returns the plaintext?
- decryption
Historical Ciphers
Cryptography has ancient roots, with simple ciphers like the Caesar Cipher, which shifts each letter by a set number. For example, shifting TRYHACKME by a key of 3 results in WUBKDFNPH. To decrypt, reverse the shift by the same key. This simplicity, however, makes it vulnerable to brute-force attacks since there are only 25 possible keys in the English alphabet.
Other notable historical ciphers:
- Vigenère cipher (16th century)
- Enigma machine (WWII)
- One-time pad (Cold War)
Questions and Answers
- Knowing that XRPCTCRGNEI was encrypted using Caesar Cipher, what is the original plaintext?
- ICANENCRYPT
Types of Encryption
There are two main encryption types: symmetric and asymmetric.
- Symmetric Encryption: Uses the same key for both encryption and decryption. Keeping this key secure is crucial as it is shared with intended recipients. Examples include DES, 3DES, and AES.
- DES: A 56-bit key, now insecure as it was cracked in under 24 hours in 1999.
- 3DES: An extension of DES, using a 168-bit key (effective security of 112 bits); deprecated in 2019.
- AES: Adopted in 2001, with key sizes of 128, 192, or 256 bits; the current standard.
- Asymmetric Encryption: Uses two keys — public for encryption and private for decryption. Asymmetric encryption includes RSA, Diffie-Hellman, and ECC, where ECC achieves strong security with shorter keys. This type is based on problems that are easy to compute in one direction but hard to reverse, ensuring long-term security.
Questions and Answers
- Should you trust DES? (Yea/Nay)
- Nay
- When was AES adopted as an encryption standard?
- 2001
Basic Math
Cryptography relies on math, especially XOR and modulo operations.
- XOR Operation: XOR (exclusive OR) compares binary bits; it returns 1 if bits differ, 0 if they’re the same. XOR is useful in cryptography due to properties like A ⊕ A = 0 and A ⊕ 0 = A. For encryption, XOR can be applied to plaintext and a key to produce ciphertext, and the original text can be recovered by XORing the ciphertext with the key again.
- Modulo Operation: The modulo (X%Y) gives the remainder of dividing X by Y. It’s commonly used in cryptographic algorithms. The result of X%Y is always between 0 and Y-1.
Questions and Answers
- What’s 1001 ⊕ 1010?
- 0011
- What’s 118613842%9091?
- 3565
- What’s 60%12?
- 0
