Skip to content

Commit 32b26ef

Browse files
committed
Test that assertion verification works with U2F-formatted public keys
1 parent bff7968 commit 32b26ef

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

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

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ import com.yubico.webauthn.data.UserVerificationRequirement
5252
import com.yubico.webauthn.exception.InvalidSignatureCountException
5353
import com.yubico.webauthn.extension.appid.AppId
5454
import com.yubico.webauthn.test.Helpers
55+
import com.yubico.webauthn.test.RealExamples
5556
import com.yubico.webauthn.test.Util.toStepWithUtilities
5657
import org.junit.runner.RunWith
5758
import org.scalacheck.Gen
@@ -1946,6 +1947,55 @@ class RelyingPartyAssertionSpec
19461947
test(RegistrationTestData.Packed.SelfAttestationRs1)
19471948
}
19481949
}
1950+
1951+
it("a U2F-formatted public key.") {
1952+
val testData = RealExamples.YubiKeyNeo.asRegistrationTestData
1953+
val x = ByteArray.fromHex(
1954+
"39C94FBBDDC694A925E6F8657C66916CFE84CD0222EDFCF281B21F5CDC347923"
1955+
)
1956+
val y = ByteArray.fromHex(
1957+
"D6B0D2021CFE1724A6FE81E3568C4FFAE339298216A30AFC18C0B975F2E2A891"
1958+
)
1959+
val u2fPubkey = ByteArray.fromHex("04").concat(x).concat(y)
1960+
1961+
val cred1 = RegisteredCredential
1962+
.builder()
1963+
.credentialId(testData.assertion.get.response.getId)
1964+
.userHandle(testData.userId.getId)
1965+
.publicKeyCose(u2fPubkey)
1966+
.signatureCount(0)
1967+
.build()
1968+
1969+
val cred2 = RegisteredCredential
1970+
.builder()
1971+
.credentialId(testData.assertion.get.response.getId)
1972+
.userHandle(testData.userId.getId)
1973+
.publicKeyCose(u2fPubkey)
1974+
.signatureCount(0)
1975+
.build()
1976+
1977+
for { cred <- List(cred1, cred2) } {
1978+
val rp = RelyingParty
1979+
.builder()
1980+
.identity(testData.rpId)
1981+
.credentialRepository(
1982+
Helpers.CredentialRepository.withUser(testData.userId, cred)
1983+
)
1984+
.build()
1985+
1986+
val result = rp.finishAssertion(
1987+
FinishAssertionOptions
1988+
.builder()
1989+
.request(testData.assertion.get.request)
1990+
.response(testData.assertion.get.response)
1991+
.build()
1992+
)
1993+
1994+
result.isSuccess should be(true)
1995+
result.getUserHandle should equal(testData.userId.getId)
1996+
result.getCredentialId should equal(testData.response.getId)
1997+
}
1998+
}
19491999
}
19502000

19512001
describe("The default RelyingParty settings") {

0 commit comments

Comments
 (0)