Giter Club home page Giter Club logo

spake2-java's Introduction

SPAKE2-Java

Implementation of SPAKE2 protocol in Java, fully compatible with BoringSSL implementation.

DISCLAIMER: This is an unaudited library tested with Android 11 wireless debugging. Use it at your own risk.

The ultimate goal of this project is to provide both pure java and (for android) JNI implementation of SPAKE2. The project is fully usable as of now, but it requires further optimizations.

Get Started

import io.github.muntashirakon.crypto.spake2.* in your project. Do not import any other files from io.github.muntashirakon.crypto as there's no guarantee that they will not be modified in the future.

// Create alice and bob
Spake2Context alice = new Spake2Context(Spake2Role.Alice, "alice", "bob");
Spake2Context bob = new Spake2Context(Spake2Role.Bob, "bob", "alice");
// The below methods are kept for compatibility with BoringSSL
// alice.setDisablePasswordScalarHack(true);
// bob.setDisablePasswordScalarHack(true);
// Messages
byte[] aliceMsg = alice.generateMessage(alicePassword.getBytes(StandardCharsets.UTF_8));
byte[] bobMsg = bob.generateMessage(bobPassword.getBytes(StandardCharsets.UTF_8));
// Fetch keys
byte[] aliceKey = alice.processMessage(bobMsg);
byte[] bobKey = bob.processMessage(aliceMsg);

Notice for BoringSSL Users

Beware that strings in C/C++ adds a NULL character (i.e. \u0000) at the end, so if you've accidentally used sizeof(my_name) instead of sizeof(my_name)-1, you have to make sure that you're adding this character to your Java implementation too.

Credits

  • ED25519 implementation is a modified and a simplified version of the EdDSA-Java library (CC0 license).
  • Spake2 implementation is based on BoringSSL's spake25519.c (MIT license).
  • A few methods are modified from Curve25519-java (GPL-3.0 license).

License

Copyright 2021 Muntashir Al-Islam

Licensed under the GPLv3: https://www.gnu.org/licenses/gpl-3.0.html

spake2-java's People

Contributors

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