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

Commit

Permalink
Use the EntriesInKeysetOrder field instead of building a local slice …
Browse files Browse the repository at this point in the history
…of all entries.

PiperOrigin-RevId: 621771983
  • Loading branch information
chuckx authored and copybara-github committed Apr 4, 2024
1 parent e16626b commit a954cf0
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions go/streamingaead/decrypt_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (
"errors"
"io"

"github.com/google/tink/go/core/primitiveset"
"github.com/google/tink/go/tink"
)

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

// For legacy reasons (Tink always encrypted with non-RAW keys) we use all
// primitives, even those which have output_prefix_type != RAW.
var allEntries []*primitiveset.Entry
for _, entryList := range dr.wrapped.ps.Entries {
allEntries = append(allEntries, entryList...)
}
if err != nil {
return 0, err
}

dr.matchAttempted = true
ur := &unreader{r: dr.cr}

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

0 comments on commit a954cf0

Please sign in to comment.