Skip to content

Commit 9f3a263

Browse files
committed
Fix leading zeroes when negating Y coordinate of EC key
1 parent 6d3b5b3 commit 9f3a263

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

webauthn-server-core/src/test/scala/com/yubico/webauthn/RelyingPartyRegistrationSpec.scala

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2343,13 +2343,16 @@ class RelyingPartyRegistrationSpec
23432343
)
23442344
.getBytes
23452345
)
2346+
val yneg = TestAuthenticator.Es256PrimeModulus
2347+
.subtract(
2348+
new BigInteger(1, cose.get(-3).GetByteString())
2349+
)
2350+
val ynegBytes = yneg.toByteArray.dropWhile(_ == 0)
23462351
cose.Set(
23472352
-3,
2348-
TestAuthenticator.Es256PrimeModulus
2349-
.subtract(
2350-
new BigInteger(1, cose.get(-3).GetByteString())
2351-
), // Setting to BigInteger seems to work, but Array[Byte] does not
2353+
Array.fill[Byte](32 - ynegBytes.length)(0) ++ ynegBytes,
23522354
)
2355+
23532356
val testData = (RegistrationTestData.from _).tupled(
23542357
makeCred(
23552358
authDataAndKeypair = Some((authData, keypair)),

0 commit comments

Comments
 (0)