Exemplo n.º 1
0
        /// <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>
        protected async Task ReceiveY()
        {
            OtherY = new byte[96];
            await ReceiveMessage(OtherY, 96);

            S = ModuloCalculator.Calculate(OtherY, X);
            await doneReceiveY();
        }
Exemplo n.º 2
0
        /// <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>
        protected async ReusableTask ReceiveY()
        {
            byte[] otherY = new byte[96];
            await ReceiveMessage(otherY, 96).ConfigureAwait(false);

            S = ModuloCalculator.Calculate(otherY, X);
            await DoneReceiveY().ConfigureAwait(false);
        }
Exemplo n.º 3
0
        /// <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>
        protected async ReusableTask ReceiveY()
        {
            byte[] otherY = new byte[96];
            await ReceiveMessage(otherY, 96);

            S = ModuloCalculator.Calculate(otherY, X);
            await doneReceiveY();
        }
Exemplo n.º 4
0
        protected EncryptedSocket(EncryptionTypes allowedEncryption)
        {
            random = RandomNumberGenerator.Create();
            hasher = HashAlgoFactory.Create <SHA1> ();

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

            SetMinCryptoAllowed(allowedEncryption);
        }
Exemplo n.º 5
0
        /// <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()
        {
            var otherY = new byte[96];

            using (NetworkIO.BufferPool.Rent(otherY.Length, out ByteBuffer buffer)) {
                await ReceiveMessageAsync(buffer, otherY.Length).ConfigureAwait(false);

                Buffer.BlockCopy(buffer.Data, 0, otherY, 0, otherY.Length);
                S = ModuloCalculator.Calculate(otherY, X);
                await DoneReceiveY().ConfigureAwait(false);
            }
        }
Exemplo n.º 6
0
 /// <summary>
 /// Calculate 2^X mod P
 /// </summary>
 private void GenerateY()
 {
     Y = ModuloCalculator.Calculate(ModuloCalculator.TWO, X);
 }
Exemplo n.º 7
0
 protected virtual void doneReceiveY()
 {
     S = ModuloCalculator.Calculate(OtherY, X);
 }