All Projects → idlesign → srptools

idlesign / srptools

Licence: BSD-3-Clause license
Tools to implement Secure Remote Password (SRP) authentication

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to srptools

SRP
Secure Remote Password (SRP) for Swift
Stars: ✭ 44 (+100%)
Mutual labels:  srp, rfc-2945, rfc-5054
pundit kit
Extension for pundit which allows to describe namespaces of policies in routes-like style
Stars: ✭ 12 (-45.45%)
Mutual labels:  srp
URP-Sun-Shafts
A URP port of Unity's classic Standard Assets Effects package's Sun Shaft effect
Stars: ✭ 36 (+63.64%)
Mutual labels:  srp
cognito-srp
Go library for AWS Cognito SRP
Stars: ✭ 40 (+81.82%)
Mutual labels:  srp
RamblerAppDelegateProxy
divide et impera
Stars: ✭ 83 (+277.27%)
Mutual labels:  srp
Attrs
Python Classes Without Boilerplate
Stars: ✭ 3,786 (+17109.09%)
Mutual labels:  srp
mbedtls-esp8266
Updated and Upgraded mbedTLS library for the ESP8266 (probably ESP32 too)
Stars: ✭ 13 (-40.91%)
Mutual labels:  srp
scst
No description or website provided.
Stars: ✭ 61 (+177.27%)
Mutual labels:  srp
AppWindowUtility
This utility is for Unity to configure application window style. With this utility, you can make your application window transparent, frameless and more.
Stars: ✭ 26 (+18.18%)
Mutual labels:  srp
Volumetric-Occlusion-Mask-SRP
Using SRP to create a volumetric occlusion mask for objects to use in their render pass
Stars: ✭ 17 (-22.73%)
Mutual labels:  srp
aws-sdk-net-extensions-cognito
An extension library to assist in the Amazon Cognito User Pools authentication process
Stars: ✭ 80 (+263.64%)
Mutual labels:  srp

srptools

https://github.com/idlesign/srptools

release lic coverage

Description

Tools to implement Secure Remote Password (SRP) authentication

SRP is a secure password-based authentication and key-exchange protocol - a password-authenticated key agreement protocol (PAKE).

This package contains protocol implementation for Python 2 and 3.

You may import it into you applications and use its API or you may use srptools command-line utility (CLI):

CLI usage

Command-line utility requires click package to be installed.

Basic scenario:

> srptools get_user_data_triplet
> srptools server get_private_and_public
> srptools client get_private_and_public
> srptools client get_session_data
> srptools server get_session_data

Help is available:

> srptools --help

API usage

Preliminary step. Agree on communication details:

from srptools import SRPContext

context = SRPContext('alice', 'password123')
username, password_verifier, salt = context.get_user_data_triplet()
prime = context.prime
gen = context.generator

Simplified workflow:

from srptools import SRPContext, SRPServerSession, SRPClientSession

# Receive username from client and generate server public.
server_session = SRPServerSession(SRPContext(username, prime=prime, generator=gen), password_verifier)
server_public = server_session.public

# Receive server public and salt and process them.
client_session = SRPClientSession(SRPContext('alice', 'password123', prime=prime, generator=gen))
client_session.process(server_public, salt)
# Generate client public and session key.
client_public = client_session.public

# Process client public and compare session keys.
server_session.process(client_public, salt)

assert server_session.key == client_session.key

Extended workflow

from srptools import SRPContext, SRPServerSession, SRPClientSession

# Receive username from client and generate server public.
server_session = SRPServerSession(SRPContext(username, prime=prime, generator=gen), password_verifier)
server_public = server_session.public

# Receive server public and salt and process them.
client_session = SRPClientSession(SRPContext('alice', 'password123', prime=prime, generator=gen))
client_session.process(server_public, salt)
# Generate client public and session key proof.
client_public = client_session.public
client_session_key_proof = client_session.key_proof

# Process client public and verify session key proof.
server_session.process(client_public, salt)
assert server_session.verify_proof(client_session_key_proof)
# Generate session key proof hash.
server_session_key_proof_hash = client_session.key_proof_hash

# Verify session key proof hash received from server.
assert client_session.verify_proof(server_session_key_proof_hash)

Usage hints

  • srptools.constants contains basic constants which can be used with SRPContext for server and client to agree upon communication details.

  • .process() methods of session classes may raise SRPException in certain circumstances. Auth process on such occasions must be stopped.

  • .private attribute of session classes may be used to restore sessions:
    server_private = server_session.private
    
    # Restore session on new request.
    server_session = SRPServerSession(context, password_verifier, private=server_private)
  • SRPContext is rather flexible, so you can implement some custom server/client session logic with its help.

  • Basic values are represented as hex strings but base64 encoded values are also supported:

    server_public = server_session.public_b64
    
    # Receive server public and salt and process them.
    client_session = SRPClientSession(SRPContext('alice', 'password123', prime=prime, generator=gen))
    client_session.process(server_public, salt, base64=True)
    
    # Use srptools.hex_from_b64() to represent base64 value as hex.
    server_public_hex = hex_from_b64(server_public)

Links

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].