@@ -5,6 +5,7 @@ import com.fasterxml.jackson.databind.node.ArrayNode
5
5
import com .fasterxml .jackson .databind .node .JsonNodeFactory
6
6
import com .fasterxml .jackson .databind .node .ObjectNode
7
7
import com .fasterxml .jackson .databind .node .TextNode
8
+ import com .yubico .fido .metadata .FidoMetadataService .Filters .AuthenticatorToBeFiltered
8
9
import com .yubico .internal .util .CertificateParser
9
10
import com .yubico .webauthn .FinishRegistrationOptions
10
11
import com .yubico .webauthn .RegistrationResult
@@ -204,8 +205,11 @@ class FidoMds3Spec extends AnyFunSpec with Matchers {
204
205
def makeMds (
205
206
blobTuple : (String , X509Certificate , java.util.Set [CRL ]),
206
207
attestationCrls : Set [CRL ] = Set .empty,
207
- )(prefilter : MetadataBLOBPayloadEntry => Boolean ): FidoMetadataService =
208
- FidoMetadataService
208
+ )(
209
+ prefilter : MetadataBLOBPayloadEntry => Boolean ,
210
+ filter : Option [AuthenticatorToBeFiltered => Boolean ] = None ,
211
+ ): FidoMetadataService = {
212
+ val builder = FidoMetadataService
209
213
.builder()
210
214
.useBlob(makeDownloader(blobTuple).loadCachedBlob())
211
215
.prefilter(prefilter.asJava)
@@ -215,7 +219,9 @@ class FidoMds3Spec extends AnyFunSpec with Matchers {
215
219
new CollectionCertStoreParameters (attestationCrls.asJava),
216
220
)
217
221
)
218
- .build()
222
+ filter.foreach(f => builder.filter(f.asJava))
223
+ builder.build()
224
+ }
219
225
220
226
val blobTuple = makeBlob(s """ {
221
227
"legalHeader" : "Kom ihåg att du aldrig får snyta dig i mattan!",
@@ -405,6 +411,66 @@ class FidoMds3Spec extends AnyFunSpec with Matchers {
405
411
_.getAaguid.toScala.contains(aaguidB)
406
412
).isAttestationTrusted should be(false )
407
413
}
414
+
415
+ describe(" Zero AAGUIDs" ) {
416
+ val zeroAaguid =
417
+ new AAGUID (ByteArray .fromHex(" 00000000000000000000000000000000" ))
418
+
419
+ it(" are not used to find metadata entries." ) {
420
+ aaguidA should not equal zeroAaguid
421
+
422
+ val blobTuple = makeBlob(s """ {
423
+ "legalHeader" : "Kom ihåg att du aldrig får snyta dig i mattan!",
424
+ "nextUpdate" : "2022-12-01",
425
+ "no" : 0,
426
+ "entries": [
427
+ ${makeEntry(aaguid = Some (aaguidA))},
428
+ ${makeEntry(aaguid = Some (zeroAaguid))}
429
+ ]
430
+ } """ )
431
+ var filterRan = false
432
+ val mds = makeMds(blobTuple)(
433
+ _ => true ,
434
+ filter = Some ({ _ =>
435
+ filterRan = true
436
+ true
437
+ }),
438
+ )
439
+
440
+ mds.findEntries(zeroAaguid) shouldBe empty
441
+ filterRan should be(false )
442
+ }
443
+
444
+ it(" are omitted in the argument to the runtime filter." ) {
445
+ aaguidA should not equal zeroAaguid
446
+
447
+ val (cert, _) = TestAuthenticator .generateAttestationCertificate()
448
+ val acki : String = new ByteArray (
449
+ CertificateParser .computeSubjectKeyIdentifier(cert)
450
+ ).getHex
451
+ val blobTuple = makeBlob(s """ {
452
+ "legalHeader" : "Kom ihåg att du aldrig får snyta dig i mattan!",
453
+ "nextUpdate" : "2022-12-01",
454
+ "no" : 0,
455
+ "entries": [
456
+ ${makeEntry(acki = Some (Set (acki)), aaguid = Some (aaguidA))}
457
+ ]
458
+ } """ )
459
+ var filterRan = false
460
+ val mds = makeMds(blobTuple)(
461
+ _ => true ,
462
+ filter = Some ({ authenticatorToBeFiltered =>
463
+ filterRan = true
464
+ authenticatorToBeFiltered.getAaguid.toScala should be(None )
465
+ true
466
+ }),
467
+ )
468
+
469
+ mds.findEntries(List (cert).asJava, zeroAaguid).size should be(1 )
470
+ filterRan should be(true )
471
+ }
472
+ }
473
+
408
474
}
409
475
410
476
describe(" 2.1. Check whether the status report of the authenticator model has changed compared to the cached entry by looking at the fields timeOfLastStatusChange and statusReport." ) {
0 commit comments