Git Product home page Git Product logo

srp's Introduction

GitHub release Build Status Coverage Status Go Report Card GoDoc Go version Go version

SRP

An implementation of SRP-6a as documented in RFC 5054 and RFC 2945. It also exports modified versions of routines allowing it to be used with AWS Cognito which uses a variation of SRP.

Generate the verifier:

package main

import "github.com/bodgit/srp"

func main() {
	g, err := srp.GetGroup(1024)
	if err != nil {
		panic(err)
	}

	s, err := srp.NewSRP(crypto.SHA1, g)
	if err != nil {
		panic(err)
	}

	i, err := s.NewISV("username", "password")
	if err != nil {
		panic(err)
	}

	// Marshal and store i on the server against the identity
}

Example client:

package main

import "github.com/bodgit/srp"

func main() {
	g, err := srp.GetGroup(1024)
	if err != nil {
		panic(err)
	}

	s, err := srp.NewSRP(crypto.SHA1, g)
	if err != nil {
		panic(err)
	}

	client, err := s.NewClient("username", "password")
	if err != nil {
		panic(err)
	}

	// Send identity and client.A() to the server, receive salt and B

	m1, err := client.Compute(salt, b)
	if err != nil {
		panic(err)
	}

	// Send m1 to the server, receive m2

	if err := client.Check(m2); err != nil {
		panic(err)
	}

	// Use client.Key()
}

Example server:

package main

import "github.com/bodgit/srp"

func main() {
	g, err := srp.GetGroup(1024)
	if err != nil {
		panic(err)
	}

	s, err := srp.NewSRP(crypto.SHA1, g)
	if err != nil {
		panic(err)
	}

	// Receive identity and A from client, lookup/unmarshal ISV i

	server, err := s.NewServer(i, a)
	if err != nil {
		panic(err)
	}

	// Send server.Salt() and server.B() to the client, receive m1

	m2, err := server.Check(m1)
	if err != nil {
		panic(err)
	}

	// Send m2 to the client, use server.Key()
}

Other implementations

The last two implementations however assume that the client knows their salt value from the start rather than waiting for the server to provide it which doesn't match the behaviour documented in the RFC.

srp's People

Contributors

bodgit avatar dependabot[bot] avatar

Stargazers

 avatar

Watchers

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