Skip to content
  • commit-queue@webkit.org's avatar
    window.crypto.getRandomValues should return the input ArrayBufferView · 1bf9c41f
    commit-queue@webkit.org authored
    https://bugs.webkit.org/show_bug.cgi?id=104845
    
    Source/WebCore:
    
    The W3C Web Crypto API FPWD, as well as the WHATWG February 2012 draft,
    define crypto.getRandomValues() as returning the input ArrayBufferView,
    to allow function call chaining. Update the implementation to match
    the current spec, rather than the old spec of void/undefined.
    
    Patch by Ryan Sleevi <rsleevi@chromium.org> on 2012-12-20
    Reviewed by Kentaro Hara.
    
    Test: security/crypto-random-values-types.html
    
    * GNUmakefile.list.am:
    * Target.pri:
    * UseJSC.cmake:
    * WebCore.gypi:
    * WebCore.xcodeproj/project.pbxproj:
    * bindings/js/JSBindingsAllInOne.cpp:
    * bindings/js/JSCryptoCustom.cpp: Added.
    (WebCore):
    (WebCore::JSCrypto::getRandomValues):
    Added custom getRandomValues implementation so that the input wrapped
    ArrayBufferView can be returned directly to the caller. This is to
    preserve the underlying type and indexing accessor for the TypedArray
    subclass.
    * bindings/v8/custom/V8CryptoCustom.cpp: Added.
    (WebCore):
    (WebCore::V8Crypto::getRandomValuesCallback):
    Added custom getRandomValues implementation so that the input wrapped
    ArrayBufferView can be returned directly to the caller. This is to
    preserve the underlying type and indexing accessor for the TypedArray
    subclass.
    * page/Crypto.idl:
    
    LayoutTests:
    
    Patch by Ryan Sleevi <rsleevi@chromium.org> on 2012-12-20
    Reviewed by Kentaro Hara.
    
    * fast/js/resources/js-test-pre.js:
    (shouldBeType):
    Added helper to assert that an expression returns an object of the
    correct type.
    * security/crypto-random-values-types-expected.txt:
    * security/crypto-random-values-types.html:
    Test all possible TypedArray integer types and ensure that both the
    correct TypedArray type is returned and that it is equal to the input
    type; that is, that the input type is modified in place, rather then
    copied.
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@138298 268f45cc-cd09-0410-ab3c-d52691b4dbfc
    1bf9c41f