/// <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(); }
/// <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); }
/// <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(); }
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); }
/// <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); } }
/// <summary> /// Calculate 2^X mod P /// </summary> private void GenerateY() { Y = ModuloCalculator.Calculate(ModuloCalculator.TWO, X); }
protected virtual void doneReceiveY() { S = ModuloCalculator.Calculate(OtherY, X); }