Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lesves/toyrsa
A toy RSA implementation in Haskell (semestral project for non-procedural programming)
https://github.com/lesves/toyrsa
asymetric-cryptography haskell proof-of-concept rsa
Last synced: 27 days ago
JSON representation
A toy RSA implementation in Haskell (semestral project for non-procedural programming)
- Host: GitHub
- URL: https://github.com/lesves/toyrsa
- Owner: lesves
- Created: 2024-05-30T19:54:10.000Z (5 months ago)
- Default Branch: master
- Last Pushed: 2024-07-12T22:36:20.000Z (4 months ago)
- Last Synced: 2024-09-30T09:03:28.116Z (about 1 month ago)
- Topics: asymetric-cryptography, haskell, proof-of-concept, rsa
- Language: Haskell
- Homepage:
- Size: 16.6 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: docs/README.md
Awesome Lists containing this project
README
# ToyRSA
A toy RSA implementation written in Haskell as my semestral project for a non-procedural programming course.
## Usage:
```
cabal install --lib random
make all# Generate a key:
./toyrsa --gen
# Creates and .pub# Encrypt something:
./toyrsa --enc# Decrypt something:
./toyrsa --dec
```### Documentation
The program is split into 4 files.
- `Main.hs` contains the command line interface and padding scheme (which is *insecure*).
- `Lib/Utils.hs` contains basic utilities for dealing with large numbers and modular arithmetic. Exponentiation modulo n (only for nonnegative exponents, using exponentiation by squaring) and multiplicative inverse (using a modified Extended Euclidean algorithm).
- `Lib/Primes.hs` contains the algorithm which generates random primes (by generating random numbers and testing them with the Miller-Rabin primality test)
- `Lib/RSA.hs` contains the RSA cryptosystem implementation (the most complicated part is the key generation, encryption and decryption is simple modular exponentiation)The key format is simply a derived `Show` dump of the `PublicKey`/`PrivateKey` types from `Lib/RSA.hs`.