Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions service/kas/key_indexer.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ func convertAlgToEnum(alg string) (policy.Algorithm, error) {
}
}

func (p *KeyIndexer) String() string {
return fmt.Sprintf("PlatformKeyIndexer[%s]", p.kasURI)
}

func (p *KeyIndexer) FindKeyByAlgorithm(ctx context.Context, algorithm string, includeLegacy bool) (trust.KeyDetails, error) {
alg, err := convertAlgToEnum(algorithm)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions service/trust/delegating_key_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func (d *DelegatingKeyService) Name() string {
func (d *DelegatingKeyService) Decrypt(ctx context.Context, keyID KeyIdentifier, ciphertext []byte, ephemeralPublicKey []byte) (ProtectedKey, error) {
keyDetails, err := d.index.FindKeyByID(ctx, keyID)
if err != nil {
return nil, fmt.Errorf("unable to find key by ID '%s': %w", keyID, err)
return nil, fmt.Errorf("unable to find key by ID '%s' within index %s: %w", keyID, d.index, err)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For consistency with the error message in DeriveKey on line 107, consider using in index instead of within index. This makes the error messages uniform, which is helpful for logging and monitoring.

Suggested change
return nil, fmt.Errorf("unable to find key by ID '%s' within index %s: %w", keyID, d.index, err)
return nil, fmt.Errorf("unable to find key by ID '%s' in index %s: %w", keyID, d.index, err)

}

manager, err := d.getKeyManager(keyDetails.System())
Expand All @@ -104,7 +104,7 @@ func (d *DelegatingKeyService) Decrypt(ctx context.Context, keyID KeyIdentifier,
func (d *DelegatingKeyService) DeriveKey(ctx context.Context, keyID KeyIdentifier, ephemeralPublicKeyBytes []byte, curve elliptic.Curve) (ProtectedKey, error) {
keyDetails, err := d.index.FindKeyByID(ctx, keyID)
if err != nil {
return nil, fmt.Errorf("unable to find key by ID '%s': %w", keyID, err)
return nil, fmt.Errorf("unable to find key by ID '%s' in index %s: %w", keyID, d.index, err)
}

manager, err := d.getKeyManager(keyDetails.System())
Expand Down
Loading