Lidgren.Network.Authentication.NetSRP.CalcK C# (CSharp) Method

CalcK() public static method

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
return Byte[]
        public static Byte[] CalcK(NetBigInteger S)
        {
            SHA256 sha256 = SHA256.Create();
            Byte[] ba = sha256.ComputeHash(S.ToByteArray());
            return ba;
        }

Usage Example

Ejemplo n.º 1
0
        /// <summary>
        /// Generates key from request
        /// </summary>
        /// <param name="A">Generated A from request</param>
        /// <param name="v">Verifier v</param>
        private void KeyFromRequest(NetBigInteger A, NetBigInteger v)
        {
            // Shared random scrambler
            Lidgren.Network.NetBigInteger u = NetSRP.Calcu(A, _cache.B);

            // Sessionkey
            _cache.S = NetSRP.CalcSServer(N, A, v, u, _cache.b);
            _cache.K = NetSRP.CalcK(_cache.S);
        }
All Usage Examples Of Lidgren.Network.Authentication.NetSRP::CalcK