srp

package
v0.0.0-...-405ab28 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 2, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package srp contains implementation of Secure Remote Password protocol.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Answer

type Answer struct {
	// A parameter (see SRP)
	A []byte
	// M1 parameter (see SRP)
	M1 []byte
}

Answer is result of SRP algorithm.

type Input

type Input struct {
	// One of two salts used by the derivation function (see SRP 2FA login)
	Salt1 []byte
	// One of two salts used by the derivation function (see SRP 2FA login)
	Salt2 []byte
	// Base (see SRP 2FA login)
	G int
	// 2048-bit modulus (see SRP 2FA login)
	P []byte
}

Input is hashing algorithm parameters from server.

Copy of tg.PasswordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPow

type SRP

type SRP struct {
	// contains filtered or unexported fields
}

SRP is client implementation of Secure Remote Password protocol.

See https://core.telegram.org/api/srp.

func NewSRP

func NewSRP(random io.Reader) SRP

NewSRP creates new SRP instance.

func (SRP) Hash

func (s SRP) Hash(password, srpB, random []byte, i Input) (Answer, error)

Hash computes user password hash using parameters from server.

See https://core.telegram.org/api/srp#checking-the-password-with-srp.

func (SRP) NewHash

func (s SRP) NewHash(password []byte, i Input) (hash, newSalt []byte, _ error)

NewHash computes new user password hash using parameters from server.

See https://core.telegram.org/api/srp#setting-a-new-2fa-password.

TDLib implementation: See https://github.com/tdlib/td/blob/fa8feefed70d64271945e9d5fd010b957d93c8cd/td/telegram/PasswordManager.cpp#L57.

TDesktop implementation: See https://github.com/telegramdesktop/tdesktop/blob/v3.4.8/Telegram/SourceFiles/core/core_cloud_password.cpp#L68.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL