1. 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
  2. 04 Dec, 2013 1 commit
    • ap@apple.com's avatar
      Update WebCrypto JWK mapping to newer proposal · e6074e79
      ap@apple.com authored
      https://bugs.webkit.org/show_bug.cgi?id=124218
      
      Reviewed by Anders Carlsson.
      
      Source/WebCore: 
      
      Tests: crypto/subtle/jwk-export-use-values.html
             crypto/subtle/jwk-import-use-values.html
      
      1. "extractable" renamed to "ext" in JWK.
      2. New values for "use" mapping, which can now be combined into comma separated lists,
      and cover all possible WebCrypto usages.
      
      * bindings/js/JSCryptoKeySerializationJWK.cpp:
      (WebCore::JSCryptoKeySerializationJWK::reconcileUsages):
      (WebCore::JSCryptoKeySerializationJWK::reconcileExtractable):
      (WebCore::JSCryptoKeySerializationJWK::addJWKAlgorithmToJSON):
      (WebCore::processUseValue):
      (WebCore::JSCryptoKeySerializationJWK::addJWKUseToJSON):
      (WebCore::JSCryptoKeySerializationJWK::serialize):
      
      LayoutTests: 
      
      * crypto/subtle/jwk-export-use-values-expected.txt: Added.
      * crypto/subtle/jwk-export-use-values.html: Added.
      * crypto/subtle/jwk-import-use-values-expected.txt: Added.
      * crypto/subtle/jwk-import-use-values.html: Added.
      New tests for "use" mapping.
      
      * crypto/subtle/aes-cbc-import-jwk.html:
      * crypto/subtle/aes-cbc-unwrap-rsa.html:
      * crypto/subtle/aes-cbc-wrap-rsa-non-extractable.html:
      * crypto/subtle/aes-cbc-wrap-rsa.html:
      * crypto/subtle/aes-export-key-expected.txt:
      * crypto/subtle/aes-export-key.html:
      * crypto/subtle/hmac-export-key-expected.txt:
      * crypto/subtle/hmac-export-key.html:
      * crypto/subtle/hmac-import-jwk.html:
      * crypto/subtle/import-jwk-expected.txt:
      * crypto/subtle/import-jwk.html:
      * crypto/subtle/rsa-export-key-expected.txt:
      * crypto/subtle/rsa-export-key.html:
      * crypto/subtle/rsa-export-private-key-expected.txt:
      * crypto/subtle/rsa-export-private-key.html:
      * crypto/subtle/rsa-oaep-key-manipulation-expected.txt:
      * crypto/subtle/rsa-oaep-key-manipulation.html:
      
      
      
      git-svn-id: http://svn.webkit.org/repository/webkit/trunk@160061 268f45cc-cd09-0410-ab3c-d52691b4dbfc
      e6074e79
  3. 16 Nov, 2013 1 commit
    • ap@apple.com's avatar
      WebCrypto no longer uses sequences of ArrayBuffers · b651c9a6
      ap@apple.com authored
      https://bugs.webkit.org/show_bug.cgi?id=124451
      
      Reviewed by Sam Weinig.
      
      Source/WebCore: 
      
      Covered by existing tests.
      
      Changed all operations to take single CryptoOperationData objects.
      
      * bindings/js/JSCryptoOperationData.cpp:
      * bindings/js/JSCryptoOperationData.h:
      * bindings/js/JSSubtleCryptoCustom.cpp:
      (WebCore::JSSubtleCrypto::encrypt):
      (WebCore::JSSubtleCrypto::decrypt):
      (WebCore::JSSubtleCrypto::sign):
      (WebCore::JSSubtleCrypto::verify):
      (WebCore::JSSubtleCrypto::digest):
      * crypto/CryptoAlgorithm.cpp:
      (WebCore::CryptoAlgorithm::encrypt):
      (WebCore::CryptoAlgorithm::decrypt):
      (WebCore::CryptoAlgorithm::sign):
      (WebCore::CryptoAlgorithm::verify):
      (WebCore::CryptoAlgorithm::digest):
      * crypto/CryptoAlgorithm.h:
      * crypto/CryptoAlgorithmRSASSA_PKCS1_v1_5Mac.cpp:
      (WebCore::CryptoAlgorithmRSASSA_PKCS1_v1_5::sign):
      (WebCore::CryptoAlgorithmRSASSA_PKCS1_v1_5::verify):
      * crypto/algorithms/CryptoAlgorithmAES_CBC.h:
      * crypto/algorithms/CryptoAlgorithmHMAC.h:
      * crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.h:
      * crypto/algorithms/CryptoAlgorithmSHA1.cpp:
      (WebCore::CryptoAlgorithmSHA1::digest):
      * crypto/algorithms/CryptoAlgorithmSHA1.h:
      * crypto/algorithms/CryptoAlgorithmSHA224.cpp:
      (WebCore::CryptoAlgorithmSHA224::digest):
      * crypto/algorithms/CryptoAlgorithmSHA224.h:
      * crypto/algorithms/CryptoAlgorithmSHA256.cpp:
      (WebCore::CryptoAlgorithmSHA256::digest):
      * crypto/algorithms/CryptoAlgorithmSHA256.h:
      * crypto/algorithms/CryptoAlgorithmSHA384.cpp:
      (WebCore::CryptoAlgorithmSHA384::digest):
      * crypto/algorithms/CryptoAlgorithmSHA384.h:
      * crypto/algorithms/CryptoAlgorithmSHA512.cpp:
      (WebCore::CryptoAlgorithmSHA512::digest):
      * crypto/algorithms/CryptoAlgorithmSHA512.h:
      * crypto/mac/CryptoAlgorithmAES_CBCMac.cpp:
      (WebCore::transformAES_CBC):
      (WebCore::CryptoAlgorithmAES_CBC::encrypt):
      (WebCore::CryptoAlgorithmAES_CBC::decrypt):
      * crypto/mac/CryptoAlgorithmHMACMac.cpp:
      (WebCore::calculateSignature):
      (WebCore::CryptoAlgorithmHMAC::sign):
      (WebCore::CryptoAlgorithmHMAC::verify):
      * crypto/parameters/CryptoAlgorithmRsaKeyGenParams.h:
      
      LayoutTests: 
      
      Updated tests accordingly.
      
      * crypto/subtle/aes-cbc-192-encrypt-decrypt.html:
      * crypto/subtle/aes-cbc-256-encrypt-decrypt.html:
      * crypto/subtle/aes-cbc-encrypt-decrypt-expected.txt:
      * crypto/subtle/aes-cbc-encrypt-decrypt-with-padding.html:
      * crypto/subtle/aes-cbc-encrypt-decrypt.html:
      * crypto/subtle/aes-cbc-import-jwk.html:
      * crypto/subtle/aes-cbc-wrong-key-class-expected.txt:
      * crypto/subtle/aes-cbc-wrong-key-class.html:
      * crypto/subtle/argument-conversion-expected.txt:
      * crypto/subtle/argument-conversion.html:
      * crypto/subtle/hmac-import-jwk.html:
      * crypto/subtle/hmac-sign-verify-empty-key.html:
      * crypto/subtle/hmac-sign-verify.html:
      * 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@159379 268f45cc-cd09-0410-ab3c-d52691b4dbfc
      b651c9a6
  4. 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
  5. 08 Nov, 2013 1 commit
    • ap@apple.com's avatar
      Implement JWK key import for HMAC and AES-CBC · 7f6fd501
      ap@apple.com authored
      https://bugs.webkit.org/show_bug.cgi?id=124059
      
      Reviewed by Anders Carlsson.
      
      Source/WebCore: 
      
      Tests: crypto/subtle/aes-cbc-import-jwk.html
             crypto/subtle/hmac-import-jwk.html
             crypto/subtle/import-jwk.html
      
      WebCrypto supports multiple key formats - raw, pkcs8, spki, jwk. The design is that
      we'll transform these into parsed KeyData subclasses before passing to algorithms.
      
      CryptoKeySerialization is a base class for handling all these formats.
      
      * WebCore.xcodeproj/project.pbxproj: Added new files. Removed CryptoKeyFormat.h.
              
      * bindings/js/JSCryptoKeySerializationJWK.h: Added.
      * bindings/js/JSCryptoKeySerializationJWK.cpp: Added.
      (WebCore::getStringFromJSON): A helper. Note that we can rely on the object being
      a nice freshly parsed JSON, no getters or anything.
      (WebCore::getBooleanFromJSON): Ditto.
      (WebCore::JSCryptoKeySerializationJWK::JSCryptoKeySerializationJWK):
      (WebCore::JSCryptoKeySerializationJWK::~JSCryptoKeySerializationJWK):
      (WebCore::createHMACParameters): A simple helper.
      (WebCore::JSCryptoKeySerializationJWK::reconcileAlgorithm): WebCrypto API is weird,
      you can have algorithm parameters both inside a JWK key and passed as importKey()
      arguments. They need to agree, whatever that means for specific serialization's
      algorithm options (not all necessarily have a 1-1 matching to WebCrypto).
      (WebCore::JSCryptoKeySerializationJWK::reconcileUsages): Take an intersection of usages.
      (WebCore::JSCryptoKeySerializationJWK::reconcileExtractable): Only extractable if
      both JWK and the caller agree.
      (WebCore::JSCryptoKeySerializationJWK::keySizeIsValid): Verify validity of JWK key.
      (WebCore::JSCryptoKeySerializationJWK::keyData): Return an appropriate KeyData
      subclass.
      
      * bindings/js/JSSubtleCryptoCustom.cpp:
      (WebCore::ENUM_CLASS): Moved CryptoKeyFormat here.
      (WebCore::cryptoKeyFormatFromJSValue): Added a human readable string to an exception.
      (WebCore::JSSubtleCrypto::importKey): Support multiple key formats, not just raw.
      
      * crypto/CryptoAlgorithm.cpp: (WebCore::CryptoAlgorithm::importKey):
      * crypto/CryptoAlgorithm.h:
      Updated signature for importKey to one that makes more sense. Decoding formats all
      the way from a binary blob is not something that CryptoAlgorithm subclasses should
      do, we now pass a KeyData subclass instead.
      Removed exportKey/wrapKey/unwrapKey altogether, because I don't yet know what the
      signatures will be.
      
      * crypto/CryptoKeyData.h: Added.
      (WebCore::CryptoKeyData::ENUM_CLASS):
      (WebCore::CryptoKeyData::CryptoKeyData):
      (WebCore::CryptoKeyData::~CryptoKeyData):
      (WebCore::CryptoKeyData::format):
      A base class for passing key material to algorithms. Currently, only one type is
      supported, that being OctetSequence for secret keys. Keys for RSA and EC are more
      complicated, and secret/public ones are different too.
      
      * crypto/CryptoKeyFormat.h: Removed. There are too many key format classes
      confusingly floating around, and this was only needed in one file for parsing.
      
      * crypto/CryptoKeySerialization.h: Added.
      Base class for handling raw/pkcs8/spki/jwk keys.
      
      * crypto/algorithms/CryptoAlgorithmAES_CBC.cpp:
      (WebCore::CryptoAlgorithmAES_CBC::importKey):
      * crypto/algorithms/CryptoAlgorithmAES_CBC.h:
      Updated to use CryptoKeyData.
      
      * crypto/algorithms/CryptoAlgorithmHMAC.cpp:
      (WebCore::CryptoAlgorithmHMAC::importKey):
      * crypto/algorithms/CryptoAlgorithmHMAC.h:
      Updated to use CryptoKeyData.
      
      * crypto/keys/CryptoKeyDataOctetSequence.cpp: Added.
      (WebCore::CryptoKeyDataOctetSequence::CryptoKeyDataOctetSequence):
      (WebCore::CryptoKeyDataOctetSequence::~CryptoKeyDataOctetSequence):
      * crypto/keys/CryptoKeyDataOctetSequence.h: Added.
      (WebCore::asCryptoKeyDataOctetSequence):
      * crypto/keys/CryptoKeySerializationRaw.cpp: Added.
      (WebCore::CryptoKeySerializationRaw::CryptoKeySerializationRaw):
      (WebCore::CryptoKeySerializationRaw::~CryptoKeySerializationRaw):
      (WebCore::CryptoKeySerializationRaw::reconcileAlgorithm):
      (WebCore::CryptoKeySerializationRaw::reconcileUsages):
      (WebCore::CryptoKeySerializationRaw::reconcileExtractable):
      (WebCore::CryptoKeySerializationRaw::keyData):
      * crypto/keys/CryptoKeySerializationRaw.h: Added.
      Much code to pass around a Vector<char>.
      
      LayoutTests: 
      
      * crypto/subtle/aes-cbc-import-jwk-expected.txt: Added.
      * crypto/subtle/aes-cbc-import-jwk.html: Added.
      * crypto/subtle/hmac-import-jwk-expected.txt: Added.
      * crypto/subtle/hmac-import-jwk.html: Added.
      * crypto/subtle/import-jwk-expected.txt: Added.
      * crypto/subtle/import-jwk.html: Added.
      
      
      
      git-svn-id: http://svn.webkit.org/repository/webkit/trunk@158943 268f45cc-cd09-0410-ab3c-d52691b4dbfc
      7f6fd501
  6. 02 Nov, 2013 1 commit
    • ap@apple.com's avatar
      Add WebCrypto AES-CBC · ea43d19f
      ap@apple.com authored
      https://bugs.webkit.org/show_bug.cgi?id=123647
      
      Reviewed by Anders Carlsson.
      
      Source/WebCore:
      
      Tests: crypto/subtle/aes-cbc-192-encrypt-decrypt.html
             crypto/subtle/aes-cbc-256-encrypt-decrypt.html
             crypto/subtle/aes-cbc-encrypt-decrypt-with-padding.html
             crypto/subtle/aes-cbc-encrypt-decrypt.html
             crypto/subtle/aes-cbc-invalid-length.html
             crypto/subtle/aes-cbc-wrong-key-class.html
      
      * WebCore.xcodeproj/project.pbxproj: Added new files.
      * bindings/js/JSCryptoAlgorithmDictionary.cpp:
      (WebCore::getProperty): Factored out a function to get a property as JSValue.
      (WebCore::getHashAlgorithm): Use it.
      (WebCore::createAesCbcParams): Added converter for AesCbcParams.
      (WebCore::JSCryptoAlgorithmDictionary::createParametersForEncrypt): Support AES_CBC.
      (WebCore::JSCryptoAlgorithmDictionary::createParametersForDecrypt): Ditto.
      (WebCore::JSCryptoAlgorithmDictionary::createParametersForImportKey): Support all
      algorithms, all the new ones just have trivial dictionaries.
      (WebCore::JSCryptoAlgorithmDictionary::createParametersForExportKey): Ditto.
      
      * bindings/js/JSCryptoOperationData.cpp: Added.
      (WebCore::sequenceOfCryptoOperationDataFromJSValue):
      (WebCore::cryptoOperationDataFromJSValue):
      * bindings/js/JSCryptoOperationData.h: Added.
      Moved CryptoOperationData bindings out of JSSubtleCryptoCustom.cpp, so that we
      could use them in JSCryptoAlgorithmDictionary.cpp.
      
      * bindings/js/JSDOMPromise.h: (WebCore::PromiseWrapper::reject): Added a specialization
      to reject with null result. The spec doesn't actually say how algorithms fail.
      
      * bindings/js/JSSubtleCryptoCustom.cpp:
      (WebCore::JSSubtleCrypto::encrypt): Added.
      (WebCore::JSSubtleCrypto::decrypt): Ditto.
      (WebCore::JSSubtleCrypto::sign): Style fix.
      
      * crypto/CryptoAlgorithmAesCbcParams.h: Added.
      
      * crypto/CryptoKey.h:
      (WebCore::CryptoKeyClass):
      * crypto/keys/CryptoKeyHMAC.h:
      (WebCore::asCryptoKeyHMAC):
      Added poor man's RTTI, so that we can safely upcast Keys passed fro JavaScript code.
      
      * crypto/CryptoKeyAES.cpp: Added.
      (WebCore::CryptoKeyAES::CryptoKeyAES):
      (WebCore::CryptoKeyAES::~CryptoKeyAES):
      (WebCore::CryptoKeyAES::buildAlgorithmDescription):
      * crypto/CryptoKeyAES.h: Added.
      (WebCore::asCryptoKeyAES):
      AES keys are the same for all algorithms, but they still need to remember the algorithm.
      
      * crypto/SubtleCrypto.idl: Added encrypt/decrypt.
      
      * crypto/algorithms/CryptoAlgorithmAES_CBC.cpp: Added.
      (WebCore::CryptoAlgorithmAES_CBC::CryptoAlgorithmAES_CBC):
      (WebCore::CryptoAlgorithmAES_CBC::~CryptoAlgorithmAES_CBC):
      (WebCore::CryptoAlgorithmAES_CBC::create):
      (WebCore::CryptoAlgorithmAES_CBC::identifier):
      (WebCore::CryptoAlgorithmAES_CBC::importKey):
      (WebCore::CryptoAlgorithmAES_CBC::exportKey):
      * crypto/algorithms/CryptoAlgorithmAES_CBC.h: Added.
      * crypto/mac/CryptoAlgorithmAES_CBCMac.cpp: Added.
      (WebCore::transformAES_CBC):
      (WebCore::CryptoAlgorithmAES_CBC::encrypt):
      (WebCore::CryptoAlgorithmAES_CBC::decrypt):
      (WebCore::CryptoAlgorithmAES_CBC::generateKey):
      Added.
      
      * crypto/mac/CryptoAlgorithmHMACMac.cpp:
      (WebCore::CryptoAlgorithmHMAC::sign):
      (WebCore::CryptoAlgorithmHMAC::verify):
      Check key class before casting it to CryptoKeyHMAC.
      
      * crypto/mac/CryptoAlgorithmRegistryMac.cpp:
      (WebCore::CryptoAlgorithmRegistry::platformRegisterAlgorithms): Register AES-CBC
      on Mac, so that it can be used.
      
      Source/WTF:
      
      * wtf/FixedArray.h: (WTF::FixedArray::data): Added a const version of the function.
      
      * wtf/Vector.h: Added a comment to Vector constructor about how it is different
      from std::vector.
      
      LayoutTests:
      
      Part of aes-cbc-encrypt-decrypt.html test was taken from Blink.
      
      * crypto/subtle/aes-cbc-192-encrypt-decrypt-expected.txt: Added.
      * crypto/subtle/aes-cbc-192-encrypt-decrypt.html: Added.
      * crypto/subtle/aes-cbc-256-encrypt-decrypt-expected.txt: Added.
      * crypto/subtle/aes-cbc-256-encrypt-decrypt.html: Added.
      * crypto/subtle/aes-cbc-encrypt-decrypt-expected.txt: Added.
      * crypto/subtle/aes-cbc-encrypt-decrypt-with-padding-expected.txt: Added.
      * crypto/subtle/aes-cbc-encrypt-decrypt-with-padding.html: Added.
      * crypto/subtle/aes-cbc-encrypt-decrypt.html: Added.
      * crypto/subtle/aes-cbc-invalid-length-expected.txt: Added.
      * crypto/subtle/aes-cbc-invalid-length.html: Added.
      * crypto/subtle/aes-cbc-wrong-key-class-expected.txt: Added.
      * crypto/subtle/aes-cbc-wrong-key-class.html: Added.
      
      * crypto/subtle/hmac-sign-verify-expected.txt:
      * crypto/subtle/hmac-sign-verify.html:
      Corrected a description.
      
      * crypto/subtle/resources/common.js: (hexToArrayBuffer): Added a helper.
      
      
      git-svn-id: http://svn.webkit.org/repository/webkit/trunk@158485 268f45cc-cd09-0410-ab3c-d52691b4dbfc
      ea43d19f