@@ -146,13 +146,13 @@ object TestAuthenticator {
146
146
val format : String
147
147
def makeAttestationStatement (
148
148
authDataBytes : ByteArray ,
149
- clientDataJson : String ,
149
+ clientDataJson : ByteArray ,
150
150
): JsonNode
151
151
def certChain : List [(X509Certificate , PrivateKey )] = Nil
152
152
153
153
def makeAttestationObjectBytes (
154
154
authDataBytes : ByteArray ,
155
- clientDataJson : String ,
155
+ clientDataJson : ByteArray ,
156
156
): ByteArray = {
157
157
val f = JsonNodeFactory .instance
158
158
val attObj = f
@@ -177,7 +177,7 @@ object TestAuthenticator {
177
177
override def certChain = signer.certChain
178
178
override def makeAttestationStatement (
179
179
authDataBytes : ByteArray ,
180
- clientDataJson : String ,
180
+ clientDataJson : ByteArray ,
181
181
): JsonNode =
182
182
makePackedAttestationStatement(authDataBytes, clientDataJson, signer)
183
183
}
@@ -188,7 +188,7 @@ object TestAuthenticator {
188
188
override def certChain = signer.certChain
189
189
override def makeAttestationStatement (
190
190
authDataBytes : ByteArray ,
191
- clientDataJson : String ,
191
+ clientDataJson : ByteArray ,
192
192
): JsonNode =
193
193
makeU2fAttestationStatement(authDataBytes, clientDataJson, signer)
194
194
}
@@ -202,7 +202,7 @@ object TestAuthenticator {
202
202
override def certChain = cert.certChain
203
203
override def makeAttestationStatement (
204
204
authDataBytes : ByteArray ,
205
- clientDataJson : String ,
205
+ clientDataJson : ByteArray ,
206
206
): JsonNode =
207
207
makeAndroidSafetynetAttestationStatement(
208
208
authDataBytes,
@@ -230,7 +230,7 @@ object TestAuthenticator {
230
230
override val format = " apple"
231
231
override def makeAttestationStatement (
232
232
authDataBytes : ByteArray ,
233
- clientDataJson : String ,
233
+ clientDataJson : ByteArray ,
234
234
): JsonNode =
235
235
makeAppleAttestationStatement(
236
236
caCert,
@@ -264,7 +264,7 @@ object TestAuthenticator {
264
264
override def certChain = cert.certChain
265
265
override def makeAttestationStatement (
266
266
authDataBytes : ByteArray ,
267
- clientDataJson : String ,
267
+ clientDataJson : ByteArray ,
268
268
): JsonNode =
269
269
makeTpmAttestationStatement(
270
270
authDataBytes,
@@ -287,7 +287,7 @@ object TestAuthenticator {
287
287
override def certChain = Nil
288
288
override def makeAttestationStatement (
289
289
authDataBytes : ByteArray ,
290
- clientDataJson : String ,
290
+ clientDataJson : ByteArray ,
291
291
): JsonNode =
292
292
makeNoneAttestationStatement()
293
293
}
@@ -458,9 +458,9 @@ object TestAuthenticator {
458
458
459
459
def createCredential (
460
460
authDataBytes : ByteArray ,
461
- clientDataJson : String ,
462
461
credentialKeypair : KeyPair ,
463
462
attestationMaker : AttestationMaker ,
463
+ clientDataJson : Option [String ] = None ,
464
464
clientExtensions : ClientRegistrationExtensionOutputs =
465
465
ClientRegistrationExtensionOutputs .builder().build(),
466
466
): (
@@ -472,10 +472,15 @@ object TestAuthenticator {
472
472
List [(X509Certificate , PrivateKey )],
473
473
) = {
474
474
475
- val clientDataJsonBytes = toBytes(clientDataJson)
475
+ val clientDataJsonBytes = toBytes(
476
+ clientDataJson.getOrElse(createClientData())
477
+ )
476
478
477
479
val attestationObjectBytes =
478
- attestationMaker.makeAttestationObjectBytes(authDataBytes, clientDataJson)
480
+ attestationMaker.makeAttestationObjectBytes(
481
+ authDataBytes,
482
+ clientDataJsonBytes,
483
+ )
479
484
480
485
val response = AuthenticatorAttestationResponse
481
486
.builder()
@@ -517,7 +522,6 @@ object TestAuthenticator {
517
522
createCredential(
518
523
authDataBytes = authData,
519
524
credentialKeypair = credentialKeypair,
520
- clientDataJson = createClientData(),
521
525
attestationMaker = attestationMaker,
522
526
)
523
527
}
@@ -539,7 +543,6 @@ object TestAuthenticator {
539
543
val signer = SelfAttestation (keypair, keyAlgorithm)
540
544
createCredential(
541
545
authDataBytes = authData,
542
- clientDataJson = createClientData(),
543
546
credentialKeypair = keypair,
544
547
attestationMaker = attestationMaker(signer),
545
548
)
@@ -563,7 +566,7 @@ object TestAuthenticator {
563
566
)
564
567
createCredential(
565
568
authDataBytes = authData,
566
- clientDataJson = createClientData(challenge = challenge),
569
+ clientDataJson = Some ( createClientData(challenge = challenge) ),
567
570
credentialKeypair = keypair,
568
571
attestationMaker = AttestationMaker .none(),
569
572
)
@@ -678,14 +681,14 @@ object TestAuthenticator {
678
681
679
682
def makeU2fAttestationStatement (
680
683
authDataBytes : ByteArray ,
681
- clientDataJson : String ,
684
+ clientDataJson : ByteArray ,
682
685
signer : AttestationSigner ,
683
686
): JsonNode = {
684
687
val authData = new AuthenticatorData (authDataBytes)
685
688
686
689
def makeSignedData (
687
690
rpIdHash : ByteArray ,
688
- clientDataJson : String ,
691
+ clientDataJson : ByteArray ,
689
692
credentialId : ByteArray ,
690
693
credentialPublicKeyRawBytes : ByteArray ,
691
694
): ByteArray = {
@@ -732,7 +735,7 @@ object TestAuthenticator {
732
735
733
736
def makePackedAttestationStatement (
734
737
authDataBytes : ByteArray ,
735
- clientDataJson : String ,
738
+ clientDataJson : ByteArray ,
736
739
signer : AttestationSigner ,
737
740
): JsonNode = {
738
741
val signedData = new ByteArray (
@@ -766,7 +769,7 @@ object TestAuthenticator {
766
769
767
770
def makeAndroidSafetynetAttestationStatement (
768
771
authDataBytes : ByteArray ,
769
- clientDataJson : String ,
772
+ clientDataJson : ByteArray ,
770
773
cert : AttestationCert ,
771
774
ctsProfileMatch : Boolean = true ,
772
775
): JsonNode = {
@@ -834,15 +837,12 @@ object TestAuthenticator {
834
837
caCert : X509Certificate ,
835
838
caKey : PrivateKey ,
836
839
authDataBytes : ByteArray ,
837
- clientDataJson : String ,
840
+ clientDataJson : ByteArray ,
838
841
addNonceExtension : Boolean = true ,
839
842
nonceValue : Option [ByteArray ] = None ,
840
843
certSubjectPublicKey : Option [PublicKey ] = None ,
841
844
): JsonNode = {
842
- val clientDataJSON = new ByteArray (
843
- clientDataJson.getBytes(StandardCharsets .UTF_8 )
844
- )
845
- val clientDataJsonHash = Crypto .sha256(clientDataJSON)
845
+ val clientDataJsonHash = Crypto .sha256(clientDataJson)
846
846
val nonceToHash = authDataBytes.concat(clientDataJsonHash)
847
847
val nonce = Crypto .sha256(nonceToHash)
848
848
@@ -895,7 +895,7 @@ object TestAuthenticator {
895
895
896
896
def makeTpmAttestationStatement (
897
897
authDataBytes : ByteArray ,
898
- clientDataJson : String ,
898
+ clientDataJson : ByteArray ,
899
899
cert : AttestationCert ,
900
900
ver : Option [String ] = Some (" 2.0" ),
901
901
magic : ByteArray = TpmAttestationStatementVerifier .TPM_GENERATED_VALUE ,
@@ -933,13 +933,10 @@ object TestAuthenticator {
933
933
case TpmAlgHash .SHA512 => Crypto .sha512 _
934
934
case TpmAlgHash .SHA1 => Crypto .sha1 _
935
935
}
936
- val extraData = {
937
- hashFunc(
938
- authDataBytes concat Crypto .sha256(
939
- new ByteArray (clientDataJson.getBytes(StandardCharsets .UTF_8 ))
940
- )
941
- )
942
- }
936
+ val extraData = hashFunc(
937
+ authDataBytes concat Crypto .sha256(clientDataJson)
938
+ )
939
+
943
940
val (parameters, unique) = WebAuthnTestCodecs .getCoseKty(cosePubkey) match {
944
941
case 3 => { // RSA
945
942
val cose = CBORObject .DecodeFromBytes (cosePubkey.getBytes)
0 commit comments