Skip to content

Commit

Permalink
refactor: Ensure big.Int return a 32-byte slice
Browse files Browse the repository at this point in the history
  • Loading branch information
ikimonogakari committed Nov 12, 2024
1 parent c42f846 commit a82e18a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion protocol/assertion.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ func (car CredentialAssertionResponse) Parse() (par *ParsedCredentialAssertionDa
// Specification: §7.2 Verifying an Authentication Assertion (https://www.w3.org/TR/webauthn/#sctn-verifying-assertion)
func (p *ParsedCredentialAssertionData) Verify(storedChallenge string, relyingPartyID string, rpOrigins, rpTopOrigins []string, rpTopOriginsVerify TopOriginVerificationMode, appID string, verifyUser bool, credentialBytes []byte) error {
// Steps 4 through 6 in verifying the assertion data (https://www.w3.org/TR/webauthn/#verifying-assertion) are
// "assertive" steps, i.e "Let JSONtext be the result of running UTF-8 decode on the value of cData."
// "assertive" steps, i.e. "Let JSONtext be the result of running UTF-8 decode on the value of cData."
// We handle these steps in part as we verify but also beforehand

// Handle steps 7 through 10 of assertion by verifying stored data against the Collected Client Data
Expand Down
6 changes: 4 additions & 2 deletions protocol/webauthncose/webauthncose.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ type PublicKeyData struct {
Algorithm int64 `cbor:"3,keyasint" json:"alg"`
}

const ecCoordSize = 32

type EC2PublicKeyData struct {
PublicKeyData

Expand Down Expand Up @@ -180,8 +182,8 @@ func ParseFIDOPublicKey(keyBytes []byte) (data EC2PublicKeyData, err error) {
PublicKeyData: PublicKeyData{
Algorithm: int64(AlgES256),
},
XCoord: x.Bytes(),
YCoord: y.Bytes(),
XCoord: x.FillBytes(make([]byte, ecCoordSize)),
YCoord: y.FillBytes(make([]byte, ecCoordSize)),
}, nil
}

Expand Down

0 comments on commit a82e18a

Please sign in to comment.