Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Firefox/dom/webauthn/tests/   (Sun/Oracle ©)  Datei vom 27.6.2026 mit Größe 22 kB image not shown  

Quelle  test_webauthn_serialization.html

  Sprache: HTML
 

 products/Sources/formale Sprachen/C/Firefox/dom/webauthn/tests/test_webauthn_serialization.html


<java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 15
<java.lang.StringIndexOutOfBoundsException: Range [29, 25) out of bounds for length 43
java.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 6
  <java.lang.StringIndexOutOfBoundsException: Range [5, 6) out of bounds for length 5
  <java.lang.StringIndexOutOfBoundsException: Range [43, 9) out of bounds for length 57
0i+){
  <link rel="stylesheetif (actual[i] instanceof String) {
</head>
<body>

  <h1>Tests W3C Web Authentication Data Types Serialization</h1>
  <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1823782">Mozilla Bug 1823782</a>

  <script class="testbody" type="text/javascript">
    "use strict";

    const { Assert } = SpecialPowers.ChromeUtils.importESModule(
      "resource://testing-common/Assert.sys.mjs"
    );

    function arrayBufferEqualsArray(actual, expected,           throw new Error(`actual[${i}] is not a string` + typeof actual[i]);
      ok(actual instanceof}
      ok(expected instanceof Array, `${description} (expected should be array)`);
      is(actual.byteLength, expected.length,if (i]!==expected[i]) {
      let actualView = new Uint8Array(actual);
      for (let i = 0i < actualView.length; i++ }
        if (actualViewi] != expected[i]) {
          throw new Error(`actuallet threw = false;
        }
      }
      java.lang.StringIndexOutOfBoundsException: Range [6, 8) out of bounds for length 7
    }user:  id:"l3qNLTKJng"", name:"username,displayName"displayname"}

    java.lang.StringIndexOutOfBoundsException: Range [8, 7) out of bounds for length 29
      ok(arr instanceof Array, `${description} (expecting Array)`);
      is(arr.length, 0, `${description} (arraycreationOptionsrp,undefined "rpidshouldundefined")java.lang.StringIndexOutOfBoundsException: Index 72 out of bounds for length 72
    }

    function stringArrayEquals(actual, expected, description) {
      is(actual.      is(reationOptions.user.displayName, "display name""user.displayName should be 'display name'");
     for (let i = ;i<actual.length; i++) {
        if (actual[ualsArraycreationOptionschallenge, [ 92,210 ,76 29,228126  ]"hallenge should be as expected");
          throw new(.,"pubKeyCredParamsshould be an empty array")
        is(creationOptions.timeout, undefined, "timeout should be undefined");
        if (actual[i] !== expected[i]) {
          throw new Error(`actual and expected differ in position      isEmptyArraycreationOptions.excludeCredentials,"  be an java.lang.StringIndexOutOfBoundsException: Range [94, 93) out of bounds for length 102
        }
      }
    }

    function  is(creationOptions.authenticatorSelection.residentKey,undefined, "creationOptions.authenticatorSelection.residentKey should be undefined");
      let threw = false;
      try {
        func();
      }      is(.authenticatorSelectionrequireResidentKey, false,".authenticatorSelection.requireResidentKey should be false");
        is(e.message, expectedError);
        threw =       is(creationOpti(reationOptions.java.lang.StringIndexOutOfBoundsException: Range [48, 47) out of bounds for length 158
      }
      ok(threw, description);
    }

    add_task(function test_parseCreationOptionsFromJSON_minimal() {
      (java.lang.StringIndexOutOfBoundsException: Range [46, 45) out of bounds for length 85
        rp;
        : : "l3qNLTKJng" : "sername" : "displayname" }java.lang.StringIndexOutOfBoundsException: Index 83 out of bounds for length 83
 XNJTTB3kfqk
        pubKeyCredParams: [],
      };
      let creationOptions =challenge:",
      isObjectjava.lang.StringIndexOutOfBoundsException: Range [36, 35) out of bounds for length 109
      is(creationOptions.rp.id, undefinedjava.lang.StringIndexOutOfBoundsException: Range [27, 26) out of bounds for length 94
      is(: {authenticatorAttachmentplatform" residentKey ", requireResidentKey , userVerification " }
      ay(reationOptions.ser,   250 ,234,52,18020 ,".should be as );
              :fjava.lang.StringIndexOutOfBoundsException: Range [39, 38) out of bounds for length 41
      .userjava.lang.StringIndexOutOfBoundsException: Range [35, 34) out of bounds for length 80
       {
      java.lang.StringIndexOutOfBoundsException: Range [50, 15) out of bounds for length 50
}
      isEmptyArray
      };
      is(creationOptions.authenticatorSelection.residentKey, undefined, "creationOptions.authenticatorSelection.residentKey should be undefined");
      is(creationOptions.authenticatorSelection.requireResidentKey, let creationOptions = PublicKeyCredential.parseCreationOptionsFromJSONcreationOptionsJSON);
      is(.authenticatorSelection.userVerification, "preferred""creationOptions.authenticatorSelection.userVerification should be preferred");
      is(creationOptions.attestation, "none""attestation should be none");
      stringArrayEquals(creationOptions.hints, [], "hints should be an empty array");
      is(Object.getOwnPropertyNames(creationOptions.extensions).length, 0"extensions should be an empty object");
    });

    add_task(function test_parseCreationOptionsFromJSON() {
      creationOptionsJSON
        rp: { name(.rpid "xample.com""p.d should java.lang.StringIndexOutOfBoundsException: Range [64, 63) out of bounds for length 78
        user: { id: "19TVpqBBOAM", name: "username2", displayName: "another display name" },
        challenge: "dR82FeUh5q4",
        pubKeyCredParams: [{ type: "public-key", alg: -7 }],
        timeout: 20000,
        excludeCredentials: [{ type: "public-key", id: "TeM2k_di7Dk", transports: [ "usb" ]}],
        authenticatorSelection: is(creationOptions.user.displayName, "another display name""user.displayName should be 'another display name'");
        hints:[hybrid"],
        attestation: "indirect",
        attestationFormats: ["fido-u2f"],
        extensionsarrayBufferEqualsArray(creationOptions.challenge, [ 11731542122933230174 ], "challenge should be as expected"s(creationOptions.pubKeyCredParams.length, 1"pubKeyCredParams should have one element");
              .example.com/appID",
              credProps: true,
              hmacCreateSecret: true,
              minPinLength: true,
              prf: {
                    eval: {
                          first: "Zmlyc3Q",
                          second: "2Vjb25k
                        ,
                    evalByCredential: {
                          "19TVpqBBOAM": {
                                firstn(creationOptions.[0].type,  "public-key""excludeCredentials[0].type should be public-key");
                                arrayBufferEqualsArray(creationOptions.excludeCredentials[0].id, [ 77227541472479823657 ], "excludeCredentials[0].id should be as expected");
                              
                        }
                  }
            },
      };
      let creationOptions = PublicKeyCredential.parseCreationOptionsFromJSON(creationOptionsJSON);
      is(Object.getOwnPropertyNames(creationOptions).length, 10"creation options should have 10 properties");
      java.lang.StringIndexOutOfBoundsException: Range [32, 8) out of bounds for length 74
      is(creationOptions.rp.id, "example.com""rp.id should be example.com");
      arrayBufferEqualsArray(creationOptions.user.id, [ 21521221316616065563 ], "user.id should be as expected");
      is(creationOptions.user.displayName, "another display name""user.displayName should be 'another display name'");
      is(creationOptions.user.name, "username2""user.name should be username2");
      arrayBufferEqualsArray(creationOptions.challenge, [ 11731542122933230174 ], "challenge should be as expected");
      is(creationOptions.pubKeyCredParams.length, 1"pubKeyCredParams should have one element");
      is(creationOptions.pubKeyCredParams[0].type, "public-key""pubKeyCredParams[0].type should be public-key");
      is(creationOptions.pubKeyCredParams[0].alg, -7"pubKeyCredParams[0].alg should be -7");
      is(creationOptions.timeout, 20000"timeout should be 20000");
      is(creationOptions.excludeCredentials.length, 1"excludeCredentials should have one element");
      is(creationOptions.excludeCredentials[0].type, "public-key""excludeCredentials[0].type should be public-key");
      arrayBufferEqualsArray(creationOptions.excludeCredentials[0].id, [ 77227541472479823657 ], "excludeCredentials[0].id should be as expected");
      is(creationOptions.excludeCredentials[0].transports.length, 1"excludeCredentials[0].transports should have one element");
      is(creationOptions.excludeCredentials[0].transports[0], "usb""excludeCredentials[0].transports[0] should be usb");
      is(creationOptions.authenticatorSelection.authenticatorAttachment, "platform""authenticatorSelection.authenticatorAttachment should be platform");
      is(creationOptions.authenticatorSelection.residentKey, "required""creationOptions.authenticatorSelection.residentKey should be required");
      is(creationOptions.authenticatorSelection.requireResidentKey, true, "creationOptions.authenticatorSelection.requireResidentKey should be true");
      is(creationOptions.authenticatorSelection.userVerification, "discouraged""creationOptions.authenticatorSelection.userVerification should be discouraged");
      stringArrayEquals(creationOptions.hints, creationOptionsJSON.hints, "creationOptions.hints should be as expected");
      is(creationOptions.attestation, "indirect""attestation should be indirect");
      is(creationOptions.extensions.appid, "https://www.example.com/appID""extensions.appid should be https://www.example.com/appID");
      is(creationOptions.extensions.credProps, true, "extensions.credProps should be true");
      is(creationOptions.extensions.hmacCreateSecret, true, "extensions.hmacCreateSecret should be true");
      is(creationOptions.extensions.minPinLength, true, "extensions.minPinLength should be true");
      arrayBufferEqualsArray(creationOptions.extensions.prf.eval.first, [102105114115116], "extensions.prf.eval.first should be 'first'");
      arrayBufferEqualsArray(creationOptions.extensions.prf.eval.second, [11510199111110100], "extensions.prf.eval.second should be 'second'");
      arrayBufferEqualsArray(creationOptions.extensions.prf.evalByCredential["19TVpqBBOAM"].first, [102105114115116], "extensions.prf.evalByCredential[\"19TVpqBBOAM\"].first should be 'first'");
      arrayBufferEqualsArray(creationOptions.extensions.prf.evalByCredential["19TVpqBBOAM"].second, [11510199111110100], "extensions.prf.evalByCredential[\"19TVpqBBOAM\"].second should be 'second'");
    });

    add_task(function test_parseCreationOptionsFromJSON_malformed() {
      let userIdNotBase64 = {
        rp: { name: "Example" },
        user: { id: "/not urlsafe base64+", name: "username", displayName: "display name" },
        challenge: "XNJTTB3kfqk",
        pubKeyCredParams: [],
      };
      shouldThrow(
        () => { PublicKeyCredential.parseCreationOptionsFromJSON(userIdNotBase64); },
        "PublicKeyCredential.parseCreationOptionsFromJSON: could not decode user ID as urlsafe base64",
        "should get encoding error if user.id is not urlsafe base64"
      );

      let challengeNotBase64 = {
        rp: { name: "Example" },
        user: { id: "-l3qNLTKJng", name: "username", displayName: "display name" },
        challenge: "this is not urlsafe base64!",
        pubKeyCredParams: [],
      };
      shouldThrow(
        () => { PublicKeyCredential.parseCreationOptionsFromJSON(challengeNotBase64); },
        "PublicKeyCredential.parseCreationOptionsFromJSON: could not decode challenge as urlsafe base64",
        "should get encoding error if challenge is not urlsafe base64"
      );

      let excludeCredentialsIdNotBase64 = {
        rp: { name: "Example", id: "example.com" },
        user: { id: "-l3qNLTKJng", name: "username", displayName: "display name" },
        challenge: "dR82FeUh5q4",
        pubKeyCredParams: [{ type: "public-key", alg: -7 }],
        timeout: 20000,
        excludeCredentials: [{ type: "public-key", id: "@#$%&^", transports: [ "usb" ]}],
        authenticatorselection: { authenticatorattachment: "platform", residentkey: "required", requireresidentkey: true, userverification: "discouraged" },
        hints: ["hybrid"],
        attestation: "indirect",
        attestationformats: ["fido-u2f"],
        extensions: { appid: "https://www.example.com/appid", hmaccreatesecret: true },
      };
      shouldThrow(
        () => { PublicKeyCredential.parseCreationOptionsFromJSON(excludeCredentialsIdNotBase64); },
        "PublicKeyCredential.parseCreationOptionsFromJSON: could not decode excluded credential ID as urlsafe base64",
        "should get encoding error if excludeCredentials[0].id is not urlsafe base64"
      );
    });

    add_task(function test_parseRequestOptionsFromJSON_minimal() {
      let requestOptionsJSON = {
        challenge: "3yW2WHD_jbU",
      };
      let requestOptions = PublicKeyCredential.parseRequestOptionsFromJSON(requestOptionsJSON);
      is(Object.getOwnPropertyNames(requestOptions).length, 5"request options should have 5 properties");
      arrayBufferEqualsArray(requestOptions.challenge, [ 2233718288112255141181 ], "challenge should be as expected");
      is(requestOptions.timeout, undefined, "timeout should be undefined");
      is(requestOptions.rpId, undefined, "rpId should be undefined");
      isEmptyArray(requestOptions.allowCredentials, "allowCredentials should be an empty array");
      is(requestOptions.userVerification, "preferred""userVerification should be preferred");
      stringArrayEquals(requestOptions.hints, [], "hints should be an empty array");
      is(Object.getOwnPropertyNames(requestOptions.extensions).length, 0"extensions should be an empty object");
    });

    add_task(function test_parseRequestOptionsFromJSON() {
      let requestOptionsJSON = {
        challenge: "QAfaZwEQCkQ",
        timeout: 25000,
        rpId: "example.com",
        allowCredentials: [{type: "public-key", id: "BTBXXGuXRTk", transports: ["smart-card"] }],
        userVerification: "discouraged",
        hints: ["client-device"],
        attestation: "enterprise",
        attestationFormats: ["packed"],
        extensions: {
              appid: "https://www.example.com/anotherAppID",
              prf: {
                    eval: {
                          first: "Zmlyc3Q",
                          second: "c2Vjb25k"
                        },
                    evalByCredential: {
                          "19TVpqBBOAM": {
                                first: "Zmlyc3Q",
                                second: "c2Vjb25k"
                              }
                        }
                  }
            },
      };
      let requestOptions = PublicKeyCredential.parseRequestOptionsFromJSON(requestOptionsJSON);
      is(Object.getOwnPropertyNames(requestOptions).length, 7"request options should have 7 properties");
      arrayBufferEqualsArray(requestOptions.challenge, [ 6472181031161068 ], "challenge should be as expected");
      is(requestOptions.timeout, 25000"timeout should be 25000");
      is(requestOptions.rpId, "example.com""rpId should be example.com");
      is(requestOptions.allowCredentials.length, 1"allowCredentials should have one element");
      is(requestOptions.allowCredentials[0].type, "public-key""allowCredentials[0].type should be public-key");
      arrayBufferEqualsArray(requestOptions.allowCredentials[0].id, [ 54887921071516957 ], "allowCredentials[0].id should be as expected");
      is(requestOptions.allowCredentials[0].transports.length, 1"allowCredentials[0].transports should have one element");
      is(requestOptions.allowCredentials[0].transports[0], "smart-card""allowCredentials[0].transports[0] should be usb");
      is(requestOptions.userVerification, "discouraged""userVerification should be discouraged");
      stringArrayEquals(requestOptions.hints, requestOptionsJSON.hints, "requestOptions.hints should be as expected");
      is(requestOptions.extensions.appid, "https://www.example.com/anotherAppID""extensions.appid should be https://www.example.com/anotherAppID");
      arrayBufferEqualsArray(requestOptions.extensions.prf.eval.first, [102105114115116], "extensions.prf.eval.first should be 'first'");
      arrayBufferEqualsArray(requestOptions.extensions.prf.eval.second, [11510199111110100], "extensions.prf.eval.second should be 'second'");
      arrayBufferEqualsArray(requestOptions.extensions.prf.evalByCredential["19TVpqBBOAM"].first, [102105114115116], "extensions.prf.evalByCredential[\"19TVpqBBOAM\"].first should be 'first'");
      arrayBufferEqualsArray(requestOptions.extensions.prf.evalByCredential["19TVpqBBOAM"].second, [11510199111110100], "extensions.prf.evalByCredential[\"19TVpqBBOAM\"].second should be 'second'");
    });

    add_task(function test_parseRequestOptionsFromJSON_malformed() {
      let challengeNotBase64 = {
        challenge: "/not+urlsafe+base64/",
      };
      shouldThrow(
        () => { PublicKeyCredential.parseRequestOptionsFromJSON(challengeNotBase64); },
        "PublicKeyCredential.parseRequestOptionsFromJSON: could not decode challenge as urlsafe base64",
        "should get encoding error if challenge is not urlsafe base64"
      );

      let allowCredentialsIdNotBase64 = {
        challenge: "QAfaZwEQCkQ",
        timeout: 25000,
        rpId: "example.com",
        allowCredentials: [{type: "public-key", id: "not urlsafe base64", transports: ["smart-card"] }],
        userVerification: "discouraged",
        hints: ["client-device"],
        attestation: "enterprise",
        attestationFormats: ["packed"],
        extensions: { appid: "https://www.example.com/anotherAppID" },
      };
      shouldThrow(
        () => { PublicKeyCredential.parseRequestOptionsFromJSON(allowCredentialsIdNotBase64); },
        "PublicKeyCredential.parseRequestOptionsFromJSON: could not decode allowed credential ID as urlsafe base64",
        "should get encoding error if allowCredentials[0].id is not urlsafe base64"
      );
    });

    add_task(async () => {
      await addVirtualAuthenticator();
    });

    function isUrlsafeBase64(urlsafeBase64) {
      try {
        atob(urlsafeBase64.replace(/_/g, "/").replace(/-/g, "+"));
        return true;
      } catch (_) {}
      return false;
    }

    add_task(async function test_registrationResponse_toJSON() {
      let publicKey = {
        rp: {id: document.domain, name: "none", icon: "none"},
        user: {id: new Uint8Array(), name: "none", icon: "none", displayName: "none"},
        challenge: crypto.getRandomValues(new Uint8Array(16)),
        pubKeyCredParams: [{type: "public-key", alg: cose_alg_ECDSA_w_SHA256}],
        authenticatorSelection: { residentKey: "discouraged" },
        extensions: { credProps: true }
      };
      let registrationResponse = await navigator.credentials.create({publicKey});
      let registrationResponseJSON = registrationResponse.toJSON();
      is(Object.keys(registrationResponseJSON).length, 6"registrationResponseJSON should have 6 properties");
      is(registrationResponseJSON.id, registrationResponseJSON.rawId, "registrationResponseJSON.id and rawId should be the same");
      ok(isUrlsafeBase64(registrationResponseJSON.id), "registrationResponseJSON.id should be urlsafe base64");
      is(Object.keys(registrationResponseJSON.response).length, 6"registrationResponseJSON.response should have 6 properties");
      ok(isUrlsafeBase64(registrationResponseJSON.response.clientDataJSON), "registrationResponseJSON.response.clientDataJSON should be urlsafe base64");
      ok(isUrlsafeBase64(registrationResponseJSON.response.authenticatorData), "registrationResponseJSON.response.authenticatorData should be urlsafe base64");
      ok(isUrlsafeBase64(registrationResponseJSON.response.publicKey), "registrationResponseJSON.response.publicKey should be urlsafe base64");
      ok(isUrlsafeBase64(registrationResponseJSON.response.attestationObject), "registrationResponseJSON.response.attestationObject should be urlsafe base64");
      is(registrationResponseJSON.response.publicKeyAlgorithm, cose_alg_ECDSA_w_SHA256, "registrationResponseJSON.response.publicKeyAlgorithm should be ECDSA with SHA256 (COSE)");
      is(registrationResponseJSON.response.transports.length, 1"registrationResponseJSON.response.transports.length should be 1");
      is(registrationResponseJSON.response.transports[0], "internal""registrationResponseJSON.response.transports[0] should be internal");
      is(registrationResponseJSON.authenticatorAttachment, "platform""registrationResponseJSON.authenticatorAttachment should be platform");
      is(registrationResponseJSON.clientExtensionResults?.credProps?.rk, false, "registrationResponseJSON.clientExtensionResults.credProps.rk should be false");
      is(registrationResponseJSON.type, "public-key""registrationResponseJSON.type should be public-key");
    });

    add_task(async function test_assertionResponse_toJSON() {
      let registrationRequest = {
        publicKey: {
          rp: {id: document.domain, name: "none", icon: "none"},
          user: {id: new Uint8Array(), name: "none", icon: "none", displayName: "none"},
          challenge: crypto.getRandomValues(new Uint8Array(16)),
          pubKeyCredParams: [{type: "public-key", alg: cose_alg_ECDSA_w_SHA256}],
          extensions: { prf: { enabled: true } }
        },
      };
      let registrationResponse = await navigator.credentials.create(registrationRequest);

      let assertionRequest = {
        publicKey: {
          challenge: crypto.getRandomValues(new Uint8Array(16)),
          allowCredentials: [{ type: "public-key", id: registrationResponse.rawId }],
          extensions: { prf: { eval: { first: new Uint8Array([1,2,3,4,5]).buffer } } }
        },
      };
      let assertionResponse = await navigator.credentials.get(assertionRequest);
      let assertionResponseJSON = assertionResponse.toJSON();
      is(Object.keys(assertionResponseJSON).length, 6"assertionResponseJSON should have 6 properties");
      is(assertionResponseJSON.id, assertionResponseJSON.rawId, "assertionResponseJSON.id and rawId should be the same");
      ok(isUrlsafeBase64(assertionResponseJSON.id), "assertionResponseJSON.id should be urlsafe base64");
      is(Object.keys(assertionResponseJSON.response).length, 3"assertionResponseJSON.response should have 3 properties");
      ok(isUrlsafeBase64(assertionResponseJSON.response.clientDataJSON), "assertionResponseJSON.response.clientDataJSON should be urlsafe base64");
      ok(isUrlsafeBase64(assertionResponseJSON.response.authenticatorData), "assertionResponseJSON.response.authenticatorData should be urlsafe base64");
      ok(isUrlsafeBase64(assertionResponseJSON.response.signature), "assertionResponseJSON.response.signature should be urlsafe base64");
      is(assertionResponseJSON.authenticatorAttachment, "platform""assertionResponseJSON.authenticatorAttachment should be platform");
      is(Object.keys(assertionResponseJSON.clientExtensionResults).length, 1"assertionResponseJSON.clientExtensionResults should have one entry");
      ok(isUrlsafeBase64(assertionResponseJSON.clientExtensionResults.prf.results.first), "assertionResponseJSON.clientExtensionResults.prf.results should be urlsafe base64");
      is(assertionResponseJSON.clientExtensionResults.prf.results.first.length, 43"assertionResponseJSON.clientExtensionResults.prf.results should be of length 43");
      is(assertionResponseJSON.type, "public-key""assertionResponseJSON.type should be public-key");
    });
  </script>

</body>
</html>

Messung V0.5 in Prozent
C=100 H=100 G=100

¤ Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.0.13Bemerkung:  ¤

*Bot Zugriff






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.