GithubHelp home page GithubHelp logo

diffiehellman-aes's Introduction

DiffieHellman-AES

C#


Screenshot 2022-05-10 at PM 3 41 39

This project implements Diffie Hellman algorithm and AES algorithm. What this app does is that it creates two users Alice and Bob. Those two users then generate a unique key for themselves which are known as a & b. After this, they are to agree on two public keys p & q. In this documentation, I will be explaining everything in detail starting off from generating the keys up until printing the messages on the screen

Diffie Hellman algorithm: The Diffie-Hellman algorithm is being used to establish a shared secret that can be used for secret communications while exchanging data over a public network using the elliptic curve to generate points and get the secret key using the parameters. 1200px-Diffie-Hellman-Schlüsselaustausch svg

Parameters: G: is a very huge prime number which is practically crackable. If it was a small number, it would have no meaning because it would be so easy to be cracked. P: It is a primitive root modulo of G.*

  • Modulo operation is an operation where the result is the remainder of the division operation performed with two given integers as operands. A: Alice’s private key B: Bob’s private key.

AES algorithm: The AES Encryption algorithm (also known as the Rijndael algorithm) is a symmetric block cipher algorithm with a block/chunk size of 128 bits. It converts these individual blocks using keys of 128, 192, and 256 bits. Once it encrypts these blocks, it joins them together to form the ciphertext

security-aes_design_mobile

Screenshot 2022-05-10 at PM 4 06 39

Firstly, two accounts are created for the users. Technically, we have a class for creating users calles USER. We basically call this class two times as we want to create to users.

Screenshot 2022-05-10 at PM 4 06 59

When we create an instance of this class, the constructor takes the users name and saves it into a variable this.name because we will need to have the name as we will need it to keep track from who we got the message to display his/ her name before the message. After creating an instance, we have to initialize some variables, Private key and IV. Private key is a method whose return type is Biginteger. It generates a random number and then initialize private key to be them the non-sharable key. IV is a byte array that we need it for AES algorithm. It is basically an initialization vector that is used to ensure that the same value encrypted multiple times, even with the same secret key, will not always result in the same encrypted value. This is an added security layer.

Screenshot 2022-05-10 at PM 4 20 22

After initializing the fields, we call a method called Generate_Key() . what this method does is that it calculates the modulo operation and then initializes the first key calculated from the first user.

Screenshot 2022-05-10 at PM 4 24 20

We call this function for as many users as there are, so that it calculates the keys for the users. This calculation is the first round. First round:

Screenshot 2022-05-10 at PM 4 27 35

Screenshot 2022-05-10 at PM 4 28 04

Screenshot 2022-05-10 at PM 4 30 33

After Generating the public keys, we exchange the keys between the users. Exchange_Keys(Biginteger GeneratedPublicKey , byte[] IV) This method take the generated keys which are permitted to be exchanged over the network and them calculate the second round. Second round:

Screenshot 2022-05-10 at PM 4 29 25

Screenshot 2022-05-10 at PM 4 29 36

Now everything is all set. Keys are exchanged. For AES, it is the typical algorithm. The only thing I add to it is Screenshot 2022-05-10 at PM 4 38 02

The final keys are not consistent in bits and the size of them does not work for AES algorithm and that what happened to me. As AES works with { 128-bit, 192-bit, 256- bit} keys, I used that method that makes the key consistent in bits 32 byte * 8 = 256 bits. This has a salt array filed, it is made up of numbers added to the key before its hashing. it helps creating a unique key.

Screenshot 2022-05-10 at PM 4 58 33

IDisposable is an interface that contains a single method, Dispose(), for releasing unmanaged resources, like files, streams, database connections and so on.

diffiehellman-aes's People

Contributors

raidansz avatar

Watchers

 avatar

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.