Skip to content

This library aim to generate an RSA keypair in python for self-training purpose

Notifications You must be signed in to change notification settings

Cypher-Project/Pubcrypt

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Pubcrypt ~ RSA keypair

This library aim to generate an RSA keypair in python. Other features like encryption, decryption and prime_factor recovery are available. I've started this project in the purpose of training myself to implemente cryptographic algorithm. In consequence, this library do NOT aim for a profesional purpose.

Table of contents

Installation

Install the very last version: git clone https://github.com/Bl4omArchie/pubcrypt
Install the last stable version: https://github.com/Bl4omArchie/pubcrypt/releases/tag/v1.0

Once you installed the package, you can call function from the test.py file. With the app.py file, call directly your function from the command line:

usage: app.py [-h] [-g G] [-enc ENC] [-dec DEC] [-r R] [-e E] [-n N] [-d D]

Call function from pubcrypt module

optional arguments:
  -h, --help  show this help message and exit
  -g G        Generate an RSA keypair. Indicate the bits size as an argument
  -enc ENC    encryption your data
  -dec DEC    decrypt your data
  -r R        recover your primes factor. Indicate the public modulus as an argument
  -e E        Public exponent. By default: e=65537
  -n N        Public modulus
  -d D        Private exponent

Documentation

pubcrypt/cryptosystem/rsa.py

functions Parameters Return
generate nBits, e=65537 public and private keypair: n, e, d
primitive_exp m, exp, n plaintext or ciphertext
prime_recovery n, e, d p, q
nBits = the size in bits of your key [2048, 8192] <br>
n = public modulus <br>
e = public exponent <br>
d = private exponent <br>
exp = public or private exponent <br>
p, q = first and second prime factor <br>

pubcrypt/number/primality.py:

functions Parameters Return
get_prime_factors pBits, e a prime p
miller_rabin p, r PRIME or NOT_PRIME
r = number of round for Miller Rabin primality test. Set to 5

pubcrypt/number/random.py:

functions Parameters Return
get_prime_factors pBits, e a prime p
miller_rabin p, r PRIME or NOT_PRIME

pubcrypt/number/util.py:

functions Parameters Return
invmod a, b inverse of a modulo b
gcd a, b gcd of a and b
lcm a, b lcm of a and b
pair wise consistency test m, e, n True or False
isqrt x square root of x
perfect_square c PERFECT_SQUARE or NOT_PERFECT_SQUARE

pubcrypt/number/random.py

functions Parameters Return
RBG nBits a bit string of nBits
RNG nBits an integer of nBits
int_to_bytes a, b a bit string representing the integer x
bytes_to_int m, e, n an integer representing the string x

A more precise description is available below each function

Plan

✅ Main branch

  • generate(), primitive_exp(), prime_recovery()
  • Miller Rabin primality test
  • README + gitignore
  • app.py: where you can use the library with command from the terminal

🚧 pubcrypt-dev

  • benchmark + pdf with graph an tutorial
  • improve app.py with a file argument where you can indicate your value directly from a file.
  • PKCS: encryption, decryption and signature methods

Version

Version Description
v1.0 first stable version of pubcrypt. Can generate, encrypt, decrypt and recover prime factors
v1.1 command line version added

Author

You can contact me and see my work here:

References

About

This library aim to generate an RSA keypair in python for self-training purpose

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%