Description:
Modern cryptography is based on publicly known mathematical algorithms that operate on binary bit sequences and utilitize secret keys. This section will describe concepts for the following three types of modern cryptography;
- Symmetric (Secret Key) Cryptography – Same key is used to encrypt and decrypt
- Asymmetric (Public Key) Cryptography – Key Pair (public key and private key) is used to encrypt and decrypt.
- Hashing (aka checksum) – One-way mathematical value computed to verify the data integrity of a message.
Symmetric (Secret Key) Cryptography Concepts:
- Symmetric key cryptography (Private-key) – same key is used for encrypt and decrypt (e.g., AES , DES, Blowfish, IDEA, etc.)
- XOR – eXclusive OR by
^
symbol is a cheap way to encrypt data with a password. - Modulo operator – remainder from mathematical operation (division)
- pseudo-random number generators – algorithm used for generating random numbers
- stream ciphers – symmetric key cipher that encrypts data one bit at a time using a shared key.
- block ciphers – encrypts fixed-length blocks of data using modes of operation
- Advantage: Fast and efficient encryption of large amounts of data. Easy to implement at the hardware level.
- Disadvantage: Single key is used for both encryption and decryption (potential for compromise).
Asymmetric (Public Key) Encryption Concepts:
- Asymmetric key cryptography (Public-key) – two different keys are used (public and private) for encrypt and decrypt (e.g, RSA )
- Public Key Certificate – (aka digital certificate) – electronic document used to prove the ownership of a public key.
- Diffie-Hellman key exchange – one of the first public key algorithms used securely exchanging cryptographic keys over a public channel.
- RSA (Rivest–Shamir–Adleman) is a public-key cryptosystem that is widely used for secure data transmission. (public-key cryptography)
Public Key Encryption (cont) – Key Management:
- Public Key Infrastructure (PKI); a set of roles, policies, and procedures needed to create, manage, distribute, use, store and revoke digital certificates and manage public-key encryption.
- Private key – part of the asymmetric key pair that is used with a public key algorithm to provide assurance as to the integrity of information,
- Public Key Certificate – (aka digital certificate) – electronic document used to prove the ownership of a public key.
- Certificate Authorities – entity that issues digital certificates to certify the ownership of a public keys
Hashing Concepts:
- Hash – one-way encryption algorithm used on a message of any length to produce a fixed length hash number (aka checksum) which is used to verify the data integrity of message.
- Salt – random data added to hashed data, passwords or passphrases to safeguard passwords in plain text storage.
- Password hash – Usually stored in the format
$id$salt$hash
in the etc/shadow file where the id identifies the hashing algorithm (e.g., MD4, MD5, SHA, XOR, etc) - Message Authentication Codes (MAC) – short piece of information used to authenticate a message is from the stated sender (non repudiation)
CTF Evaluation Steps (advanced)
In a CTF. you will most likely get basic exercises like the following:
- basic substitution and XOR
- pseudo-random number generators
- stream and block ciphers, and their modes of operation
- message authentication codes
- Diffie-Hellman key exchange
- RSA (public-key cryptography)
Practice Challenge Platforms
- TryHackMe – See the free ‘Encryption – Crypto 101’ module . Includes instruction and challenges for novices.
- PicoCTF – See the Cryptography section under the practice tab for challenges.
- CryptoPals – site hosts the following eight sets crypto of challenging with solutions; 1) Basics; 2) Block crypto; 3) Block & stream crypto; 4) Stream crypto and randomness; 5) Diffie-Hellman ; 6) RSA and DSA; 7) Hashes; 8) Abstract Algebra
- Cryptohack – Design for people also learning some python skills but most of the initial challenges can be done using web based tools.)
Recommendations for CTF Challenges
- Focus on discovering patterns in the ciphertext to comprehend how encryption transpired.
- Unlike hashing, encryption is not a one-way process, so we can reverse it to obtain the plaintext.
- Brute force is the last choice during cryptanalysis, since modern ciphers can have extremely large key sizes. While solving these challenges, you should refrain from mindless brute forcing or using automated tools as far as possible.
- Instead, it is best to study the cryptosystem as intricately as possible and develop code breaking skills along the way.
References:
- TryHackMe – See the free ‘Encryption – Crypto 101’ module for instruction and challenges.
- CTF 101 Cryptography – Includes sections on ; 1) XOR; 2) Cesear Cipher; 3)Substitution Cipher; 4)Vigenere Cipher ; 5)Hashing Functions ; 6) Block Ciphers; 7) Stream Ciphers; and 8)RSA (Rivest–Shamir–Adleman)
- Youtube: Cryptography Concepts – SY0-601 CompTIA Security+ : 2.8 (5:32)
- Youtube: Cryptographic Attacks – CompTIA Security+ SY0-501 – 1.2 (xx:xx)
- Youtube: Symmetric and Asymmetric Cryptography – SY0-601 CompTIA Security+ : 2.8 (9:20)
- Youtube: Hashing and Digital Signatures – SY0-601 CompTIA Security+ : 2.8 (10:51)
- RSA Encryption Blog by MuirlandOracle (18 min Read)