Published on

Offensive and Defensive Cryptography

803 words5 min read

Crypton is an educational library to learn and practice Offensive and Defensive Cryptography.

It is basically a collection of explanation and implementation of all the existing vulnerabilities and attacks on various Encryption Systems (Symmetric and Asymmetric), Digital Signatures, Message Authentication Codes and Authenticated Encryption Systems.

Each attack is also supplemented with example challenges from "Capture The Flag" contests and their respective write-ups. Individuals who are already acquainted (or are into CTFs) with this field can use Crypton as a tool to solve challenges based on a particular existing vulnerability.

Block Ciphers

TopicExplanationImpl./ExploitChallenge
Block Cipher Basics - working of block ciphers, padding etc.link
Modes of Encryption - different modes of operation on block ciphers: ECB, CBC, CTRlink
Block Size Detection - detect blocksize of a block cipher encrypting data on a remote servicelink
Mode Detection - detect type of mode of encryption: independent or dependent encryption of blockslink
ECB Byte at a Time - byte at a time decryption of a secret string running on a remote service encrypting input+secret in ECB modelinklink
CBC IV Detection - detect the value of Initialisation Vector on a remote service that is encrypting our input using a block cipher in CBC modelinklink
CBC Bit Flipping Attack - exploiting cookie generation mechanism to login as admin when cookie is generated using a block cipher in CBC modelinklink
CBC Byte at a Time - byte at a time decryption of a secret string running on a remote service encrypting input+secret in ECB modelinklink
CBC Padding Oracle Attack - decryption of data encrypted by a vulnerable service providing encryption/decryptionlinklink
CTR Bit Flipping - exploiting cookie generation mechanism to login as admin when cookie is generated using a block cipher in CBC modelinklink

RSA Encryption

TopicExplanationImpl./ExploitChallenge
Unpadded RSA Enc/Dec - key generation, distribution, encryption/decryption, verification of decryption formula and padding in RSAlink
Direct Root Attack - attack on unpadded RSA with low public key exponentlink
Fermat's Factorisation - technique used to factor modulus n when p and q values are in proximitylinklinklink
Pollard's p-1 Factorisation - technique to factorise n when both of it's factors p & q, p-1 and q-1 have very small prime divisorslinklinklink
Common Modulus Attack - decrypt ciphertext when it's corresponding plaintext is encrypted two different times with the same modulus nlinklinklink
Common Prime Attack - retrieve factors of moduli n1 and n2 when they have a common factorlinklink
Wiener's Attack - get value of decryption key exponent d when d < N0.25linklinklink
Wiener's Attack Variant - get value of decryption key exponent d when d is a few bits greater than N0.25 or d < N0.25linklinklink
Coppersmith's Attack - coppersmith's theorem, attack on stereotyped messages and factoring n with high bits knownlinklinklink
Franklin Reiter Related Message Attack - attack to retrieve related messages encrypted using the same moduluslinklinklink
Hastad's Broadcast Attack- with extension - attack to retrieve a message broadcasted among different people, encrypted using same exponent but different modulilinklinklink
PKCS1-v1.5-Padded-RSA-Encryption/Decryption - ASN1 encoding, padded RSA encryption (needs to be fixed)
Least Significant Bit Oracle Attack - attack on RSA oracle leaking least significant bit value on decryptionlinklink
Attack-Retrieve-Modulus - attack on RSA oracle to extract value of modulus in case it is not publiclinklinklink
Intro-RSA-Challenges - basic challenges in RSA related to Number Theorylinklink

Message Authentication Codes (MACs)

TopicExplanationImpl./ExploitChallenge
Message Authentication Code- internals and security analysis of MACslink
CBC MAC Forgery- generating two message M1 and M2 having the same CBC-MAC authentication taglinklink
Length Extension Attack on CBC-MAC- generate a valid authentication tag of message M1 || M2 (concatenation) given MAC(M1)linklink

Discrete Logarithm Problem

TopicExplanationImpl./ExploitChallenge
DLP- Cyclic Groups, Discrete Logarithm Problemlinklink
Pollard's Rho Algorithm to solve DLPlinklinklink
Baby Step Giant Step Algorithm to solve DLPlinklink
Pohlig Hellman Algorithm to solve DLPlinklink
Elliptic Curve DLP- defining identity element, inverse of a point, cyclic groups over points on an EC, Hasse's theorem, ECDLPlink
Baby Step Giant Step Algorithm to solve Elliptic Curve DLPlinklink
Pollard's Rho Algorithm to solve Elliptic Curve DLPlinklinklink

ElGamal Encryption

TopicExplanationImpl./ExploitChallenge
ElGamal Cryptosystem- Encryption/Decryption- key generation, encryption, decryption in ElGamal Cryptosystemlinklinklink

Authenticated Encryption (AE)

TopicExplanationImpl./ExploitChallenge
AE basics & internals- working of authenticated encryptionlink
AE with MACs- different techniques of implementing AE with MACs: Encrypt and MAC, MAC then encrypt and encrypt then MAClink
Authenticated Cipherslink
AE with Associated Datalink
AES-GCM- encryption in AES-GCM, Wegman-Carter MAClinklink
Forbidden Attack on AES-GCM- attack on AES-GCM due to nonce-reuselinklink

Elliptic Curves

TopicExplanationImpl./ExploitChallenge
Elliptic Curve Internals- defining Elliptic Curves, point addition, point doubling and scalar multiplicationlinkpython, sage

Digital Signatures

TopicExplanationImpl./ExploitChallenge
ElGamal Signatures- key generation, signature generation, signature verification and correctness of ElGamal Signature schemelinklinklink
Elliptic Curve DSA- signature generation, signature verification and correctness of signature algorithmlink
Attack k-reuse ECDSA- forging of ECDSA signatures due to reuse of klink
Unpadded RSA Digital Signatures- signature generation and verification in RSA digital signature schemelinklink
PKCS1-v1.5 padded RSA Digital Signatureslinklink
e=3 Bleichenbacher's Attacklinklinklink

Identification

TopicExplanationImpl./ExploitChallenge
Identification Internalslink
Ephemeral Key Authenticationlinklink

Diffie Hellman Key Exchange

TopicExplanationImpl./ExploitChallenge
Diffie Hellman Key Exchange Internalslinklink
Small Subgroup Confinement Attackslinklinklink
Invalid Curve Point Attacklinklinklink