Skip to content
Open
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: 3 additions & 1 deletion go/cmd/passkey-verify/passkey-verify.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

import (
"crypto/ecdsa"
"crypto/sha256"
"flag"
"fmt"
"log"
Expand Down Expand Up @@ -121,9 +122,10 @@ func main() {

// TODO decode CBOR data

message := sha256.Sum256(assertion.Response.AttToBeSigned)
verified := ecdsa.VerifyASN1(
registration.Response.PublicKeyECDSA,
assertion.Response.VerifiableBytes,
message[:],
assertion.Response.Signature,
)
if !verified {
Expand Down
9 changes: 3 additions & 6 deletions go/passkey/passkey.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ type Assertion struct {
ClientDataJSON RawURLBase64 `json:"clientDataJSON"`
ClientData ClientData `json:"-"`
Signature RawURLBase64 `json:"signature"`
VerifiableBytes []byte `json:"-"`
AttToBeSigned []byte `json:"-"`
} `json:"response"`
}

Expand All @@ -118,18 +118,15 @@ func ParseAssertion(credentialRequestResponse []byte) (*Assertion, error) {
}

clientDataHash := sha256.Sum256(credReq.Response.ClientDataJSON)
verifiableData := append(credReq.Response.AuthenticatorDataRaw, clientDataHash[:]...)
// each algo specifies the SHA-xxx hash in its name
// exception: SHA512 used for EDDSA
verifiableHash := sha256.Sum256(verifiableData)
attToBeSigned := append(credReq.Response.AuthenticatorDataRaw, clientDataHash[:]...)

var err error
credReq.Response.AuthenticatorData, err = ParseAuthenticatorData(credReq.Response.AuthenticatorDataRaw)
if err != nil {
return nil, err
}

credReq.Response.VerifiableBytes = verifiableHash[:]
credReq.Response.AttToBeSigned = attToBeSigned

return credReq, nil
}
Expand Down