Exemple #1
0
        private static async Task CheckSecret(NamedGroup group, byte[] privKey, byte[] peerKey, byte[] publicKey, byte[] secret)
        {
            using (var bufferPool = new MemoryPool())
            {
                var options = new PipeOptions(bufferPool);
                var pipe    = new Pipe(options);
                var write   = pipe.Writer.Alloc();
                write.WriteBigEndian((byte)peerKey.Length);
                write.Write(peerKey);
                await write.FlushAsync();

                var reader = await pipe.Reader.ReadAsync();

                var instance = new OpenSsl11.OpenSslFiniteFieldKeyExchange(group);
                instance.GenerateKeys(privKey, publicKey);
                SetPeerKey(reader, instance);
                var buffer = new byte[instance.KeyExchangeSize];
                var size   = instance.DeriveSecret(buffer);
                TestSecret(secret, buffer, size);
            }
        }
Exemple #2
0
 private static void SetPeerKey(ReadResult reader, OpenSsl11.OpenSslFiniteFieldKeyExchange instance) => instance.SetPeerKey(new Internal.BigEndianAdvancingSpan(reader.Buffer.ToSpan()), null, Certificates.SignatureScheme.none);