Skip to content

Commit

Permalink
Sign a hashed message in hardware key warmup call (#48206)
Browse files Browse the repository at this point in the history
Otherwise, signing may fail with "input must be a hashed message" error.
  • Loading branch information
gzdunek authored Oct 31, 2024
1 parent 225f285 commit 47494db
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions api/utils/keys/yubikey.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,8 +291,8 @@ func (y *YubiKeyPrivateKey) Public() crypto.PublicKey {
// WarmupHardwareKey performs a bogus sign() call to prompt the user for
// a PIN/touch (if needed).
func (y *YubiKeyPrivateKey) WarmupHardwareKey(ctx context.Context) error {
b := make([]byte, 256)
_, err := y.sign(ctx, rand.Reader, b, crypto.SHA256)
hash := sha256.Sum256(make([]byte, 256))
_, err := y.sign(ctx, rand.Reader, hash[:], crypto.SHA256)
return trace.Wrap(err, "failed to access a YubiKey private key")
}

Expand Down

0 comments on commit 47494db

Please sign in to comment.