Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lambdacasserole/mayo
Diffie-Hellman key exchange utility for Java on Maven.
https://github.com/lambdacasserole/mayo
diffie-hellman encryption java key-exchange-algorithms maven
Last synced: about 1 month ago
JSON representation
Diffie-Hellman key exchange utility for Java on Maven.
- Host: GitHub
- URL: https://github.com/lambdacasserole/mayo
- Owner: lambdacasserole
- License: mit
- Created: 2016-06-07T13:01:45.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2016-07-05T09:16:31.000Z (over 8 years ago)
- Last Synced: 2024-11-01T09:28:25.533Z (3 months ago)
- Topics: diffie-hellman, encryption, java, key-exchange-algorithms, maven
- Language: Java
- Size: 6.84 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Mayo
Diffie-Hellman key exchange utility for Java on Maven.Very tiny library for generating Diffie-Hellman private keys, public keys and shared secrets using Java's `BigInteger` type. Use it like this:
```
// Generate Alice's key pair.
BigInteger alicePrivateKey = DiffieHellmanKeyGenerator.generatePrivateKey();
BigInteger alicePublicKey = DiffieHellmanKeyGenerator.generatePublicKey(alicePrivateKey);// Generate Bob's key pair.
BigInteger bobPrivateKey = DiffieHellmanKeyGenerator.generatePrivateKey();
BigInteger bobPublicKey = DiffieHellmanKeyGenerator.generatePublicKey(bobPrivateKey);// Arrive at shared secret.
BigInteger aliceSharedSecret = DiffieHellmanKeyGenerator.generateSharedKey(bobPublicKey, alicePrivateKey);
BigInteger bobSharedSecret = DiffieHellmanKeyGenerator.generateSharedKey(alicePublicKey, bobPrivateKey);assertEquals(aliceSharedSecret, bobSharedSecret); // Alice and Bob should have arrived at same secret.
```Feel free to transmit the public keys in the clear. By the end of the handshake you'll both have arrived at the same secret to use with symmetric encryption, without transmitting the secret in the clear. Mayo uses a 1536-bit prime.
## Installation
You can pull this package into your Maven project straight from here using JitPack. Add JitPack as a repository first:```
jitpack.io
https://jitpack.io
```
Then add a dependency on Mayo:
```
com.github.lambdacasserole
mayo
v1.0
```
## Limitations
I'm not a cryptographer and for all I know there's a horrible mistake in this library that's going to open it up to a trillion different attacks. Use a time-tested and reliable implementation over Mayo any day.Also, there are a [number of well-known attacks](https://weakdh.org/) on Diffie-Hellman key exchanges.
## Contributing
For most intents and purposes, Mayo is considered to fulfil its original use case. Bug fixes and suggestions are welcome, however, from any member of the community.