Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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)

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`.