/// <summary>
        /// Receive the first 768 bits of the transmission from the remote client, which is Y in the protocol
        /// (Either "1 A->B: Diffie Hellman Ya, PadA" or "2 B->A: Diffie Hellman Yb, PadB")
        /// </summary>
        async ReusableTask ReceiveYAsync()
        {
            using (MemoryPool.Default.Rent(96, out Memory <byte> otherY))
                using (NetworkIO.BufferPool.Rent(otherY.Length, out Memory <byte> buffer)) {
                    await ReceiveMessageAsync(buffer).ConfigureAwait(false);

                    buffer.Span.CopyTo(otherY.Span);
                    S = ModuloCalculator.Calculate(otherY.Span, X);
                    await DoneReceiveY().ConfigureAwait(false);
                }
        }
예제 #2
0
        protected EncryptedSocket(Factories factories, IList <EncryptionType> allowedEncryption)
        {
            unsafeRandom = new Random();
            random       = RandomNumberGenerator.Create();
            hasher       = factories.CreateSHA1();

            X = new byte[20];
            random.GetBytes(X);
            Y = ModuloCalculator.Calculate(ModuloCalculator.TWO, X);

            SetMinCryptoAllowed(allowedEncryption);
        }