forked from quic-go/quic-go
remove entropy from packet packer
This commit is contained in:
@@ -2,7 +2,6 @@ package utils
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"crypto/rand"
|
||||
"io"
|
||||
|
||||
"github.com/lucas-clemente/quic-go/protocol"
|
||||
@@ -163,13 +162,6 @@ func WriteUint16(b *bytes.Buffer, i uint16) {
|
||||
b.WriteByte(uint8(i >> 8))
|
||||
}
|
||||
|
||||
// RandomBit returns a cryptographically secure random bit (encoded as true / false)
|
||||
func RandomBit() (bool, error) {
|
||||
b := make([]byte, 1)
|
||||
_, err := rand.Read(b)
|
||||
return b[0]%2 == 0, err
|
||||
}
|
||||
|
||||
// Uint32Slice attaches the methods of sort.Interface to []uint32, sorting in increasing order.
|
||||
type Uint32Slice []uint32
|
||||
|
||||
|
||||
@@ -174,24 +174,6 @@ var _ = Describe("Utils", func() {
|
||||
})
|
||||
})
|
||||
|
||||
Context("Rand", func() {
|
||||
It("returns either true or false", func() {
|
||||
countTrue := 0
|
||||
countFalse := 0
|
||||
for i := 0; i < 100; i++ {
|
||||
val, err := RandomBit()
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
if val {
|
||||
countTrue++
|
||||
} else {
|
||||
countFalse++
|
||||
}
|
||||
}
|
||||
Expect(countTrue).ToNot(BeZero())
|
||||
Expect(countFalse).ToNot(BeZero())
|
||||
})
|
||||
})
|
||||
|
||||
Context("ReadUintN", func() {
|
||||
It("reads n bytes", func() {
|
||||
m := map[uint8]uint64{
|
||||
|
||||
Reference in New Issue
Block a user