Coder Social home page Coder Social logo

srp6ago's Introduction

srp6ago

Test

This is tiny golang SRP6a implementation fully complies with the RFC-5054/RFC-2945.

This server is used with javascript SRP6a client implementation.

Installation

go get github.com/wault-pw/srp6ago

Usage

All returned values are bytes, so it's up to you how to encode the communication between server and client (protobuf or HEX representation with JSON).

Login flow

package main

import (
    "github.com/wault-pw/srp6ago"
)

func main() {
	// verifier and salt come from database
	// after user registration
	verifier, salt := []byte{}, []byte{}
	server := srp6ago.NewServer(verifier, salt, srp6ago.RFC5054b1024Sha1)
	
	// 1) send salt and server public key to the client
	serverPublicKey, _ := server.PublicKey()
	
	// 2) retrieve client's public key and a proof
	clientPublicKey, clientProof := []byte{}, []byte{}
	err := server.SetClientPublicKey(clientPublicKey)
	if err != nil {
        panic("server aborts")
	}
	
	// 3) Validate client proof
	// if OK, user is authenticates
	server.IsProofValid(clientProof)
	
	// 4) Now you have identical session key
	// with client
	server.SecretKey()
	
	// 5) You may send server proof back to the client
	server.Proof()
}

You can marshal SRP server and restore its state between HTTP requests:

server := srp6ago.NewServer(verifier, salt, srp6ago.RFC5054b1024Sha1)
bin := server.Marshal()
server, _ = srp6ago.UnmarshalServer(bin)

SRP Group Parameters

Preconfigured RFC-5054 SRP Group Parameters:

package main

import (
    "github.com/wault-pw/srp6ago"
)

func main() {
	// RFC-5054 complicated params set:
	srp6ago.RFC5054b1024Sha1
	srp6ago.RFC5054b1536Sha1
	srp6ago.RFC5054b2048Sha1
	srp6ago.RFC5054b3072Sha1
	srp6ago.RFC5054b4096Sha1
	srp6ago.RFC5054b6144Sha1
	srp6ago.RFC5054b8192Sha1

	// RFC-5054 complicated set,
	// with non-standart hash function SHA-256
	srp6ago.RFC5054b8192Sha256
	srp6ago.RFC5054b6144Sha256
	srp6ago.RFC5054b4096Sha256
	srp6ago.RFC5054b1024Sha256
	srp6ago.RFC5054b1536Sha256
	srp6ago.RFC5054b2048Sha256
	srp6ago.RFC5054b3072Sha256	
}

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.