forked from quic-go/quic-go
@@ -6,6 +6,7 @@ import (
|
||||
"compress/zlib"
|
||||
"encoding/binary"
|
||||
"errors"
|
||||
"fmt"
|
||||
"hash/fnv"
|
||||
|
||||
"github.com/lucas-clemente/quic-go/utils"
|
||||
@@ -63,7 +64,7 @@ func compressChain(chain [][]byte, pCommonSetHashes, pCachedHashes []byte) ([]by
|
||||
if totalUncompressedLen > 0 {
|
||||
gz, err := zlib.NewWriterLevelDict(res, flate.BestCompression, buildZlibDictForEntries(entries, chain))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
return nil, fmt.Errorf("cert compression failed: %s", err.Error())
|
||||
}
|
||||
|
||||
utils.WriteUint32(res, uint32(totalUncompressedLen))
|
||||
|
||||
@@ -17,17 +17,17 @@ type curve25519KEX struct {
|
||||
var _ KeyExchange = &curve25519KEX{}
|
||||
|
||||
// NewCurve25519KEX creates a new KeyExchange using Curve25519, see https://cr.yp.to/ecdh.html
|
||||
func NewCurve25519KEX() KeyExchange {
|
||||
func NewCurve25519KEX() (KeyExchange, error) {
|
||||
c := &curve25519KEX{}
|
||||
if _, err := io.ReadFull(rand.Reader, c.secret[:]); err != nil {
|
||||
panic("Curve25519: could not create private key")
|
||||
return nil, errors.New("Curve25519: could not create private key")
|
||||
}
|
||||
// See https://cr.yp.to/ecdh.html
|
||||
c.secret[0] &= 248
|
||||
c.secret[31] &= 127
|
||||
c.secret[31] |= 64
|
||||
curve25519.ScalarBaseMult(&c.public, &c.secret)
|
||||
return c
|
||||
return c, nil
|
||||
}
|
||||
|
||||
func (c *curve25519KEX) PublicKey() []byte {
|
||||
|
||||
@@ -7,8 +7,10 @@ import (
|
||||
|
||||
var _ = Describe("ProofRsa", func() {
|
||||
It("works", func() {
|
||||
a := NewCurve25519KEX()
|
||||
b := NewCurve25519KEX()
|
||||
a, err := NewCurve25519KEX()
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
b, err := NewCurve25519KEX()
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
sA, err := a.CalculateSharedKey(b.PublicKey())
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
sB, err := b.CalculateSharedKey(a.PublicKey())
|
||||
|
||||
Reference in New Issue
Block a user