From 6732e80d060ba5f663e311092cc4973cda7df75e Mon Sep 17 00:00:00 2001 From: 9seconds Date: Mon, 11 Nov 2019 15:22:28 +0300 Subject: [PATCH] Use recommended way of generating x25519 curve --- tlstypes/server_hello.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/tlstypes/server_hello.go b/tlstypes/server_hello.go index e2dd739..4918926 100644 --- a/tlstypes/server_hello.go +++ b/tlstypes/server_hello.go @@ -77,12 +77,11 @@ func makeTLSExtensions(buf io.Writer) { 0x00, 0x20, // 32 bytes of key }) - var dst, in, base [32]byte + var scalar [32]byte - rand.Read(in[:]) // nolint: errcheck - rand.Read(base[:]) // nolint: errcheck - curve25519.ScalarMult(&dst, &in, &base) - buf.Write(dst[:]) // nolint: errcheck + rand.Read(scalar[:]) // nolint: errcheck + curve, _ := curve25519.X25519(scalar[:], curve25519.Basepoint) + buf.Write(curve) // nolint: errcheck buf.Write([]byte{ // nolint: errcheck 0x00, 0x2b, // Extension - Supported Versions