C# Класс 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.
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
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

Открытые методы

Метод Описание
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.

Приватные методы

Метод Описание
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.

Описание методов

CalcA() публичный статический Метод

Returns A.
public static CalcA ( NetBigInteger N, NetBigInteger g, NetBigInteger a ) : NetBigInteger
N NetBigInteger
g NetBigInteger
a NetBigInteger
Результат NetBigInteger

CalcB() публичный статический Метод

Calculates B.
public static CalcB ( NetBigInteger N, NetBigInteger g, NetBigInteger b, NetBigInteger v ) : NetBigInteger
N NetBigInteger
g NetBigInteger
b NetBigInteger
v NetBigInteger
Результат NetBigInteger

CalcK() публичный статический Метод

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
Результат Byte[]

CalcM() публичный статический Метод

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
Результат Byte[]

CalcM2() публичный статический Метод

M2 is Server's proof of K.
public static CalcM2 ( NetBigInteger A, Byte M, Byte K ) : Byte[]
A NetBigInteger
M Byte
K Byte
Результат Byte[]

CalcSClient() публичный статический Метод

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
Результат NetBigInteger

CalcSServer() публичный статический Метод

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
Результат NetBigInteger

CalcV() публичный статический Метод

Calculates V. The password verifier.
public static CalcV ( NetBigInteger N, NetBigInteger g, NetBigInteger x ) : NetBigInteger
N NetBigInteger
g NetBigInteger
x NetBigInteger
Результат NetBigInteger

Calck() публичный статический Метод

Calculates k.
public static Calck ( NetBigInteger N, NetBigInteger g ) : NetBigInteger
N NetBigInteger
g NetBigInteger
Результат NetBigInteger

Calcu() публичный статический Метод

Calculates u.
public static Calcu ( NetBigInteger A, NetBigInteger B ) : NetBigInteger
A NetBigInteger
B NetBigInteger
Результат NetBigInteger

Calcx() публичный статический Метод

Calculates x.
public static Calcx ( Byte salt, String userName, String password ) : NetBigInteger
salt Byte
userName String
password String
Результат NetBigInteger

CreateEncryption() публичный статический Метод

Create XTEA symmetrical encryption object from sessionValue
public static CreateEncryption ( Byte sessionValue ) : NetXtea
sessionValue Byte
Результат NetXtea

GenerateSalt() публичный статический Метод

Returns cryptographically random salt bytes.
public static GenerateSalt ( ) : Byte[]
Результат Byte[]

GetNandG() публичный статический Метод

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
Результат NetBigInteger

Geta() публичный статический Метод

Returns a - a random private value.
public static Geta ( ) : NetBigInteger
Результат NetBigInteger

Getb() публичный статический Метод

Returns b - a random private value.
public static Getb ( ) : NetBigInteger
Результат NetBigInteger

PasswordVerifier() публичный статический Метод

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
Результат NetBigInteger

Описание свойств

N1024Bit публичное статическое свойство

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
Результат NetBigInteger

N1536Bit публичное статическое свойство

A large safe 1536 bit prime. All SRP arithmetic is done modulo N.
public static NetBigInteger N1536Bit
Результат NetBigInteger

N2048Bit публичное статическое свойство

A large safe 2048 bit prime. All SRP arithmetic is done modulo N.
public static NetBigInteger N2048Bit
Результат NetBigInteger

N3072Bit публичное статическое свойство

A large safe 3072 bit prime. All SRP arithmetic is done modulo N.
public static NetBigInteger N3072Bit
Результат NetBigInteger

N4096Bit публичное статическое свойство

A large safe 4096 bit prime. All SRP arithmetic is done modulo N.
public static NetBigInteger N4096Bit
Результат NetBigInteger

N6144Bit публичное статическое свойство

A large safe 6144 bit prime. All SRP arithmetic is done modulo N.
public static NetBigInteger N6144Bit
Результат NetBigInteger

N8192Bit публичное статическое свойство

A large safe 8192 bit prime. All SRP arithmetic is done modulo N.
public static NetBigInteger N8192Bit
Результат NetBigInteger

g1024Bit публичное статическое свойство

Generator modulo N for 1024 bit N.
public static NetBigInteger g1024Bit
Результат NetBigInteger

g1536Bit публичное статическое свойство

Generator modulo N for 1536 bit N.
public static NetBigInteger g1536Bit
Результат NetBigInteger

g2048Bit публичное статическое свойство

Generator modulo N for 2048 bit N.
public static NetBigInteger g2048Bit
Результат NetBigInteger

g3072Bit публичное статическое свойство

Generator modulo N for 3072 bit N.
public static NetBigInteger g3072Bit
Результат NetBigInteger

g4096Bit публичное статическое свойство

Generator modulo N for 4096 bit N.
public static NetBigInteger g4096Bit
Результат NetBigInteger

g6144Bit публичное статическое свойство

Generator modulo N for 6144 bit N.
public static NetBigInteger g6144Bit
Результат NetBigInteger

g8192Bit публичное статическое свойство

Generator modulo N for 8192 bit N.
public static NetBigInteger g8192Bit
Результат NetBigInteger