TestPasskeys.cpp 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703
  1. /*
  2. * Copyright (C) 2024 KeePassXC Team <team@keepassxc.org>
  3. *
  4. * This program is free software: you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation, either version 2 or (at your option)
  7. * version 3 of the License.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. */
  17. #include "TestPasskeys.h"
  18. #include "browser/BrowserCbor.h"
  19. #include "browser/BrowserMessageBuilder.h"
  20. #include "browser/BrowserPasskeysClient.h"
  21. #include "browser/BrowserService.h"
  22. #include "browser/PasskeyUtils.h"
  23. #include "core/Database.h"
  24. #include "core/Entry.h"
  25. #include "core/Group.h"
  26. #include "crypto/Crypto.h"
  27. #include <QJsonArray>
  28. #include <QJsonDocument>
  29. #include <QTest>
  30. #include <botan/sodium.h>
  31. using namespace Botan::Sodium;
  32. QTEST_GUILESS_MAIN(TestPasskeys)
  33. // Register request
  34. // clang-format off
  35. const QString PublicKeyCredentialOptions = R"(
  36. {
  37. "attestation": "none",
  38. "authenticatorSelection": {
  39. "residentKey": "preferred",
  40. "requireResidentKey": false,
  41. "userVerification": "required"
  42. },
  43. "challenge": "lVeHzVxWsr8MQxMkZF0ti6FXhdgMljqKzgA-q_zk2Mnii3eJ47VF97sqUoYktVC85WAZ1uIASm-a_lDFZwsLfw",
  44. "pubKeyCredParams": [
  45. {
  46. "type": "public-key",
  47. "alg": -7
  48. },
  49. {
  50. "type": "public-key",
  51. "alg": -257
  52. }
  53. ],
  54. "rp": {
  55. "name": "webauthn.io",
  56. "id": "webauthn.io"
  57. },
  58. "timeout": 60000,
  59. "excludeCredentials": [],
  60. "user": {
  61. "displayName": "Test User",
  62. "id": "VkdWemRDQlZjMlZ5",
  63. "name": "Test User"
  64. }
  65. }
  66. )";
  67. // Register response
  68. const QString PublicKeyCredential = R"(
  69. {
  70. "authenticatorAttachment": "platform",
  71. "id": "yrzFJ5lwcpTwYMOdXSmxF5b5cYQlqBMzbbU_d-oFLO8",
  72. "rawId": "cabcc52799707294f060c39d5d29b11796f9718425a813336db53f77ea052cef",
  73. "response": {
  74. "attestationObject": "o2NmbXRkbm9uZWdhdHRTdG10oGhhdXRoRGF0YVikdKbqkhPJnC90siSSsyDPQCYqlMGpUKA5fyklC2CEHvBFAAAAAP2xQbJdhEQ-ijVGmMIFpQIAIMq8xSeZcHKU8GDDnV0psReW-XGEJagTM221P3fqBSzvpQECAyYgASFYIAbsrzRbYpFhbRlZA6ZQKsoxxJWoaeXwh-XUuDLNCIXdIlgg4u5_6Q8O6R0Hg0oDCdtCJLEL0yX_GDLhU5m3HUIE54M",
  75. "clientDataJSON": "eyJ0eXBlIjoid2ViYXV0aG4uY3JlYXRlIiwiY2hhbGxlbmdlIjoibFZlSHpWeFdzcjhNUXhNa1pGMHRpNkZYaGRnTWxqcUt6Z0EtcV96azJNbmlpM2VKNDdWRjk3c3FVb1lrdFZDODVXQVoxdUlBU20tYV9sREZad3NMZnciLCJvcmlnaW4iOiJodHRwczovL3dlYmF1dGhuLmlvIiwiY3Jvc3NPcmlnaW4iOmZhbHNlfQ"
  76. },
  77. "type": "public-key"
  78. }
  79. )";
  80. // Get request
  81. const QString PublicKeyCredentialRequestOptions = R"(
  82. {
  83. "allowCredentials": [
  84. {
  85. "id": "yrzFJ5lwcpTwYMOdXSmxF5b5cYQlqBMzbbU_d-oFLO8",
  86. "transports": ["internal"],
  87. "type": "public-key"
  88. }
  89. ],
  90. "challenge": "9z36vTfQTL95Lf7WnZgyte7ohGeF-XRiLxkL-LuGU1zopRmMIUA1LVwzGpyIm1fOBn1QnRa0QH27ADAaJGHysQ",
  91. "rpId": "webauthn.io",
  92. "timeout": 60000,
  93. "userVerification": "required"
  94. }
  95. )";
  96. const QJsonArray validPubKeyCredParams = {
  97. QJsonObject({
  98. {"type", "public-key"},
  99. {"alg", -7}
  100. }),
  101. QJsonObject({
  102. {"type", "public-key"},
  103. {"alg", -257}
  104. }),
  105. };
  106. // clang-format on
  107. void TestPasskeys::initTestCase()
  108. {
  109. QVERIFY(Crypto::init());
  110. }
  111. void TestPasskeys::init()
  112. {
  113. }
  114. void TestPasskeys::testBase64WithHexStrings()
  115. {
  116. const size_t bufSize = 64;
  117. unsigned char buf[bufSize] = {31, 141, 30, 29, 142, 73, 5, 239, 242, 84, 187, 202, 40, 54, 15, 223,
  118. 201, 0, 108, 109, 209, 104, 207, 239, 160, 89, 208, 117, 134, 66, 42, 12,
  119. 31, 66, 163, 248, 221, 88, 241, 164, 6, 55, 182, 97, 186, 243, 162, 162,
  120. 81, 220, 55, 60, 93, 207, 170, 222, 56, 234, 227, 45, 115, 175, 138, 182};
  121. auto base64FromArray = browserMessageBuilder()->getBase64FromArray(reinterpret_cast<const char*>(buf), bufSize);
  122. QCOMPARE(base64FromArray,
  123. QString("H40eHY5JBe_yVLvKKDYP38kAbG3RaM_voFnQdYZCKgwfQqP43VjxpAY3tmG686KiUdw3PF3Pqt446uMtc6-Ktg"));
  124. auto arrayFromBase64 = browserMessageBuilder()->getArrayFromBase64(base64FromArray);
  125. QCOMPARE(arrayFromBase64.size(), bufSize);
  126. for (size_t i = 0; i < bufSize; i++) {
  127. QCOMPARE(static_cast<unsigned char>(arrayFromBase64.at(i)), buf[i]);
  128. }
  129. auto randomDataBase64 = browserMessageBuilder()->getRandomBytesAsBase64(24);
  130. QCOMPARE(randomDataBase64.isEmpty(), false);
  131. }
  132. void TestPasskeys::testDecodeResponseData()
  133. {
  134. const auto publicKeyCredential = browserMessageBuilder()->getJsonObject(PublicKeyCredential.toUtf8());
  135. auto response = publicKeyCredential["response"].toObject();
  136. auto clientDataJson = response["clientDataJSON"].toString();
  137. auto attestationObject = response["attestationObject"].toString();
  138. QVERIFY(!clientDataJson.isEmpty());
  139. QVERIFY(!attestationObject.isEmpty());
  140. // Parse clientDataJSON
  141. auto clientDataByteArray = browserMessageBuilder()->getArrayFromBase64(clientDataJson);
  142. auto clientDataJsonObject = browserMessageBuilder()->getJsonObject(clientDataByteArray);
  143. QCOMPARE(clientDataJsonObject["challenge"],
  144. QString("lVeHzVxWsr8MQxMkZF0ti6FXhdgMljqKzgA-q_zk2Mnii3eJ47VF97sqUoYktVC85WAZ1uIASm-a_lDFZwsLfw"));
  145. QCOMPARE(clientDataJsonObject["origin"], QString("https://webauthn.io"));
  146. QCOMPARE(clientDataJsonObject["type"], QString("webauthn.create"));
  147. // Parse attestationObject (CBOR decoding needed)
  148. BrowserCbor browserCbor;
  149. auto attestationByteArray = browserMessageBuilder()->getArrayFromBase64(attestationObject);
  150. auto attestationJsonObject = browserCbor.getJsonFromCborData(attestationByteArray);
  151. // Parse authData
  152. auto authDataJsonObject = attestationJsonObject["authData"].toString();
  153. auto authDataArray = browserMessageBuilder()->getArrayFromBase64(authDataJsonObject);
  154. QVERIFY(authDataArray.size() >= 37);
  155. auto authData = browserPasskeys()->parseAuthData(authDataArray);
  156. auto credentialData = authData["credentialData"].toObject();
  157. auto flags = authData["flags"].toObject();
  158. auto publicKey = credentialData["publicKey"].toObject();
  159. // The attestationObject should include the same ID after decoding with the response root
  160. QCOMPARE(credentialData["credentialId"].toString(), publicKeyCredential["id"].toString());
  161. QCOMPARE(credentialData["aaguid"].toString(), QString("_bFBsl2ERD6KNUaYwgWlAg"));
  162. QCOMPARE(authData["rpIdHash"].toString(), QString("dKbqkhPJnC90siSSsyDPQCYqlMGpUKA5fyklC2CEHvA"));
  163. QCOMPARE(flags["AT"], true);
  164. QCOMPARE(flags["UP"], true);
  165. QCOMPARE(publicKey["1"], 2);
  166. QCOMPARE(publicKey["3"], -7);
  167. QCOMPARE(publicKey["-1"], 1);
  168. QCOMPARE(publicKey["-2"], QString("BuyvNFtikWFtGVkDplAqyjHElahp5fCH5dS4Ms0Ihd0"));
  169. QCOMPARE(publicKey["-3"], QString("4u5_6Q8O6R0Hg0oDCdtCJLEL0yX_GDLhU5m3HUIE54M"));
  170. }
  171. void TestPasskeys::testLoadingECPrivateKeyFromPem()
  172. {
  173. #if BOTAN_VERSION_CODE < BOTAN_VERSION_CODE_FOR(2, 14, 0)
  174. QSKIP("ECDSA Signature is broken on Botan < 2.14.0");
  175. #endif
  176. const auto publicKeyCredentialRequestOptions =
  177. browserMessageBuilder()->getJsonObject(PublicKeyCredentialRequestOptions.toUtf8());
  178. const auto privateKeyPem = QString("-----BEGIN PRIVATE KEY-----"
  179. "MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQg5DX2R6I37nMSZqCp"
  180. "XfHlE3UeitkGGE03FqGsdfxIBoOhRANCAAQG7K80W2KRYW0ZWQOmUCrKMcSVqGnl"
  181. "8Ifl1LgyzQiF3eLuf+kPDukdB4NKAwnbQiSxC9Ml/xgy4VOZtx1CBOeD"
  182. "-----END PRIVATE KEY-----");
  183. const auto authenticatorData =
  184. browserMessageBuilder()->getArrayFromBase64("dKbqkhPJnC90siSSsyDPQCYqlMGpUKA5fyklC2CEHvAFAAAAAA");
  185. const auto clientData = browserMessageBuilder()->getArrayFromBase64(
  186. "eyJ0eXBlIjoid2ViYXV0aG4uZ2V0IiwiY2hhbGxlbmdlIjoiOXozNnZUZlFUTDk1TGY3V25aZ3l0ZTdvaEdlRi1YUmlMeGtMLUx1R1Uxem9wUm"
  187. "1NSVVBMUxWd3pHcHlJbTFmT0JuMVFuUmEwUUgyN0FEQWFKR0h5c1EiLCJvcmlnaW4iOiJodHRwczovL3dlYmF1dGhuLmlvIiwiY3Jvc3NPcmln"
  188. "aW4iOmZhbHNlfQ");
  189. const auto signature = browserPasskeys()->buildSignature(authenticatorData, clientData, privateKeyPem);
  190. QCOMPARE(
  191. browserMessageBuilder()->getBase64FromArray(signature),
  192. QString("MEYCIQCpbDaYJ4b2ofqWBxfRNbH3XCpsyao7Iui5lVuJRU9HIQIhAPl5moNZgJu5zmurkKK_P900Ct6wd3ahVIqCEqTeeRdE"));
  193. }
  194. void TestPasskeys::testLoadingRSAPrivateKeyFromPem()
  195. {
  196. const auto privateKeyPem = QString("-----BEGIN PRIVATE KEY-----"
  197. "MIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQC5OHjBHQaRfxxX\n4WHRmqq7e7JgT"
  198. "FRs1bd4dIOFAOZnhNE3vAg2IF5VurmeB+9ye9xh7frw8ubrL0cv\nsBWiJfN5CY3SYGRLbGTtBC0fZ6"
  199. "OhhhjwvVM1GW6nVeRU66atzuo4NBfYXJWIYECd\npRBU4+xsDL4vJnn1mj05+v/Tqp6Uo1HrEPx9+Dc"
  200. "oYJD+cw7+OQ83XeGmjD+Dtm5z\nNIyYdweaafVR4PEUlB3CYZuOq9xcpxay3ps2MuYT1zGoiQqk6fla"
  201. "d+0tBWGY8Lwp\nCVulXCv7ljNJ4gxgQtOqWX8j2hC0hBxeqNYDYbrkECid3TsMTEMcV5uaVJXULg4t"
  202. "\nn6UItA11AgMBAAECggEAC3B0WBxHuieIfllOOOC4H9/7S7fDH2f7+W2cFtQ6pqo9\nCq0WBmkYMmw"
  203. "Xx9hpHoq4TnhhHyL9WzPzuKYD0Vx4gvacV/ckkppFScnQKJ2hF+99\nLax1DbU+UImSknfDDFPYbYld"
  204. "b1CD2rpJG1i6X2fRQ6NuK+F7jE05mqcIyE+ZajK+\nIpx8XFmE+tI1EEWsn3CzxMLiTQfXyFt/drM9i"
  205. "GYfcDjYY+q5vzGU3Kxj68gjc96A\nOra79DGOmwX+4zIwo5sSzI3noHnhWPLsaRtE5jWu21Qkb+1BvB"
  206. "jPmbQfN274OQfy\n8/BNNR/NZM1mJm/8x4Mt+h5d946XlIo0AkyYZXY/UQKBgQDYI3G3BCwaYk6MDMe"
  207. "T\nIamRZo25phPtr3if47dhT2xFWJplIt35sW+6KjD6c1Qpb2aGOUh7JPmb57H54OgJ\nmojkS5tv9Y"
  208. "EQZFfgCCZoeuqBx+ArqtJdkXOiNEFS0dpt44I+eO3Do5pnwKRemH+Y\ncqJ/eMH96UMzYDO7WNsyOyo"
  209. "5UQKBgQDbYU0KbGbTrMEV4T9Q41rZ2TnWzs5moqn2\nCRtB8LOdKAZUG7FRsw5KgC1CvFn3Xuk+qphY"
  210. "GUQeJvv7FjxMRUv4BktNpXju6eUj\n3tWHzI2QOkHaeq/XibwbNomfkdyTjtLX2+v8DBHcZnCSlukxc"
  211. "JISyPqZ6CnTjXGE\nEGB+itBI5QKBgQCA+gWttOusguVkZWvivL+3aH9CPXy+5WsR3o1boE13xDu+Bm"
  212. "R3\n0A5gBTVc/t1GLJf9mMlL0vCwvD5UYoWU1YbC1OtYkCQIaBiYM8TXrCGseF2pMTJ/\na4CZVp10k"
  213. "o3J7W2XYgpgKIzHRQnQ+SeLDT0y3BjHMB9N1SaJsah7/RphQQKBgQCr\nL+4yKAzFOJUjQbVqpT8Lp5"
  214. "qeqJofNOdzef+vIOjHxafKkiF4I0UPlZ276cY6ZfGU\nWQKwHGcvMDSI5fz/d0OksySn3mvT4uhPaV8"
  215. "urMv6s7sXhY0Zn/0NLy2NOwDolBar\nIo2vDKwTVEyb1u75CWKzDemfl66ryj++Uhk6JZAKkQKBgQCc"
  216. "NYVe7m648DzD0nu9\n3lgetBTaAS1zZmMs8Cinj44v0ksfqxrRBzBZcO9kCQqiJZ7uCAaVYcQ+PwkY+"
  217. "05C\n+w1+KvdGcKM+8TQYTQM3s2B9IyKExRS/dbQf9F7stJL+k5vbt6OUerwfmbNI9R3t\ngDZ4DEfo"
  218. "pPivs9dnequ9wfaPOw=="
  219. "-----END PRIVATE KEY-----");
  220. const auto authenticatorData =
  221. browserMessageBuilder()->getArrayFromBase64("dKbqkhPJnC90siSSsyDPQCYqlMGpUKA5fyklC2CEHvAFAAAAAA");
  222. const auto clientData = browserMessageBuilder()->getArrayFromBase64(
  223. "eyJ0eXBlIjoid2ViYXV0aG4uZ2V0IiwiY2hhbGxlbmdlIjoiOXozNnZUZlFUTDk1TGY3V25aZ3l0ZTdvaEdlRi1YUmlMeGtMLUx1R1Uxem9wUm"
  224. "1NSVVBMUxWd3pHcHlJbTFmT0JuMVFuUmEwUUgyN0FEQWFKR0h5c1EiLCJvcmlnaW4iOiJodHRwczovL3dlYmF1dGhuLmlvIiwiY3Jvc3NPcmln"
  225. "aW4iOmZhbHNlfQ");
  226. const auto signature = browserPasskeys()->buildSignature(authenticatorData, clientData, privateKeyPem);
  227. QCOMPARE(
  228. browserMessageBuilder()->getBase64FromArray(signature),
  229. QString("MOGw6KrerCgPf2mPig7FOTFIUDXYAU1v2uZj89_NgQTg2UddWnAB3JId3pa4zXghj8CkjjadVOI_LvweJGCEpmPQnRby71yFXnja6j"
  230. "Y3woX2b2klG2fB2alGZHHrVg6yVEmnAii4kYSdmoWxI7SmzLftoZfCJNFPFHujx2Pbr-6dIB02sZhtncetT0cpyWobtj9r7C5dIGfm"
  231. "J5n-LccP-F9gXGqtbN605VrIkC2WNztjdk3dAt5FGM_dlIwSe-vP1dKfIuNqAEbgr2IVZAUFn_ZfzUo-XbXTysksuz9JZfEopJBiUi"
  232. "9tjQDNvrYQFqB6wDPqkZAomkbRCohUb3TzCg"));
  233. }
  234. void TestPasskeys::testCreatingAttestationObjectWithEC()
  235. {
  236. // Predefined values for a desired outcome
  237. const auto id = QString("yrzFJ5lwcpTwYMOdXSmxF5b5cYQlqBMzbbU_d-oFLO8");
  238. const auto predefinedFirst = QString("BuyvNFtikWFtGVkDplAqyjHElahp5fCH5dS4Ms0Ihd0");
  239. const auto predefinedSecond = QString("4u5_6Q8O6R0Hg0oDCdtCJLEL0yX_GDLhU5m3HUIE54M");
  240. const auto publicKeyCredentialOptions = browserMessageBuilder()->getJsonObject(PublicKeyCredentialOptions.toUtf8());
  241. QJsonObject credentialCreationOptions;
  242. browserPasskeysClient()->getCredentialCreationOptions(
  243. publicKeyCredentialOptions, QString("https://webauthn.io"), &credentialCreationOptions);
  244. auto rpIdHash = browserMessageBuilder()->getSha256HashAsBase64(QString("webauthn.io"));
  245. QCOMPARE(rpIdHash, QString("dKbqkhPJnC90siSSsyDPQCYqlMGpUKA5fyklC2CEHvA"));
  246. TestingVariables testingVariables = {id, predefinedFirst, predefinedSecond};
  247. const auto alg = browserPasskeys()->getAlgorithmFromPublicKey(credentialCreationOptions);
  248. const auto credentialPrivateKey =
  249. browserPasskeys()->buildCredentialPrivateKey(alg, predefinedFirst, predefinedSecond);
  250. auto result = browserPasskeys()->buildAttestationObject(
  251. credentialCreationOptions, "", id, credentialPrivateKey.cborEncodedPublicKey, testingVariables);
  252. QCOMPARE(
  253. result,
  254. QString("\xA3"
  255. "cfmtdnonegattStmt\xA0hauthDataX\xA4t\xA6\xEA\x92\x13\xC9\x9C/t\xB2$\x92\xB3 \xCF@&*\x94\xC1\xA9P\xA0"
  256. "9\x7F)%\x0B`\x84\x1E\xF0"
  257. "E\x00\x00\x00\x01\x01\x02\x03\x04\x05\x06\x07\b\x01\x02\x03\x04\x05\x06\x07\b\x00 \x8B\xB0\xCA"
  258. "6\x17\xD6\xDE\x01\x11|\xEA\x94\r\xA0R\xC0\x80_\xF3r\xFBr\xB5\x02\x03:"
  259. "\xBAr\x0Fi\x81\xFE\xA5\x01\x02\x03& \x01!X "
  260. "e\xE2\xF2\x1F:cq\xD3G\xEA\xE0\xF7\x1F\xCF\xFA\\\xABO\xF6\x86\x88\x80\t\xAE\x81\x8BT\xB2\x9B\x15\x85~"
  261. "\"X \\\x8E\x1E@\xDB\x97T-\xF8\x9B\xB0\xAD"
  262. "5\xDC\x12^\xC3\x95\x05\xC6\xDF^\x03\xCB\xB4Q\x91\xFF|\xDB\x94\xB7"));
  263. // Double check that the result can be decoded
  264. BrowserCbor browserCbor;
  265. auto attestationJsonObject = browserCbor.getJsonFromCborData(result);
  266. // Parse authData
  267. auto authDataJsonObject = attestationJsonObject["authData"].toString();
  268. auto authDataArray = browserMessageBuilder()->getArrayFromBase64(authDataJsonObject);
  269. QVERIFY(authDataArray.size() >= 37);
  270. auto authData = browserPasskeys()->parseAuthData(authDataArray);
  271. auto credentialData = authData["credentialData"].toObject();
  272. auto flags = authData["flags"].toObject();
  273. auto publicKey = credentialData["publicKey"].toObject();
  274. // The attestationObject should include the same ID after decoding with the response root
  275. QCOMPARE(credentialData["credentialId"].toString(), QString("yrzFJ5lwcpTwYMOdXSmxF5b5cYQlqBMzbbU_d-oFLO8"));
  276. QCOMPARE(authData["rpIdHash"].toString(), QString("dKbqkhPJnC90siSSsyDPQCYqlMGpUKA5fyklC2CEHvA"));
  277. QCOMPARE(flags["AT"], true);
  278. QCOMPARE(flags["UP"], true);
  279. QCOMPARE(publicKey["1"], WebAuthnCoseKeyType::EC2);
  280. QCOMPARE(publicKey["3"], WebAuthnAlgorithms::ES256);
  281. QCOMPARE(publicKey["-1"], 1);
  282. QCOMPARE(publicKey["-2"], predefinedFirst);
  283. QCOMPARE(publicKey["-3"], predefinedSecond);
  284. }
  285. void TestPasskeys::testCreatingAttestationObjectWithRSA()
  286. {
  287. // Predefined values for a desired outcome
  288. const auto id = QString("yrzFJ5lwcpTwYMOdXSmxF5b5cYQlqBMzbbU_d-oFLO8");
  289. const auto predefinedModulus = QString("vUhOZnyn8yn7U-nuHlsXZ6WDWLuYvevWWnwtoHxDEQq27vlp7yAfeVvAPkcvhxRcwoCEUespoa5"
  290. "5IDbkpp2Ypd6b15KbB4C-_4gM4r2FK9gfXghLPAXsMhstYv4keNFb4ghdlY5oUU3JCqUSMyOpmd"
  291. "HeX-RikLL0wgGv_tLT2DaDiWeyQCAtiDblr6COuTAU2kTpLc3Bn35geV9Iqw4iT8DwBQ-f8vjnI"
  292. "EDANXKUiRPojfy1q7WwEl-zMv6Ke2jFHxf68u82BSy3u9DOQaa24FAHoCm8Yd0n5IazMyoxyttl"
  293. "tRt8un8myVOGxcXMiR9_kQb9pu1RRLQMQLd-icE1Qw");
  294. const auto predefinedExponent = QString("AQAB");
  295. // Force algorithm to RSA
  296. QJsonArray pubKeyCredParams;
  297. pubKeyCredParams.append(QJsonObject({{"type", "public-key"}, {"alg", -257}}));
  298. const auto publicKeyCredentialOptions = browserMessageBuilder()->getJsonObject(PublicKeyCredentialOptions.toUtf8());
  299. QJsonObject credentialCreationOptions;
  300. browserPasskeysClient()->getCredentialCreationOptions(
  301. publicKeyCredentialOptions, QString("https://webauthn.io"), &credentialCreationOptions);
  302. credentialCreationOptions["credTypesAndPubKeyAlgs"] = pubKeyCredParams;
  303. auto rpIdHash = browserMessageBuilder()->getSha256HashAsBase64(QString("webauthn.io"));
  304. QCOMPARE(rpIdHash, QString("dKbqkhPJnC90siSSsyDPQCYqlMGpUKA5fyklC2CEHvA"));
  305. TestingVariables testingVariables = {id, predefinedModulus, predefinedExponent};
  306. const auto alg = browserPasskeys()->getAlgorithmFromPublicKey(credentialCreationOptions);
  307. auto credentialPrivateKey =
  308. browserPasskeys()->buildCredentialPrivateKey(alg, predefinedModulus, predefinedExponent);
  309. auto result = browserPasskeys()->buildAttestationObject(
  310. credentialCreationOptions, "", id, credentialPrivateKey.cborEncodedPublicKey, testingVariables);
  311. // Double check that the result can be decoded
  312. BrowserCbor browserCbor;
  313. auto attestationJsonObject = browserCbor.getJsonFromCborData(result);
  314. // Parse authData
  315. auto authDataJsonObject = attestationJsonObject["authData"].toString();
  316. auto authDataArray = browserMessageBuilder()->getArrayFromBase64(authDataJsonObject);
  317. QVERIFY(authDataArray.size() >= 37);
  318. auto authData = browserPasskeys()->parseAuthData(authDataArray);
  319. auto credentialData = authData["credentialData"].toObject();
  320. auto flags = authData["flags"].toObject();
  321. auto publicKey = credentialData["publicKey"].toObject();
  322. // The attestationObject should include the same ID after decoding with the response root
  323. QCOMPARE(credentialData["credentialId"].toString(), QString("yrzFJ5lwcpTwYMOdXSmxF5b5cYQlqBMzbbU_d-oFLO8"));
  324. QCOMPARE(authData["rpIdHash"].toString(), QString("dKbqkhPJnC90siSSsyDPQCYqlMGpUKA5fyklC2CEHvA"));
  325. QCOMPARE(flags["AT"], true);
  326. QCOMPARE(flags["UP"], true);
  327. QCOMPARE(publicKey["1"], WebAuthnCoseKeyType::RSA);
  328. QCOMPARE(publicKey["3"], WebAuthnAlgorithms::RS256);
  329. QCOMPARE(publicKey["-1"], predefinedModulus);
  330. QCOMPARE(publicKey["-2"], predefinedExponent);
  331. }
  332. void TestPasskeys::testRegister()
  333. {
  334. // Predefined values for a desired outcome
  335. const auto predefinedId = QString("yrzFJ5lwcpTwYMOdXSmxF5b5cYQlqBMzbbU_d-oFLO8");
  336. const auto predefinedX = QString("BuyvNFtikWFtGVkDplAqyjHElahp5fCH5dS4Ms0Ihd0");
  337. const auto predefinedY = QString("4u5_6Q8O6R0Hg0oDCdtCJLEL0yX_GDLhU5m3HUIE54M");
  338. const auto origin = QString("https://webauthn.io");
  339. const auto testDataPublicKey = browserMessageBuilder()->getJsonObject(PublicKeyCredential.toUtf8());
  340. const auto testDataResponse = testDataPublicKey["response"];
  341. const auto publicKeyCredentialOptions = browserMessageBuilder()->getJsonObject(PublicKeyCredentialOptions.toUtf8());
  342. QJsonObject credentialCreationOptions;
  343. const auto creationResult = browserPasskeysClient()->getCredentialCreationOptions(
  344. publicKeyCredentialOptions, origin, &credentialCreationOptions);
  345. QVERIFY(creationResult == 0);
  346. TestingVariables testingVariables = {predefinedId, predefinedX, predefinedY};
  347. auto result = browserPasskeys()->buildRegisterPublicKeyCredential(credentialCreationOptions, testingVariables);
  348. auto publicKeyCredential = result.response;
  349. QCOMPARE(publicKeyCredential["type"], QString("public-key"));
  350. QCOMPARE(publicKeyCredential["authenticatorAttachment"], QString("platform"));
  351. QCOMPARE(publicKeyCredential["id"], QString("yrzFJ5lwcpTwYMOdXSmxF5b5cYQlqBMzbbU_d-oFLO8"));
  352. auto response = publicKeyCredential["response"].toObject();
  353. auto attestationObject = response["attestationObject"].toString();
  354. auto clientDataJson = response["clientDataJSON"].toString();
  355. QCOMPARE(attestationObject, testDataResponse["attestationObject"].toString());
  356. // Parse clientDataJSON
  357. auto clientDataByteArray = browserMessageBuilder()->getArrayFromBase64(clientDataJson);
  358. auto clientDataJsonObject = browserMessageBuilder()->getJsonObject(clientDataByteArray);
  359. QCOMPARE(clientDataJsonObject["challenge"],
  360. QString("lVeHzVxWsr8MQxMkZF0ti6FXhdgMljqKzgA-q_zk2Mnii3eJ47VF97sqUoYktVC85WAZ1uIASm-a_lDFZwsLfw"));
  361. QCOMPARE(clientDataJsonObject["origin"], origin);
  362. QCOMPARE(clientDataJsonObject["type"], QString("webauthn.create"));
  363. }
  364. void TestPasskeys::testGet()
  365. {
  366. #if BOTAN_VERSION_CODE < BOTAN_VERSION_CODE_FOR(2, 14, 0)
  367. QSKIP("ECDSA Signature is broken on Botan < 2.14.0");
  368. #endif
  369. const auto privateKeyPem = QString("-----BEGIN PRIVATE KEY-----"
  370. "MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQg5DX2R6I37nMSZqCp"
  371. "XfHlE3UeitkGGE03FqGsdfxIBoOhRANCAAQG7K80W2KRYW0ZWQOmUCrKMcSVqGnl"
  372. "8Ifl1LgyzQiF3eLuf+kPDukdB4NKAwnbQiSxC9Ml/xgy4VOZtx1CBOeD"
  373. "-----END PRIVATE KEY-----");
  374. const auto origin = QString("https://webauthn.io");
  375. const auto id = QString("yrzFJ5lwcpTwYMOdXSmxF5b5cYQlqBMzbbU_d-oFLO8");
  376. const auto publicKeyCredentialRequestOptions =
  377. browserMessageBuilder()->getJsonObject(PublicKeyCredentialRequestOptions.toUtf8());
  378. QJsonObject assertionOptions;
  379. const auto assertionResult =
  380. browserPasskeysClient()->getAssertionOptions(publicKeyCredentialRequestOptions, origin, &assertionOptions);
  381. QVERIFY(assertionResult == 0);
  382. auto publicKeyCredential = browserPasskeys()->buildGetPublicKeyCredential(assertionOptions, id, {}, privateKeyPem);
  383. QVERIFY(!publicKeyCredential.isEmpty());
  384. QCOMPARE(publicKeyCredential["id"].toString(), id);
  385. auto response = publicKeyCredential["response"].toObject();
  386. QCOMPARE(response["authenticatorData"].toString(), QString("dKbqkhPJnC90siSSsyDPQCYqlMGpUKA5fyklC2CEHvAFAAAAAA"));
  387. QCOMPARE(response["clientDataJSON"].toString(),
  388. QString("eyJjaGFsbGVuZ2UiOiI5ejM2dlRmUVRMOTVMZjdXblpneXRlN29oR2VGLVhSaUx4a0wtTHVHVTF6b3BSbU1JVUExTFZ3ekdwe"
  389. "UltMWZPQm4xUW5SYTBRSDI3QURBYUpHSHlzUSIsImNyb3NzT3JpZ2luIjpmYWxzZSwib3JpZ2luIjoiaHR0cHM6Ly93ZWJhdX"
  390. "Robi5pbyIsInR5cGUiOiJ3ZWJhdXRobi5nZXQifQ"));
  391. QCOMPARE(
  392. response["signature"].toString(),
  393. QString("MEUCIHFv0lOOGGloi_XoH5s3QDSs__8yAp9ZTMEjNiacMpOxAiEA04LAfO6TE7j12XNxd3zHQpn4kZN82jQFPntPiPBSD5c"));
  394. auto clientDataJson = response["clientDataJSON"].toString();
  395. auto clientDataByteArray = browserMessageBuilder()->getArrayFromBase64(clientDataJson);
  396. auto clientDataJsonObject = browserMessageBuilder()->getJsonObject(clientDataByteArray);
  397. QCOMPARE(clientDataJsonObject["challenge"].toString(), publicKeyCredentialRequestOptions["challenge"].toString());
  398. }
  399. void TestPasskeys::testExtensions()
  400. {
  401. auto extensions = QJsonObject({{"credProps", true}, {"uvm", true}});
  402. auto result = passkeyUtils()->buildExtensionData(extensions);
  403. BrowserCbor cbor;
  404. auto extensionJson = cbor.getJsonFromCborData(result.extensionData);
  405. auto uvmArray = result.extensionObject["uvm"].toArray();
  406. QCOMPARE(result.extensionObject["credProps"].toObject()["rk"].toBool(), true);
  407. QCOMPARE(uvmArray.size(), 1);
  408. QCOMPARE(uvmArray.first().toArray().size(), 3);
  409. auto partial = QJsonObject({{"props", true}, {"uvm", true}});
  410. auto faulty = QJsonObject({{"uvx", true}});
  411. auto partialData = passkeyUtils()->buildExtensionData(partial);
  412. auto faultyData = passkeyUtils()->buildExtensionData(faulty);
  413. auto partialJson = cbor.getJsonFromCborData(partialData.extensionData);
  414. QCOMPARE(partialJson["uvm"].toArray().size(), 1);
  415. auto faultyJson = cbor.getJsonFromCborData(faultyData.extensionData);
  416. QCOMPARE(faultyJson.size(), 0);
  417. }
  418. void TestPasskeys::testParseFlags()
  419. {
  420. auto registerResult = browserPasskeys()->parseFlags("\x45");
  421. QCOMPARE(registerResult["ED"], false);
  422. QCOMPARE(registerResult["AT"], true);
  423. QCOMPARE(registerResult["BS"], false);
  424. QCOMPARE(registerResult["BE"], false);
  425. QCOMPARE(registerResult["UV"], true);
  426. QCOMPARE(registerResult["UP"], true);
  427. auto getResult = browserPasskeys()->parseFlags("\x05"); // Only UP and UV
  428. QCOMPARE(getResult["ED"], false);
  429. QCOMPARE(getResult["AT"], false);
  430. QCOMPARE(getResult["BS"], false);
  431. QCOMPARE(getResult["BE"], false);
  432. QCOMPARE(getResult["UV"], true);
  433. QCOMPARE(getResult["UP"], true);
  434. }
  435. void TestPasskeys::testSetFlags()
  436. {
  437. auto registerJson =
  438. QJsonObject({{"ED", false}, {"AT", true}, {"BS", false}, {"BE", false}, {"UV", true}, {"UP", true}});
  439. auto registerResult = browserPasskeys()->setFlagsFromJson(registerJson);
  440. QCOMPARE(registerResult, 0x45);
  441. auto getJson =
  442. QJsonObject({{"ED", false}, {"AT", false}, {"BS", false}, {"BE", false}, {"UV", true}, {"UP", true}});
  443. auto getResult = browserPasskeys()->setFlagsFromJson(getJson);
  444. QCOMPARE(getResult, 0x05);
  445. // With "discouraged", so UV is false
  446. auto discouragedJson =
  447. QJsonObject({{"ED", false}, {"AT", false}, {"BS", false}, {"BE", false}, {"UV", false}, {"UP", true}});
  448. auto discouragedResult = browserPasskeys()->setFlagsFromJson(discouragedJson);
  449. QCOMPARE(discouragedResult, 0x01);
  450. }
  451. void TestPasskeys::testEntry()
  452. {
  453. Database db;
  454. auto* root = db.rootGroup();
  455. root->setUuid(QUuid::createUuid());
  456. auto* group1 = new Group();
  457. group1->setUuid(QUuid::createUuid());
  458. group1->setParent(root);
  459. auto* entry = new Entry();
  460. entry->setGroup(root);
  461. browserService()->addPasskeyToEntry(entry,
  462. QString("example.com"),
  463. QString("example.com"),
  464. QString("username"),
  465. QString("userId"),
  466. QString("userHandle"),
  467. QString("privateKey"));
  468. QVERIFY(entry->hasPasskey());
  469. }
  470. void TestPasskeys::testIsDomain()
  471. {
  472. QVERIFY(passkeyUtils()->isDomain("test.example.com"));
  473. QVERIFY(passkeyUtils()->isDomain("example.com"));
  474. QVERIFY(!passkeyUtils()->isDomain("exa[mple.org"));
  475. QVERIFY(!passkeyUtils()->isDomain("example.com."));
  476. QVERIFY(!passkeyUtils()->isDomain("127.0.0.1"));
  477. QVERIFY(!passkeyUtils()->isDomain("127.0.0.1."));
  478. }
  479. // List from https://html.spec.whatwg.org/multipage/browsers.html#is-a-registrable-domain-suffix-of-or-is-equal-to
  480. void TestPasskeys::testRegistrableDomainSuffix()
  481. {
  482. QVERIFY(passkeyUtils()->isRegistrableDomainSuffix(QString("example.com"), QString("example.com")));
  483. QVERIFY(!passkeyUtils()->isRegistrableDomainSuffix(QString("example.com"), QString("example.com.")));
  484. QVERIFY(!passkeyUtils()->isRegistrableDomainSuffix(QString("example.com."), QString("example.com")));
  485. QVERIFY(passkeyUtils()->isRegistrableDomainSuffix(QString("example.com"), QString("www.example.com")));
  486. QVERIFY(!passkeyUtils()->isRegistrableDomainSuffix(QString("com"), QString("example.com")));
  487. QVERIFY(passkeyUtils()->isRegistrableDomainSuffix(QString("example"), QString("example")));
  488. QVERIFY(
  489. !passkeyUtils()->isRegistrableDomainSuffix(QString("s3.amazonaws.com"), QString("example.s3.amazonaws.com")));
  490. QVERIFY(!passkeyUtils()->isRegistrableDomainSuffix(QString("example.compute.amazonaws.com"),
  491. QString("www.example.compute.amazonaws.com")));
  492. QVERIFY(!passkeyUtils()->isRegistrableDomainSuffix(QString("amazonaws.com"),
  493. QString("www.example.compute.amazonaws.com")));
  494. QVERIFY(passkeyUtils()->isRegistrableDomainSuffix(QString("amazonaws.com"), QString("test.amazonaws.com")));
  495. }
  496. void TestPasskeys::testRpIdValidation()
  497. {
  498. QString result;
  499. auto allowedIdentical = passkeyUtils()->validateRpId(QString("example.com"), QString("example.com"), &result);
  500. QCOMPARE(result, QString("example.com"));
  501. QVERIFY(allowedIdentical == PASSKEYS_SUCCESS);
  502. result.clear();
  503. auto allowedSubdomain = passkeyUtils()->validateRpId(QString("example.com"), QString("www.example.com"), &result);
  504. QCOMPARE(result, QString("example.com"));
  505. QVERIFY(allowedSubdomain == PASSKEYS_SUCCESS);
  506. result.clear();
  507. QJsonValue emptyValue;
  508. auto emptyRpId = passkeyUtils()->validateRpId(emptyValue, QString("example.com"), &result);
  509. QCOMPARE(result, QString("example.com"));
  510. QVERIFY(emptyRpId == PASSKEYS_SUCCESS);
  511. result.clear();
  512. auto ipRpId = passkeyUtils()->validateRpId(QString("127.0.0.1"), QString("example.com"), &result);
  513. QCOMPARE(result, QString(""));
  514. QVERIFY(ipRpId == ERROR_PASSKEYS_DOMAIN_RPID_MISMATCH);
  515. result.clear();
  516. auto emptyOrigin = passkeyUtils()->validateRpId(QString("example.com"), QString(""), &result);
  517. QVERIFY(result.isEmpty());
  518. QCOMPARE(emptyOrigin, ERROR_PASSKEYS_ORIGIN_NOT_ALLOWED);
  519. result.clear();
  520. auto ipOrigin = passkeyUtils()->validateRpId(QString("example.com"), QString("127.0.0.1"), &result);
  521. QVERIFY(result.isEmpty());
  522. QCOMPARE(ipOrigin, ERROR_PASSKEYS_DOMAIN_RPID_MISMATCH);
  523. result.clear();
  524. auto invalidRpId = passkeyUtils()->validateRpId(QString(".com"), QString("example.com"), &result);
  525. QVERIFY(result.isEmpty());
  526. QCOMPARE(invalidRpId, ERROR_PASSKEYS_DOMAIN_RPID_MISMATCH);
  527. result.clear();
  528. auto malformedOrigin = passkeyUtils()->validateRpId(QString("example.com."), QString("example.com."), &result);
  529. QVERIFY(result.isEmpty());
  530. QCOMPARE(malformedOrigin, ERROR_PASSKEYS_DOMAIN_RPID_MISMATCH);
  531. result.clear();
  532. auto malformed = passkeyUtils()->validateRpId(QString("...com."), QString("example...com"), &result);
  533. QVERIFY(result.isEmpty());
  534. QCOMPARE(malformed, ERROR_PASSKEYS_DOMAIN_RPID_MISMATCH);
  535. result.clear();
  536. auto differentDomain = passkeyUtils()->validateRpId(QString("another.com"), QString("example.com"), &result);
  537. QVERIFY(result.isEmpty());
  538. QCOMPARE(differentDomain, ERROR_PASSKEYS_DOMAIN_RPID_MISMATCH);
  539. }
  540. void TestPasskeys::testParseAttestation()
  541. {
  542. QVERIFY(passkeyUtils()->parseAttestation(QString("")) == QString("none"));
  543. QVERIFY(passkeyUtils()->parseAttestation(QString("direct")) == QString("direct"));
  544. QVERIFY(passkeyUtils()->parseAttestation(QString("none")) == QString("none"));
  545. QVERIFY(passkeyUtils()->parseAttestation(QString("indirect")) == QString("none"));
  546. QVERIFY(passkeyUtils()->parseAttestation(QString("invalidvalue")) == QString("none"));
  547. }
  548. void TestPasskeys::testParseCredentialTypes()
  549. {
  550. const QJsonArray invalidPubKeyCredParams = {
  551. QJsonObject({{"type", "private-key"}, {"alg", -7}}),
  552. QJsonObject({{"type", "private-key"}, {"alg", -257}}),
  553. };
  554. const QJsonArray partiallyInvalidPubKeyCredParams = {
  555. QJsonObject({{"type", "private-key"}, {"alg", -7}}),
  556. QJsonObject({{"type", "public-key"}, {"alg", -257}}),
  557. };
  558. auto validResponse = passkeyUtils()->parseCredentialTypes(validPubKeyCredParams);
  559. QVERIFY(validResponse == validPubKeyCredParams);
  560. auto invalidResponse = passkeyUtils()->parseCredentialTypes(invalidPubKeyCredParams);
  561. QVERIFY(invalidResponse.isEmpty());
  562. auto partiallyInvalidResponse = passkeyUtils()->parseCredentialTypes(partiallyInvalidPubKeyCredParams);
  563. QVERIFY(partiallyInvalidResponse != validPubKeyCredParams);
  564. QVERIFY(partiallyInvalidResponse.size() == 1);
  565. QVERIFY(partiallyInvalidResponse.first()["type"].toString() == QString("public-key"));
  566. QVERIFY(partiallyInvalidResponse.first()["alg"].toInt() == -257);
  567. auto emptyResponse = passkeyUtils()->parseCredentialTypes({});
  568. QVERIFY(emptyResponse == validPubKeyCredParams);
  569. const auto publicKeyOptions = browserMessageBuilder()->getJsonObject(PublicKeyCredentialOptions.toUtf8());
  570. auto responseFromPublicKey = passkeyUtils()->parseCredentialTypes(publicKeyOptions["pubKeyCredParams"].toArray());
  571. QVERIFY(responseFromPublicKey == validPubKeyCredParams);
  572. }
  573. void TestPasskeys::testIsAuthenticatorSelectionValid()
  574. {
  575. QVERIFY(passkeyUtils()->isAuthenticatorSelectionValid({}));
  576. QVERIFY(passkeyUtils()->isAuthenticatorSelectionValid(QJsonObject({{"authenticatorAttachment", "platform"}})));
  577. QVERIFY(
  578. passkeyUtils()->isAuthenticatorSelectionValid(QJsonObject({{"authenticatorAttachment", "cross-platform"}})));
  579. QVERIFY(!passkeyUtils()->isAuthenticatorSelectionValid(QJsonObject({{"authenticatorAttachment", "something"}})));
  580. }
  581. void TestPasskeys::testIsResidentKeyRequired()
  582. {
  583. QVERIFY(passkeyUtils()->isResidentKeyRequired(QJsonObject({{"residentKey", "required"}})));
  584. QVERIFY(passkeyUtils()->isResidentKeyRequired(QJsonObject({{"residentKey", "preferred"}})));
  585. QVERIFY(!passkeyUtils()->isResidentKeyRequired(QJsonObject({{"residentKey", "discouraged"}})));
  586. QVERIFY(passkeyUtils()->isResidentKeyRequired(QJsonObject({{"requireResidentKey", true}})));
  587. }
  588. void TestPasskeys::testIsUserVerificationRequired()
  589. {
  590. QVERIFY(passkeyUtils()->isUserVerificationRequired(QJsonObject({{"userVerification", "required"}})));
  591. QVERIFY(passkeyUtils()->isUserVerificationRequired(QJsonObject({{"userVerification", "preferred"}})));
  592. QVERIFY(!passkeyUtils()->isUserVerificationRequired(QJsonObject({{"userVerification", "discouraged"}})));
  593. }
  594. void TestPasskeys::testAllowLocalhostWithPasskeys()
  595. {
  596. QVERIFY(passkeyUtils()->isOriginAllowedWithLocalhost(false, "https://example.com"));
  597. QVERIFY(!passkeyUtils()->isOriginAllowedWithLocalhost(false, "http://example.com"));
  598. QVERIFY(passkeyUtils()->isOriginAllowedWithLocalhost(true, "https://example.com"));
  599. QVERIFY(!passkeyUtils()->isOriginAllowedWithLocalhost(true, "http://example.com"));
  600. QVERIFY(!passkeyUtils()->isOriginAllowedWithLocalhost(false, "http://localhost"));
  601. QVERIFY(passkeyUtils()->isOriginAllowedWithLocalhost(true, "http://localhost"));
  602. QVERIFY(!passkeyUtils()->isOriginAllowedWithLocalhost(true, "http://localhosting"));
  603. QVERIFY(passkeyUtils()->isOriginAllowedWithLocalhost(true, "http://test.localhost"));
  604. QVERIFY(!passkeyUtils()->isOriginAllowedWithLocalhost(false, "http://test.localhost"));
  605. QVERIFY(!passkeyUtils()->isOriginAllowedWithLocalhost(true, "http://localhost.example.com"));
  606. }