Repository containing my Sage and/or Python implementations of attacks on popular ciphers and public key cryptosystems.
As of yet, there are implementations for attacks against RSA, Diffie-Hellman and its elliptic curve variant, AES-ECB, and AES-CBC. There are also miscellaneous factoring attacks, which may be applicable for targeting many public key schemes, and some notes on topics such as elliptic curve pairings. I plan to finish all existing public key attacks in the future and significantly expand attack support for symmetric key primitives, as the latter has been relatively lacking for the past few years. Additionally, I aim to add more general purpose algorithms in the domains of factoring, state recovery for non-cryptographically secure PRNG (such as ones that use linear congruential generators or linear-feedback shift registers), and more, the reason being that doing so should allow for more flexibility when attacking cryptographic primitives.
SageMath is available on both Windows and Un*x.
To install SageMath on Windows, download an installer from the following link: https://github.com/sagemath/sage-windows/releases
To install on Ubuntu and other Linux distros, I believe sudo apt install sagemath
, or something along those lines will get the job done.
SageMath also has a presence in the cloud:
SageMathCell: (useful as a quick go-to for evaluating Sage code without the need to save, also be mindful of no external connections)
CoCalc: (optimal for hosting personal projects in the cloud)
It is also possible to host a personal SageMath server, though I have never tried this.
The Notes directory contains my notes on miscellaneous cryptography-related topics. As of now, I have written up a summary of the first few chapters of Craig Costello's Pairings for Beginners and a SageMath script demonstrating elliptic curve point addition and doubling in projective coordinates.
Feel free to let me know if there are any bugs.
Q: Why use SageMath instead of pure Python?
A: Sage provides many convenient number-theoretic functions and constructors for algebraic structures commonly used by or used against cryptographic primitives, such as groups, polynomial rings, fields, and elliptic curves. This saves a lot of time since it allows focus to be placed solely on implementing attacks and useful general purpose algorithms rather than the structures that they depend upon.