Skip to content

Commit b2adc65

Browse files
matthewstevenson88arvindbr8
authored andcommitted
Revert "alts: Reduce ALTS counter overflow length from 5 to 4. (grpc#6699)" (grpc#6746)
This reverts commit 7b8d0fd.
1 parent 03d4358 commit b2adc65

File tree

3 files changed

+10
-24
lines changed

3 files changed

+10
-24
lines changed

credentials/alts/internal/conn/aes128gcm.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import (
2828
const (
2929
// Overflow length n in bytes, never encrypt more than 2^(n*8) frames (in
3030
// each direction).
31-
overflowLenAES128GCM = 4
31+
overflowLenAES128GCM = 5
3232
)
3333

3434
// aes128gcm is the struct that holds necessary information for ALTS record.

credentials/alts/internal/conn/aes128gcmrekey.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import (
2727
const (
2828
// Overflow length n in bytes, never encrypt more than 2^(n*8) frames (in
2929
// each direction).
30-
overflowLenAES128GCMRekey = 4
30+
overflowLenAES128GCMRekey = 8
3131
nonceLen = 12
3232
aeadKeyLen = 16
3333
kdfKeyLen = 32

credentials/alts/internal/conn/counter_test.go

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,8 @@ func (s) TestCounterSides(t *testing.T) {
5252

5353
func (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

Comments
 (0)