Log Message
[GTK] Support latest SubtleCrypto HMAC APIs https://bugs.webkit.org/show_bug.cgi?id=165863
Reviewed by Sam Weinig. Source/WebCore: SubtleCrypto spec is updated, and new delegate implementations are required to support these interfaces. This patch implements platformSign and platformVerify with WorkQueues for gcrypt backend. * crypto/gcrypt/CryptoAlgorithmHMACGCrypt.cpp: (WebCore::calculateSignature): (WebCore::CryptoAlgorithmHMAC::platformSign): (WebCore::CryptoAlgorithmHMAC::platformVerify): LayoutTests: Enable HMAC tests. * platform/gtk/TestExpectations:
Modified Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (209848 => 209849)
--- trunk/LayoutTests/ChangeLog 2016-12-15 02:23:56 UTC (rev 209848)
+++ trunk/LayoutTests/ChangeLog 2016-12-15 02:31:37 UTC (rev 209849)
@@ -1,3 +1,14 @@
+2016-12-14 Yusuke Suzuki <[email protected]>
+
+ [GTK] Support latest SubtleCrypto HMAC APIs
+ https://bugs.webkit.org/show_bug.cgi?id=165863
+
+ Reviewed by Sam Weinig.
+
+ Enable HMAC tests.
+
+ * platform/gtk/TestExpectations:
+
2016-12-14 Simon Fraser <[email protected]>
Fix cause of viewport-related flakiness in iOS tests
Modified: trunk/LayoutTests/platform/gtk/TestExpectations (209848 => 209849)
--- trunk/LayoutTests/platform/gtk/TestExpectations 2016-12-15 02:23:56 UTC (rev 209848)
+++ trunk/LayoutTests/platform/gtk/TestExpectations 2016-12-15 02:31:37 UTC (rev 209849)
@@ -365,6 +365,46 @@
webkit.org/b/133122 crypto/subtle [ Skip ]
webkit.org/b/133122 crypto/webkitSubtle [ Skip ]
webkit.org/b/133122 crypto/workers/subtle [ Skip ]
+crypto/subtle/hmac-export-key-malformed-parameters.html [ Pass ]
+crypto/subtle/hmac-generate-export-key-jwk-sha1.html [ Pass ]
+crypto/subtle/hmac-generate-export-key-jwk-sha224.html [ Pass ]
+crypto/subtle/hmac-generate-export-key-jwk-sha256.html [ Pass ]
+crypto/subtle/hmac-generate-export-key-jwk-sha384.html [ Pass ]
+crypto/subtle/hmac-generate-export-key-jwk-sha512.html [ Pass ]
+crypto/subtle/hmac-generate-export-raw-key.html [ Pass ]
+crypto/subtle/hmac-generate-key-customized-length.html [ Pass ]
+crypto/subtle/hmac-generate-key-hash-object.html [ Pass ]
+crypto/subtle/hmac-generate-key-malformed-parameters.html [ Pass ]
+crypto/subtle/hmac-generate-key-sha1.html [ Pass ]
+crypto/subtle/hmac-generate-key-sha224.html [ Pass ]
+crypto/subtle/hmac-generate-key-sha256.html [ Pass ]
+crypto/subtle/hmac-generate-key-sha384.html [ Pass ]
+crypto/subtle/hmac-generate-key-sha512.html [ Pass ]
+crypto/subtle/hmac-generate-key-sign-verify.html [ Pass ]
+crypto/subtle/hmac-import-jwk-key-export-jwk-key.html [ Pass ]
+crypto/subtle/hmac-import-jwk-key-export-raw-key.html [ Pass ]
+crypto/subtle/hmac-import-jwk-key-minimum.html [ Pass ]
+crypto/subtle/hmac-import-jwk-key-non-extractable.html [ Pass ]
+crypto/subtle/hmac-import-jwk-key-sha1.html [ Pass ]
+crypto/subtle/hmac-import-jwk-key-sha224.html [ Pass ]
+crypto/subtle/hmac-import-jwk-key-sha256.html [ Pass ]
+crypto/subtle/hmac-import-jwk-key-sha384.html [ Pass ]
+crypto/subtle/hmac-import-jwk-key-sha512.html [ Pass ]
+crypto/subtle/hmac-import-key-malformed-parameters.html [ Pass ]
+crypto/subtle/hmac-import-key-sign-sha1.html [ Pass ]
+crypto/subtle/hmac-import-key-sign-sha224.html [ Pass ]
+crypto/subtle/hmac-import-key-sign-sha256.html [ Pass ]
+crypto/subtle/hmac-import-key-sign-sha384.html [ Pass ]
+crypto/subtle/hmac-import-key-sign-sha512.html [ Pass ]
+crypto/subtle/hmac-import-key-verify-sha1.html [ Pass ]
+crypto/subtle/hmac-import-key-verify-sha224.html [ Pass ]
+crypto/subtle/hmac-import-key-verify-sha256.html [ Pass ]
+crypto/subtle/hmac-import-key-verify-sha384.html [ Pass ]
+crypto/subtle/hmac-import-key-verify-sha512.html [ Pass ]
+crypto/subtle/hmac-import-raw-key-customized-length.html [ Pass ]
+crypto/subtle/hmac-import-raw-key-export-jwk-key.html [ Pass ]
+crypto/subtle/hmac-import-raw-key-export-raw-key.html [ Pass ]
+crypto/subtle/hmac-import-raw-key.html [ Pass ]
webkit.org/b/133319 crypto/webkitSubtle/sha-1.html [ Pass ]
webkit.org/b/133319 crypto/webkitSubtle/sha-224.html [ Pass ]
webkit.org/b/133319 crypto/webkitSubtle/sha-256.html [ Pass ]
Modified: trunk/Source/WebCore/ChangeLog (209848 => 209849)
--- trunk/Source/WebCore/ChangeLog 2016-12-15 02:23:56 UTC (rev 209848)
+++ trunk/Source/WebCore/ChangeLog 2016-12-15 02:31:37 UTC (rev 209849)
@@ -1,3 +1,18 @@
+2016-12-14 Yusuke Suzuki <[email protected]>
+
+ [GTK] Support latest SubtleCrypto HMAC APIs
+ https://bugs.webkit.org/show_bug.cgi?id=165863
+
+ Reviewed by Sam Weinig.
+
+ SubtleCrypto spec is updated, and new delegate implementations are required to support these interfaces.
+ This patch implements platformSign and platformVerify with WorkQueues for gcrypt backend.
+
+ * crypto/gcrypt/CryptoAlgorithmHMACGCrypt.cpp:
+ (WebCore::calculateSignature):
+ (WebCore::CryptoAlgorithmHMAC::platformSign):
+ (WebCore::CryptoAlgorithmHMAC::platformVerify):
+
2016-12-14 Chris Dumez <[email protected]>
Unreviewed, rolling out r209415.
Modified: trunk/Source/WebCore/crypto/gcrypt/CryptoAlgorithmHMACGCrypt.cpp (209848 => 209849)
--- trunk/Source/WebCore/crypto/gcrypt/CryptoAlgorithmHMACGCrypt.cpp 2016-12-15 02:23:56 UTC (rev 209848)
+++ trunk/Source/WebCore/crypto/gcrypt/CryptoAlgorithmHMACGCrypt.cpp 2016-12-15 02:31:37 UTC (rev 209849)
@@ -1,6 +1,8 @@
/*
* Copyright (C) 2014 Igalia S.L.
* Copyright (C) 2016 SoftAtHome
+ * Copyright (C) 2016 Apple Inc.
+ * Copyright (C) 2016 Yusuke Suzuki <[email protected]>.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -32,7 +34,7 @@
#include "CryptoAlgorithmHmacParamsDeprecated.h"
#include "CryptoKeyHMAC.h"
#include "ExceptionCode.h"
-#include "NotImplemented.h"
+#include "ScriptExecutionContext.h"
#include <gcrypt.h>
#include <wtf/CryptographicUtilities.h>
@@ -56,7 +58,7 @@
}
}
-static std::optional<Vector<uint8_t>> calculateSignature(int algorithm, const Vector<uint8_t>& key, const CryptoOperationData& data)
+static std::optional<Vector<uint8_t>> calculateSignature(int algorithm, const Vector<uint8_t>& key, const uint8_t* data, size_t dataLength)
{
size_t digestLength = gcry_mac_get_algo_maclen(algorithm);
const void* keyData = key.data() ? key.data() : reinterpret_cast<const uint8_t*>("");
@@ -75,7 +77,7 @@
if (err)
goto cleanup;
- err = gcry_mac_write(hd, data.first, data.second);
+ err = gcry_mac_write(hd, data, dataLength);
if (err)
goto cleanup;
@@ -97,16 +99,63 @@
return WTFMove(signature);
}
-void CryptoAlgorithmHMAC::platformSign(Ref<CryptoKey>&&, Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&)
+static std::optional<Vector<uint8_t>> calculateSignature(int algorithm, const Vector<uint8_t>& key, const CryptoOperationData& data)
{
- notImplemented();
+ return calculateSignature(algorithm, key, data.first, data.second);
}
-void CryptoAlgorithmHMAC::platformVerify(Ref<CryptoKey>&&, Vector<uint8_t>&&, Vector<uint8_t>&&, BoolCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&)
+void CryptoAlgorithmHMAC::platformSign(Ref<CryptoKey>&& key, Vector<uint8_t>&& data, VectorCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context, WorkQueue& workQueue)
{
- notImplemented();
+ context.ref();
+ workQueue.dispatch([key = WTFMove(key), data = "" callback = WTFMove(callback), exceptionCallback = WTFMove(exceptionCallback), &context]() mutable {
+ auto& hmacKey = downcast<CryptoKeyHMAC>(key.get());
+ auto algorithm = getGCryptDigestAlgorithm(hmacKey.hashAlgorithmIdentifier());
+ if (algorithm != GCRY_MAC_NONE) {
+ auto result = calculateSignature(algorithm, hmacKey.key(), data.data(), data.size());
+ if (result) {
+ // We should only dereference callbacks after being back to the Document/Worker threads.
+ context.postTask([callback = WTFMove(callback), result = WTFMove(*result), exceptionCallback = WTFMove(exceptionCallback)](ScriptExecutionContext& context) {
+ callback(result);
+ context.deref();
+ });
+ return;
+ }
+ }
+ // We should only dereference callbacks after being back to the Document/Worker threads.
+ context.postTask([exceptionCallback = WTFMove(exceptionCallback), callback = WTFMove(callback)](ScriptExecutionContext& context) {
+ exceptionCallback(OperationError);
+ context.deref();
+ });
+ });
}
+void CryptoAlgorithmHMAC::platformVerify(Ref<CryptoKey>&& key, Vector<uint8_t>&& signature, Vector<uint8_t>&& data, BoolCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context, WorkQueue& workQueue)
+{
+ context.ref();
+ workQueue.dispatch([key = WTFMove(key), signature = WTFMove(signature), data = "" callback = WTFMove(callback), exceptionCallback = WTFMove(exceptionCallback), &context]() mutable {
+ auto& hmacKey = downcast<CryptoKeyHMAC>(key.get());
+ auto algorithm = getGCryptDigestAlgorithm(hmacKey.hashAlgorithmIdentifier());
+ if (algorithm != GCRY_MAC_NONE) {
+ auto expectedSignature = calculateSignature(algorithm, hmacKey.key(), data.data(), data.size());
+ if (expectedSignature) {
+ // Using a constant time comparison to prevent timing attacks.
+ bool result = signature.size() == expectedSignature->size() && !constantTimeMemcmp(expectedSignature->data(), signature.data(), expectedSignature->size());
+ // We should only dereference callbacks after being back to the Document/Worker threads.
+ context.postTask([callback = WTFMove(callback), result, exceptionCallback = WTFMove(exceptionCallback)](ScriptExecutionContext& context) {
+ callback(result);
+ context.deref();
+ });
+ return;
+ }
+ }
+ // We should only dereference callbacks after being back to the Document/Worker threads.
+ context.postTask([exceptionCallback = WTFMove(exceptionCallback), callback = WTFMove(callback)](ScriptExecutionContext& context) {
+ exceptionCallback(OperationError);
+ context.deref();
+ });
+ });
+}
+
ExceptionOr<void> CryptoAlgorithmHMAC::platformSign(const CryptoAlgorithmHmacParamsDeprecated& parameters, const CryptoKeyHMAC& key, const CryptoOperationData& data, VectorCallback&& callback, VoidCallback&& failureCallback)
{
int algorithm = getGCryptDigestAlgorithm(parameters.hash);
_______________________________________________ webkit-changes mailing list [email protected] https://lists.webkit.org/mailman/listinfo/webkit-changes
