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

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

        Reviewed by Sam Weinig.

        crypto.getRandomValues should support all integer array types
        https://bugs.webkit.org/show_bug.cgi?id=54342

        Test which types of arrays work with crypto.getRandomValues.

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

        Reviewed by Sam Weinig.

        crypto.getRandomValues should support all integer array types
        https://bugs.webkit.org/show_bug.cgi?id=54342

        As discussed on whatwg, we should support all the integer array types.

        Test: security/crypto-random-values-types.html

        * page/Crypto.cpp:
        (WebCore::Crypto::getRandomValues):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@78422 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent ca9201fd
2011-02-12 Adam Barth <abarth@webkit.org>
Reviewed by Sam Weinig.
crypto.getRandomValues should support all integer array types
https://bugs.webkit.org/show_bug.cgi?id=54342
Test which types of arrays work with crypto.getRandomValues.
* security/crypto-random-values-types-expected.txt: Added.
* security/crypto-random-values-types.html: Added.
2011-02-12 Jochen Eisinger <jochen@chromium.org>
Reviewed by Jeremy Orlow.
Tests which types are valid for 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 crypto.getRandomValues(new Uint8Array(3)) is undefined.
PASS crypto.getRandomValues(new Int8Array(3)) is undefined.
PASS crypto.getRandomValues(new Uint16Array(3)) is undefined.
PASS crypto.getRandomValues(new Int16Array(3)) is undefined.
PASS crypto.getRandomValues(new Uint32Array(3)) is undefined.
PASS crypto.getRandomValues(new Int32Array(3)) is undefined.
PASS crypto.getRandomValues(new Float32Array(3)) threw exception Error: VALIDATION_ERR: DOM Exception 16.
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 which types are valid for crypto.randomValues.");
if (!window.ArrayBuffer)
debug("This test requres ArrayBuffers to run!");
shouldBe("'crypto' in window", "true");
shouldBe("'getRandomValues' in window.crypto", "true");
shouldBeUndefined("crypto.getRandomValues(new Uint8Array(3))");
shouldBeUndefined("crypto.getRandomValues(new Int8Array(3))");
shouldBeUndefined("crypto.getRandomValues(new Uint16Array(3))");
shouldBeUndefined("crypto.getRandomValues(new Int16Array(3))");
shouldBeUndefined("crypto.getRandomValues(new Uint32Array(3))");
shouldBeUndefined("crypto.getRandomValues(new Int32Array(3))");
shouldThrow("crypto.getRandomValues(new Float32Array(3))");
var successfullyParsed = true;
</script>
<script src="../fast/js/resources/js-test-post.js"></script>
</body>
</html>
2011-02-12 Adam Barth <abarth@webkit.org>
Reviewed by Sam Weinig.
crypto.getRandomValues should support all integer array types
https://bugs.webkit.org/show_bug.cgi?id=54342
As discussed on whatwg, we should support all the integer array types.
Test: security/crypto-random-values-types.html
* page/Crypto.cpp:
(WebCore::Crypto::getRandomValues):
2011-02-12 Adam Barth <abarth@webkit.org>
Reviewed by Mark Rowe.
......@@ -34,9 +34,22 @@
#include "Uint8Array.h"
#include <wtf/CryptographicallyRandomNumber.h>
namespace WebCore {
namespace {
bool isIntegerArray(ArrayBufferView* array)
{
return array->isByteArray()
|| array->isUnsignedByteArray()
|| array->isShortArray()
|| array->isUnsignedShortArray()
|| array->isIntArray()
|| array->isUnsignedIntArray();
}
}
Crypto::Crypto()
{
}
......@@ -44,7 +57,7 @@ Crypto::Crypto()
void Crypto::getRandomValues(ArrayBufferView* array, ExceptionCode& ec)
{
#if USE(OS_RANDOMNESS)
if (!array || !array->isUnsignedByteArray()) {
if (!array || !isIntegerArray(array)) {
ec = VALIDATION_ERR;
return;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment