ctr := c.NewCTR(iv)
tmp := make([]byte, len(plaintext))
ctr.XORKeyStream(tmp, plaintext)
- if bytes.Compare(tmp, ciphertext) != 0 {
+ if !bytes.Equal(tmp, ciphertext) {
t.Fatal("encryption failed")
}
ctr = c.NewCTR(iv)
ctr.XORKeyStream(tmp, tmp)
- if bytes.Compare(tmp, plaintext) != 0 {
+ if !bytes.Equal(tmp, plaintext) {
t.Fatal("decryption failed")
}
}
ctr := c.NewCTR(iv[:])
tmp := make([]byte, len(plaintext))
ctr.XORKeyStream(tmp, plaintext)
- if bytes.Compare(tmp, ciphertext) != 0 {
+ if !bytes.Equal(tmp, ciphertext) {
t.Fatal("encryption failed")
}
ctr = c.NewCTR(iv[:])
ctr.XORKeyStream(tmp, tmp)
- if bytes.Compare(tmp, plaintext) != 0 {
+ if !bytes.Equal(tmp, plaintext) {
t.Fatal("decryption failed")
}
}
ctr.XORKeyStream(tmp, pt[:])
ctr = c.NewCTR(iv[:])
ctr.XORKeyStream(tmp, tmp)
- return bytes.Compare(tmp, pt) == 0
+ return bytes.Equal(tmp, pt)
}
if err := quick.Check(f, nil); err != nil {
t.Error(err)