Skip to content

Commit

Permalink
Use consistent error messages in keyset
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 649348958
Change-Id: I332d52a18a414232bb52ec83572a317efc7ecf78
  • Loading branch information
morambro authored and copybara-github committed Jul 4, 2024
1 parent 505d5f0 commit a19e826
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions keyset/handle.go
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ func (h *Handle) WriteWithAssociatedData(writer Writer, masterKey tink.AEAD, ass
// contains secret key material.
func (h *Handle) WriteWithNoSecrets(w Writer) error {
if h.hasSecrets() {
return errors.New("exporting unencrypted secret key material is forbidden")
return errors.New("keyset.Handle: exporting unencrypted secret key material is forbidden")
}

return w.Write(h.ks)
Expand Down Expand Up @@ -359,7 +359,7 @@ func WithConfig(c Config) PrimitivesOption {
func (h *Handle) Primitives(opts ...PrimitivesOption) (*primitiveset.PrimitiveSet, error) {
p, err := h.primitives(nil, opts...)
if err != nil {
return nil, fmt.Errorf("handle.Primitives: %v", err)
return nil, fmt.Errorf("keyset.Handle: %v", err)
}
return p, nil
}
Expand All @@ -379,7 +379,7 @@ func (h *Handle) Primitives(opts ...PrimitivesOption) (*primitiveset.PrimitiveSe
func (h *Handle) PrimitivesWithKeyManager(km registry.KeyManager) (*primitiveset.PrimitiveSet, error) {
p, err := h.primitives(km)
if err != nil {
return nil, fmt.Errorf("handle.PrimitivesWithKeyManager: %v", err)
return nil, fmt.Errorf("keyset.Handle: %v", err)
}
return p, nil
}
Expand Down
4 changes: 2 additions & 2 deletions keyset/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,11 @@ func (km *Manager) getIDForKey(key key.Key) (uint32, error) {
// enabled by default.
func (km *Manager) AddKey(key key.Key) (uint32, error) {
if key == nil {
return 0, fmt.Errorf("keyset.Handle: entry must have Key set")
return 0, fmt.Errorf("keyset.Manager: entry must have Key set")
}
keysetKey, err := protoserialization.SerializeKey(key)
if err != nil {
return 0, fmt.Errorf("keyset.Handle: %v", err)
return 0, fmt.Errorf("keyset.Manager: %v", err)
}
// This is going to be either an ID requirement or a new random ID.
keysetKey.KeyId, err = km.getIDForKey(key)
Expand Down

0 comments on commit a19e826

Please sign in to comment.