C# Class Lidgren.Network.Authentication.NetSRP

Library of SRP Functions used in SRP protocol. Refs: http://srp.stanford.edu/design.html http://www.ietf.org/internet-drafts/draft-ietf-tls-srp-09.txt Required Credit to Tom Wu for the SRP algo: "This product uses the 'Secure Remote Password' cryptographic authentication system developed by Tom Wu ([email protected])." Note: Method naming follows the SRP6 naming of variables which may be a single upper case or lower case character. This allows a reader to more easily follow the protocol at the expense of non-standard method naming convension.
Afficher le fichier Open project: SleeplessByte/lidgren-srp6a Class Usage Examples

Méthodes publiques

Свойство Type Description
N1024Bit NetBigInteger
N1536Bit NetBigInteger
N2048Bit NetBigInteger
N3072Bit NetBigInteger
N4096Bit NetBigInteger
N6144Bit NetBigInteger
N8192Bit NetBigInteger
g1024Bit NetBigInteger
g1536Bit NetBigInteger
g2048Bit NetBigInteger
g3072Bit NetBigInteger
g4096Bit NetBigInteger
g6144Bit NetBigInteger
g8192Bit NetBigInteger

Méthodes publiques

Méthode Description
CalcA ( NetBigInteger N, NetBigInteger g, NetBigInteger a ) : NetBigInteger

Returns A.

CalcB ( NetBigInteger N, NetBigInteger g, NetBigInteger b, NetBigInteger v ) : NetBigInteger

Calculates B.

CalcK ( NetBigInteger S ) : Byte[]

Returns 32 byte array using SHA256 one-way hash of value S. RijndaelManaged, for example can use max key of 32 bytes directly, so this is convienent. If you need more or less entropy, add or subtract bytes as required. Naturally, both sides need to be able to generate the same key bytes. It is recommended to just use the 32 bytes as returned from this method.

CalcM ( NetBigInteger N, NetBigInteger g, String userName, Byte salt, NetBigInteger A, NetBigInteger B, Byte K ) : Byte[]

M is client's proof of K.

CalcM2 ( NetBigInteger A, Byte M, Byte K ) : Byte[]

M2 is Server's proof of K.

CalcSClient ( NetBigInteger N, NetBigInteger g, NetBigInteger B, NetBigInteger k, NetBigInteger x, NetBigInteger a, NetBigInteger u ) : NetBigInteger

Calculates client's S.

CalcSServer ( NetBigInteger N, NetBigInteger A, NetBigInteger v, NetBigInteger u, NetBigInteger b ) : NetBigInteger

Calculates server's S.

CalcV ( NetBigInteger N, NetBigInteger g, NetBigInteger x ) : NetBigInteger

Calculates V. The password verifier.

Calck ( NetBigInteger N, NetBigInteger g ) : NetBigInteger

Calculates k.

Calcu ( NetBigInteger A, NetBigInteger B ) : NetBigInteger

Calculates u.

Calcx ( Byte salt, String userName, String password ) : NetBigInteger

Calculates x.

CreateEncryption ( Byte sessionValue ) : NetXtea

Create XTEA symmetrical encryption object from sessionValue

GenerateSalt ( ) : Byte[]

Returns cryptographically random salt bytes.

GetNandG ( Int32 keySize, NetBigInteger &g ) : NetBigInteger

Returns N and g as an out parameter based on given keySize.

Geta ( ) : NetBigInteger

Returns a - a random private value.

Getb ( ) : NetBigInteger

Returns b - a random private value.

PasswordVerifier ( String userName, String password, Byte salt, NetBigInteger N, NetBigInteger g ) : NetBigInteger

Host stores v (password verifier) in database.

Private Methods

Méthode Description
XorArrays ( Byte array1, Byte array2 ) : Byte[]

XOR two byte arrays together and returns result. Both arrays must be same length and neither can be null. Resulting array will be same size as array1.

Method Details

CalcA() public static méthode

Returns A.
public static CalcA ( NetBigInteger N, NetBigInteger g, NetBigInteger a ) : NetBigInteger
N NetBigInteger
g NetBigInteger
a NetBigInteger
Résultat NetBigInteger

CalcB() public static méthode

Calculates B.
public static CalcB ( NetBigInteger N, NetBigInteger g, NetBigInteger b, NetBigInteger v ) : NetBigInteger
N NetBigInteger
g NetBigInteger
b NetBigInteger
v NetBigInteger
Résultat NetBigInteger

CalcK() public static méthode

Returns 32 byte array using SHA256 one-way hash of value S. RijndaelManaged, for example can use max key of 32 bytes directly, so this is convienent. If you need more or less entropy, add or subtract bytes as required. Naturally, both sides need to be able to generate the same key bytes. It is recommended to just use the 32 bytes as returned from this method.
public static CalcK ( NetBigInteger S ) : Byte[]
S NetBigInteger
Résultat Byte[]

CalcM() public static méthode

M is client's proof of K.
public static CalcM ( NetBigInteger N, NetBigInteger g, String userName, Byte salt, NetBigInteger A, NetBigInteger B, Byte K ) : Byte[]
N NetBigInteger
g NetBigInteger
userName String
salt Byte
A NetBigInteger
B NetBigInteger
K Byte
Résultat Byte[]

CalcM2() public static méthode

M2 is Server's proof of K.
public static CalcM2 ( NetBigInteger A, Byte M, Byte K ) : Byte[]
A NetBigInteger
M Byte
K Byte
Résultat Byte[]

CalcSClient() public static méthode

Calculates client's S.
public static CalcSClient ( NetBigInteger N, NetBigInteger g, NetBigInteger B, NetBigInteger k, NetBigInteger x, NetBigInteger a, NetBigInteger u ) : NetBigInteger
N NetBigInteger
g NetBigInteger
B NetBigInteger
k NetBigInteger
x NetBigInteger
a NetBigInteger
u NetBigInteger
Résultat NetBigInteger

CalcSServer() public static méthode

Calculates server's S.
public static CalcSServer ( NetBigInteger N, NetBigInteger A, NetBigInteger v, NetBigInteger u, NetBigInteger b ) : NetBigInteger
N NetBigInteger
A NetBigInteger
v NetBigInteger
u NetBigInteger
b NetBigInteger
Résultat NetBigInteger

CalcV() public static méthode

Calculates V. The password verifier.
public static CalcV ( NetBigInteger N, NetBigInteger g, NetBigInteger x ) : NetBigInteger
N NetBigInteger
g NetBigInteger
x NetBigInteger
Résultat NetBigInteger

Calck() public static méthode

Calculates k.
public static Calck ( NetBigInteger N, NetBigInteger g ) : NetBigInteger
N NetBigInteger
g NetBigInteger
Résultat NetBigInteger

Calcu() public static méthode

Calculates u.
public static Calcu ( NetBigInteger A, NetBigInteger B ) : NetBigInteger
A NetBigInteger
B NetBigInteger
Résultat NetBigInteger

Calcx() public static méthode

Calculates x.
public static Calcx ( Byte salt, String userName, String password ) : NetBigInteger
salt Byte
userName String
password String
Résultat NetBigInteger

CreateEncryption() public static méthode

Create XTEA symmetrical encryption object from sessionValue
public static CreateEncryption ( Byte sessionValue ) : NetXtea
sessionValue Byte
Résultat NetXtea

GenerateSalt() public static méthode

Returns cryptographically random salt bytes.
public static GenerateSalt ( ) : Byte[]
Résultat Byte[]

GetNandG() public static méthode

Returns N and g as an out parameter based on given keySize.
public static GetNandG ( Int32 keySize, NetBigInteger &g ) : NetBigInteger
keySize System.Int32
g NetBigInteger
Résultat NetBigInteger

Geta() public static méthode

Returns a - a random private value.
public static Geta ( ) : NetBigInteger
Résultat NetBigInteger

Getb() public static méthode

Returns b - a random private value.
public static Getb ( ) : NetBigInteger
Résultat NetBigInteger

PasswordVerifier() public static méthode

Host stores v (password verifier) in database.
public static PasswordVerifier ( String userName, String password, Byte salt, NetBigInteger N, NetBigInteger g ) : NetBigInteger
userName String
password String
salt Byte
N NetBigInteger
g NetBigInteger
Résultat NetBigInteger

Property Details

N1024Bit public_oe static_oe property

A large safe 1024 bit prime. All SRP arithmetic is done modulo N. See: http://www.ietf.org/internet-drafts/draft-ietf-tls-srp-09.txt
public static NetBigInteger N1024Bit
Résultat NetBigInteger

N1536Bit public_oe static_oe property

A large safe 1536 bit prime. All SRP arithmetic is done modulo N.
public static NetBigInteger N1536Bit
Résultat NetBigInteger

N2048Bit public_oe static_oe property

A large safe 2048 bit prime. All SRP arithmetic is done modulo N.
public static NetBigInteger N2048Bit
Résultat NetBigInteger

N3072Bit public_oe static_oe property

A large safe 3072 bit prime. All SRP arithmetic is done modulo N.
public static NetBigInteger N3072Bit
Résultat NetBigInteger

N4096Bit public_oe static_oe property

A large safe 4096 bit prime. All SRP arithmetic is done modulo N.
public static NetBigInteger N4096Bit
Résultat NetBigInteger

N6144Bit public_oe static_oe property

A large safe 6144 bit prime. All SRP arithmetic is done modulo N.
public static NetBigInteger N6144Bit
Résultat NetBigInteger

N8192Bit public_oe static_oe property

A large safe 8192 bit prime. All SRP arithmetic is done modulo N.
public static NetBigInteger N8192Bit
Résultat NetBigInteger

g1024Bit public_oe static_oe property

Generator modulo N for 1024 bit N.
public static NetBigInteger g1024Bit
Résultat NetBigInteger

g1536Bit public_oe static_oe property

Generator modulo N for 1536 bit N.
public static NetBigInteger g1536Bit
Résultat NetBigInteger

g2048Bit public_oe static_oe property

Generator modulo N for 2048 bit N.
public static NetBigInteger g2048Bit
Résultat NetBigInteger

g3072Bit public_oe static_oe property

Generator modulo N for 3072 bit N.
public static NetBigInteger g3072Bit
Résultat NetBigInteger

g4096Bit public_oe static_oe property

Generator modulo N for 4096 bit N.
public static NetBigInteger g4096Bit
Résultat NetBigInteger

g6144Bit public_oe static_oe property

Generator modulo N for 6144 bit N.
public static NetBigInteger g6144Bit
Résultat NetBigInteger

g8192Bit public_oe static_oe property

Generator modulo N for 8192 bit N.
public static NetBigInteger g8192Bit
Résultat NetBigInteger