Skip to content
  • ap@apple.com's avatar
    [WebCrypto] Add SHA-1 · d23ff7fa
    ap@apple.com authored
    https://bugs.webkit.org/show_bug.cgi?id=123582
    
    Reviewed by Anders Carlsson.
    
    Source/WebCore: 
    
    Tests: security/crypto-subtle-arguments.html
           security/crypto-subtle-sha1.html
    
    * WebCore.xcodeproj/project.pbxproj: Added new files.
    
    * bindings/js/JSSubtleCryptoCustom.cpp:
    (WebCore::createAlgorithmFromJSValue):
    (WebCore::sequenceOfCryptoOperationDataFromJSValue):
    (WebCore::JSSubtleCrypto::digest):
    * crypto/SubtleCrypto.idl:
    Added bindings for crypto.digest.
    
    * crypto/algorithms: Added.
    * crypto/algorithms/CryptoAlgorithmSHA1.cpp: Added.
    * crypto/algorithms/CryptoAlgorithmSHA1.h: Added.
    * crypto/mac/CryptoAlgorithmRegistryMac.cpp:
    (WebCore::CryptoAlgorithmRegistry::platformRegisterAlgorithms): Register SHA-1.
    
    * crypto/mac/CryptoAlgorithmSHA1Mac.cpp: Added.
    (WebCore::CryptoAlgorithmSHA1::digest): Performs the work synchronously, because
    otherwise we'd have to copy the data first, which is crazy for something as simple
    as hashing. We can change to a dispatch queue later if we find that it's actually
    better to copy and do the work asynchronously.
    
    LayoutTests: 
    
    * security/resources/common.js: Added from Blink.
    (importTestKeys):
    (asciiToArrayBuffer):
    (printRejectedResult):
    (printAcceptedResult):
    (failAndFinishJSTest):
    
    * security/crypto-subtle-arguments-expected.txt: Added.
    * security/crypto-subtle-arguments.html: Added.
    Added tests for how bindings treat crazy arguments. Heavily based on a test from Blink.
    
    * security/crypto-subtle-sha1-expected.txt: Added.
    * security/crypto-subtle-sha1.html: Added.
    Test that SHA-1 works.
    
    * TestExpectations: Skip these tests everywhere for now.
    
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@158387 268f45cc-cd09-0410-ab3c-d52691b4dbfc
    d23ff7fa