@@ -52,9 +52,8 @@ func (s) TestCounterSides(t *testing.T) {
5252
5353func (s ) TestCounterInc (t * testing.T ) {
5454 for _ , test := range []struct {
55- counter []byte
56- want []byte
57- expectInvalid bool
55+ counter []byte
56+ want []byte
5857 }{
5958 {
6059 counter : []byte {0x00 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 },
@@ -73,32 +72,19 @@ func (s) TestCounterInc(t *testing.T) {
7372 want : []byte {0x43 , 0xff , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 },
7473 },
7574 {
76- counter : []byte {0xff , 0xff , 0xff , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 },
77- want : []byte {0x00 , 0x00 , 0x00 , 0x01 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 },
75+ counter : []byte {0xff , 0xff , 0xff , 0xff , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 },
76+ want : []byte {0x00 , 0x00 , 0x00 , 0x00 , 0x01 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 },
7877 },
7978 {
80- counter : []byte {0xff , 0xff , 0xff , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x80 },
81- want : []byte {0x00 , 0x00 , 0x00 , 0x01 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x80 },
82- },
83- {
84- counter : []byte {0xff , 0xff , 0xff , 0xff , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 },
85- want : []byte {},
86- expectInvalid : true ,
87- },
88- {
89- counter : []byte {0xff , 0xff , 0xff , 0xff , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x80 },
90- want : []byte {},
91- expectInvalid : true ,
79+ counter : []byte {0xff , 0xff , 0xff , 0xff , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x80 },
80+ want : []byte {0x00 , 0x00 , 0x00 , 0x00 , 0x01 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x80 },
9281 },
9382 } {
9483 c := CounterFromValue (test .counter , overflowLenAES128GCM )
9584 c .Inc ()
9685 value , _ := c .Value ()
97- if got , want := c .invalid , test .expectInvalid ; got != want {
98- t .Errorf ("counter.invalid=%t, want=%t" , got , want )
99- }
100- if got , want := value , test .want ; ! bytes .Equal (got , want ) {
101- t .Errorf ("counter(%v).Inc() =\n %v, want\n %v" , test .counter , got , want )
86+ if g , w := value , test .want ; ! bytes .Equal (g , w ) || c .invalid {
87+ t .Errorf ("counter(%v).Inc() =\n %v, want\n %v" , test .counter , g , w )
10288 }
10389 }
10490}
0 commit comments