haikuwebkit/LayoutTests/crypto/subtle/derive-bits-malformed-param...

56 lines
1.4 KiB
HTML
Raw Permalink Normal View History

[WebCrypto] Implement ECDH DeriveBits operation https://bugs.webkit.org/show_bug.cgi?id=169319 <rdar://problem/23789585> Reviewed by Brent Fulgham. Source/WebCore: This patch implements DeriveBits operation of ECDH according to the spec: https://www.w3.org/TR/WebCryptoAPI/#ecdh-operations. Tests: crypto/subtle/derive-bits-malformed-parameters.html crypto/subtle/ecdh-derive-bits-malformed-parametrs.html crypto/subtle/ecdh-generate-key-derive-bits.html crypto/subtle/ecdh-import-key-derive-bits-custom-length.html crypto/subtle/ecdh-import-key-derive-bits-null-length.html crypto/workers/subtle/ecdh-import-key-derive-bits.html * CMakeLists.txt: * DerivedSources.make: * PlatformGTK.cmake: * PlatformMac.cmake: * WebCore.xcodeproj/project.pbxproj: * bindings/js/JSSubtleCryptoCustom.cpp: (WebCore::normalizeCryptoAlgorithmParameters): (WebCore::jsSubtleCryptoFunctionDeriveKeyPromise): (WebCore::jsSubtleCryptoFunctionDeriveBitsPromise): (WebCore::JSSubtleCrypto::generateKey): Reorder a bit of the functions. * crypto/CommonCryptoUtilities.h: * crypto/CryptoAlgorithm.cpp: (WebCore::CryptoAlgorithm::deriveBits): * crypto/CryptoAlgorithm.h: * crypto/CryptoAlgorithmParameters.h: * crypto/algorithms/CryptoAlgorithmECDH.cpp: (WebCore::CryptoAlgorithmECDH::deriveBits): * crypto/algorithms/CryptoAlgorithmECDH.h: * crypto/gnutls/CryptoAlgorithmECDHGnuTLS.cpp: Added. (WebCore::CryptoAlgorithmECDH::platformDeriveBits): * crypto/keys/CryptoKeyEC.h: * crypto/mac/CryptoAlgorithmECDHMac.cpp: Added. (WebCore::CryptoAlgorithmECDH::platformDeriveBits): * crypto/parameters/CryptoAlgorithmEcdhKeyDeriveParams.h: Added. * crypto/parameters/EcdhKeyDeriveParams.idl: Added. LayoutTests: * TestExpectations: Refine some comments. * crypto/subtle/derive-bits-malformed-parameters-expected.txt: Renamed from LayoutTests/crypto/subtle/deriveBits-malformed-parameters-expected.txt. * crypto/subtle/derive-bits-malformed-parameters.html: Added. * crypto/subtle/deriveBits-malformed-parameters.html: Removed. * crypto/subtle/ecdh-derive-bits-malformed-parametrs-expected.txt: Added. * crypto/subtle/ecdh-derive-bits-malformed-parametrs.html: Added. * crypto/subtle/ecdh-generate-key-derive-bits-expected.txt: Added. * crypto/subtle/ecdh-generate-key-derive-bits.html: Added. * crypto/subtle/ecdh-import-key-derive-bits-custom-length-expected.txt: Added. * crypto/subtle/ecdh-import-key-derive-bits-custom-length.html: Added. * crypto/subtle/ecdh-import-key-derive-bits-null-length-expected.txt: Added. * crypto/subtle/ecdh-import-key-derive-bits-null-length.html: Added. * crypto/workers/subtle/ecdh-import-key-derive-bits-expected.txt: Added. * crypto/workers/subtle/ecdh-import-key-derive-bits.html: Added. * crypto/workers/subtle/resources/ecdh-import-key-derive-bits.js: Added. Canonical link: https://commits.webkit.org/186381@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@213624 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-03-09 04:04:29 +00:00
<!DOCTYPE html>
<html>
<head>
<script src="../../resources/js-test-pre.js"></script>
<script src="../resources/common.js"></script>
</head>
<body>
<p id="description"></p>
<div id="console"></div>
<script>
description("Test deriveBits operation with malformed parameters");
jsTestIsAsync = true;
var extractable = true;
var hmacImportParams = {
name: "hmac",
hash: "sha-1",
}
var rawKey = asciiToUint8Array("jnOw99oOZFLIEPMr");
var jwkKey = {
kty: "EC",
crv: "P-256",
x: "1FSVWieTvikFkG1NOyhkUCaMbdQhxwH6aCu4Ez-sRtA",
y: "9jmNTLqM4cjBhdAnHcNI9YQV3O8LFmo-EdZWk8ntAaI",
d: "ppxBSov3N8_AUcisAuvmLV4yE8e_L_BLE8bZb9Z1Xjg",
};
// Not enough arguments.
shouldReject('crypto.subtle.deriveBits()');
shouldReject('crypto.subtle.deriveBits(1)');
shouldReject('crypto.subtle.deriveBits(1, 2)');
crypto.subtle.importKey("raw", rawKey, hmacImportParams, extractable, ["sign", "verify"]).then(function(result) {
wrongKey = result;
// Wrong algorithm identifier.
shouldReject('crypto.subtle.deriveBits({ name:"ECDH", public:wrongKey }, wrongKey, 128)');
return crypto.subtle.importKey("jwk", jwkKey, { name: "ECDH", namedCurve: "P-256" }, extractable, ["deriveKey"]);
}).then(function(result) {
wrongKey = result;
// Wrong usage.
shouldReject('crypto.subtle.deriveBits({ name:"ECDH", public:wrongKey }, wrongKey, 128)');
finishJSTest();
});
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>