Commit ba712d32 authored by abarth@webkit.org's avatar abarth@webkit.org

2011-02-10 Adam Barth <abarth@webkit.org>

        Reviewed by Eric Seidel.

        WebKit should have a cryptographic RNG
        https://bugs.webkit.org/show_bug.cgi?id=22049

        Test crypto.getRandomValues API.  It's pretty hard to write a
        deterministic API for a randomized API, but this test should catch some
        regressions.

        * security/crypto-random-values-expected.txt: Added.
        * security/crypto-random-values.html: Added.
2011-02-10  Adam Barth  <abarth@webkit.org>

        Reviewed by Eric Seidel.

        WebKit should have a cryptographic RNG
        https://bugs.webkit.org/show_bug.cgi?id=22049

        Teach JavaScriptCore how to export this function.

        * JavaScriptCore.exp:
        * JavaScriptCore.xcodeproj/project.pbxproj:
2011-02-10  Adam Barth  <abarth@webkit.org>

        Reviewed by Eric Seidel.

        WebKit should have a cryptographic RNG
        https://bugs.webkit.org/show_bug.cgi?id=22049

        Add crypto.getRandomValues.  Yes, all these diffs are required to
        expose a single function to the DOM.

        Test: security/crypto-random-values.html

        * Android.mk:
        * CMakeLists.txt:
        * DerivedSources.cpp:
        * DerivedSources.make:
        * ForwardingHeaders/wtf/CryptographicallyRandomNumber.h: Added.
        * GNUmakefile.am:
        * WebCore.gypi:
        * WebCore.pri:
        * WebCore.pro:
        * WebCore.vcproj/WebCore.vcproj:
        * WebCore.xcodeproj/project.pbxproj:
        * bindings/js/JSDOMWindowCustom.cpp:
        * bindings/v8/custom/V8DOMWindowCustom.cpp:
        * config.h:
        * page/Crypto.cpp: Added.
        (WebCore::Crypto::Crypto):
        (WebCore::Crypto::getRandomValues):
        * page/Crypto.h: Added.
        (WebCore::Crypto::create):
        * page/Crypto.idl: Added.
        * page/DOMWindow.cpp:
        (WebCore::DOMWindow::clear):
        (WebCore::DOMWindow::crypto):
        * page/DOMWindow.h:
        (WebCore::DOMWindow::optionalCrypto):
        * page/DOMWindow.idl:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@78321 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 3043e530
2011-02-10 Adam Barth <abarth@webkit.org>
Reviewed by Eric Seidel.
WebKit should have a cryptographic RNG
https://bugs.webkit.org/show_bug.cgi?id=22049
Test crypto.getRandomValues API. It's pretty hard to write a
deterministic API for a randomized API, but this test should catch some
regressions.
* security/crypto-random-values-expected.txt: Added.
* security/crypto-random-values.html: Added.
2011-02-10 Maciej Stachowiak <mjs@apple.com>
Reviewed by Dan Bernstein.
Tests crypto.randomValues.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS 'crypto' in window is true
PASS 'getRandomValues' in window.crypto is true
PASS matchingBytes < 100 is true
PASS successfullyParsed is true
TEST COMPLETE
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="../fast/js/resources/js-test-style.css">
<script src="../fast/js/resources/js-test-pre.js"></script>
<script src="resources/utilities.js"></script>
</head>
<body>
<p id="description"></p>
<div id="console"></div>
<script>
description("Tests crypto.randomValues.");
if (!window.ArrayBuffer)
debug("This test requres ArrayBuffers to run!");
shouldBe("'crypto' in window", "true");
shouldBe("'getRandomValues' in window.crypto", "true");
try {
// FIXME: This test is flaky. If we ran this test every second since the
// beginning of the universe, on average, it would have failed
// 2^{-748} times.
var reference = new Uint8Array(100);
var sample = new Uint8Array(100);
crypto.getRandomValues(reference);
crypto.getRandomValues(sample);
var matchingBytes = 0;
for (var i = 0; i < reference.length; i++) {
if (reference[i] == sample[i])
matchingBytes++;
}
shouldBe("matchingBytes < 100", "true");
} catch(ex) {
debug(ex);
}
var successfullyParsed = true;
</script>
<script src="../fast/js/resources/js-test-post.js"></script>
</body>
</html>
2011-02-10 Adam Barth <abarth@webkit.org>
Reviewed by Eric Seidel.
WebKit should have a cryptographic RNG
https://bugs.webkit.org/show_bug.cgi?id=22049
Teach JavaScriptCore how to export this function.
* JavaScriptCore.exp:
* JavaScriptCore.xcodeproj/project.pbxproj:
2011-02-10 Geoffrey Garen <ggaren@apple.com>
Reviewed by Sam Weinig.
......
......@@ -433,6 +433,7 @@ __ZN3WTF23dayInMonthFromDayInYearEib
__ZN3WTF23waitForThreadCompletionEjPPv
__ZN3WTF27releaseFastMallocFreeMemoryEv
__ZN3WTF28setMainThreadCallbacksPausedEb
__ZN3WTF29cryptographicallyRandomValuesEPvm
__ZN3WTF36lockAtomicallyInitializedStaticMutexEv
__ZN3WTF37parseDateFromNullTerminatedCharactersEPKc
__ZN3WTF38unlockAtomicallyInitializedStaticMutexEv
......
......@@ -336,7 +336,7 @@
97941A5713029AAB004A3447 /* OSRandomSource.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 97941A3F130299DB004A3447 /* OSRandomSource.cpp */; };
97941A5A13029ACC004A3447 /* OSRandomSource.h in Headers */ = {isa = PBXBuildFile; fileRef = 97941A40130299DB004A3447 /* OSRandomSource.h */; };
97941A7E1302A098004A3447 /* CryptographicallyRandomNumber.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 97941A7C1302A098004A3447 /* CryptographicallyRandomNumber.cpp */; };
97941A7F1302A098004A3447 /* CryptographicallyRandomNumber.h in Headers */ = {isa = PBXBuildFile; fileRef = 97941A7D1302A098004A3447 /* CryptographicallyRandomNumber.h */; };
97941A7F1302A098004A3447 /* CryptographicallyRandomNumber.h in Headers */ = {isa = PBXBuildFile; fileRef = 97941A7D1302A098004A3447 /* CryptographicallyRandomNumber.h */; settings = {ATTRIBUTES = (Private, ); }; };
A1712B3B11C7B212007A5315 /* RegExpCache.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A1712B3A11C7B212007A5315 /* RegExpCache.cpp */; };
A1712B3F11C7B228007A5315 /* RegExpCache.h in Headers */ = {isa = PBXBuildFile; fileRef = A1712B3E11C7B228007A5315 /* RegExpCache.h */; settings = {ATTRIBUTES = (Private, ); }; };
A1712B4111C7B235007A5315 /* RegExpKey.h in Headers */ = {isa = PBXBuildFile; fileRef = A1712B4011C7B235007A5315 /* RegExpKey.h */; settings = {ATTRIBUTES = (Private, ); }; };
......
......@@ -409,6 +409,7 @@ LOCAL_SRC_FILES := $(LOCAL_SRC_FILES) \
page/Console.cpp \
page/ContentSecurityPolicy.cpp \
page/ContextMenuController.cpp \
page/Crypto.cpp \
page/DOMSelection.cpp \
page/DOMTimer.cpp \
page/DOMWindow.cpp \
......
......@@ -319,6 +319,7 @@ SET(WebCore_IDL_FILES
page/BarInfo.idl
page/Console.idl
page/Coordinates.idl
page/Crypto.idl
page/DOMSelection.idl
page/DOMWindow.idl
page/EventSource.idl
......@@ -1110,6 +1111,7 @@ SET(WebCore_SOURCES
page/Console.cpp
page/ContentSecurityPolicy.cpp
page/ContextMenuController.cpp
page/Crypto.cpp
page/DOMSelection.cpp
page/DOMTimer.cpp
page/DOMWindow.cpp
......
2011-02-10 Adam Barth <abarth@webkit.org>
Reviewed by Eric Seidel.
WebKit should have a cryptographic RNG
https://bugs.webkit.org/show_bug.cgi?id=22049
Add crypto.getRandomValues. Yes, all these diffs are required to
expose a single function to the DOM.
Test: security/crypto-random-values.html
* Android.mk:
* CMakeLists.txt:
* DerivedSources.cpp:
* DerivedSources.make:
* ForwardingHeaders/wtf/CryptographicallyRandomNumber.h: Added.
* GNUmakefile.am:
* WebCore.gypi:
* WebCore.pri:
* WebCore.pro:
* WebCore.vcproj/WebCore.vcproj:
* WebCore.xcodeproj/project.pbxproj:
* bindings/js/JSDOMWindowCustom.cpp:
* bindings/v8/custom/V8DOMWindowCustom.cpp:
* config.h:
* page/Crypto.cpp: Added.
(WebCore::Crypto::Crypto):
(WebCore::Crypto::getRandomValues):
* page/Crypto.h: Added.
(WebCore::Crypto::create):
* page/Crypto.idl: Added.
* page/DOMWindow.cpp:
(WebCore::DOMWindow::clear):
(WebCore::DOMWindow::crypto):
* page/DOMWindow.h:
(WebCore::DOMWindow::optionalCrypto):
* page/DOMWindow.idl:
2011-02-11 Ryuan Choi <ryuan.choi@samsung.com>
Unreviewed build fix.
......@@ -50,6 +50,7 @@
#include "JSConsole.cpp"
#include "JSCoordinates.cpp"
#include "JSCounter.cpp"
#include "JSCrypto.cpp"
#include "JSCSSCharsetRule.cpp"
#include "JSCSSFontFaceRule.cpp"
#include "JSCSSImportRule.cpp"
......
......@@ -127,6 +127,7 @@ DOM_CLASSES = \
Console \
Coordinates \
Counter \
Crypto \
CustomEvent \
DataGridColumn \
DataGridColumnList \
......
#ifndef WebCore_FWD_CryptographicallyRandomNumber_h
#define WebCore_FWD_CryptographicallyRandomNumber_h
#include <JavaScriptCore/CryptographicallyRandomNumber.h>
#endif
......@@ -162,6 +162,8 @@ webcore_built_sources += \
DerivedSources/WebCore/JSCoordinates.h \
DerivedSources/WebCore/JSCounter.cpp \
DerivedSources/WebCore/JSCounter.h \
DerivedSources/WebCore/JSCrypto.cpp \
DerivedSources/WebCore/JSCrypto.h \
DerivedSources/WebCore/JSCSSCharsetRule.cpp \
DerivedSources/WebCore/JSCSSCharsetRule.h \
DerivedSources/WebCore/JSCSSFontFaceRule.cpp \
......@@ -2173,9 +2175,9 @@ webcore_sources += \
Source/WebCore/page/animation/KeyframeAnimation.h \
Source/WebCore/page/BarInfo.cpp \
Source/WebCore/page/BarInfo.h \
Source/WebCore/page/ChromeClient.h \
Source/WebCore/page/Chrome.cpp \
Source/WebCore/page/Chrome.h \
Source/WebCore/page/ChromeClient.h \
Source/WebCore/page/Console.cpp \
Source/WebCore/page/Console.h \
Source/WebCore/page/ContentSecurityPolicy.cpp \
......@@ -2185,6 +2187,8 @@ webcore_sources += \
Source/WebCore/page/ContextMenuController.h \
Source/WebCore/page/ContextMenuProvider.h \
Source/WebCore/page/Coordinates.h \
Source/WebCore/page/Crypto.cpp \
Source/WebCore/page/Crypto.h \
Source/WebCore/page/DOMSelection.cpp \
Source/WebCore/page/DOMSelection.h \
Source/WebCore/page/DOMTimer.cpp \
......@@ -2213,9 +2217,9 @@ webcore_sources += \
Source/WebCore/page/Geolocation.cpp \
Source/WebCore/page/Geolocation.h \
Source/WebCore/page/GeolocationClient.h \
Source/WebCore/page/GeolocationError.h \
Source/WebCore/page/GeolocationController.cpp \
Source/WebCore/page/GeolocationController.h \
Source/WebCore/page/GeolocationError.h \
Source/WebCore/page/GeolocationPosition.h \
Source/WebCore/page/GeolocationPositionCache.cpp \
Source/WebCore/page/GeolocationPositionCache.h \
......@@ -2232,30 +2236,30 @@ webcore_sources += \
Source/WebCore/page/MemoryInfo.h \
Source/WebCore/page/MouseEventWithHitTestResults.cpp \
Source/WebCore/page/MouseEventWithHitTestResults.h \
Source/WebCore/page/NavigatorBase.cpp \
Source/WebCore/page/NavigatorBase.h \
Source/WebCore/page/Navigator.cpp \
Source/WebCore/page/Navigator.h \
Source/WebCore/page/NavigatorBase.cpp \
Source/WebCore/page/NavigatorBase.h \
Source/WebCore/page/OriginAccessEntry.cpp \
Source/WebCore/page/OriginAccessEntry.h \
Source/WebCore/page/Page.cpp \
Source/WebCore/page/Page.h \
Source/WebCore/page/PageGroup.cpp \
Source/WebCore/page/PageGroup.h \
Source/WebCore/page/PageGroupLoadDeferrer.cpp \
Source/WebCore/page/PageGroupLoadDeferrer.h \
Source/WebCore/page/Page.h \
Source/WebCore/page/Performance.cpp \
Source/WebCore/page/Performance.h \
Source/WebCore/page/PerformanceNavigation.cpp \
Source/WebCore/page/PerformanceNavigation.h \
Source/WebCore/page/PerformanceTiming.cpp \
Source/WebCore/page/PerformanceTiming.h \
Source/WebCore/page/PluginHalterClient.h \
Source/WebCore/page/PluginHalter.cpp \
Source/WebCore/page/PluginHalter.h \
Source/WebCore/page/PluginHalterClient.h \
Source/WebCore/page/PositionCallback.h \
Source/WebCore/page/PositionErrorCallback.h \
Source/WebCore/page/PositionError.h \
Source/WebCore/page/PositionErrorCallback.h \
Source/WebCore/page/PositionOptions.h \
Source/WebCore/page/PrintContext.cpp \
Source/WebCore/page/PrintContext.h \
......
......@@ -245,6 +245,7 @@
'page/BarInfo.idl',
'page/Console.idl',
'page/Coordinates.idl',
'page/Crypto.idl',
'page/DOMSelection.idl',
'page/DOMWindow.idl',
'page/EventSource.idl',
......@@ -2279,6 +2280,8 @@
'page/ContextMenuController.cpp',
'page/ContextMenuController.h',
'page/ContextMenuProvider.h',
'page/Crypto.cpp',
'page/Crypto.h',
'page/DOMSelection.cpp',
'page/DOMSelection.h',
'page/DOMTimer.cpp',
......
......@@ -308,6 +308,7 @@ IDL_BINDINGS += \
page/BarInfo.idl \
page/Console.idl \
page/Coordinates.idl \
page/Crypto.idl \
page/DOMSelection.idl \
page/DOMWindow.idl \
page/EventSource.idl \
......
......@@ -1128,11 +1128,10 @@ SOURCES += \
page/Console.cpp \
page/ContentSecurityPolicy.cpp \
page/ContextMenuController.cpp \
page/Crypto.cpp \
page/DOMSelection.cpp \
page/DOMTimer.cpp \
page/DOMWindow.cpp \
page/Navigator.cpp \
page/NavigatorBase.cpp \
page/DragController.cpp \
page/EventHandler.cpp \
page/EventSource.cpp \
......@@ -1148,6 +1147,8 @@ SOURCES += \
page/Location.cpp \
page/MemoryInfo.cpp \
page/MouseEventWithHitTestResults.cpp \
page/Navigator.cpp \
page/NavigatorBase.cpp \
page/OriginAccessEntry.cpp \
page/Page.cpp \
page/PageGroup.cpp \
......@@ -1157,8 +1158,8 @@ SOURCES += \
page/PerformanceTiming.cpp \
page/PluginHalter.cpp \
page/PrintContext.cpp \
page/SecurityOrigin.cpp \
page/Screen.cpp \
page/SecurityOrigin.cpp \
page/Settings.cpp \
page/SpatialNavigation.cpp \
page/SuspendableTimer.cpp \
......
......@@ -1753,6 +1753,62 @@
RelativePath="$(ConfigurationBuildDir)\obj\$(ProjectName)\DerivedSources\JSCounter.h"
>
</File>
<File
RelativePath="$(ConfigurationBuildDir)\obj\$(ProjectName)\DerivedSources\JSCrypto.cpp"
>
<FileConfiguration
Name="Debug|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
/>
</FileConfiguration>
<FileConfiguration
Name="Debug_Cairo_CFLite|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
/>
</FileConfiguration>
<FileConfiguration
Name="Release_Cairo_CFLite|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
/>
</FileConfiguration>
<FileConfiguration
Name="Debug_All|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
/>
</FileConfiguration>
<FileConfiguration
Name="Release_LTCG|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
/>
</FileConfiguration>
</File>
<File
RelativePath="$(ConfigurationBuildDir)\obj\$(ProjectName)\DerivedSources\JSCrypto.h"
>
</File>
<File
RelativePath="$(ConfigurationBuildDir)\obj\$(ProjectName)\DerivedSources\JSCSSCharsetRule.cpp"
>
......@@ -3032,6 +3032,10 @@
973889A1116EA9DC00ADF313 /* DocumentWriter.h in Headers */ = {isa = PBXBuildFile; fileRef = 9738899F116EA9DC00ADF313 /* DocumentWriter.h */; settings = {ATTRIBUTES = (Private, ); }; };
973E325610883B7C005BC493 /* ResourceLoadNotifier.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 973E325410883B7C005BC493 /* ResourceLoadNotifier.cpp */; };
973E325710883B7C005BC493 /* ResourceLoadNotifier.h in Headers */ = {isa = PBXBuildFile; fileRef = 973E325510883B7C005BC493 /* ResourceLoadNotifier.h */; settings = {ATTRIBUTES = (Private, ); }; };
975CA28A130365F800E99AD9 /* Crypto.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 975CA287130365F800E99AD9 /* Crypto.cpp */; };
975CA28B130365F800E99AD9 /* Crypto.h in Headers */ = {isa = PBXBuildFile; fileRef = 975CA288130365F800E99AD9 /* Crypto.h */; };
975CA2A11303679D00E99AD9 /* JSCrypto.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 975CA29F1303679D00E99AD9 /* JSCrypto.cpp */; };
975CA2A21303679D00E99AD9 /* JSCrypto.h in Headers */ = {isa = PBXBuildFile; fileRef = 975CA2A01303679D00E99AD9 /* JSCrypto.h */; };
976D6C77122B8A3D001FD1F7 /* AsyncFileWriter.h in Headers */ = {isa = PBXBuildFile; fileRef = 976D6C58122B8A3D001FD1F7 /* AsyncFileWriter.h */; };
976D6C78122B8A3D001FD1F7 /* Blob.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 976D6C59122B8A3D001FD1F7 /* Blob.cpp */; };
976D6C79122B8A3D001FD1F7 /* Blob.h in Headers */ = {isa = PBXBuildFile; fileRef = 976D6C5A122B8A3D001FD1F7 /* Blob.h */; };
......@@ -9416,6 +9420,11 @@
9738899F116EA9DC00ADF313 /* DocumentWriter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DocumentWriter.h; sourceTree = "<group>"; };
973E325410883B7C005BC493 /* ResourceLoadNotifier.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ResourceLoadNotifier.cpp; sourceTree = "<group>"; };
973E325510883B7C005BC493 /* ResourceLoadNotifier.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ResourceLoadNotifier.h; sourceTree = "<group>"; };
975CA287130365F800E99AD9 /* Crypto.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Crypto.cpp; sourceTree = "<group>"; };
975CA288130365F800E99AD9 /* Crypto.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Crypto.h; sourceTree = "<group>"; };
975CA289130365F800E99AD9 /* Crypto.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = Crypto.idl; sourceTree = "<group>"; };
975CA29F1303679D00E99AD9 /* JSCrypto.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSCrypto.cpp; sourceTree = "<group>"; };
975CA2A01303679D00E99AD9 /* JSCrypto.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSCrypto.h; sourceTree = "<group>"; };
976D6C58122B8A3D001FD1F7 /* AsyncFileWriter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AsyncFileWriter.h; path = fileapi/AsyncFileWriter.h; sourceTree = "<group>"; };
976D6C59122B8A3D001FD1F7 /* Blob.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Blob.cpp; path = fileapi/Blob.cpp; sourceTree = "<group>"; };
976D6C5A122B8A3D001FD1F7 /* Blob.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Blob.h; path = fileapi/Blob.h; sourceTree = "<group>"; };
......@@ -13956,6 +13965,9 @@
7ADE722510CBBB9B006B3B3A /* ContextMenuProvider.h */,
FE6FD4850F676E5700092873 /* Coordinates.h */,
FE6FD4860F676E5700092873 /* Coordinates.idl */,
975CA287130365F800E99AD9 /* Crypto.cpp */,
975CA288130365F800E99AD9 /* Crypto.h */,
975CA289130365F800E99AD9 /* Crypto.idl */,
BC5A86810C33676000EEA649 /* DOMSelection.cpp */,
BC5A86820C33676000EEA649 /* DOMSelection.h */,
BC5A86830C33676000EEA649 /* DOMSelection.idl */,
......@@ -18033,6 +18045,8 @@
BC124EFE0C26447A009E2349 /* JSBarInfo.h */,
BC98543B0CD3D98B00069BC1 /* JSConsole.cpp */,
BC98543C0CD3D98B00069BC1 /* JSConsole.h */,
975CA29F1303679D00E99AD9 /* JSCrypto.cpp */,
975CA2A01303679D00E99AD9 /* JSCrypto.h */,
BC5A86B30C3367E800EEA649 /* JSDOMSelection.cpp */,
BC5A86B40C3367E800EEA649 /* JSDOMSelection.h */,
1403BA0B09EB18C700797C7F /* JSDOMWindow.cpp */,
......@@ -22444,6 +22458,8 @@
E1BE512E0CF6C512002EA959 /* XSLTUnicodeSort.h in Headers */,
9343CB8212F25E510033C5EE /* TextCodecUTF8.h in Headers */,
977E2E0F12F0FC9C00C13379 /* XSSFilter.h in Headers */,
975CA28B130365F800E99AD9 /* Crypto.h in Headers */,
975CA2A21303679D00E99AD9 /* JSCrypto.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......@@ -25127,6 +25143,8 @@
9343CB8112F25E510033C5EE /* TextCodecUTF8.cpp in Sources */,
977E2E0E12F0FC9C00C13379 /* XSSFilter.cpp in Sources */,
0F29C16E1300C2E2002D794E /* AccessibilityAllInOne.cpp in Sources */,
975CA28A130365F800E99AD9 /* Crypto.cpp in Sources */,
975CA2A11303679D00E99AD9 /* JSCrypto.cpp in Sources */,
A1E1154413015C3D0054AC8C /* DistantLightSource.cpp in Sources */,
A1E1154613015C4E0054AC8C /* PointLightSource.cpp in Sources */,
A1E1154813015C5D0054AC8C /* SpotLightSource.cpp in Sources */,
......@@ -489,11 +489,6 @@ void JSDOMWindow::setLocation(ExecState* exec, JSValue value)
impl()->setLocation(ustringToString(locationString), activeDOMWindow(exec), firstDOMWindow(exec));
}
JSValue JSDOMWindow::crypto(ExecState*) const
{
return jsUndefined();
}
JSValue JSDOMWindow::event(ExecState* exec) const
{
Event* event = currentEvent();
......
......@@ -183,12 +183,6 @@ void V8DOMWindow::eventAccessorSetter(v8::Local<v8::String> name, v8::Local<v8::
context->Global()->SetHiddenValue(eventSymbol, value);
}
v8::Handle<v8::Value> V8DOMWindow::cryptoAccessorGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
{
// FIXME: Implement me.
return v8::Undefined();
}
void V8DOMWindow::locationAccessorSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info)
{
DOMWindow* imp = V8DOMWindow::toNative(info.Holder());
......
......@@ -171,6 +171,10 @@
#define USE_SYSTEM_MALLOC 1
#endif
#if OS(DARWIN) || OS(UNIX) || OS(WINDOWS)
#define WTF_USE_OS_RANDOMNESS 1
#endif
#if PLATFORM(CHROMIUM)
#if !OS(DARWIN)
......
/*
* Copyright (C) 2011 Google 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.
* 3. Neither the name of Google, Inc. ("Google") 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 GOOGLE 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 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"
#include "Crypto.h"
#include "ExceptionCode.h"
#include "Uint8Array.h"
#include <wtf/CryptographicallyRandomNumber.h>
namespace WebCore {
Crypto::Crypto()
{
}
void Crypto::getRandomValues(ArrayBufferView* array, ExceptionCode& ec)
{
#if USE(OS_RANDOMNESS)
if (!array || !array->isUnsignedByteArray()) {
ec = VALIDATION_ERR;
return;
}
cryptographicallyRandomValues(array->baseAddress(), array->byteLength());
#else
ASSERT_UNUSED(array, array);
ec = NOT_SUPPORTED_ERR;
#endif
}
}
/*
* Copyright (C) 2011 Google 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.
* 3. Neither the name of Google, Inc. ("Google") 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 GOOGLE 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 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.
*/
#ifndef Crypto_h
#define Crypto_h
#include <wtf/Forward.h>
#include <wtf/PassRefPtr.h>
#include <wtf/RefCounted.h>
namespace WebCore {
class ArrayBufferView;
typedef int ExceptionCode;
class Crypto : public RefCounted<Crypto> {
public:
static PassRefPtr<Crypto> create() { return adoptRef(new Crypto()); }
void getRandomValues(ArrayBufferView*, ExceptionCode&);
private:
Crypto();
};
}
#endif
/*
* Copyright (C) 2011 Google 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.
* 3. Neither the name of Googl, Inc. ("Google") 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 GOOGLE 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 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.
*/
module window {
interface [
OmitConstructor
] Crypto {
// FIXME: We should just enable ArrayBuffer support all the time.
[Conditional=WEBGL|BLOB] void getRandomValues(in ArrayBufferView array) raises(DOMException);
};
}
......@@ -37,6 +37,7 @@
#include "CSSStyleSelector.h"
#include "Chrome.h"
#include "Console.h"
#include "Crypto.h"
#include "DOMApplicationCache.h"
#include "DOMSelection.h"
#include "DOMSettableTokenList.h"
......@@ -433,6 +434,8 @@ void DOMWindow::clear()
m_history->disconnectFrame();
m_history = 0;
m_crypto = 0;
if (m_locationbar)
m_locationbar->disconnectFrame();
m_locationbar = 0;
......@@ -530,6 +533,13 @@ History* DOMWindow::history() const
return m_history.get();
}
Crypto* DOMWindow::crypto() const
{
if (!m_crypto)
m_crypto = Crypto::create();
return m_crypto.get();