Diff
Modified: trunk/Source/WebCore/ChangeLog (253810 => 253811)
--- trunk/Source/WebCore/ChangeLog 2019-12-20 03:32:37 UTC (rev 253810)
+++ trunk/Source/WebCore/ChangeLog 2019-12-20 10:31:03 UTC (rev 253811)
@@ -1,3 +1,74 @@
+2019-12-20 Jiewen Tan <[email protected]>
+
+ [WebAuthn] Implement coders for CTAP ClientPIN requests and responses
+ https://bugs.webkit.org/show_bug.cgi?id=205376
+ <rdar://problem/58034395>
+
+ Reviewed by Brent Fulgham.
+
+ This patch implements coders for authenticatorClientPIN requests and responses
+ following the spec:
+ https://fidoalliance.org/specs/fido-v2.0-ps-20190130/fido-client-to-authenticator-protocol-v2.0-ps-20190130.html#authenticatorClientPIN
+
+ Specifically, it
+ i) implements authenticatorClientPIN subCommand: getRetries, getKeyAgreement and getPINToken;
+ ii) adds pinAuth/pinProtocol to authenticatorMakeCredential/authenticatorGetAssertion.
+
+ The authenticatorClientPIN subCommands are based on a Chromium patch:
+ https://chromium-review.googlesource.com/c/chromium/src/+/1457004 Specifically, it adopts the
+ interfaces from that patch, but rewrites the BoringSSL-based crypto features using WebCore's
+ WebCrypto implementation. This allows us to focus on high level crypto interfaces, and lets
+ WebCrypto handle the underlying crypto library. Also, the original Chromium patch lacks tests.
+ We introduce a large set of API tests to confirm proper function.
+
+ This patch also makes the AES CBC, EDCH, and HMAC platform* implementations public, so that
+ these implementations can be shared by WebAuthentication and test infrastructure.
+
+ Covered by API tests.
+
+ * Modules/webauthn/WebAuthenticationConstants.h:
+ * Modules/webauthn/cbor/CBORReader.cpp:
+ (cbor::CBORReader::readCBORMap):
+ Let CBORReader recognize negative map keys.
+ * Modules/webauthn/fido/DeviceRequestConverter.cpp:
+ (fido::encodeMakeCredenitalRequestAsCBOR):
+ (fido::encodeGetAssertionRequestAsCBOR):
+ * Modules/webauthn/fido/DeviceRequestConverter.h:
+ * Modules/webauthn/fido/Pin.cpp: Added.
+ (fido::pin::hasAtLeastFourCodepoints):
+ (fido::pin::makePinAuth):
+ (fido::pin::encodeRawPublicKey):
+ (fido::pin::validateAndConvertToUTF8):
+ (fido::pin::encodePinCommand):
+ (fido::pin::RetriesResponse::parse):
+ (fido::pin::KeyAgreementResponse::KeyAgreementResponse):
+ (fido::pin::KeyAgreementResponse::parse):
+ (fido::pin::KeyAgreementResponse::parseFromCOSE):
+ (fido::pin::encodeCOSEPublicKey):
+ (fido::pin::TokenResponse::TokenResponse):
+ (fido::pin::TokenResponse::parse):
+ (fido::pin::TokenResponse::pinAuth const):
+ (fido::pin::TokenResponse::token const):
+ (fido::pin::encodeAsCBOR):
+ (fido::pin::TokenRequest::tryCreate):
+ (fido::pin::TokenRequest::TokenRequest):
+ (fido::pin::TokenRequest::sharedKey const):
+ * Modules/webauthn/fido/Pin.h: Added.
+ * Sources.txt:
+ * WebCore.xcodeproj/project.pbxproj:
+ * crypto/CryptoAlgorithm.h:
+ * crypto/algorithms/CryptoAlgorithmAES_CBC.h:
+ * crypto/algorithms/CryptoAlgorithmECDH.h:
+ * crypto/algorithms/CryptoAlgorithmHMAC.h:
+ * crypto/keys/CryptoKeyAES.cpp:
+ * crypto/keys/CryptoKeyAES.h:
+ * crypto/keys/CryptoKeyEC.h:
+ * crypto/mac/CryptoAlgorithmAES_CBCMac.cpp:
+ (WebCore::CryptoAlgorithmAES_CBC::platformEncrypt):
+ (WebCore::CryptoAlgorithmAES_CBC::platformDecrypt):
+ * crypto/mac/CryptoKeyRSAMac.cpp:
+ (WebCore::CryptoKeyRSA::algorithm const):
+
2019-12-19 Doug Kelly <[email protected]>
Update TrackBase to store m_mediaElement as a WeakPtr
Modified: trunk/Source/WebCore/Modules/webauthn/WebAuthenticationConstants.h (253810 => 253811)
--- trunk/Source/WebCore/Modules/webauthn/WebAuthenticationConstants.h 2019-12-20 03:32:37 UTC (rev 253810)
+++ trunk/Source/WebCore/Modules/webauthn/WebAuthenticationConstants.h 2019-12-20 10:31:03 UTC (rev 253811)
@@ -38,6 +38,7 @@
// Values
const int64_t EC2 = 2;
const int64_t ES256 = -7;
+const int64_t ECDH256 = -25;
const int64_t P_256 = 1;
} // namespace COSE
Modified: trunk/Source/WebCore/Modules/webauthn/cbor/CBORReader.cpp (253810 => 253811)
--- trunk/Source/WebCore/Modules/webauthn/cbor/CBORReader.cpp 2019-12-20 03:32:37 UTC (rev 253810)
+++ trunk/Source/WebCore/Modules/webauthn/cbor/CBORReader.cpp 2019-12-20 10:31:03 UTC (rev 253811)
@@ -269,7 +269,7 @@
return WTF::nullopt;
// Only CBOR maps with integer or string type keys are allowed.
- if (key.value().type() != CBORValue::Type::String && key.value().type() != CBORValue::Type::Unsigned) {
+ if (!key->isString() && !key->isInteger()) {
m_errorCode = DecoderError::IncorrectMapKeyType;
return WTF::nullopt;
}
Modified: trunk/Source/WebCore/Modules/webauthn/fido/DeviceRequestConverter.cpp (253810 => 253811)
--- trunk/Source/WebCore/Modules/webauthn/fido/DeviceRequestConverter.cpp 2019-12-20 03:32:37 UTC (rev 253810)
+++ trunk/Source/WebCore/Modules/webauthn/fido/DeviceRequestConverter.cpp 2019-12-20 10:31:03 UTC (rev 253811)
@@ -87,7 +87,7 @@
return CBORValue(WTFMove(cborDescriptorMap));
}
-Vector<uint8_t> encodeMakeCredenitalRequestAsCBOR(const Vector<uint8_t>& hash, const PublicKeyCredentialCreationOptions& options, UVAvailability uvCapability)
+Vector<uint8_t> encodeMakeCredenitalRequestAsCBOR(const Vector<uint8_t>& hash, const PublicKeyCredentialCreationOptions& options, UVAvailability uvCapability, Optional<PinParameters> pin)
{
CBORValue::MapValue cborMap;
cborMap[CBORValue(1)] = CBORValue(hash);
@@ -124,6 +124,12 @@
if (!optionMap.empty())
cborMap[CBORValue(7)] = CBORValue(WTFMove(optionMap));
+ if (pin) {
+ ASSERT(pin->protocol >= 0);
+ cborMap[CBORValue(8)] = CBORValue(pin->protocol);
+ cborMap[CBORValue(9)] = CBORValue(WTFMove(pin->auth));
+ }
+
auto serializedParam = CBORWriter::write(CBORValue(WTFMove(cborMap)));
ASSERT(serializedParam);
@@ -132,7 +138,7 @@
return cborRequest;
}
-Vector<uint8_t> encodeGetAssertionRequestAsCBOR(const Vector<uint8_t>& hash, const PublicKeyCredentialRequestOptions& options, UVAvailability uvCapability)
+Vector<uint8_t> encodeGetAssertionRequestAsCBOR(const Vector<uint8_t>& hash, const PublicKeyCredentialRequestOptions& options, UVAvailability uvCapability, Optional<PinParameters> pin)
{
CBORValue::MapValue cborMap;
cborMap[CBORValue(1)] = CBORValue(options.rpId);
@@ -164,6 +170,12 @@
if (!optionMap.empty())
cborMap[CBORValue(5)] = CBORValue(WTFMove(optionMap));
+ if (pin) {
+ ASSERT(pin->protocol >= 0);
+ cborMap[CBORValue(8)] = CBORValue(pin->protocol);
+ cborMap[CBORValue(9)] = CBORValue(WTFMove(pin->auth));
+ }
+
auto serializedParam = CBORWriter::write(CBORValue(WTFMove(cborMap)));
ASSERT(serializedParam);
Modified: trunk/Source/WebCore/Modules/webauthn/fido/DeviceRequestConverter.h (253810 => 253811)
--- trunk/Source/WebCore/Modules/webauthn/fido/DeviceRequestConverter.h 2019-12-20 03:32:37 UTC (rev 253810)
+++ trunk/Source/WebCore/Modules/webauthn/fido/DeviceRequestConverter.h 2019-12-20 10:31:03 UTC (rev 253811)
@@ -42,15 +42,20 @@
namespace fido {
+struct PinParameters {
+ int protocol;
+ Vector<uint8_t> auth;
+};
+
// Serializes MakeCredential request parameter into CBOR encoded map with
// integer keys and CBOR encoded values as defined by the CTAP spec.
// https://fidoalliance.org/specs/fido-v2.0-ps-20170927/fido-client-to-authenticator-protocol-v2.0-ps-20170927.html#authenticatorMakeCredential
-WEBCORE_EXPORT Vector<uint8_t> encodeMakeCredenitalRequestAsCBOR(const Vector<uint8_t>& hash, const WebCore::PublicKeyCredentialCreationOptions&, AuthenticatorSupportedOptions::UserVerificationAvailability);
+WEBCORE_EXPORT Vector<uint8_t> encodeMakeCredenitalRequestAsCBOR(const Vector<uint8_t>& hash, const WebCore::PublicKeyCredentialCreationOptions&, AuthenticatorSupportedOptions::UserVerificationAvailability, Optional<PinParameters> pin = WTF::nullopt);
// Serializes GetAssertion request parameter into CBOR encoded map with
// integer keys and CBOR encoded values as defined by the CTAP spec.
// https://fidoalliance.org/specs/fido-v2.0-ps-20170927/fido-client-to-authenticator-protocol-v2.0-ps-20170927.html#authenticatorGetAssertion
-WEBCORE_EXPORT Vector<uint8_t> encodeGetAssertionRequestAsCBOR(const Vector<uint8_t>& hash, const WebCore::PublicKeyCredentialRequestOptions&, AuthenticatorSupportedOptions::UserVerificationAvailability);
+WEBCORE_EXPORT Vector<uint8_t> encodeGetAssertionRequestAsCBOR(const Vector<uint8_t>& hash, const WebCore::PublicKeyCredentialRequestOptions&, AuthenticatorSupportedOptions::UserVerificationAvailability, Optional<PinParameters> pin = WTF::nullopt);
// Represents CTAP requests with empty parameters, including
// AuthenticatorGetInfo, AuthenticatorReset and AuthenticatorGetNextAssertion commands.
Added: trunk/Source/WebCore/Modules/webauthn/fido/Pin.cpp (0 => 253811)
--- trunk/Source/WebCore/Modules/webauthn/fido/Pin.cpp (rev 0)
+++ trunk/Source/WebCore/Modules/webauthn/fido/Pin.cpp 2019-12-20 10:31:03 UTC (rev 253811)
@@ -0,0 +1,317 @@
+// Copyright 2019 The Chromium Authors. All rights reserved.
+// Copyright (C) 2019 Apple Inc. All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+#include "config.h"
+#include "Pin.h"
+
+#if ENABLE(WEB_AUTHN)
+
+#include "CBORReader.h"
+#include "CBORWriter.h"
+#include "CryptoAlgorithmAES_CBC.h"
+#include "CryptoAlgorithmAesCbcCfbParams.h"
+#include "CryptoAlgorithmECDH.h"
+#include "CryptoAlgorithmHMAC.h"
+#include "CryptoKeyAES.h"
+#include "CryptoKeyEC.h"
+#include "CryptoKeyHMAC.h"
+#include <pal/crypto/CryptoDigest.h>
+
+namespace fido {
+namespace pin {
+using namespace cbor;
+
+// hasAtLeastFourCodepoints returns true if |pin| contains
+// four or more code points. This reflects the "4 Unicode characters"
+// requirement in CTAP2.
+static bool hasAtLeastFourCodepoints(const String& pin)
+{
+ return pin.length() >= 4;
+}
+
+// makePinAuth returns `LEFT(HMAC-SHA-256(secret, data), 16)`.
+static Vector<uint8_t> makePinAuth(const CryptoKeyHMAC& key, const Vector<uint8_t>& data)
+{
+ auto result = CryptoAlgorithmHMAC::platformSign(key, data);
+ ASSERT(!result.hasException());
+ auto pinAuth = result.releaseReturnValue();
+ pinAuth.shrink(16);
+ return pinAuth;
+}
+
+Vector<uint8_t> encodeRawPublicKey(const Vector<uint8_t>& x, const Vector<uint8_t>& y)
+{
+ Vector<uint8_t> rawKey;
+ rawKey.reserveCapacity(1 + x.size() + y.size());
+ rawKey.append(0x04);
+ rawKey.appendVector(x);
+ rawKey.appendVector(y);
+ return rawKey;
+}
+
+Optional<CString> validateAndConvertToUTF8(const String& pin)
+{
+ if (!hasAtLeastFourCodepoints(pin))
+ return WTF::nullopt;
+ auto result = pin.utf8();
+ if (result.length() < kMinBytes || result.length() > kMaxBytes)
+ return WTF::nullopt;
+ return result;
+}
+
+// encodePINCommand returns a CTAP2 PIN command for the operation |subcommand|.
+// Additional elements of the top-level CBOR map can be added with the optional
+// |addAdditional| callback.
+static Vector<uint8_t> encodePinCommand(Subcommand subcommand, Function<void(CBORValue::MapValue*)> addAdditional = nullptr)
+{
+ CBORValue::MapValue map;
+ map.emplace(static_cast<int64_t>(RequestKey::kProtocol), kProtocolVersion);
+ map.emplace(static_cast<int64_t>(RequestKey::kSubcommand), static_cast<int64_t>(subcommand));
+
+ if (addAdditional)
+ addAdditional(&map);
+
+ // FIXME(205375)
+ auto serializedParam = CBORWriter::write(CBORValue(WTFMove(map)));
+ ASSERT(serializedParam);
+
+ Vector<uint8_t> cborRequest({ static_cast<uint8_t>(CtapRequestCommand::kAuthenticatorClientPin) });
+ cborRequest.appendVector(*serializedParam);
+ return cborRequest;
+}
+
+RetriesResponse::RetriesResponse() = default;
+
+Optional<RetriesResponse> RetriesResponse::parse(const Vector<uint8_t>& inBuffer)
+{
+ // FIXME(205375)
+ if (inBuffer.size() <= kResponseCodeLength || getResponseCode(inBuffer) != CtapDeviceResponseCode::kSuccess)
+ return WTF::nullopt;
+
+ Vector<uint8_t> buffer;
+ buffer.append(inBuffer.data() + 1, inBuffer.size() - 1);
+ Optional<CBOR> decodedResponse = cbor::CBORReader::read(buffer);
+ if (!decodedResponse || !decodedResponse->isMap())
+ return WTF::nullopt;
+ const auto& responseMap = decodedResponse->getMap();
+
+ auto it = responseMap.find(CBORValue(static_cast<int64_t>(ResponseKey::kRetries)));
+ if (it == responseMap.end() || !it->second.isUnsigned())
+ return WTF::nullopt;
+
+ RetriesResponse ret;
+ ret.retries = static_cast<int64_t>(it->second.getUnsigned());
+ return ret;
+}
+
+KeyAgreementResponse::KeyAgreementResponse(Ref<CryptoKeyEC>&& peerKey)
+ : peerKey(WTFMove(peerKey))
+{
+}
+
+Optional<KeyAgreementResponse> KeyAgreementResponse::parse(const Vector<uint8_t>& inBuffer)
+{
+ // FIXME(205375)
+ if (inBuffer.size() <= kResponseCodeLength || getResponseCode(inBuffer) != CtapDeviceResponseCode::kSuccess)
+ return WTF::nullopt;
+
+ Vector<uint8_t> buffer;
+ buffer.append(inBuffer.data() + 1, inBuffer.size() - 1);
+ auto decodedResponse = cbor::CBORReader::read(buffer);
+ if (!decodedResponse || !decodedResponse->isMap())
+ return WTF::nullopt;
+ const auto& responseMap = decodedResponse->getMap();
+
+ // The ephemeral key is encoded as a COSE structure.
+ auto it = responseMap.find(CBORValue(static_cast<int64_t>(ResponseKey::kKeyAgreement)));
+ if (it == responseMap.end() || !it->second.isMap())
+ return WTF::nullopt;
+ const auto& coseKey = it->second.getMap();
+
+ return parseFromCOSE(coseKey);
+}
+
+Optional<KeyAgreementResponse> KeyAgreementResponse::parseFromCOSE(const CBORValue::MapValue& coseKey)
+{
+ // The COSE key must be a P-256 point. See
+ // https://tools.ietf.org/html/rfc8152#section-7.1
+ for (const auto& pair : Vector<std::pair<int64_t, int64_t>>({
+ { static_cast<int64_t>(COSE::kty), static_cast<int64_t>(COSE::EC2) },
+ { static_cast<int64_t>(COSE::alg), static_cast<int64_t>(COSE::ECDH256) },
+ { static_cast<int64_t>(COSE::crv), static_cast<int64_t>(COSE::P_256) },
+ })) {
+ auto it = coseKey.find(CBORValue(pair.first));
+ if (it == coseKey.end() || !it->second.isInteger() || it->second.getInteger() != pair.second)
+ return WTF::nullopt;
+ }
+
+ // See https://tools.ietf.org/html/rfc8152#section-13.1.1
+ const auto& xIt = coseKey.find(CBORValue(static_cast<int64_t>(COSE::x)));
+ const auto& yIt = coseKey.find(CBORValue(static_cast<int64_t>(COSE::y)));
+ if (xIt == coseKey.end() || yIt == coseKey.end() || !xIt->second.isByteString() || !yIt->second.isByteString())
+ return WTF::nullopt;
+
+ const auto& x = xIt->second.getByteString();
+ const auto& y = yIt->second.getByteString();
+ auto peerKey = CryptoKeyEC::importRaw(CryptoAlgorithmIdentifier::ECDH, "P-256", encodeRawPublicKey(x, y), true, CryptoKeyUsageDeriveBits);
+ if (!peerKey)
+ return WTF::nullopt;
+
+ return KeyAgreementResponse(peerKey.releaseNonNull());
+}
+
+cbor::CBORValue::MapValue encodeCOSEPublicKey(const Vector<uint8_t>& rawPublicKey)
+{
+ ASSERT(rawPublicKey.size() == 65);
+ Vector<uint8_t> x;
+ x.append(rawPublicKey.data() + 1, ES256FieldElementLength);
+ Vector<uint8_t> y;
+ y.append(rawPublicKey.data() + 1 + ES256FieldElementLength, ES256FieldElementLength);
+
+ cbor::CBORValue::MapValue publicKeyMap;
+ publicKeyMap[cbor::CBORValue(COSE::kty)] = cbor::CBORValue(COSE::EC2);
+ publicKeyMap[cbor::CBORValue(COSE::alg)] = cbor::CBORValue(COSE::ECDH256);
+ publicKeyMap[cbor::CBORValue(COSE::crv)] = cbor::CBORValue(COSE::P_256);
+ publicKeyMap[cbor::CBORValue(COSE::x)] = cbor::CBORValue(WTFMove(x));
+ publicKeyMap[cbor::CBORValue(COSE::y)] = cbor::CBORValue(WTFMove(y));
+
+ return publicKeyMap;
+}
+
+TokenResponse::TokenResponse(Ref<WebCore::CryptoKeyHMAC>&& token)
+ : m_token(WTFMove(token))
+{
+}
+
+Optional<TokenResponse> TokenResponse::parse(const WebCore::CryptoKeyAES& sharedKey, const Vector<uint8_t>& inBuffer)
+{
+ // FIXME(205375)
+ if (inBuffer.size() <= kResponseCodeLength || getResponseCode(inBuffer) != CtapDeviceResponseCode::kSuccess)
+ return WTF::nullopt;
+
+ Vector<uint8_t> buffer;
+ buffer.append(inBuffer.data() + 1, inBuffer.size() - 1);
+ auto decodedResponse = cbor::CBORReader::read(buffer);
+ if (!decodedResponse || !decodedResponse->isMap())
+ return WTF::nullopt;
+ const auto& responseMap = decodedResponse->getMap();
+
+ auto it = responseMap.find(CBORValue(static_cast<int64_t>(ResponseKey::kPinToken)));
+ if (it == responseMap.end() || !it->second.isByteString())
+ return WTF::nullopt;
+ const auto& encryptedToken = it->second.getByteString();
+
+ auto tokenResult = CryptoAlgorithmAES_CBC::platformDecrypt({ }, sharedKey, encryptedToken);
+ if (tokenResult.hasException())
+ return WTF::nullopt;
+ auto token = tokenResult.releaseReturnValue();
+
+ auto tokenKey = CryptoKeyHMAC::importRaw(token.size() * 8, CryptoAlgorithmIdentifier::SHA_256, WTFMove(token), true, CryptoKeyUsageSign);
+ ASSERT(tokenKey);
+
+ return TokenResponse(tokenKey.releaseNonNull());
+}
+
+Vector<uint8_t> TokenResponse::pinAuth(const Vector<uint8_t>& clientDataHash) const
+{
+ return makePinAuth(m_token, clientDataHash);
+}
+
+const Vector<uint8_t>& TokenResponse::token() const
+{
+ return m_token->key();
+}
+
+Vector<uint8_t> encodeAsCBOR(const RetriesRequest&)
+{
+ return encodePinCommand(Subcommand::kGetRetries);
+}
+
+Vector<uint8_t> encodeAsCBOR(const KeyAgreementRequest&)
+{
+ return encodePinCommand(Subcommand::kGetKeyAgreement);
+}
+
+Optional<TokenRequest> TokenRequest::tryCreate(const CString& pin, const CryptoKeyEC& peerKey)
+{
+ // The following implements Section 5.5.4 Getting sharedSecret from Authenticator.
+ // https://fidoalliance.org/specs/fido-v2.0-ps-20190130/fido-client-to-authenticator-protocol-v2.0-ps-20190130.html#gettingSharedSecret
+ // 1. Generate a P256 key pair.
+ auto keyPairResult = CryptoKeyEC::generatePair(CryptoAlgorithmIdentifier::ECDH, "P-256", true, CryptoKeyUsageDeriveBits);
+ ASSERT(!keyPairResult.hasException());
+ auto keyPair = keyPairResult.releaseReturnValue();
+
+ // 2. Use ECDH to compute the shared AES-CBC key.
+ auto sharedKeyResult = CryptoAlgorithmECDH::platformDeriveBits(downcast<CryptoKeyEC>(*keyPair.privateKey), peerKey);
+ if (!sharedKeyResult)
+ return WTF::nullopt;
+ auto sharedKey = CryptoKeyAES::importRaw(CryptoAlgorithmIdentifier::AES_CBC, WTFMove(*sharedKeyResult), true, CryptoKeyUsageEncrypt | CryptoKeyUsageDecrypt);
+ ASSERT(sharedKey);
+
+ // The following encodes the public key of the above key pair into COSE format.
+ auto rawPublicKeyResult = downcast<CryptoKeyEC>(*keyPair.publicKey).exportRaw();
+ ASSERT(!rawPublicKeyResult.hasException());
+ auto coseKey = encodeCOSEPublicKey(rawPublicKeyResult.returnValue());
+
+ // The following calculates a SHA-256 digest of the PIN, and shrink to the left 16 bytes.
+ auto crypto = PAL::CryptoDigest::create(PAL::CryptoDigest::Algorithm::SHA_256);
+ crypto->addBytes(pin.data(), pin.length());
+ auto pinHash = crypto->computeHash();
+ pinHash.shrink(16);
+
+ return TokenRequest(sharedKey.releaseNonNull(), WTFMove(coseKey), WTFMove(pinHash));
+}
+
+TokenRequest::TokenRequest(Ref<WebCore::CryptoKeyAES>&& sharedKey, cbor::CBORValue::MapValue&& coseKey, Vector<uint8_t>&& pinHash)
+ : m_sharedKey(WTFMove(sharedKey))
+ , m_coseKey(WTFMove(coseKey))
+ , m_pinHash(WTFMove(pinHash))
+{
+}
+
+const CryptoKeyAES& TokenRequest::sharedKey() const
+{
+ return m_sharedKey;
+}
+
+Vector<uint8_t> encodeAsCBOR(const TokenRequest& request)
+{
+ auto result = CryptoAlgorithmAES_CBC::platformEncrypt({ }, request.sharedKey(), request.m_pinHash);
+ ASSERT(!result.hasException());
+
+ return encodePinCommand(Subcommand::kGetPinToken, [coseKey = WTFMove(request.m_coseKey), encryptedPin = result.releaseReturnValue()] (CBORValue::MapValue* map) mutable {
+ map->emplace(static_cast<int64_t>(RequestKey::kKeyAgreement), WTFMove(coseKey));
+ map->emplace(static_cast<int64_t>(RequestKey::kPinHashEnc), WTFMove(encryptedPin));
+ });
+}
+
+} // namespace pin
+} // namespace fido
+
+#endif // ENABLE(WEB_AUTHN)
Added: trunk/Source/WebCore/Modules/webauthn/fido/Pin.h (0 => 253811)
--- trunk/Source/WebCore/Modules/webauthn/fido/Pin.h (rev 0)
+++ trunk/Source/WebCore/Modules/webauthn/fido/Pin.h 2019-12-20 10:31:03 UTC (rev 253811)
@@ -0,0 +1,187 @@
+// Copyright 2019 The Chromium Authors. All rights reserved.
+// Copyright (C) 2019 Apple Inc. All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+// This file contains structures to implement the CTAP2 PIN protocol, version
+// one. See
+// https://fidoalliance.org/specs/fido-v2.0-rd-20180702/fido-client-to-authenticator-protocol-v2.0-rd-20180702.html#authenticatorClientPIN
+
+#pragma once
+
+#if ENABLE(WEB_AUTHN)
+
+#include "CBORValue.h"
+#include "FidoConstants.h"
+
+namespace WebCore {
+class CryptoKeyAES;
+class CryptoKeyEC;
+class CryptoKeyHMAC;
+}
+
+namespace fido {
+namespace pin {
+
+// Subcommand enumerates the subcommands to the main |authenticatorClientPIN|
+// command. See
+// https://fidoalliance.org/specs/fido-v2.0-rd-20180702/fido-client-to-authenticator-protocol-v2.0-rd-20180702.html#authenticatorClientPIN
+enum class Subcommand : uint8_t {
+ kGetRetries = 0x01,
+ kGetKeyAgreement = 0x02,
+ kSetPin = 0x03,
+ kChangePin = 0x04,
+ kGetPinToken = 0x05,
+};
+
+// RequestKey enumerates the keys in the top-level CBOR map for all PIN
+// commands.
+enum class RequestKey : uint8_t {
+ kProtocol = 1,
+ kSubcommand = 2,
+ kKeyAgreement = 3,
+ kPinAuth = 4,
+ kNewPinEnc = 5,
+ kPinHashEnc = 6,
+};
+
+// ResponseKey enumerates the keys in the top-level CBOR map for all PIN
+// responses.
+enum class ResponseKey : uint8_t {
+ kKeyAgreement = 1,
+ kPinToken = 2,
+ kRetries = 3,
+};
+
+// kProtocolVersion is the version of the PIN protocol that this code
+// implements.
+constexpr int kProtocolVersion = 1;
+
+// encodeCOSEPublicKey takes a raw ECDH256 public key and returns it as a COSE structure.
+WEBCORE_EXPORT cbor::CBORValue::MapValue encodeCOSEPublicKey(const Vector<uint8_t>& key);
+
+// encodeRawPublicKey takes X & Y and returns them as a 0x04 || X || Y byte array.
+WEBCORE_EXPORT Vector<uint8_t> encodeRawPublicKey(const Vector<uint8_t>& X, const Vector<uint8_t>& Y);
+
+// validateAndConvertToUTF8 convert the input to a UTF8 CString if it is a syntactically valid PIN.
+WEBCORE_EXPORT Optional<CString> validateAndConvertToUTF8(const String& pin);
+
+// kMinBytes is the minimum number of *bytes* of PIN data that a CTAP2 device
+// will accept. Since the PIN is UTF-8 encoded, this could be a single code
+// point. However, the platform is supposed to additionally enforce a 4
+// *character* minimum
+constexpr size_t kMinBytes = 4;
+// kMaxBytes is the maximum number of bytes of PIN data that a CTAP2 device will
+// accept.
+constexpr size_t kMaxBytes = 63;
+
+// RetriesRequest asks an authenticator for the number of remaining PIN attempts
+// before the device is locked.
+struct RetriesRequest {
+};
+
+// RetriesResponse reflects an authenticator's response to a |RetriesRequest|.
+struct RetriesResponse {
+ WEBCORE_EXPORT static Optional<RetriesResponse> parse(const Vector<uint8_t>&);
+
+ // retries is the number of PIN attempts remaining before the authenticator
+ // locks.
+ int retries;
+
+private:
+ RetriesResponse();
+};
+
+// KeyAgreementRequest asks an authenticator for an ephemeral ECDH key for
+// encrypting PIN material in future requests.
+struct KeyAgreementRequest {
+};
+
+// KeyAgreementResponse reflects an authenticator's response to a
+// |KeyAgreementRequest| and is also used as representation of the
+// authenticator's ephemeral key.
+struct KeyAgreementResponse {
+ WEBCORE_EXPORT static Optional<KeyAgreementResponse> parse(const Vector<uint8_t>&);
+ WEBCORE_EXPORT static Optional<KeyAgreementResponse> parseFromCOSE(const cbor::CBORValue::MapValue&);
+
+ Ref<WebCore::CryptoKeyEC> peerKey;
+
+private:
+ explicit KeyAgreementResponse(Ref<WebCore::CryptoKeyEC>&&);
+};
+
+// TokenRequest requests a pin-token from an authenticator. These tokens can be
+// used to show user-verification in other operations, e.g. when getting an
+// assertion.
+class TokenRequest {
+ WTF_MAKE_NONCOPYABLE(TokenRequest);
+public:
+ WEBCORE_EXPORT static Optional<TokenRequest> tryCreate(const CString& pin, const WebCore::CryptoKeyEC&);
+ TokenRequest(TokenRequest&&) = default;
+
+ // sharedKey returns the shared ECDH key that was used to encrypt the PIN.
+ // This is needed to decrypt the response.
+ const WebCore::CryptoKeyAES& sharedKey() const;
+
+ friend Vector<uint8_t> encodeAsCBOR(const TokenRequest&);
+
+private:
+ TokenRequest(Ref<WebCore::CryptoKeyAES>&& sharedKey, cbor::CBORValue::MapValue&& coseKey, Vector<uint8_t>&& pinHash);
+
+ Ref<WebCore::CryptoKeyAES> m_sharedKey;
+ mutable cbor::CBORValue::MapValue m_coseKey;
+ Vector<uint8_t> m_pinHash; // Only the left 16 bytes are kept.
+};
+
+// TokenResponse represents the response to a pin-token request. In order to
+// decrypt a response, the shared key from the request is needed. Once a pin-
+// token has been decrypted, it can be used to calculate the pinAuth parameters
+// needed to show user-verification in future operations.
+class TokenResponse {
+public:
+ WEBCORE_EXPORT static Optional<TokenResponse> parse(const WebCore::CryptoKeyAES& sharedKey, const Vector<uint8_t>& inBuffer);
+
+ // pinAuth returns a pinAuth parameter for a request that will use the given
+ // client-data hash.
+ WEBCORE_EXPORT Vector<uint8_t> pinAuth(const Vector<uint8_t>& clientDataHash) const;
+
+ WEBCORE_EXPORT const Vector<uint8_t>& token() const;
+
+private:
+ explicit TokenResponse(Ref<WebCore::CryptoKeyHMAC>&&);
+
+ Ref<WebCore::CryptoKeyHMAC> m_token;
+};
+
+WEBCORE_EXPORT Vector<uint8_t> encodeAsCBOR(const RetriesRequest&);
+WEBCORE_EXPORT Vector<uint8_t> encodeAsCBOR(const KeyAgreementRequest&);
+WEBCORE_EXPORT Vector<uint8_t> encodeAsCBOR(const TokenRequest&);
+
+} // namespace pin
+} // namespace fido
+
+#endif // ENABLE(WEB_AUTHN)
Modified: trunk/Source/WebCore/Sources.txt (253810 => 253811)
--- trunk/Source/WebCore/Sources.txt 2019-12-20 03:32:37 UTC (rev 253810)
+++ trunk/Source/WebCore/Sources.txt 2019-12-20 10:31:03 UTC (rev 253811)
@@ -286,6 +286,7 @@
Modules/webauthn/fido/FidoHidMessage.cpp
Modules/webauthn/fido/FidoHidPacket.cpp
Modules/webauthn/fido/FidoParsingUtils.cpp
+Modules/webauthn/fido/Pin.cpp
Modules/webauthn/fido/U2fCommandConstructor.cpp
Modules/webauthn/fido/U2fResponseConverter.cpp
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (253810 => 253811)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2019-12-20 03:32:37 UTC (rev 253810)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2019-12-20 10:31:03 UTC (rev 253811)
@@ -1764,9 +1764,10 @@
57156114234C7FD6008FC7AB /* JSMockWebAuthenticationConfiguration.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 57156111234C7FBC008FC7AB /* JSMockWebAuthenticationConfiguration.cpp */; };
57156115234C7FDC008FC7AB /* JSMockWebAuthenticationConfiguration.h in Headers */ = {isa = PBXBuildFile; fileRef = 57156110234C7FBC008FC7AB /* JSMockWebAuthenticationConfiguration.h */; };
571F21891DA57C54005C9EFD /* JSSubtleCrypto.h in Headers */ = {isa = PBXBuildFile; fileRef = 571F21881DA57C54005C9EFD /* JSSubtleCrypto.h */; };
- 572093D31DDCEB9A00310AB0 /* CryptoAlgorithmAesCbcCfbParams.h in Headers */ = {isa = PBXBuildFile; fileRef = 572093D21DDCEB9A00310AB0 /* CryptoAlgorithmAesCbcCfbParams.h */; };
+ 572093D31DDCEB9A00310AB0 /* CryptoAlgorithmAesCbcCfbParams.h in Headers */ = {isa = PBXBuildFile; fileRef = 572093D21DDCEB9A00310AB0 /* CryptoAlgorithmAesCbcCfbParams.h */; settings = {ATTRIBUTES = (Private, ); }; };
5721A9871ECE53B10081295A /* CryptoDigestAlgorithm.h in Headers */ = {isa = PBXBuildFile; fileRef = 5721A9861ECE53B10081295A /* CryptoDigestAlgorithm.h */; };
5721A98B1ECE57040081295A /* CryptoAlgorithmRsaPssParams.h in Headers */ = {isa = PBXBuildFile; fileRef = 5721A9881ECE57040081295A /* CryptoAlgorithmRsaPssParams.h */; };
+ 572576D623A8872B00909540 /* CryptoKeyFormat.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C9ACAC91F40B96A00F3AA09 /* CryptoKeyFormat.h */; settings = {ATTRIBUTES = (Private, ); }; };
572A7F211C6E5719009C6149 /* SimulatedClick.h in Headers */ = {isa = PBXBuildFile; fileRef = 572A7F201C6E5719009C6149 /* SimulatedClick.h */; };
572B401F21757A64000AD43E /* DeviceRequestConverter.h in Headers */ = {isa = PBXBuildFile; fileRef = 572B401D21757A64000AD43E /* DeviceRequestConverter.h */; settings = {ATTRIBUTES = (Private, ); }; };
572B402C21769020000AD43E /* JSUserVerificationRequirement.h in Headers */ = {isa = PBXBuildFile; fileRef = 572B402A2176901F000AD43E /* JSUserVerificationRequirement.h */; };
@@ -1793,18 +1794,19 @@
57303C2C2009B4A800355965 /* AuthenticatorAssertionResponse.h in Headers */ = {isa = PBXBuildFile; fileRef = 57303C272009B2FC00355965 /* AuthenticatorAssertionResponse.h */; settings = {ATTRIBUTES = (Private, ); }; };
57303C2F2009B7E100355965 /* JSAuthenticatorAssertionResponse.h in Headers */ = {isa = PBXBuildFile; fileRef = 57303C2D2009B7D900355965 /* JSAuthenticatorAssertionResponse.h */; };
57303C4620105D2F00355965 /* AuthenticatorCoordinator.h in Headers */ = {isa = PBXBuildFile; fileRef = 57303C4320105B3D00355965 /* AuthenticatorCoordinator.h */; settings = {ATTRIBUTES = (Private, ); }; };
- 573489391DAC6B6E00DC0667 /* CryptoAlgorithmParameters.h in Headers */ = {isa = PBXBuildFile; fileRef = 573489381DAC6B6D00DC0667 /* CryptoAlgorithmParameters.h */; };
+ 573489391DAC6B6E00DC0667 /* CryptoAlgorithmParameters.h in Headers */ = {isa = PBXBuildFile; fileRef = 573489381DAC6B6D00DC0667 /* CryptoAlgorithmParameters.h */; settings = {ATTRIBUTES = (Private, ); }; };
5739E12F1DAC7F7800E14383 /* JSCryptoAlgorithmParameters.h in Headers */ = {isa = PBXBuildFile; fileRef = 5739E12E1DAC7F7800E14383 /* JSCryptoAlgorithmParameters.h */; };
573F5332216806E10045587A /* FidoHidMessage.h in Headers */ = {isa = PBXBuildFile; fileRef = 57BAF28A2167D303008E954E /* FidoHidMessage.h */; settings = {ATTRIBUTES = (Private, ); }; };
573F533721680D150045587A /* FidoParsingUtils.h in Headers */ = {isa = PBXBuildFile; fileRef = 573F533521680D140045587A /* FidoParsingUtils.h */; settings = {ATTRIBUTES = (Private, ); }; };
574F55E1204F3B23002948C6 /* WebAuthenticationConstants.h in Headers */ = {isa = PBXBuildFile; fileRef = 574F55DC204F3732002948C6 /* WebAuthenticationConstants.h */; settings = {ATTRIBUTES = (Private, ); }; };
- 5750A9751E68D00000705C4A /* CryptoKeyEC.h in Headers */ = {isa = PBXBuildFile; fileRef = 5750A9731E68D00000705C4A /* CryptoKeyEC.h */; };
+ 5750A9751E68D00000705C4A /* CryptoKeyEC.h in Headers */ = {isa = PBXBuildFile; fileRef = 5750A9731E68D00000705C4A /* CryptoKeyEC.h */; settings = {ATTRIBUTES = (Private, ); }; };
5750A97E1E6A13EF00705C4A /* CryptoAlgorithmEcKeyParams.h in Headers */ = {isa = PBXBuildFile; fileRef = 5750A97D1E6A13EF00705C4A /* CryptoAlgorithmEcKeyParams.h */; };
5750A9821E6A150800705C4A /* JSEcKeyParams.h in Headers */ = {isa = PBXBuildFile; fileRef = 5750A9801E6A150800705C4A /* JSEcKeyParams.h */; };
- 5750A9871E6A216800705C4A /* CryptoAlgorithmECDH.h in Headers */ = {isa = PBXBuildFile; fileRef = 5750A9851E6A216800705C4A /* CryptoAlgorithmECDH.h */; };
+ 5750A9871E6A216800705C4A /* CryptoAlgorithmECDH.h in Headers */ = {isa = PBXBuildFile; fileRef = 5750A9851E6A216800705C4A /* CryptoAlgorithmECDH.h */; settings = {ATTRIBUTES = (Private, ); }; };
5754719F1ECE628300DD63B2 /* JSRsaPssParams.h in Headers */ = {isa = PBXBuildFile; fileRef = 575471991ECE5D2A00DD63B2 /* JSRsaPssParams.h */; };
57585961239F124D00C74572 /* JSAuthenticationExtensionsClientOutputs.h in Headers */ = {isa = PBXBuildFile; fileRef = 5758595E239F117300C74572 /* JSAuthenticationExtensionsClientOutputs.h */; };
5758596C239F321C00C74572 /* AuthenticationExtensionsClientOutputs.h in Headers */ = {isa = PBXBuildFile; fileRef = 57585965239F14CC00C74572 /* AuthenticationExtensionsClientOutputs.h */; settings = {ATTRIBUTES = (Private, ); }; };
+ 5758597C23A1FCF300C74572 /* Pin.h in Headers */ = {isa = PBXBuildFile; fileRef = 5758597923A1FCF200C74572 /* Pin.h */; settings = {ATTRIBUTES = (Private, ); }; };
5760827220215A5500116678 /* AuthenticatorCoordinatorClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 576082702021513F00116678 /* AuthenticatorCoordinatorClient.h */; settings = {ATTRIBUTES = (Private, ); }; };
5768142A1E6F99C100E77754 /* CryptoAlgorithmEcdhKeyDeriveParams.h in Headers */ = {isa = PBXBuildFile; fileRef = 576814291E6F99C100E77754 /* CryptoAlgorithmEcdhKeyDeriveParams.h */; };
576814411E709FA400E77754 /* JSEcdhKeyDeriveParams.h in Headers */ = {isa = PBXBuildFile; fileRef = 5768143E1E709C3600E77754 /* JSEcdhKeyDeriveParams.h */; };
@@ -1840,8 +1842,8 @@
57E1E5AD1E8DD09B00EE37C9 /* JSAesCtrParams.h in Headers */ = {isa = PBXBuildFile; fileRef = 57E1E5AB1E8DD09B00EE37C9 /* JSAesCtrParams.h */; };
57E2335B1DC7D5E500F28D01 /* JSJsonWebKey.h in Headers */ = {isa = PBXBuildFile; fileRef = 57E2335A1DC7D5E500F28D01 /* JSJsonWebKey.h */; };
57E2335D1DC7D60800F28D01 /* JSRsaOtherPrimesInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = 57E2335C1DC7D60800F28D01 /* JSRsaOtherPrimesInfo.h */; };
- 57E233631DC7DA2400F28D01 /* RsaOtherPrimesInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = 57E233621DC7DA2400F28D01 /* RsaOtherPrimesInfo.h */; };
- 57E233651DC7DB1F00F28D01 /* JsonWebKey.h in Headers */ = {isa = PBXBuildFile; fileRef = 57E233641DC7DB1F00F28D01 /* JsonWebKey.h */; };
+ 57E233631DC7DA2400F28D01 /* RsaOtherPrimesInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = 57E233621DC7DA2400F28D01 /* RsaOtherPrimesInfo.h */; settings = {ATTRIBUTES = (Private, ); }; };
+ 57E233651DC7DB1F00F28D01 /* JsonWebKey.h in Headers */ = {isa = PBXBuildFile; fileRef = 57E233641DC7DB1F00F28D01 /* JsonWebKey.h */; settings = {ATTRIBUTES = (Private, ); }; };
57E233671DCAB21C00F28D01 /* JSHmacKeyParams.h in Headers */ = {isa = PBXBuildFile; fileRef = 57E233661DCAB21C00F28D01 /* JSHmacKeyParams.h */; };
57E2336E1DCD43FD00F28D01 /* CryptoAlgorithmRsaHashedImportParams.h in Headers */ = {isa = PBXBuildFile; fileRef = 57E2336D1DCD43FD00F28D01 /* CryptoAlgorithmRsaHashedImportParams.h */; };
57E233711DCD468F00F28D01 /* JSRsaHashedImportParams.h in Headers */ = {isa = PBXBuildFile; fileRef = 57E233701DCD468F00F28D01 /* JSRsaHashedImportParams.h */; };
@@ -2299,12 +2301,12 @@
7C8E34C71E4A33B00054CE23 /* JSDOMConvertXPathNSResolver.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C8E34AC1E4A338E0054CE23 /* JSDOMConvertXPathNSResolver.h */; settings = {ATTRIBUTES = (Private, ); }; };
7C93F34A1AA6BA5E00A98BAB /* CompiledContentExtension.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C93F3481AA6BA5E00A98BAB /* CompiledContentExtension.h */; settings = {ATTRIBUTES = (Private, ); }; };
7C93F34E1AA6BF0700A98BAB /* ContentExtensionCompiler.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C93F34C1AA6BF0700A98BAB /* ContentExtensionCompiler.h */; settings = {ATTRIBUTES = (Private, ); }; };
- 7C9ACA921F3CC0AA00F3AA09 /* CryptoKeyAlgorithm.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C9ACA8F1F3CC0AA00F3AA09 /* CryptoKeyAlgorithm.h */; };
- 7C9ACA981F3CCDAD00F3AA09 /* CryptoAesKeyAlgorithm.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C9ACA961F3CCDAD00F3AA09 /* CryptoAesKeyAlgorithm.h */; };
- 7C9ACA9C1F3CCDF200F3AA09 /* CryptoEcKeyAlgorithm.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C9ACA9A1F3CCDF200F3AA09 /* CryptoEcKeyAlgorithm.h */; };
- 7C9ACAA01F3CCE3000F3AA09 /* CryptoHmacKeyAlgorithm.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C9ACA9E1F3CCE3000F3AA09 /* CryptoHmacKeyAlgorithm.h */; };
- 7C9ACAA41F3CCE6900F3AA09 /* CryptoRsaKeyAlgorithm.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C9ACAA21F3CCE6900F3AA09 /* CryptoRsaKeyAlgorithm.h */; };
- 7C9ACAA81F3CCEB400F3AA09 /* CryptoRsaHashedKeyAlgorithm.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C9ACAA61F3CCEB400F3AA09 /* CryptoRsaHashedKeyAlgorithm.h */; };
+ 7C9ACA921F3CC0AA00F3AA09 /* CryptoKeyAlgorithm.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C9ACA8F1F3CC0AA00F3AA09 /* CryptoKeyAlgorithm.h */; settings = {ATTRIBUTES = (Private, ); }; };
+ 7C9ACA981F3CCDAD00F3AA09 /* CryptoAesKeyAlgorithm.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C9ACA961F3CCDAD00F3AA09 /* CryptoAesKeyAlgorithm.h */; settings = {ATTRIBUTES = (Private, ); }; };
+ 7C9ACA9C1F3CCDF200F3AA09 /* CryptoEcKeyAlgorithm.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C9ACA9A1F3CCDF200F3AA09 /* CryptoEcKeyAlgorithm.h */; settings = {ATTRIBUTES = (Private, ); }; };
+ 7C9ACAA01F3CCE3000F3AA09 /* CryptoHmacKeyAlgorithm.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C9ACA9E1F3CCE3000F3AA09 /* CryptoHmacKeyAlgorithm.h */; settings = {ATTRIBUTES = (Private, ); }; };
+ 7C9ACAA41F3CCE6900F3AA09 /* CryptoRsaKeyAlgorithm.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C9ACAA21F3CCE6900F3AA09 /* CryptoRsaKeyAlgorithm.h */; settings = {ATTRIBUTES = (Private, ); }; };
+ 7C9ACAA81F3CCEB400F3AA09 /* CryptoRsaHashedKeyAlgorithm.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C9ACAA61F3CCEB400F3AA09 /* CryptoRsaHashedKeyAlgorithm.h */; settings = {ATTRIBUTES = (Private, ); }; };
7C9ACAB81F3CF1AE00F3AA09 /* JSCryptoAesKeyAlgorithm.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C9ACAAA1F3CDB6300F3AA09 /* JSCryptoAesKeyAlgorithm.h */; };
7C9ACABA1F3CF1AE00F3AA09 /* JSCryptoEcKeyAlgorithm.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C9ACAAC1F3CDB9D00F3AA09 /* JSCryptoEcKeyAlgorithm.h */; };
7C9ACABC1F3CF1AE00F3AA09 /* JSCryptoHmacKeyAlgorithm.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C9ACAAF1F3CDB9F00F3AA09 /* JSCryptoHmacKeyAlgorithm.h */; };
@@ -4697,9 +4699,9 @@
E124748410AA161D00B79493 /* AuthenticationClient.h in Headers */ = {isa = PBXBuildFile; fileRef = E124748310AA161D00B79493 /* AuthenticationClient.h */; settings = {ATTRIBUTES = (Private, ); }; };
E125F82C1822CFEC00D84CD9 /* CryptoAlgorithmSHA1.h in Headers */ = {isa = PBXBuildFile; fileRef = E125F82A1822CFEC00D84CD9 /* CryptoAlgorithmSHA1.h */; };
E125F8321822F11B00D84CD9 /* CryptoAlgorithmHMAC.h in Headers */ = {isa = PBXBuildFile; fileRef = E125F8301822F11B00D84CD9 /* CryptoAlgorithmHMAC.h */; };
- E125F8361822F18A00D84CD9 /* CryptoKeyHMAC.h in Headers */ = {isa = PBXBuildFile; fileRef = E125F8341822F18A00D84CD9 /* CryptoKeyHMAC.h */; };
- E125F8421824253A00D84CD9 /* CryptoAlgorithmAES_CBC.h in Headers */ = {isa = PBXBuildFile; fileRef = E125F8401824253A00D84CD9 /* CryptoAlgorithmAES_CBC.h */; };
- E125F84E1824289D00D84CD9 /* CryptoKeyAES.h in Headers */ = {isa = PBXBuildFile; fileRef = E125F84C1824289D00D84CD9 /* CryptoKeyAES.h */; };
+ E125F8361822F18A00D84CD9 /* CryptoKeyHMAC.h in Headers */ = {isa = PBXBuildFile; fileRef = E125F8341822F18A00D84CD9 /* CryptoKeyHMAC.h */; settings = {ATTRIBUTES = (Private, ); }; };
+ E125F8421824253A00D84CD9 /* CryptoAlgorithmAES_CBC.h in Headers */ = {isa = PBXBuildFile; fileRef = E125F8401824253A00D84CD9 /* CryptoAlgorithmAES_CBC.h */; settings = {ATTRIBUTES = (Private, ); }; };
+ E125F84E1824289D00D84CD9 /* CryptoKeyAES.h in Headers */ = {isa = PBXBuildFile; fileRef = E125F84C1824289D00D84CD9 /* CryptoKeyAES.h */; settings = {ATTRIBUTES = (Private, ); }; };
E12719C70EEEC16800F61213 /* NavigatorBase.h in Headers */ = {isa = PBXBuildFile; fileRef = E12719C60EEEC16800F61213 /* NavigatorBase.h */; };
E1271A0B0EEEC77A00F61213 /* WorkerNavigator.h in Headers */ = {isa = PBXBuildFile; fileRef = E1271A0A0EEEC77A00F61213 /* WorkerNavigator.h */; };
E1271A580EEECDE400F61213 /* JSWorkerNavigator.h in Headers */ = {isa = PBXBuildFile; fileRef = E1271A560EEECDE400F61213 /* JSWorkerNavigator.h */; };
@@ -4714,7 +4716,7 @@
E14F1C4514B5DAC600EA9009 /* HTMLFormControlElementWithState.h in Headers */ = {isa = PBXBuildFile; fileRef = E14F1C4314B5DAC600EA9009 /* HTMLFormControlElementWithState.h */; settings = {ATTRIBUTES = (Private, ); }; };
E152551516FD2350003D7ADB /* WebCoreResourceHandleAsOperationQueueDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = E152551316FD234F003D7ADB /* WebCoreResourceHandleAsOperationQueueDelegate.h */; };
E157A8E11817331C009F821D /* JSCryptoKey.h in Headers */ = {isa = PBXBuildFile; fileRef = E157A8DF1817331C009F821D /* JSCryptoKey.h */; };
- E157A8E518173A3A009F821D /* CryptoKey.h in Headers */ = {isa = PBXBuildFile; fileRef = E157A8E318173A3A009F821D /* CryptoKey.h */; };
+ E157A8E518173A3A009F821D /* CryptoKey.h in Headers */ = {isa = PBXBuildFile; fileRef = E157A8E318173A3A009F821D /* CryptoKey.h */; settings = {ATTRIBUTES = (Private, ); }; };
E15A36D71104572000B7B639 /* XMLNSNames.h in Headers */ = {isa = PBXBuildFile; fileRef = E15A36D61104572000B7B639 /* XMLNSNames.h */; };
E15A36D91104572700B7B639 /* XMLNSNames.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E15A36D81104572700B7B639 /* XMLNSNames.cpp */; };
E15FF7D518C9553800FE4C87 /* KeypressCommand.h in Headers */ = {isa = PBXBuildFile; fileRef = E15FF7D418C9553800FE4C87 /* KeypressCommand.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -4723,8 +4725,8 @@
E16982551134629D00894115 /* ObjCRuntimeObject.h in Headers */ = {isa = PBXBuildFile; fileRef = E16982541134629D00894115 /* ObjCRuntimeObject.h */; };
E16982601134636A00894115 /* ObjCRuntimeObject.mm in Sources */ = {isa = PBXBuildFile; fileRef = E169825F1134636A00894115 /* ObjCRuntimeObject.mm */; };
E16A84FA14C85CCC002977DF /* CSSBorderImage.h in Headers */ = {isa = PBXBuildFile; fileRef = E16A84F814C85CCC002977DF /* CSSBorderImage.h */; };
- E172AF6E180F24C600FBADB9 /* CryptoAlgorithm.h in Headers */ = {isa = PBXBuildFile; fileRef = E172AF6C180F24C600FBADB9 /* CryptoAlgorithm.h */; };
- E172AF70180F289500FBADB9 /* CryptoKeyUsage.h in Headers */ = {isa = PBXBuildFile; fileRef = E172AF6F180F289500FBADB9 /* CryptoKeyUsage.h */; };
+ E172AF6E180F24C600FBADB9 /* CryptoAlgorithm.h in Headers */ = {isa = PBXBuildFile; fileRef = E172AF6C180F24C600FBADB9 /* CryptoAlgorithm.h */; settings = {ATTRIBUTES = (Private, ); }; };
+ E172AF70180F289500FBADB9 /* CryptoKeyUsage.h in Headers */ = {isa = PBXBuildFile; fileRef = E172AF6F180F289500FBADB9 /* CryptoKeyUsage.h */; settings = {ATTRIBUTES = (Private, ); }; };
E172AF901811BC3700FBADB9 /* JSDOMPromiseDeferred.h in Headers */ = {isa = PBXBuildFile; fileRef = E172AF8E1811BC3700FBADB9 /* JSDOMPromiseDeferred.h */; settings = {ATTRIBUTES = (Private, ); }; };
E179F0DA1B9774FE00ED0A27 /* Internals.mm in Sources */ = {isa = PBXBuildFile; fileRef = E179F0D91B9774FE00ED0A27 /* Internals.mm */; };
E17B491616A9B094001C8839 /* TransitionEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = E17B491416A9B093001C8839 /* TransitionEvent.h */; };
@@ -4737,7 +4739,7 @@
E18823662031F59400B42DF3 /* VRPlatformManager.h in Headers */ = {isa = PBXBuildFile; fileRef = E18823612031F55B00B42DF3 /* VRPlatformManager.h */; settings = {ATTRIBUTES = (Private, ); }; };
E18C35441F71970C00FF632D /* WebArchiveResourceWebResourceHandler.h in Headers */ = {isa = PBXBuildFile; fileRef = E18C35411F7196CD00FF632D /* WebArchiveResourceWebResourceHandler.h */; };
E18DF33518AAF12C00773E59 /* SerializedCryptoKeyWrap.h in Headers */ = {isa = PBXBuildFile; fileRef = E18DF33418AAF12C00773E59 /* SerializedCryptoKeyWrap.h */; settings = {ATTRIBUTES = (Private, ); }; };
- E19727161820549E00592D51 /* CryptoKeyType.h in Headers */ = {isa = PBXBuildFile; fileRef = E19727151820549E00592D51 /* CryptoKeyType.h */; };
+ E19727161820549E00592D51 /* CryptoKeyType.h in Headers */ = {isa = PBXBuildFile; fileRef = E19727151820549E00592D51 /* CryptoKeyType.h */; settings = {ATTRIBUTES = (Private, ); }; };
E19AC3EF1824DC7900349426 /* CryptoAlgorithmSHA224.h in Headers */ = {isa = PBXBuildFile; fileRef = E19AC3E71824DC7900349426 /* CryptoAlgorithmSHA224.h */; };
E19AC3F11824DC7900349426 /* CryptoAlgorithmSHA256.h in Headers */ = {isa = PBXBuildFile; fileRef = E19AC3E91824DC7900349426 /* CryptoAlgorithmSHA256.h */; };
E19AC3F31824DC7900349426 /* CryptoAlgorithmSHA384.h in Headers */ = {isa = PBXBuildFile; fileRef = E19AC3EB1824DC7900349426 /* CryptoAlgorithmSHA384.h */; };
@@ -4761,7 +4763,7 @@
E1C415DA0F655D6F0092D2FB /* CrossOriginPreflightResultCache.h in Headers */ = {isa = PBXBuildFile; fileRef = E1C415D90F655D6F0092D2FB /* CrossOriginPreflightResultCache.h */; settings = {ATTRIBUTES = (Private, ); }; };
E1C416120F6562FD0092D2FB /* CrossOriginAccessControl.h in Headers */ = {isa = PBXBuildFile; fileRef = E1C416110F6562FD0092D2FB /* CrossOriginAccessControl.h */; settings = {ATTRIBUTES = (Private, ); }; };
E1C4DE690EA75C1E0023CCD6 /* ActiveDOMObject.h in Headers */ = {isa = PBXBuildFile; fileRef = E1C4DE680EA75C1E0023CCD6 /* ActiveDOMObject.h */; settings = {ATTRIBUTES = (Private, ); }; };
- E1C657251816E69D00256CDD /* CryptoAlgorithmIdentifier.h in Headers */ = {isa = PBXBuildFile; fileRef = E1C657241816E69D00256CDD /* CryptoAlgorithmIdentifier.h */; };
+ E1C657251816E69D00256CDD /* CryptoAlgorithmIdentifier.h in Headers */ = {isa = PBXBuildFile; fileRef = E1C657241816E69D00256CDD /* CryptoAlgorithmIdentifier.h */; settings = {ATTRIBUTES = (Private, ); }; };
E1C94AF9191303F000D5A893 /* BlobPart.h in Headers */ = {isa = PBXBuildFile; fileRef = E1C94AF7191303F000D5A893 /* BlobPart.h */; settings = {ATTRIBUTES = (Private, ); }; };
E1CAA5C60E8BD23600A73ECA /* JSWorker.h in Headers */ = {isa = PBXBuildFile; fileRef = E1CAA5C50E8BD23600A73ECA /* JSWorker.h */; };
E1CDE9221501916900862CC5 /* AsyncFileStream.h in Headers */ = {isa = PBXBuildFile; fileRef = E1CDE9211501916900862CC5 /* AsyncFileStream.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -4774,7 +4776,7 @@
E1F80B8818317252007885C3 /* CryptoKeyPair.h in Headers */ = {isa = PBXBuildFile; fileRef = E1F80B8618317252007885C3 /* CryptoKeyPair.h */; settings = {ATTRIBUTES = (Private, ); }; };
E1F80B8E183172B5007885C3 /* JSCryptoKeyPair.h in Headers */ = {isa = PBXBuildFile; fileRef = E1F80B8C183172B5007885C3 /* JSCryptoKeyPair.h */; };
E1FE136B183FE1AB00892F13 /* CryptoAlgorithmRSA_OAEP.h in Headers */ = {isa = PBXBuildFile; fileRef = E1FE1369183FE1AB00892F13 /* CryptoAlgorithmRSA_OAEP.h */; };
- E1FE137518402A6700892F13 /* CommonCryptoUtilities.h in Headers */ = {isa = PBXBuildFile; fileRef = E1FE137318402A6700892F13 /* CommonCryptoUtilities.h */; };
+ E1FE137518402A6700892F13 /* CommonCryptoUtilities.h in Headers */ = {isa = PBXBuildFile; fileRef = E1FE137318402A6700892F13 /* CommonCryptoUtilities.h */; settings = {ATTRIBUTES = (Private, ); }; };
E1FE137B184D21BB00892F13 /* CryptoAlgorithmAES_KW.h in Headers */ = {isa = PBXBuildFile; fileRef = E1FE1379184D21BB00892F13 /* CryptoAlgorithmAES_KW.h */; };
E1FF57A30F01255B00891EBB /* ThreadGlobalData.h in Headers */ = {isa = PBXBuildFile; fileRef = E1FF57A20F01255B00891EBB /* ThreadGlobalData.h */; settings = {ATTRIBUTES = (Private, ); }; };
E1FF8F6D180DB5BE00132674 /* CryptoAlgorithmRegistry.h in Headers */ = {isa = PBXBuildFile; fileRef = E1FF8F6B180DB5BE00132674 /* CryptoAlgorithmRegistry.h */; };
@@ -8798,6 +8800,8 @@
57585969239F1EC700C74572 /* AuthenticatorResponse.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = AuthenticatorResponse.cpp; sourceTree = "<group>"; };
5758596B239F284B00C74572 /* AuthenticatorAttestationResponse.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = AuthenticatorAttestationResponse.cpp; sourceTree = "<group>"; };
5758596E239F397900C74572 /* AuthenticatorAssertionResponse.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = AuthenticatorAssertionResponse.cpp; sourceTree = "<group>"; };
+ 5758597823A1FCE600C74572 /* Pin.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Pin.cpp; sourceTree = "<group>"; };
+ 5758597923A1FCF200C74572 /* Pin.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Pin.h; sourceTree = "<group>"; };
5760824F20118D8D00116678 /* JSBasicCredentialCustom.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = JSBasicCredentialCustom.cpp; sourceTree = "<group>"; };
576082562011BE0200116678 /* JSAuthenticatorResponseCustom.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = JSAuthenticatorResponseCustom.cpp; sourceTree = "<group>"; };
576082702021513F00116678 /* AuthenticatorCoordinatorClient.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AuthenticatorCoordinatorClient.h; sourceTree = "<group>"; };
@@ -19993,6 +19997,8 @@
578A4C0A2167D29600D08F34 /* FidoHidPacket.h */,
573F533621680D150045587A /* FidoParsingUtils.cpp */,
573F533521680D140045587A /* FidoParsingUtils.h */,
+ 5758597823A1FCE600C74572 /* Pin.cpp */,
+ 5758597923A1FCF200C74572 /* Pin.h */,
57152B6A21CD995C000C37CA /* U2fCommandConstructor.cpp */,
57152B6C21CD995C000C37CA /* U2fCommandConstructor.h */,
57152B7B21DD8BA1000C37CA /* U2fResponseConverter.cpp */,
@@ -29417,6 +29423,7 @@
E125F84E1824289D00D84CD9 /* CryptoKeyAES.h in Headers */,
7C9ACA921F3CC0AA00F3AA09 /* CryptoKeyAlgorithm.h in Headers */,
5750A9751E68D00000705C4A /* CryptoKeyEC.h in Headers */,
+ 572576D623A8872B00909540 /* CryptoKeyFormat.h in Headers */,
E125F8361822F18A00D84CD9 /* CryptoKeyHMAC.h in Headers */,
E1F80B8818317252007885C3 /* CryptoKeyPair.h in Headers */,
57E657DF1E71373A00F941CA /* CryptoKeyRaw.h in Headers */,
@@ -31721,6 +31728,7 @@
1DBC1B562347B3D200B901AF /* PictureInPictureObserver.h in Headers */,
1D2C82B7236A3F6A0055D6C5 /* PictureInPictureSupport.h in Headers */,
1D2F8E062344752300993B68 /* PictureInPictureWindow.h in Headers */,
+ 5758597C23A1FCF300C74572 /* Pin.h in Headers */,
D0FF2A5E11F8C45A007E74E0 /* PingLoader.h in Headers */,
CD7D33441C7A123F00041293 /* PixelBufferConformerCV.h in Headers */,
CDEFA2281E7669E8000AE99C /* PlatformAudioData.h in Headers */,
Modified: trunk/Source/WebCore/crypto/CryptoAlgorithm.h (253810 => 253811)
--- trunk/Source/WebCore/crypto/CryptoAlgorithm.h 2019-12-20 03:32:37 UTC (rev 253810)
+++ trunk/Source/WebCore/crypto/CryptoAlgorithm.h 2019-12-20 10:31:03 UTC (rev 253811)
@@ -31,7 +31,6 @@
#include "CryptoKeyUsage.h"
#include "ExceptionOr.h"
#include "JsonWebKey.h"
-#include "SubtleCrypto.h"
#include <wtf/Function.h>
#include <wtf/ThreadSafeRefCounted.h>
#include <wtf/Variant.h>
Modified: trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_CBC.h (253810 => 253811)
--- trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_CBC.h 2019-12-20 03:32:37 UTC (rev 253810)
+++ trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_CBC.h 2019-12-20 10:31:03 UTC (rev 253811)
@@ -40,6 +40,10 @@
static constexpr CryptoAlgorithmIdentifier s_identifier = CryptoAlgorithmIdentifier::AES_CBC;
static Ref<CryptoAlgorithm> create();
+ // Operations can be performed directly.
+ WEBCORE_EXPORT static ExceptionOr<Vector<uint8_t>> platformEncrypt(const CryptoAlgorithmAesCbcCfbParams&, const CryptoKeyAES&, const Vector<uint8_t>&);
+ WEBCORE_EXPORT static ExceptionOr<Vector<uint8_t>> platformDecrypt(const CryptoAlgorithmAesCbcCfbParams&, const CryptoKeyAES&, const Vector<uint8_t>&);
+
private:
CryptoAlgorithmAES_CBC() = default;
CryptoAlgorithmIdentifier identifier() const final;
@@ -50,9 +54,6 @@
void importKey(CryptoKeyFormat, KeyData&&, const CryptoAlgorithmParameters&, bool extractable, CryptoKeyUsageBitmap, KeyCallback&&, ExceptionCallback&&) final;
void exportKey(CryptoKeyFormat, Ref<CryptoKey>&&, KeyDataCallback&&, ExceptionCallback&&) final;
ExceptionOr<size_t> getKeyLength(const CryptoAlgorithmParameters&) final;
-
- static ExceptionOr<Vector<uint8_t>> platformEncrypt(const CryptoAlgorithmAesCbcCfbParams&, const CryptoKeyAES&, const Vector<uint8_t>&);
- static ExceptionOr<Vector<uint8_t>> platformDecrypt(const CryptoAlgorithmAesCbcCfbParams&, const CryptoKeyAES&, const Vector<uint8_t>&);
};
} // namespace WebCore
Modified: trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmECDH.h (253810 => 253811)
--- trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmECDH.h 2019-12-20 03:32:37 UTC (rev 253810)
+++ trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmECDH.h 2019-12-20 10:31:03 UTC (rev 253811)
@@ -39,6 +39,9 @@
static constexpr CryptoAlgorithmIdentifier s_identifier = CryptoAlgorithmIdentifier::ECDH;
static Ref<CryptoAlgorithm> create();
+ // Operations can be performed directly.
+ WEBCORE_EXPORT static Optional<Vector<uint8_t>> platformDeriveBits(const CryptoKeyEC&, const CryptoKeyEC&);
+
private:
CryptoAlgorithmECDH() = default;
CryptoAlgorithmIdentifier identifier() const final;
@@ -47,8 +50,6 @@
void deriveBits(const CryptoAlgorithmParameters&, Ref<CryptoKey>&&, size_t length, VectorCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&) final;
void importKey(CryptoKeyFormat, KeyData&&, const CryptoAlgorithmParameters&, bool extractable, CryptoKeyUsageBitmap, KeyCallback&&, ExceptionCallback&&) final;
void exportKey(CryptoKeyFormat, Ref<CryptoKey>&&, KeyDataCallback&&, ExceptionCallback&&) final;
-
- static Optional<Vector<uint8_t>> platformDeriveBits(const CryptoKeyEC&, const CryptoKeyEC&);
};
} // namespace WebCore
Modified: trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmHMAC.h (253810 => 253811)
--- trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmHMAC.h 2019-12-20 03:32:37 UTC (rev 253810)
+++ trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmHMAC.h 2019-12-20 10:31:03 UTC (rev 253811)
@@ -39,6 +39,10 @@
static constexpr CryptoAlgorithmIdentifier s_identifier = CryptoAlgorithmIdentifier::HMAC;
static Ref<CryptoAlgorithm> create();
+ // Operations can be performed directly.
+ static ExceptionOr<Vector<uint8_t>> platformSign(const CryptoKeyHMAC&, const Vector<uint8_t>&);
+ static ExceptionOr<bool> platformVerify(const CryptoKeyHMAC&, const Vector<uint8_t>&, const Vector<uint8_t>&);
+
private:
CryptoAlgorithmHMAC() = default;
CryptoAlgorithmIdentifier identifier() const final;
@@ -49,9 +53,6 @@
void importKey(CryptoKeyFormat, KeyData&&, const CryptoAlgorithmParameters&, bool extractable, CryptoKeyUsageBitmap, KeyCallback&&, ExceptionCallback&&) final;
void exportKey(CryptoKeyFormat, Ref<CryptoKey>&&, KeyDataCallback&&, ExceptionCallback&&) final;
ExceptionOr<size_t> getKeyLength(const CryptoAlgorithmParameters&) final;
-
- static ExceptionOr<Vector<uint8_t>> platformSign(const CryptoKeyHMAC&, const Vector<uint8_t>&);
- static ExceptionOr<bool> platformVerify(const CryptoKeyHMAC&, const Vector<uint8_t>&, const Vector<uint8_t>&);
};
} // namespace WebCore
Modified: trunk/Source/WebCore/crypto/keys/CryptoKeyAES.cpp (253810 => 253811)
--- trunk/Source/WebCore/crypto/keys/CryptoKeyAES.cpp 2019-12-20 03:32:37 UTC (rev 253810)
+++ trunk/Source/WebCore/crypto/keys/CryptoKeyAES.cpp 2019-12-20 10:31:03 UTC (rev 253811)
@@ -28,6 +28,7 @@
#if ENABLE(WEB_CRYPTO)
+#include "CryptoAesKeyAlgorithm.h"
#include "CryptoAlgorithmAesKeyParams.h"
#include "CryptoAlgorithmRegistry.h"
#include "ExceptionOr.h"
Modified: trunk/Source/WebCore/crypto/keys/CryptoKeyAES.h (253810 => 253811)
--- trunk/Source/WebCore/crypto/keys/CryptoKeyAES.h 2019-12-20 03:32:37 UTC (rev 253810)
+++ trunk/Source/WebCore/crypto/keys/CryptoKeyAES.h 2019-12-20 10:31:03 UTC (rev 253811)
@@ -54,7 +54,7 @@
static bool isValidAESAlgorithm(CryptoAlgorithmIdentifier);
static RefPtr<CryptoKeyAES> generate(CryptoAlgorithmIdentifier, size_t lengthBits, bool extractable, CryptoKeyUsageBitmap);
- static RefPtr<CryptoKeyAES> importRaw(CryptoAlgorithmIdentifier, Vector<uint8_t>&& keyData, bool extractable, CryptoKeyUsageBitmap);
+ WEBCORE_EXPORT static RefPtr<CryptoKeyAES> importRaw(CryptoAlgorithmIdentifier, Vector<uint8_t>&& keyData, bool extractable, CryptoKeyUsageBitmap);
using CheckAlgCallback = Function<bool(size_t, const String&)>;
static RefPtr<CryptoKeyAES> importJwk(CryptoAlgorithmIdentifier, JsonWebKey&&, bool extractable, CryptoKeyUsageBitmap, CheckAlgCallback&&);
Modified: trunk/Source/WebCore/crypto/keys/CryptoKeyEC.h (253810 => 253811)
--- trunk/Source/WebCore/crypto/keys/CryptoKeyEC.h 2019-12-20 03:32:37 UTC (rev 253810)
+++ trunk/Source/WebCore/crypto/keys/CryptoKeyEC.h 2019-12-20 10:31:03 UTC (rev 253811)
@@ -69,13 +69,13 @@
}
virtual ~CryptoKeyEC() = default;
- static ExceptionOr<CryptoKeyPair> generatePair(CryptoAlgorithmIdentifier, const String& curve, bool extractable, CryptoKeyUsageBitmap);
- static RefPtr<CryptoKeyEC> importRaw(CryptoAlgorithmIdentifier, const String& curve, Vector<uint8_t>&& keyData, bool extractable, CryptoKeyUsageBitmap);
+ WEBCORE_EXPORT static ExceptionOr<CryptoKeyPair> generatePair(CryptoAlgorithmIdentifier, const String& curve, bool extractable, CryptoKeyUsageBitmap);
+ WEBCORE_EXPORT static RefPtr<CryptoKeyEC> importRaw(CryptoAlgorithmIdentifier, const String& curve, Vector<uint8_t>&& keyData, bool extractable, CryptoKeyUsageBitmap);
static RefPtr<CryptoKeyEC> importJwk(CryptoAlgorithmIdentifier, const String& curve, JsonWebKey&&, bool extractable, CryptoKeyUsageBitmap);
static RefPtr<CryptoKeyEC> importSpki(CryptoAlgorithmIdentifier, const String& curve, Vector<uint8_t>&& keyData, bool extractable, CryptoKeyUsageBitmap);
static RefPtr<CryptoKeyEC> importPkcs8(CryptoAlgorithmIdentifier, const String& curve, Vector<uint8_t>&& keyData, bool extractable, CryptoKeyUsageBitmap);
- ExceptionOr<Vector<uint8_t>> exportRaw() const;
+ WEBCORE_EXPORT ExceptionOr<Vector<uint8_t>> exportRaw() const;
ExceptionOr<JsonWebKey> exportJwk() const;
ExceptionOr<Vector<uint8_t>> exportSpki() const;
ExceptionOr<Vector<uint8_t>> exportPkcs8() const;
Modified: trunk/Source/WebCore/crypto/mac/CryptoAlgorithmAES_CBCMac.cpp (253810 => 253811)
--- trunk/Source/WebCore/crypto/mac/CryptoAlgorithmAES_CBCMac.cpp 2019-12-20 03:32:37 UTC (rev 253810)
+++ trunk/Source/WebCore/crypto/mac/CryptoAlgorithmAES_CBCMac.cpp 2019-12-20 10:31:03 UTC (rev 253811)
@@ -64,13 +64,13 @@
ExceptionOr<Vector<uint8_t>> CryptoAlgorithmAES_CBC::platformEncrypt(const CryptoAlgorithmAesCbcCfbParams& parameters, const CryptoKeyAES& key, const Vector<uint8_t>& plainText)
{
- ASSERT(parameters.ivVector().size() == kCCBlockSizeAES128);
+ ASSERT(parameters.ivVector().size() == kCCBlockSizeAES128 || parameters.ivVector().isEmpty());
return transformAES_CBC(kCCEncrypt, parameters.ivVector(), key.key(), plainText);
}
ExceptionOr<Vector<uint8_t>> CryptoAlgorithmAES_CBC::platformDecrypt(const CryptoAlgorithmAesCbcCfbParams& parameters, const CryptoKeyAES& key, const Vector<uint8_t>& cipherText)
{
- ASSERT(parameters.ivVector().size() == kCCBlockSizeAES128);
+ ASSERT(parameters.ivVector().size() == kCCBlockSizeAES128 || parameters.ivVector().isEmpty());
return transformAES_CBC(kCCDecrypt, parameters.ivVector(), key.key(), cipherText);
}
Modified: trunk/Tools/ChangeLog (253810 => 253811)
--- trunk/Tools/ChangeLog 2019-12-20 03:32:37 UTC (rev 253810)
+++ trunk/Tools/ChangeLog 2019-12-20 10:31:03 UTC (rev 253811)
@@ -1,3 +1,20 @@
+2019-12-20 Jiewen Tan <[email protected]>
+
+ [WebAuthn] Implement coders for CTAP ClientPIN requests and responses
+ https://bugs.webkit.org/show_bug.cgi?id=205376
+ <rdar://problem/58034395>
+
+ Reviewed by Brent Fulgham.
+
+ Adds API tests.
+
+ * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+ * TestWebKitAPI/Tests/WebCore/CtapPinTest.cpp: Added.
+ (TestWebKitAPI::TEST):
+ * TestWebKitAPI/Tests/WebCore/CtapRequestTest.cpp:
+ (TestWebKitAPI::TEST):
+ * TestWebKitAPI/Tests/WebCore/FidoTestData.h:
+
2019-12-19 Jonathan Bedard <[email protected]>
Python 3: Add support to run-webkit-tests
Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (253810 => 253811)
--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj 2019-12-20 03:32:37 UTC (rev 253810)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj 2019-12-20 10:31:03 UTC (rev 253811)
@@ -341,6 +341,7 @@
573255A622139BC700396AE8 /* load-web-archive-1.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 573255A222139B8F00396AE8 /* load-web-archive-1.html */; };
573255A722139BC700396AE8 /* load-web-archive-2.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 573255A322139B9000396AE8 /* load-web-archive-2.html */; };
574F55D2204D47F0002948C6 /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 574F55D0204D471C002948C6 /* Security.framework */; };
+ 5758597F23A2527A00C74572 /* CtapPinTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5758597E23A2527A00C74572 /* CtapPinTest.cpp */; };
57599E211F07191900A3FB8C /* IndexedDBStructuredCloneBackwardCompatibility.mm in Sources */ = {isa = PBXBuildFile; fileRef = 57599E201F07191700A3FB8C /* IndexedDBStructuredCloneBackwardCompatibility.mm */; };
57599E271F071AA000A3FB8C /* IndexedDBStructuredCloneBackwardCompatibility.sqlite3 in Copy Resources */ = {isa = PBXBuildFile; fileRef = 57599E241F07192C00A3FB8C /* IndexedDBStructuredCloneBackwardCompatibility.sqlite3 */; };
57599E281F071AA000A3FB8C /* IndexedDBStructuredCloneBackwardCompatibility.sqlite3-shm in Copy Resources */ = {isa = PBXBuildFile; fileRef = 57599E261F07192C00A3FB8C /* IndexedDBStructuredCloneBackwardCompatibility.sqlite3-shm */; };
@@ -1904,6 +1905,8 @@
573255A422139B9000396AE8 /* helloworld.webarchive */ = {isa = PBXFileReference; lastKnownFileType = file.bplist; path = helloworld.webarchive; sourceTree = "<group>"; };
5735F0251F3A4EA6000EE801 /* TestWebKitAPI-iOS.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = "TestWebKitAPI-iOS.entitlements"; sourceTree = "<group>"; };
574F55D0204D471C002948C6 /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = System/Library/Frameworks/Security.framework; sourceTree = SDKROOT; };
+ 5758597D23A2527A00C74572 /* CtapPinTest.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CtapPinTest.h; sourceTree = "<group>"; };
+ 5758597E23A2527A00C74572 /* CtapPinTest.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CtapPinTest.cpp; sourceTree = "<group>"; };
57599E201F07191700A3FB8C /* IndexedDBStructuredCloneBackwardCompatibility.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = IndexedDBStructuredCloneBackwardCompatibility.mm; sourceTree = "<group>"; };
57599E231F07192C00A3FB8C /* IndexedDBStructuredCloneBackwardCompatibilityWrite.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = IndexedDBStructuredCloneBackwardCompatibilityWrite.html; sourceTree = "<group>"; };
57599E241F07192C00A3FB8C /* IndexedDBStructuredCloneBackwardCompatibility.sqlite3 */ = {isa = PBXFileReference; lastKnownFileType = file; path = IndexedDBStructuredCloneBackwardCompatibility.sqlite3; sourceTree = "<group>"; };
@@ -3098,6 +3101,8 @@
1C9EB8401E380DA1005C6442 /* ComplexTextController.cpp */,
7CB184C41AA3F2100066EDFD /* ContentExtensions.cpp */,
CD5451E919E41F9D0016936F /* CSSParser.cpp */,
+ 5758597E23A2527A00C74572 /* CtapPinTest.cpp */,
+ 5758597D23A2527A00C74572 /* CtapPinTest.h */,
572B403321769A88000AD43E /* CtapRequestTest.cpp */,
572B404321781B42000AD43E /* CtapResponseTest.cpp */,
260BA5781B1D2E7B004FA07C /* DFACombiner.cpp */,
@@ -4585,6 +4590,7 @@
7CCE7EAC1A411A3400447C4C /* Counters.cpp in Sources */,
7AEAD47F1E20116C00416EFE /* CrossPartitionFileSchemeAccess.mm in Sources */,
7CCE7EDB1A411A9200447C4C /* CSSParser.cpp in Sources */,
+ 5758597F23A2527A00C74572 /* CtapPinTest.cpp in Sources */,
572B403421769A88000AD43E /* CtapRequestTest.cpp in Sources */,
572B404421781B43000AD43E /* CtapResponseTest.cpp in Sources */,
7AC7B57020D9BA5B002C09A0 /* CustomBundleObject.mm in Sources */,
Added: trunk/Tools/TestWebKitAPI/Tests/WebCore/CtapPinTest.cpp (0 => 253811)
--- trunk/Tools/TestWebKitAPI/Tests/WebCore/CtapPinTest.cpp (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebCore/CtapPinTest.cpp 2019-12-20 10:31:03 UTC (rev 253811)
@@ -0,0 +1,295 @@
+/*
+ * Copyright (C) 2019 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#if ENABLE(WEB_AUTHN)
+
+#include "FidoTestData.h"
+#include "PlatformUtilities.h"
+#include <WebCore/CBORReader.h>
+#include <WebCore/CBORValue.h>
+#include <WebCore/CryptoAlgorithmAES_CBC.h>
+#include <WebCore/CryptoAlgorithmAesCbcCfbParams.h>
+#include <WebCore/CryptoAlgorithmECDH.h>
+#include <WebCore/CryptoKeyAES.h>
+#include <WebCore/CryptoKeyEC.h>
+#include <WebCore/CryptoKeyHMAC.h>
+#include <WebCore/FidoConstants.h>
+#include <WebCore/Pin.h>
+#include <WebCore/WebAuthenticationConstants.h>
+#include <WebCore/WebAuthenticationUtils.h>
+#include <wtf/text/Base64.h>
+
+namespace TestWebKitAPI {
+using namespace WebCore;
+using namespace cbor;
+using namespace fido;
+using namespace fido::pin;
+
+TEST(CtapPinTest, TestValidateAndConvertToUTF8)
+{
+ // Failure cases
+ auto result = validateAndConvertToUTF8("123");
+ EXPECT_FALSE(result);
+ result = validateAndConvertToUTF8("");
+ EXPECT_FALSE(result);
+ result = validateAndConvertToUTF8("1234567812345678123456781234567812345678123456781234567812345678");
+ EXPECT_FALSE(result);
+
+ // Success cases
+ result = validateAndConvertToUTF8("1234");
+ EXPECT_TRUE(result);
+ EXPECT_EQ(result->length(), 4u);
+ EXPECT_STREQ(result->data(), "1234");
+
+ result = validateAndConvertToUTF8("123456781234567812345678123456781234567812345678123456781234567");
+ EXPECT_TRUE(result);
+ EXPECT_EQ(result->length(), 63u);
+ EXPECT_STREQ(result->data(), "123456781234567812345678123456781234567812345678123456781234567");
+}
+
+TEST(CtapPinTest, TestRetriesRequest)
+{
+ auto result = encodeAsCBOR(RetriesRequest { });
+ EXPECT_EQ(result.size(), sizeof(TestData::kCtapClientPinRetries));
+ EXPECT_EQ(memcmp(result.data(), TestData::kCtapClientPinRetries, result.size()), 0);
+}
+
+TEST(CtapPinTest, TestRetriesResponse)
+{
+ // Failure cases
+ auto result = RetriesResponse::parse({ });
+ EXPECT_FALSE(result);
+
+ const uint8_t testData1[] = { 0x05 }; // wrong response code
+ result = RetriesResponse::parse(convertBytesToVector(testData1, sizeof(testData1)));
+ EXPECT_FALSE(result);
+
+ const uint8_t testData2[] = { 0x00, 0x00 }; // wrong CBOR map
+ result = RetriesResponse::parse(convertBytesToVector(testData2, sizeof(testData2)));
+ EXPECT_FALSE(result);
+
+ result = RetriesResponse::parse(convertBytesToVector(TestData::kCtapClientPinTokenResponse, sizeof(TestData::kCtapClientPinTokenResponse))); // wrong response
+ EXPECT_FALSE(result);
+
+ // Success cases
+ result = RetriesResponse::parse(convertBytesToVector(TestData::kCtapClientPinRetriesResponse, sizeof(TestData::kCtapClientPinRetriesResponse)));
+ EXPECT_TRUE(result);
+ EXPECT_EQ(result->retries, 8);
+}
+
+TEST(CtapPinTest, TestKeyAgreementRequest)
+{
+ auto result = encodeAsCBOR(KeyAgreementRequest { });
+ EXPECT_EQ(result.size(), sizeof(TestData::kCtapClientPinKeyAgreement));
+ EXPECT_EQ(memcmp(result.data(), TestData::kCtapClientPinKeyAgreement, result.size()), 0);
+}
+
+TEST(CtapPinTest, TestKeyAgreementResponse)
+{
+ // Failure cases
+ auto result = KeyAgreementResponse::parse({ });
+ EXPECT_FALSE(result);
+
+ const uint8_t testData1[] = { 0x05 }; // wrong response code
+ result = KeyAgreementResponse::parse(convertBytesToVector(testData1, sizeof(testData1)));
+ EXPECT_FALSE(result);
+
+ const uint8_t testData2[] = { 0x00, 0x00 }; // wrong CBOR map
+ result = KeyAgreementResponse::parse(convertBytesToVector(testData2, sizeof(testData2)));
+ EXPECT_FALSE(result);
+
+ result = KeyAgreementResponse::parse(convertBytesToVector(TestData::kCtapClientPinTokenResponse, sizeof(TestData::kCtapClientPinTokenResponse))); // wrong response
+ EXPECT_FALSE(result);
+
+ // Test COSE
+ auto coseKey = encodeCOSEPublicKey(Vector<uint8_t>(65));
+ coseKey[CBORValue(COSE::kty)] = CBORValue(0); // wrong kty
+ auto coseResult = KeyAgreementResponse::parseFromCOSE(coseKey);
+ EXPECT_FALSE(coseResult);
+
+ coseKey = encodeCOSEPublicKey(Vector<uint8_t>(65));
+ coseKey[CBORValue(COSE::alg)] = CBORValue(0); // wrong alg
+ coseResult = KeyAgreementResponse::parseFromCOSE(coseKey);
+ EXPECT_FALSE(coseResult);
+
+ coseKey = encodeCOSEPublicKey(Vector<uint8_t>(65));
+ coseKey[CBORValue(COSE::crv)] = CBORValue(0); // wrong crv
+ coseResult = KeyAgreementResponse::parseFromCOSE(coseKey);
+ EXPECT_FALSE(coseResult);
+
+ coseKey = encodeCOSEPublicKey(Vector<uint8_t>(65));
+ coseKey[CBORValue(COSE::x)] = CBORValue(0); // wrong x
+ coseResult = KeyAgreementResponse::parseFromCOSE(coseKey);
+ EXPECT_FALSE(coseResult);
+
+ coseKey = encodeCOSEPublicKey(Vector<uint8_t>(65));
+ coseKey[CBORValue(COSE::y)] = CBORValue(0); // wrong y
+ coseResult = KeyAgreementResponse::parseFromCOSE(coseKey);
+ EXPECT_FALSE(coseResult);
+
+ // Success cases
+ result = KeyAgreementResponse::parse(convertBytesToVector(TestData::kCtapClientPinKeyAgreementResponse, sizeof(TestData::kCtapClientPinKeyAgreementResponse)));
+ EXPECT_TRUE(result);
+ auto exportedRawKey = result->peerKey->exportRaw();
+ EXPECT_FALSE(exportedRawKey.hasException());
+ Vector<uint8_t> expectedRawKey;
+ expectedRawKey.reserveCapacity(65);
+ expectedRawKey.append(0x04);
+ expectedRawKey.append(TestData::kCtapClientPinKeyAgreementResponse + 14, 32); // X
+ expectedRawKey.append(TestData::kCtapClientPinKeyAgreementResponse + 49, 32); // Y
+ EXPECT_TRUE(exportedRawKey.returnValue() == expectedRawKey);
+}
+
+TEST(CtapPinTest, TestTokenRequest)
+{
+ // Generate an EC key pair as the peer key.
+ auto keyPairResult = CryptoKeyEC::generatePair(CryptoAlgorithmIdentifier::ECDH, "P-256", true, CryptoKeyUsageDeriveBits);
+ ASSERT_FALSE(keyPairResult.hasException());
+ auto keyPair = keyPairResult.releaseReturnValue();
+
+ CString pin = "1234";
+
+ auto token = TokenRequest::tryCreate(pin, downcast<CryptoKeyEC>(*keyPair.publicKey));
+ EXPECT_TRUE(token);
+ auto result = encodeAsCBOR(*token);
+ EXPECT_EQ(result.size(), 120u);
+ EXPECT_EQ(result[0], static_cast<uint8_t>(CtapRequestCommand::kAuthenticatorClientPin));
+
+ // Decode the CBOR binary to check if each field is encoded correctly.
+ Vector<uint8_t> buffer;
+ buffer.append(result.data() + 1, result.size() - 1);
+ auto decodedResponse = cbor::CBORReader::read(buffer);
+ EXPECT_TRUE(decodedResponse);
+ EXPECT_TRUE(decodedResponse->isMap());
+ const auto& responseMap = decodedResponse->getMap();
+
+ const auto& it1 = responseMap.find(CBORValue(static_cast<uint8_t>(RequestKey::kProtocol)));
+ EXPECT_NE(it1, responseMap.end());
+ EXPECT_EQ(it1->second.getInteger(), kProtocolVersion);
+
+ const auto& it2 = responseMap.find(CBORValue(static_cast<uint8_t>(RequestKey::kSubcommand)));
+ EXPECT_NE(it2, responseMap.end());
+ EXPECT_EQ(it2->second.getInteger(), static_cast<uint8_t>(Subcommand::kGetPinToken));
+
+ // COSE
+ auto it = responseMap.find(CBORValue(static_cast<int>(RequestKey::kKeyAgreement)));
+ EXPECT_TRUE(decodedResponse);
+ EXPECT_TRUE(decodedResponse->isMap());
+ const auto& coseKey = it->second.getMap();
+
+ const auto& it3 = coseKey.find(CBORValue(COSE::kty));
+ EXPECT_NE(it3, coseKey.end());
+ EXPECT_EQ(it3->second.getInteger(), COSE::EC2);
+
+ const auto& it4 = coseKey.find(CBORValue(COSE::alg));
+ EXPECT_NE(it4, coseKey.end());
+ EXPECT_EQ(it4->second.getInteger(), COSE::ECDH256);
+
+ const auto& it5 = coseKey.find(CBORValue(COSE::crv));
+ EXPECT_NE(it5, coseKey.end());
+ EXPECT_EQ(it5->second.getInteger(), COSE::P_256);
+
+ // Check the cose key.
+ const auto& xIt = coseKey.find(CBORValue(COSE::x));
+ EXPECT_NE(xIt, coseKey.end());
+ const auto& yIt = coseKey.find(CBORValue(COSE::y));
+ EXPECT_NE(yIt, coseKey.end());
+ auto cosePublicKey = CryptoKeyEC::importRaw(CryptoAlgorithmIdentifier::ECDH, "P-256", encodeRawPublicKey(xIt->second.getByteString(), yIt->second.getByteString()), true, CryptoKeyUsageDeriveBits);
+ EXPECT_TRUE(cosePublicKey);
+
+ // Check the encrypted Pin.
+ auto sharedKeyResult = CryptoAlgorithmECDH::platformDeriveBits(downcast<CryptoKeyEC>(*keyPair.privateKey), *cosePublicKey);
+ EXPECT_TRUE(sharedKeyResult);
+ auto aesKey = CryptoKeyAES::importRaw(CryptoAlgorithmIdentifier::AES_CBC, WTFMove(*sharedKeyResult), true, CryptoKeyUsageDecrypt);
+ EXPECT_TRUE(aesKey);
+
+ const auto& it6 = responseMap.find(CBORValue(static_cast<uint8_t>(RequestKey::kPinHashEnc)));
+ EXPECT_NE(it6, responseMap.end());
+ auto pinHashResult = CryptoAlgorithmAES_CBC::platformDecrypt({ }, *aesKey, it6->second.getByteString());
+ EXPECT_FALSE(pinHashResult.hasException());
+ auto pinHash = pinHashResult.releaseReturnValue();
+ const uint8_t expectedPinHash[] = { 0x03, 0xac, 0x67, 0x42, 0x16, 0xf3, 0xe1, 0x5c, 0x76, 0x1e, 0xe1, 0xa5, 0xe2, 0x55, 0xf0, 0x67 };
+ EXPECT_EQ(pinHash.size(), 16u);
+ EXPECT_EQ(memcmp(pinHash.data(), expectedPinHash, pinHash.size()), 0);
+}
+
+TEST(CtapPinTest, TestTokenResponse)
+{
+ const uint8_t sharedKeyData[] = {
+ 0x03, 0xac, 0x67, 0x42, 0x16, 0xf3, 0xe1, 0x5c,
+ 0x76, 0x1e, 0xe1, 0xa5, 0xe2, 0x55, 0xf0, 0x67,
+ 0x95, 0x36, 0x23, 0xc8, 0xb3, 0x88, 0xb4, 0x45,
+ 0x9e, 0x13, 0xf9, 0x78, 0xd7, 0xc8, 0x46, 0xf4, };
+ auto sharedKey = CryptoKeyAES::importRaw(CryptoAlgorithmIdentifier::AES_CBC, convertBytesToVector(sharedKeyData, sizeof(sharedKeyData)), true, CryptoKeyUsageEncrypt | CryptoKeyUsageDecrypt);
+ ASSERT_TRUE(sharedKey);
+
+ // Failure cases
+ auto result = TokenResponse::parse(*sharedKey, { });
+ EXPECT_FALSE(result);
+
+ const uint8_t testData1[] = { 0x05 }; // wrong response code
+ result = TokenResponse::parse(*sharedKey, convertBytesToVector(testData1, sizeof(testData1)));
+ EXPECT_FALSE(result);
+
+ const uint8_t testData2[] = { 0x00, 0x00 }; // wrong CBOR map
+ result = TokenResponse::parse(*sharedKey, convertBytesToVector(testData2, sizeof(testData2)));
+ EXPECT_FALSE(result);
+
+ result = TokenResponse::parse(*sharedKey, convertBytesToVector(TestData::kCtapClientPinKeyAgreementResponse, sizeof(TestData::kCtapClientPinKeyAgreementResponse))); // wrong response
+ EXPECT_FALSE(result);
+
+ // Success cases
+ result = TokenResponse::parse(*sharedKey, convertBytesToVector(TestData::kCtapClientPinTokenResponse, sizeof(TestData::kCtapClientPinTokenResponse)));
+ EXPECT_TRUE(result);
+ const uint8_t expectedToken[] = { 0x03, 0xac, 0x67, 0x42, 0x16, 0xf3, 0xe1, 0x5c, 0x76, 0x1e, 0xe1, 0xa5, 0xe2, 0x55, 0xf0, 0x67 };
+ EXPECT_EQ(result->token().size(), 16u);
+ EXPECT_EQ(memcmp(result->token().data(), expectedToken, result->token().size()), 0);
+}
+
+TEST(CtapPinTest, TestPinAuth)
+{
+ // 1. Generate the token.
+ const uint8_t sharedKeyData[] = {
+ 0x03, 0xac, 0x67, 0x42, 0x16, 0xf3, 0xe1, 0x5c,
+ 0x76, 0x1e, 0xe1, 0xa5, 0xe2, 0x55, 0xf0, 0x67,
+ 0x95, 0x36, 0x23, 0xc8, 0xb3, 0x88, 0xb4, 0x45,
+ 0x9e, 0x13, 0xf9, 0x78, 0xd7, 0xc8, 0x46, 0xf4, };
+ auto sharedKey = CryptoKeyAES::importRaw(CryptoAlgorithmIdentifier::AES_CBC, convertBytesToVector(sharedKeyData, sizeof(sharedKeyData)), true, CryptoKeyUsageEncrypt | CryptoKeyUsageDecrypt);
+ ASSERT_TRUE(sharedKey);
+ auto result = TokenResponse::parse(*sharedKey, convertBytesToVector(TestData::kCtapClientPinTokenResponse, sizeof(TestData::kCtapClientPinTokenResponse)));
+ ASSERT_TRUE(result);
+
+ // 2. Generate the pinAuth.
+ auto pinAuth = result->pinAuth(convertBytesToVector(sharedKeyData, sizeof(sharedKeyData))); // sharedKeyData pretends to be clientDataHash
+ const uint8_t expectedPinAuth[] = { 0xb3, 0xc2, 0x65, 0x1c, 0xfd, 0xc8, 0x42, 0xb4, 0x60, 0x16, 0xed, 0x20, 0x64, 0x53, 0xaf, 0x84 };
+ EXPECT_EQ(pinAuth.size(), 16u);
+ EXPECT_EQ(memcmp(pinAuth.data(), expectedPinAuth, pinAuth.size()), 0);
+}
+
+} // namespace TestWebKitAPI
+
+#endif // ENABLE(WEB_AUTHN)
Modified: trunk/Tools/TestWebKitAPI/Tests/WebCore/CtapRequestTest.cpp (253810 => 253811)
--- trunk/Tools/TestWebKitAPI/Tests/WebCore/CtapRequestTest.cpp 2019-12-20 03:32:37 UTC (rev 253810)
+++ trunk/Tools/TestWebKitAPI/Tests/WebCore/CtapRequestTest.cpp 2019-12-20 10:31:03 UTC (rev 253811)
@@ -32,8 +32,10 @@
#if ENABLE(WEB_AUTHN)
#include "FidoTestData.h"
+#include "PlatformUtilities.h"
#include <WebCore/DeviceRequestConverter.h>
#include <WebCore/FidoConstants.h>
+#include <WebCore/Pin.h>
#include <WebCore/PublicKeyCredentialCreationOptions.h>
#include <WebCore/PublicKeyCredentialRequestOptions.h>
#include <wtf/text/Base64.h>
@@ -67,6 +69,33 @@
EXPECT_EQ(memcmp(serializedData.data(), TestData::kCtapMakeCredentialRequest, serializedData.size()), 0);
}
+TEST(CTAPRequestTest, TestConstructMakeCredentialRequestParamWithPin)
+{
+ PublicKeyCredentialCreationOptions::RpEntity rp;
+ rp.name = "Acme";
+ rp.id = "acme.com";
+
+ PublicKeyCredentialCreationOptions::UserEntity user;
+ user.name = "[email protected]";
+ user.icon = "https://pics.acme.com/00/p/aBjjjpqPb.png";
+ user.idVector.append(TestData::kUserId, sizeof(TestData::kUserId));
+ user.displayName = "John P. Smith";
+
+ Vector<PublicKeyCredentialCreationOptions::Parameters> params { { PublicKeyCredentialType::PublicKey, 7 }, { PublicKeyCredentialType::PublicKey, 257 } };
+ PublicKeyCredentialCreationOptions::AuthenticatorSelectionCriteria selection { PublicKeyCredentialCreationOptions::AuthenticatorAttachment::Platform, true, UserVerificationRequirement::Preferred };
+
+ PinParameters pin;
+ pin.protocol = pin::kProtocolVersion;
+ pin.auth.append(TestData::kCtap2PinAuth, sizeof(TestData::kCtap2PinAuth));
+
+ PublicKeyCredentialCreationOptions options { rp, user, { }, params, WTF::nullopt, { }, selection, AttestationConveyancePreference::None, WTF::nullopt };
+ Vector<uint8_t> hash;
+ hash.append(TestData::kClientDataHash, sizeof(TestData::kClientDataHash));
+ auto serializedData = encodeMakeCredenitalRequestAsCBOR(hash, options, AuthenticatorSupportedOptions::UserVerificationAvailability::kSupportedButNotConfigured, pin);
+ EXPECT_EQ(serializedData.size(), sizeof(TestData::kCtapMakeCredentialRequestWithPin));
+ EXPECT_EQ(memcmp(serializedData.data(), TestData::kCtapMakeCredentialRequestWithPin, serializedData.size()), 0);
+}
+
TEST(CTAPRequestTest, TestConstructGetAssertionRequest)
{
PublicKeyCredentialRequestOptions options;
@@ -104,6 +133,47 @@
EXPECT_EQ(memcmp(serializedData.data(), TestData::kTestComplexCtapGetAssertionRequest, serializedData.size()), 0);
}
+TEST(CTAPRequestTest, TestConstructGetAssertionRequestWithPin)
+{
+ PublicKeyCredentialRequestOptions options;
+ options.rpId = "acme.com";
+
+ PublicKeyCredentialDescriptor descriptor1;
+ descriptor1.type = PublicKeyCredentialType::PublicKey;
+ const uint8_t id1[] = {
+ 0xf2, 0x20, 0x06, 0xde, 0x4f, 0x90, 0x5a, 0xf6, 0x8a, 0x43, 0x94,
+ 0x2f, 0x02, 0x4f, 0x2a, 0x5e, 0xce, 0x60, 0x3d, 0x9c, 0x6d, 0x4b,
+ 0x3d, 0xf8, 0xbe, 0x08, 0xed, 0x01, 0xfc, 0x44, 0x26, 0x46, 0xd0,
+ 0x34, 0x85, 0x8a, 0xc7, 0x5b, 0xed, 0x3f, 0xd5, 0x80, 0xbf, 0x98,
+ 0x08, 0xd9, 0x4f, 0xcb, 0xee, 0x82, 0xb9, 0xb2, 0xef, 0x66, 0x77,
+ 0xaf, 0x0a, 0xdc, 0xc3, 0x58, 0x52, 0xea, 0x6b, 0x9e };
+ descriptor1.idVector.append(id1, sizeof(id1));
+ options.allowCredentials.append(descriptor1);
+
+ PublicKeyCredentialDescriptor descriptor2;
+ descriptor2.type = PublicKeyCredentialType::PublicKey;
+ const uint8_t id2[] = {
+ 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03,
+ 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03,
+ 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03,
+ 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03,
+ 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03 };
+ descriptor2.idVector.append(id2, sizeof(id2));
+ options.allowCredentials.append(descriptor2);
+
+ options.userVerification = UserVerificationRequirement::Required;
+
+ PinParameters pin;
+ pin.protocol = pin::kProtocolVersion;
+ pin.auth.append(TestData::kCtap2PinAuth, sizeof(TestData::kCtap2PinAuth));
+
+ Vector<uint8_t> hash;
+ hash.append(TestData::kClientDataHash, sizeof(TestData::kClientDataHash));
+ auto serializedData = encodeGetAssertionRequestAsCBOR(hash, options, AuthenticatorSupportedOptions::UserVerificationAvailability::kSupportedButNotConfigured, pin);
+ EXPECT_EQ(serializedData.size(), sizeof(TestData::kTestComplexCtapGetAssertionRequestWithPin));
+ EXPECT_EQ(memcmp(serializedData.data(), TestData::kTestComplexCtapGetAssertionRequestWithPin, serializedData.size()), 0);
+}
+
TEST(CTAPRequestTest, TestConstructCtapAuthenticatorRequestParam)
{
static constexpr uint8_t kSerializedGetInfoCmd = 0x04;
Modified: trunk/Tools/TestWebKitAPI/Tests/WebCore/FidoTestData.h (253810 => 253811)
--- trunk/Tools/TestWebKitAPI/Tests/WebCore/FidoTestData.h 2019-12-20 03:32:37 UTC (rev 253810)
+++ trunk/Tools/TestWebKitAPI/Tests/WebCore/FidoTestData.h 2019-12-20 10:31:03 UTC (rev 253811)
@@ -525,8 +525,104 @@
// key - "uv"
0x62, 0x75, 0x76,
// True(21)
- 0xf5};
+ 0xf5
+};
+constexpr uint8_t kCtapMakeCredentialRequestWithPin[] = {
+ // authenticatorMakeCredential command
+ 0x01,
+ // map(7)
+ 0xa7,
+ // key(1) - clientDataHash
+ 0x01,
+ // bytes(32)
+ 0x58, 0x20, 0x68, 0x71, 0x34, 0x96, 0x82, 0x22, 0xec, 0x17, 0x20, 0x2e,
+ 0x42, 0x50, 0x5f, 0x8e, 0xd2, 0xb1, 0x6a, 0xe2, 0x2f, 0x16, 0xbb, 0x05,
+ 0xb8, 0x8c, 0x25, 0xdb, 0x9e, 0x60, 0x26, 0x45, 0xf1, 0x41,
+ // key(2) - rp
+ 0x02,
+ // map(2)
+ 0xa2,
+ // key - "id"
+ 0x62, 0x69, 0x64,
+ // value - "acme.com"
+ 0x68, 0x61, 0x63, 0x6d, 0x65, 0x2e, 0x63, 0x6f, 0x6d,
+ // key - "name"
+ 0x64, 0x6e, 0x61, 0x6d, 0x65,
+ // value - "Acme"
+ 0x64, 0x41, 0x63, 0x6d, 0x65,
+ // key(3) - user
+ 0x03,
+ // map(4)
+ 0xa4,
+ // key - "id"
+ 0x62, 0x69, 0x64,
+ // value - user id
+ 0x48, 0x10, 0x98, 0x23, 0x72, 0x35, 0x40, 0x98, 0x72,
+ // key - "icon"
+ 0x64, 0x69, 0x63, 0x6f, 0x6e,
+ // value - "https://pics.acme.com/00/p/aBjjjpqPb.png"
+ 0x78, 0x28, 0x68, 0x74, 0x74, 0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x70, 0x69,
+ 0x63, 0x73, 0x2e, 0x61, 0x63, 0x6d, 0x65, 0x2e, 0x63, 0x6f, 0x6d, 0x2f,
+ 0x30, 0x30, 0x2f, 0x70, 0x2f, 0x61, 0x42, 0x6a, 0x6a, 0x6a, 0x70, 0x71,
+ 0x50, 0x62, 0x2e, 0x70, 0x6e, 0x67,
+ // key - "name"
+ 0x64, 0x6e, 0x61, 0x6d, 0x65,
+ // value - "[email protected]"
+ 0x76, 0x6a, 0x6f, 0x68, 0x6e, 0x70, 0x73, 0x6d, 0x69, 0x74, 0x68, 0x40,
+ 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x63, 0x6f, 0x6d,
+ // key - "displayName"
+ 0x6b, 0x64, 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, 0x4e, 0x61, 0x6d, 0x65,
+ // value - "John P. Smith"
+ 0x6d, 0x4a, 0x6f, 0x68, 0x6e, 0x20, 0x50, 0x2e, 0x20, 0x53, 0x6d, 0x69,
+ 0x74, 0x68,
+ // key(4) - pubKeyCredParams
+ 0x04,
+ // array(2)
+ 0x82,
+ // map(2)
+ 0xa2,
+ // key - "alg"
+ 0x63, 0x61, 0x6c, 0x67,
+ // value - 7
+ 0x07,
+ // key - "type"
+ 0x64, 0x74, 0x79, 0x70, 0x65,
+ // value - "public-key"
+ 0x6a, 0x70, 0x75, 0x62, 0x6C, 0x69, 0x63, 0x2D, 0x6B, 0x65, 0x79,
+ // map(2)
+ 0xa2,
+ // key - "alg"
+ 0x63, 0x61, 0x6c, 0x67,
+ // value - 257
+ 0x19, 0x01, 0x01,
+ // key - "type"
+ 0x64, 0x74, 0x79, 0x70, 0x65, // "type"
+ // value - "public-key"
+ 0x6a, 0x70, 0x75, 0x62, 0x6C, 0x69, 0x63, 0x2D, 0x6B, 0x65, 0x79,
+ // key(7) - options
+ 0x07,
+ // map(2)
+ 0xa2,
+ // key - "rk"
+ 0x62, 0x72, 0x6b,
+ // True(21)
+ 0xf5,
+ // key - "uv"
+ 0x62, 0x75, 0x76,
+ // True(21)
+ 0xf5,
+ // key(8) - pinProtocol
+ 0x08,
+ // value - 1
+ 0x01,
+ // key(9) - pinAuth
+ 0x09,
+ // bytes(16)
+ 0x50, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a,
+ 0x0b, 0x0c, 0x0d, 0x0e, 0x0f
+};
+
constexpr uint8_t kTestComplexCtapGetAssertionRequest[] = {
// authenticatorGetAssertion command
0x02,
@@ -589,6 +685,77 @@
0xf5,
};
+constexpr uint8_t kTestComplexCtapGetAssertionRequestWithPin[] = {
+ // authenticatorGetAssertion command
+ 0x02,
+ // map(6)
+ 0xa6,
+ // key(01) -rpId
+ 0x01,
+ // value - "acme.com"
+ 0x68, 0x61, 0x63, 0x6d, 0x65, 0x2e, 0x63, 0x6f, 0x6d,
+ // key(02) - client data hash
+ 0x02,
+ // value - bytes(32)
+ 0x58, 0x20, 0x68, 0x71, 0x34, 0x96, 0x82, 0x22, 0xec, 0x17, 0x20, 0x2e,
+ 0x42, 0x50, 0x5f, 0x8e, 0xd2, 0xb1, 0x6a, 0xe2, 0x2f, 0x16, 0xbb, 0x05,
+ 0xb8, 0x8c, 0x25, 0xdb, 0x9e, 0x60, 0x26, 0x45, 0xf1, 0x41,
+ // key(03) - allow list
+ 0x03,
+ // value - array(2)
+ 0x82,
+ // map(2)
+ 0xa2,
+ // key - "id"
+ 0x62, 0x69, 0x64,
+ // value - credential ID
+ 0x58, 0x40, 0xf2, 0x20, 0x06, 0xde, 0x4f, 0x90, 0x5a, 0xf6, 0x8a, 0x43,
+ 0x94, 0x2f, 0x02, 0x4f, 0x2a, 0x5e, 0xce, 0x60, 0x3d, 0x9c, 0x6d, 0x4b,
+ 0x3d, 0xf8, 0xbe, 0x08, 0xed, 0x01, 0xfc, 0x44, 0x26, 0x46, 0xd0, 0x34,
+ 0x85, 0x8a, 0xc7, 0x5b, 0xed, 0x3f, 0xd5, 0x80, 0xbf, 0x98, 0x08, 0xd9,
+ 0x4f, 0xcb, 0xee, 0x82, 0xb9, 0xb2, 0xef, 0x66, 0x77, 0xaf, 0x0a, 0xdc,
+ 0xc3, 0x58, 0x52, 0xea, 0x6b, 0x9e,
+ // key - "type"
+ 0x64, 0x74, 0x79, 0x70, 0x65,
+ // value - "public-key"
+ 0x6a, 0x70, 0x75, 0x62, 0x6C, 0x69, 0x63, 0x2D, 0x6B, 0x65, 0x79,
+ // map(2)
+ 0xa2,
+ // key - "id"
+ 0x62, 0x69, 0x64,
+ // value - credential ID
+ 0x58, 0x32, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03,
+ 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03,
+ 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03,
+ 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03,
+ 0x03, 0x03, 0x03, 0x03,
+ // key - "type"
+ 0x64, 0x74, 0x79, 0x70, 0x65,
+ // value - "public-key"
+ 0x6a, 0x70, 0x75, 0x62, 0x6C, 0x69, 0x63, 0x2D, 0x6B, 0x65, 0x79,
+ // unsigned(5) - options
+ 0x05,
+ // map(2)
+ 0xa2,
+ // key -"up"
+ 0x62, 0x75, 0x70,
+ // value - True(21)
+ 0xf5,
+ // key - "uv"
+ 0x62, 0x75, 0x76,
+ // value - True(21)
+ 0xf5,
+ // key(8) - pinProtocol
+ 0x08,
+ // value - 1
+ 0x01,
+ // key(9) - pinAuth
+ 0x09,
+ // bytes(16)
+ 0x50, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a,
+ 0x0b, 0x0c, 0x0d, 0x0e, 0x0f
+};
+
// CTAP responses --------------------------------------------------------------
// A sample well formed response to CTAP AuthenticatorGetInfo request. Cross
@@ -892,6 +1059,102 @@
0x01,
};
+// CTAP PIN
+
+constexpr uint8_t kCtap2PinAuth[] = {
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+ 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
+};
+
+constexpr uint8_t kCtapClientPinRetries[] = {
+ // authenticatorClientPIN command
+ 0x06,
+ // map(2)
+ 0xa2,
+ // key(1) - pinProtocol
+ 0x01,
+ // value - 1
+ 0x01,
+ // key(2) - subCommand
+ 0x02,
+ // value - 1(getRetries)
+ 0x01,
+};
+
+constexpr uint8_t kCtapClientPinKeyAgreement[] = {
+ // authenticatorClientPIN command
+ 0x06,
+ // map(2)
+ 0xa2,
+ // key(1) - pinProtocol
+ 0x01,
+ // value - 1
+ 0x01,
+ // key(2) - subCommand
+ 0x02,
+ // value - 2(getKeyAgreement)
+ 0x02,
+};
+
+constexpr uint8_t kCtapClientPinTokenResponse[] = {
+ // Success
+ 0x00,
+ // map(1)
+ 0xa1,
+ // key(2) - pinToken
+ 0x02,
+ // bytes(32)
+ 0x58, 0x20,
+ // encrypted token
+ 0x48, 0xb9, 0x5d, 0x3d, 0x9e, 0xee, 0xe5, 0x00, 0xab, 0x51, 0x13, 0x2b,
+ 0x35, 0x77, 0x66, 0x5c, 0x41, 0x7a, 0x56, 0x3e, 0xb3, 0xe2, 0x3c, 0xb7,
+ 0x6a, 0x37, 0xb3, 0xde, 0x57, 0x2b, 0xca, 0xaa,
+};
+
+constexpr uint8_t kCtapClientPinKeyAgreementResponse[] = {
+ // Success
+ 0x00,
+ // map(1)
+ 0xA1,
+ // key(1) - keyAgreement
+ 0x01,
+ // Map(5)
+ 0xA5,
+ // kty: EC key type
+ 0x01, 0x02,
+ // alg: ECDH256 signature algorithm
+ 0x03, 0x38, 0x18,
+ // crv: P-256 curve
+ 0x20, 0x01,
+ // x-coordinate
+ 0x21,
+ // Bytes(32)
+ 0x58, 0x20,
+ // Byte array content
+ 0xE8, 0x76, 0x25, 0x89, 0x6E, 0xE4, 0xE4, 0x6D, 0xC0, 0x32, 0x76, 0x6E,
+ 0x80, 0x87, 0x96, 0x2F, 0x36, 0xDF, 0x9D, 0xFE, 0x8B, 0x56, 0x7F, 0x37,
+ 0x63, 0x01, 0x5B, 0x19, 0x90, 0xA6, 0x0E, 0x14,
+ // y-coordinate
+ 0x22,
+ // Bytes(32)
+ 0x58, 0x20,
+ // Byte array content
+ 0x27, 0xDE, 0x61, 0x2D, 0x66, 0x41, 0x8B, 0xDA, 0x19, 0x50, 0x58, 0x1E,
+ 0xBC, 0x5C, 0x8C, 0x1D, 0xAD, 0x71, 0x0C, 0xB1, 0x4C, 0x22, 0xF8, 0xC9,
+ 0x70, 0x45, 0xF4, 0x61, 0x2F, 0xB2, 0x0C, 0x91,
+};
+
+constexpr uint8_t kCtapClientPinRetriesResponse[] = {
+ // Success
+ 0x00,
+ // map(1)
+ 0xa1,
+ // key(3) - retries
+ 0x03,
+ // value - 8
+ 0x08,
+};
+
} // namespace TestData
} // namespace TestWebKitAPI