Coder Social home page Coder Social logo

rsa-encryptor-decryptor's Introduction

RSA-Verilog

RSA implementation in verilog to Encrypt/Decrypt 16-bit input messages using two prime numbers p and q both 8-bits.

Brief

RSA (Rivest–Shamir–Adleman) is an algorithm used by modern computers to encrypt and decrypt messages. It is an asymmetric cryptographic algorithm. Asymmetric means that there are two different keys. This is also called public key cryptography, because one of the keys can be given to anyone. The other key must be kept private. The algorithm is based on the fact that finding the factors of a large composite number is difficult: when the factors are prime numbers, the problem is called prime factorization. It is also a key pair (public and private key) generator. rsa

RSA in action

In file encryption the file is encrypted symmetrically and the key is encrypted by RSA directly.

For Digital signatures one can use the private key to sign a message or file (or better: sign the cryptographic hash of the message/file). If a second party has the corresponding public key he can verify that the file is authentic and has not been altered or damaged.

Implementation

Main module schematic main_diagram

parameter instruction_selctor is given while instantiating main module to select whether encryption or decryption mode.

there are some intermediate I/Os to synchronize components too.

Arithmetic challenge: encryption/decryption requires math power function and M**e / M**d requires larger register so in each mpower = mpower mod N is calculated and then its multiplied by M. psuedo code shows the solution.

#Ordinary way
mpower = 1
for _ in range(d):
    mpower = mpower * M
remainder = mpower % N
#Solution
mpower = 1
for _ in range(d):
    mpower = mpower % N
    mpower = mpower * M
remainder = mpower % N   

Usage

Diagrams

main_diagram

Simulations

encryption

encryption

decryption

encryption

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.