Skip to content
This repository was archived by the owner on Apr 17, 2024. It is now read-only.

Commit a954cf0

Browse files
chuckxcopybara-github
authored andcommitted
Use the EntriesInKeysetOrder field instead of building a local slice of all entries.
PiperOrigin-RevId: 621771983
1 parent e16626b commit a954cf0

File tree

1 file changed

+4
-12
lines changed

1 file changed

+4
-12
lines changed

go/streamingaead/decrypt_reader.go

+4-12
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import (
1818
"errors"
1919
"io"
2020

21-
"github.com/google/tink/go/core/primitiveset"
2221
"github.com/google/tink/go/tink"
2322
)
2423

@@ -47,21 +46,14 @@ func (dr *decryptReader) Read(p []byte) (n int, err error) {
4746
return 0, errKeyNotFound
4847
}
4948

50-
// For legacy reasons (Tink always encrypted with non-RAW keys) we use all
51-
// primitives, even those which have output_prefix_type != RAW.
52-
var allEntries []*primitiveset.Entry
53-
for _, entryList := range dr.wrapped.ps.Entries {
54-
allEntries = append(allEntries, entryList...)
55-
}
56-
if err != nil {
57-
return 0, err
58-
}
59-
6049
dr.matchAttempted = true
6150
ur := &unreader{r: dr.cr}
6251

6352
// find proper key to decrypt ciphertext
64-
for _, e := range allEntries {
53+
//
54+
// For legacy reasons (Tink always encrypted with non-RAW keys) we use all
55+
// primitives, even those which have output_prefix_type != RAW.
56+
for _, e := range dr.wrapped.ps.EntriesInKeysetOrder {
6557
sa, ok := e.Primitive.(tink.StreamingAEAD)
6658
if !ok {
6759
continue

0 commit comments

Comments
 (0)