CSharpRTMP.Core.Protocols.Rtmfp.RtmfpUtils.ComputeAsymetricKeys C# (CSharp) Метод

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

public static ComputeAsymetricKeys ( byte sharedSecret, byte initiatorNonce, byte responderNonce, byte &requestKey, byte &responseKey ) : void
sharedSecret byte
initiatorNonce byte
responderNonce byte
requestKey byte
responseKey byte
Результат void
        public static void ComputeAsymetricKeys(byte[] sharedSecret, byte[] initiatorNonce, byte[] responderNonce,out byte[] requestKey,out byte[] responseKey)
        {
            var hmac = new HMACSHA256(responderNonce);
            var md1 = hmac.ComputeHash(initiatorNonce, 0, initiatorNonce.Length);
            hmac = new HMACSHA256(initiatorNonce);
            var md2 = hmac.ComputeHash(responderNonce, 0, responderNonce.Length);
             hmac = new HMACSHA256(sharedSecret);
             requestKey = hmac.ComputeHash(md1, 0, md1.Length);
            responseKey = hmac.ComputeHash(md2, 0, md2.Length);
        }
    }

Usage Example

Пример #1
0
        public void Run()
        {
            if (DH == null)
            {
                DH = RtmfpUtils.BeginDiffieHellman(ref Nonce);
                return;
            }
            // Compute Diffie-Hellman secret
            SharedSecret = DH.CreateSharedKey(InitiatorKey);
            // Compute Keys
            RtmfpUtils.ComputeAsymetricKeys(SharedSecret, InitiatorNonce, Nonce, out DecryptKey, out EncryptKey);
            var pSession = _handshake?.CreateSession(Value);

            if (pSession != null)
            {
                pSession.Peer.UserState = this;
            }
        }
All Usage Examples Of CSharpRTMP.Core.Protocols.Rtmfp.RtmfpUtils::ComputeAsymetricKeys