remove entropy from packet packer

This commit is contained in:
Lucas Clemente
2016-08-30 21:46:40 +02:00
parent a4d4506f31
commit 6bb89d4902
4 changed files with 12 additions and 129 deletions

View File

@@ -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

View File

@@ -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{