1. 13 Dec, 2013 1 commit
    • ap@apple.com's avatar
      WebCrypto Key.usages should be ordered alphabetically · 20890d48
      ap@apple.com authored
      https://bugs.webkit.org/show_bug.cgi?id=125696
      
      Reviewed by Darin Adler.
      
      Source/WebCore: 
      
      * crypto/CryptoKey.cpp: (WebCore::CryptoKey::usages): Do it.
      
      LayoutTests: 
      
      * crypto/subtle/aes-cbc-192-encrypt-decrypt-expected.txt:
      * crypto/subtle/aes-cbc-192-encrypt-decrypt.html:
      * crypto/subtle/aes-cbc-256-encrypt-decrypt-expected.txt:
      * crypto/subtle/aes-cbc-256-encrypt-decrypt.html:
      * crypto/subtle/aes-cbc-encrypt-decrypt-expected.txt:
      * crypto/subtle/aes-cbc-encrypt-decrypt-with-padding-expected.txt:
      * crypto/subtle/aes-cbc-encrypt-decrypt-with-padding.html:
      * crypto/subtle/aes-cbc-encrypt-decrypt.html:
      * crypto/subtle/aes-cbc-generate-key-expected.txt:
      * crypto/subtle/aes-cbc-generate-key.html:
      * crypto/subtle/aes-cbc-invalid-length-expected.txt:
      * crypto/subtle/aes-cbc-invalid-length.html:
      * crypto/subtle/aes-kw-wrap-unwrap-aes-expected.txt:
      * crypto/subtle/aes-kw-wrap-unwrap-aes.html:
      * crypto/subtle/aes-postMessage-expected.txt:
      * crypto/subtle/aes-postMessage.html:
      * crypto/subtle/hmac-postMessage-expected.txt:
      * crypto/subtle/hmac-postMessage.html:
      * crypto/subtle/jwk-import-use-values-expected.txt:
      * crypto/subtle/jwk-import-use-values.html:
      * crypto/subtle/postMessage-worker-expected.txt:
      * crypto/subtle/postMessage-worker.html:
      * crypto/subtle/resources/postMessage-worker.js:
      (onmessage):
      * crypto/subtle/rsa-oaep-key-manipulation-expected.txt:
      * crypto/subtle/rsa-oaep-key-manipulation.html:
      * crypto/subtle/rsa-oaep-wrap-unwrap-aes-expected.txt:
      * crypto/subtle/rsa-oaep-wrap-unwrap-aes.html:
      * crypto/subtle/rsaes-pkcs1-v1_5-wrap-unwrap-aes-expected.txt:
      * crypto/subtle/rsaes-pkcs1-v1_5-wrap-unwrap-aes.html:
      
      
      
      git-svn-id: http://svn.webkit.org/repository/webkit/trunk@160547 268f45cc-cd09-0410-ab3c-d52691b4dbfc
      20890d48
  2. 12 Dec, 2013 1 commit
    • ap@apple.com's avatar
      Make algorithm.name return registered name, not normalized one · 8199d8e9
      ap@apple.com authored
      https://bugs.webkit.org/show_bug.cgi?id=125641
      
      Reviewed by Anders Carlsson.
      
      Source/WebCore: 
      
      Currently, WebCrypto editor's draft stipulates that algorithm name is lowercased
      as part of normalization.
      
      But it makes little sense to register algorithms as mixed (mostly upper) case, yet
      return the name lowercased. Other implementations don't bother respecting this,
      and signs are that the spec will change.
      
      I'd like to match other implementations here, because sticking to the spec only
      makes us fail 3rd party test suites for no good reason.
      
      Updated many existing tests.
      
      * crypto/CryptoAlgorithmRegistry.cpp:
      (WebCore::CryptoAlgorithmRegistry::getIdentifierForName):
      (WebCore::CryptoAlgorithmRegistry::registerAlgorithm):
      * crypto/CryptoAlgorithmRegistry.h:
      * crypto/algorithms/CryptoAlgorithmAES_CBC.cpp:
      * crypto/algorithms/CryptoAlgorithmAES_KW.cpp:
      * crypto/algorithms/CryptoAlgorithmHMAC.cpp:
      * crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.cpp:
      * crypto/algorithms/CryptoAlgorithmRSA_OAEP.cpp:
      * crypto/algorithms/CryptoAlgorithmSHA1.cpp:
      * crypto/algorithms/CryptoAlgorithmSHA224.cpp:
      * crypto/algorithms/CryptoAlgorithmSHA256.cpp:
      * crypto/algorithms/CryptoAlgorithmSHA384.cpp:
      * crypto/algorithms/CryptoAlgorithmSHA512.cpp:
      
      LayoutTests: 
      
      * crypto/subtle/aes-cbc-192-encrypt-decrypt-expected.txt:
      * crypto/subtle/aes-cbc-192-encrypt-decrypt.html:
      * crypto/subtle/aes-cbc-256-encrypt-decrypt-expected.txt:
      * crypto/subtle/aes-cbc-256-encrypt-decrypt.html:
      * crypto/subtle/aes-cbc-encrypt-decrypt-expected.txt:
      * crypto/subtle/aes-cbc-encrypt-decrypt-with-padding-expected.txt:
      * crypto/subtle/aes-cbc-encrypt-decrypt-with-padding.html:
      * crypto/subtle/aes-cbc-encrypt-decrypt.html:
      * crypto/subtle/aes-cbc-generate-key-expected.txt:
      * crypto/subtle/aes-cbc-generate-key.html:
      * crypto/subtle/aes-cbc-import-jwk-expected.txt:
      * crypto/subtle/aes-cbc-import-jwk.html:
      * crypto/subtle/aes-cbc-invalid-length-expected.txt:
      * crypto/subtle/aes-cbc-invalid-length.html:
      * crypto/subtle/aes-cbc-unwrap-failure-expected.txt:
      * crypto/subtle/aes-cbc-unwrap-failure.html:
      * crypto/subtle/aes-cbc-unwrap-rsa-expected.txt:
      * crypto/subtle/aes-cbc-unwrap-rsa.html:
      * crypto/subtle/aes-cbc-wrap-rsa-expected.txt:
      * crypto/subtle/aes-cbc-wrap-rsa-non-extractable-expected.txt:
      * crypto/subtle/aes-cbc-wrap-rsa-non-extractable.html:
      * crypto/subtle/aes-cbc-wrap-rsa.html:
      * crypto/subtle/aes-kw-key-manipulation-expected.txt:
      * crypto/subtle/aes-kw-key-manipulation.html:
      * crypto/subtle/aes-kw-wrap-unwrap-aes-expected.txt:
      * crypto/subtle/aes-kw-wrap-unwrap-aes.html:
      * crypto/subtle/aes-postMessage-expected.txt:
      * crypto/subtle/aes-postMessage.html:
      * crypto/subtle/hmac-generate-key-expected.txt:
      * crypto/subtle/hmac-generate-key.html:
      * crypto/subtle/hmac-import-jwk-expected.txt:
      * crypto/subtle/hmac-import-jwk.html:
      * crypto/subtle/hmac-postMessage-expected.txt:
      * crypto/subtle/hmac-postMessage.html:
      * crypto/subtle/hmac-sign-verify-empty-key-expected.txt:
      * crypto/subtle/hmac-sign-verify-empty-key.html:
      * crypto/subtle/hmac-sign-verify-expected.txt:
      * crypto/subtle/hmac-sign-verify.html:
      * crypto/subtle/postMessage-worker-expected.txt:
      * crypto/subtle/postMessage-worker.html:
      * crypto/subtle/resources/postMessage-worker.js:
      * crypto/subtle/rsa-oaep-key-manipulation-expected.txt:
      * crypto/subtle/rsa-oaep-key-manipulation.html:
      * crypto/subtle/rsa-oaep-wrap-unwrap-aes-expected.txt:
      * crypto/subtle/rsa-oaep-wrap-unwrap-aes.html:
      * crypto/subtle/rsa-postMessage-expected.txt:
      * crypto/subtle/rsa-postMessage.html:
      * crypto/subtle/rsassa-pkcs1-v1_5-generate-key-expected.txt:
      * crypto/subtle/rsassa-pkcs1-v1_5-generate-key.html:
      * crypto/subtle/rsassa-pkcs1-v1_5-import-jwk-expected.txt:
      * crypto/subtle/rsassa-pkcs1-v1_5-import-jwk.html:
      
      
      
      git-svn-id: http://svn.webkit.org/repository/webkit/trunk@160491 268f45cc-cd09-0410-ab3c-d52691b4dbfc
      8199d8e9
  3. 15 Nov, 2013 1 commit
    • ap@apple.com's avatar
      Update WebCrypto tests · df32d58c
      ap@apple.com authored
      https://bugs.webkit.org/show_bug.cgi?id=124388
      
      Reviewed by Anders Carlsson.
      
      Updated tests for newer common.js. Changed some tests from just dumping results
      to comparing them to known expected ones. Fixed a syntax error in
      aes-cbc-invalid-length.html, so it now actually runs.
      
      * crypto/subtle/resources/common.js: Update to a new version from Blink, because
      it's much nicer than the old one, and it's good to be compatible at test level.
      Moved crypto.subtle definition from webkitSubtle here to avoid repeating it in all
      tests. Added a quick and dirty Promise.all implementation.
      
      * crypto/subtle/aes-cbc-192-encrypt-decrypt-expected.txt:
      * crypto/subtle/aes-cbc-192-encrypt-decrypt.html:
      * crypto/subtle/aes-cbc-256-encrypt-decrypt-expected.txt:
      * crypto/subtle/aes-cbc-256-encrypt-decrypt.html:
      * crypto/subtle/aes-cbc-encrypt-decrypt-expected.txt:
      * crypto/subtle/aes-cbc-encrypt-decrypt-with-padding-expected.txt:
      * crypto/subtle/aes-cbc-encrypt-decrypt-with-padding.html:
      * crypto/subtle/aes-cbc-encrypt-decrypt.html:
      * crypto/subtle/aes-cbc-generate-key.html:
      * crypto/subtle/aes-cbc-import-jwk-expected.txt:
      * crypto/subtle/aes-cbc-import-jwk.html:
      * crypto/subtle/aes-cbc-invalid-length-expected.txt:
      * crypto/subtle/aes-cbc-invalid-length.html:
      * crypto/subtle/aes-cbc-wrong-key-class.html:
      * crypto/subtle/aes-export-key-expected.txt:
      * crypto/subtle/aes-export-key.html:
      * crypto/subtle/argument-conversion-expected.txt:
      * crypto/subtle/argument-conversion.html:
      * crypto/subtle/hmac-export-key-expected.txt:
      * crypto/subtle/hmac-export-key.html:
      * crypto/subtle/hmac-generate-key.html:
      * crypto/subtle/hmac-import-jwk-expected.txt:
      * crypto/subtle/hmac-import-jwk.html:
      * crypto/subtle/hmac-sign-verify-empty-key-expected.txt:
      * crypto/subtle/hmac-sign-verify-empty-key.html:
      * crypto/subtle/hmac-sign-verify-expected.txt:
      * crypto/subtle/hmac-sign-verify.html:
      * crypto/subtle/import-jwk-expected.txt:
      * crypto/subtle/import-jwk.html:
      * crypto/subtle/rsassa-pkcs1-v1_5-generate-key-expected.txt:
      * crypto/subtle/rsassa-pkcs1-v1_5-generate-key.html:
      * crypto/subtle/rsassa-pkcs1-v1_5-import-jwk-expected.txt:
      * crypto/subtle/rsassa-pkcs1-v1_5-import-jwk.html:
      * crypto/subtle/rsassa-pkcs1-v1_5-sign-verify-expected.txt:
      * crypto/subtle/rsassa-pkcs1-v1_5-sign-verify.html:
      * crypto/subtle/sha-1-expected.txt:
      * crypto/subtle/sha-1.html:
      * crypto/subtle/sha-224-expected.txt:
      * crypto/subtle/sha-224.html:
      * crypto/subtle/sha-256-expected.txt:
      * crypto/subtle/sha-256.html:
      * crypto/subtle/sha-384-expected.txt:
      * crypto/subtle/sha-384.html:
      * crypto/subtle/sha-512-expected.txt:
      * crypto/subtle/sha-512.html:
      
      
      git-svn-id: http://svn.webkit.org/repository/webkit/trunk@159327 268f45cc-cd09-0410-ab3c-d52691b4dbfc
      df32d58c
  4. 04 Nov, 2013 2 commits
    • ap@apple.com's avatar
      Implement generateKey for HMAC and AES-CBC · 7537b6dc
      ap@apple.com authored
      https://bugs.webkit.org/show_bug.cgi?id=123669
      
      Reviewed by Dan Bernstein.
      
      Source/WebCore: 
      
      Tests: crypto/subtle/aes-cbc-generate-key.html
             crypto/subtle/hmac-generate-key.html
      
      * WebCore.xcodeproj/project.pbxproj: Added new files.
      
      * bindings/js/JSCryptoAlgorithmDictionary.cpp:
      (WebCore::createAesKeyGenParams): Added bindings for AesKeyGenParams.
      (WebCore::JSCryptoAlgorithmDictionary::createParametersForGenerateKey): Handle
      algorithms that generate AES and HMAC keys.
      
      * bindings/js/JSSubtleCryptoCustom.cpp: (WebCore::JSSubtleCrypto::generateKey): Added.
      
      * crypto/CryptoAlgorithmAesKeyGenParams.h: Added.
      
      * crypto/CryptoKey.cpp: (WebCore::CryptoKey::randomData):
      * crypto/CryptoKey.h:
      * crypto/CryptoKeyMac.cpp: Added
      Expose a function that produces random data for symmetric crypto keys. Cross-platform
      implementation uses ARC4 code from WTF, while Mac uses a system function that
      provides a FIPS validated random number generator.
      
      * crypto/CryptoKeyAES.cpp: (WebCore::CryptoKeyAES::generate):
      * crypto/CryptoKeyAES.h:
      Added a function that creates AES keys.
      
      * crypto/SubtleCrypto.idl: Added generateKey.
      
      * crypto/algorithms/CryptoAlgorithmAES_CBC.cpp:
      (WebCore::CryptoAlgorithmAES_CBC::generateKey): Added.
      
      * crypto/algorithms/CryptoAlgorithmHMAC.cpp:
      (WebCore::CryptoAlgorithmHMAC::generateKey): Added.
      
      * crypto/keys/CryptoKeyHMAC.cpp: (WebCore::CryptoKeyHMAC::generate):
      * crypto/keys/CryptoKeyHMAC.h:
      Added a function that creates HMAC keys.
      
      * crypto/mac/CryptoAlgorithmAES_CBCMac.cpp: Removed generateKey stub, the implementation
      ended up in cross-platform file.
      
      * crypto/mac/CryptoAlgorithmHMACMac.cpp: Ditto.
      
      LayoutTests: 
      
      * crypto/subtle/aes-cbc-generate-key-expected.txt: Added.
      * crypto/subtle/aes-cbc-generate-key.html: Added.
      * crypto/subtle/hmac-generate-key-expected.txt: Added.
      * crypto/subtle/hmac-generate-key.html: Added.
      
      * crypto/subtle/sha-1-expected.txt: Now that crypto.webkitSubtle.generateKey exists,
      a different exception is raised.
      
      
      
      git-svn-id: http://svn.webkit.org/repository/webkit/trunk@158582 268f45cc-cd09-0410-ab3c-d52691b4dbfc
      7537b6dc
    • commit-queue@webkit.org's avatar
      Unreviewed, rolling out r158526. · 18e275da
      commit-queue@webkit.org authored
      http://trac.webkit.org/changeset/158526
      https://bugs.webkit.org/show_bug.cgi?id=123744
      
      it broke the build (Requested by jessieberlin on #webkit).
      
      Source/WebCore:
      
      * WebCore.xcodeproj/project.pbxproj:
      * bindings/js/JSCryptoAlgorithmDictionary.cpp:
      (WebCore::createAesCbcParams):
      (WebCore::createHmacParams):
      (WebCore::createHmacKeyParams):
      (WebCore::JSCryptoAlgorithmDictionary::createParametersForGenerateKey):
      * bindings/js/JSSubtleCryptoCustom.cpp:
      * crypto/CryptoAlgorithmAesKeyGenParams.h: Removed.
      * crypto/CryptoKey.cpp:
      * crypto/CryptoKey.h:
      * crypto/CryptoKeyAES.cpp:
      * crypto/CryptoKeyAES.h:
      * crypto/CryptoKeyMac.cpp: Removed.
      * crypto/SubtleCrypto.idl:
      * crypto/algorithms/CryptoAlgorithmAES_CBC.cpp:
      * crypto/algorithms/CryptoAlgorithmHMAC.cpp:
      * crypto/keys/CryptoKeyHMAC.cpp:
      * crypto/keys/CryptoKeyHMAC.h:
      * crypto/mac/CryptoAlgorithmAES_CBCMac.cpp:
      (WebCore::CryptoAlgorithmAES_CBC::generateKey):
      * crypto/mac/CryptoAlgorithmHMACMac.cpp:
      (WebCore::CryptoAlgorithmHMAC::generateKey):
      
      LayoutTests:
      
      * crypto/subtle/aes-cbc-generate-key-expected.txt: Removed.
      * crypto/subtle/aes-cbc-generate-key.html: Removed.
      * crypto/subtle/hmac-generate-key-expected.txt: Removed.
      * crypto/subtle/hmac-generate-key.html: Removed.
      * crypto/subtle/sha-1-expected.txt:
      
      git-svn-id: http://svn.webkit.org/repository/webkit/trunk@158578 268f45cc-cd09-0410-ab3c-d52691b4dbfc
      18e275da
  5. 03 Nov, 2013 1 commit
    • ap@apple.com's avatar
      Implement generateKey for HMAC and AES-CBC · c07a2c0d
      ap@apple.com authored
      https://bugs.webkit.org/show_bug.cgi?id=123669
      
      Reviewed by Dan Bernstein.
      
      Source/WebCore:
      
      Tests: crypto/subtle/aes-cbc-generate-key.html
             crypto/subtle/hmac-generate-key.html
      
      * WebCore.xcodeproj/project.pbxproj: Added new files.
      
      * bindings/js/JSCryptoAlgorithmDictionary.cpp:
      (WebCore::createAesKeyGenParams): Added bindings for AesKeyGenParams.
      (WebCore::JSCryptoAlgorithmDictionary::createParametersForGenerateKey): Handle
      algorithms that generate AES and HMAC keys.
      
      * bindings/js/JSSubtleCryptoCustom.cpp: (WebCore::JSSubtleCrypto::generateKey): Added.
      
      * crypto/CryptoAlgorithmAesKeyGenParams.h: Added.
      
      * crypto/CryptoKey.cpp: (WebCore::CryptoKey::randomData):
      * crypto/CryptoKey.h:
      * crypto/CryptoKeyMac.cpp: Added
      Expose a function that produces random data for symmetric crypto keys. Cross-platform
      implementation uses ARC4 code from WTF, while Mac uses a system function that
      provides a FIPS validated random number generator.
      
      * crypto/CryptoKeyAES.cpp: (WebCore::CryptoKeyAES::generate):
      * crypto/CryptoKeyAES.h:
      Added a function that creates AES keys.
      
      * crypto/SubtleCrypto.idl: Added generateKey.
      
      * crypto/algorithms/CryptoAlgorithmAES_CBC.cpp:
      (WebCore::CryptoAlgorithmAES_CBC::generateKey): Added.
      
      * crypto/algorithms/CryptoAlgorithmHMAC.cpp:
      (WebCore::CryptoAlgorithmHMAC::generateKey): Added.
      
      * crypto/keys/CryptoKeyHMAC.cpp: (WebCore::CryptoKeyHMAC::generate):
      * crypto/keys/CryptoKeyHMAC.h:
      Added a function that creates HMAC keys.
      
      * crypto/mac/CryptoAlgorithmAES_CBCMac.cpp: Removed generateKey stub, the implementation
      ended up in cross-platform file.
      
      * crypto/mac/CryptoAlgorithmHMACMac.cpp: Ditto.
      
      LayoutTests:
      
      * crypto/subtle/aes-cbc-generate-key-expected.txt: Added.
      * crypto/subtle/aes-cbc-generate-key.html: Added.
      * crypto/subtle/hmac-generate-key-expected.txt: Added.
      * crypto/subtle/hmac-generate-key.html: Added.
      
      * crypto/subtle/sha-1-expected.txt: Now that crypto.webkitSubtle.generateKey exists,
      a different exception is raised.
      
      
      git-svn-id: http://svn.webkit.org/repository/webkit/trunk@158526 268f45cc-cd09-0410-ab3c-d52691b4dbfc
      c07a2c0d