Changeset 158578 in webkit


Ignore:
Timestamp:
Nov 4, 2013 9:37:20 AM (11 years ago)
Author:
commit-queue@webkit.org
Message:

Unreviewed, rolling out r158526.
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:
Location:
trunk
Files:
6 deleted
17 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r158576 r158578  
     12013-11-04  Commit Queue  <commit-queue@webkit.org>
     2
     3        Unreviewed, rolling out r158526.
     4        http://trac.webkit.org/changeset/158526
     5        https://bugs.webkit.org/show_bug.cgi?id=123744
     6
     7        it broke the build (Requested by jessieberlin on #webkit).
     8
     9        * crypto/subtle/aes-cbc-generate-key-expected.txt: Removed.
     10        * crypto/subtle/aes-cbc-generate-key.html: Removed.
     11        * crypto/subtle/hmac-generate-key-expected.txt: Removed.
     12        * crypto/subtle/hmac-generate-key.html: Removed.
     13        * crypto/subtle/sha-1-expected.txt:
     14
    1152013-11-04  Robert Plociennik  <r.plociennik@samsung.com>
    216
  • trunk/LayoutTests/crypto/subtle/sha-1-expected.txt

    r158526 r158578  
    1212SHA1 of [new Uint8Array([0, 1, 2, 3, 4]), new Uint8Array(5, 6, 7, 8, 9, 10])]
    1313    = [2c 7e 7c 38 4f 78 29 69 42 82 b1 e3 a6 21 6d ef 80 82 d0 55]
    14 PASS crypto.subtle.generateKey('sha-1') threw exception Error: NotSupportedError: DOM Exception 9.
     14PASS crypto.subtle.generateKey('sha-1') threw exception TypeError: undefined is not a function (evaluating 'crypto.subtle.generateKey('sha-1')').
    1515PASS successfullyParsed is true
    1616
  • trunk/Source/WebCore/ChangeLog

    r158574 r158578  
     12013-11-04  Commit Queue  <commit-queue@webkit.org>
     2
     3        Unreviewed, rolling out r158526.
     4        http://trac.webkit.org/changeset/158526
     5        https://bugs.webkit.org/show_bug.cgi?id=123744
     6
     7        it broke the build (Requested by jessieberlin on #webkit).
     8
     9        * WebCore.xcodeproj/project.pbxproj:
     10        * bindings/js/JSCryptoAlgorithmDictionary.cpp:
     11        (WebCore::createAesCbcParams):
     12        (WebCore::createHmacParams):
     13        (WebCore::createHmacKeyParams):
     14        (WebCore::JSCryptoAlgorithmDictionary::createParametersForGenerateKey):
     15        * bindings/js/JSSubtleCryptoCustom.cpp:
     16        * crypto/CryptoAlgorithmAesKeyGenParams.h: Removed.
     17        * crypto/CryptoKey.cpp:
     18        * crypto/CryptoKey.h:
     19        * crypto/CryptoKeyAES.cpp:
     20        * crypto/CryptoKeyAES.h:
     21        * crypto/CryptoKeyMac.cpp: Removed.
     22        * crypto/SubtleCrypto.idl:
     23        * crypto/algorithms/CryptoAlgorithmAES_CBC.cpp:
     24        * crypto/algorithms/CryptoAlgorithmHMAC.cpp:
     25        * crypto/keys/CryptoKeyHMAC.cpp:
     26        * crypto/keys/CryptoKeyHMAC.h:
     27        * crypto/mac/CryptoAlgorithmAES_CBCMac.cpp:
     28        (WebCore::CryptoAlgorithmAES_CBC::generateKey):
     29        * crypto/mac/CryptoAlgorithmHMACMac.cpp:
     30        (WebCore::CryptoAlgorithmHMAC::generateKey):
     31
    1322013-11-04  Przemyslaw Szymanski  <p.szymanski3@samsung.com>
    233
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r158561 r158578  
    2017720177                                E19AC3E01824DC6900349426 /* CryptoAlgorithmSHA384Mac.cpp */,
    2017820178                                E19AC3E11824DC6900349426 /* CryptoAlgorithmSHA512Mac.cpp */,
    20179                                 E19AC3F8182566F700349426 /* CryptoKeyMac.cpp */,
    2018020179                        );
    2018120180                        name = mac;
     
    2021820217                        children = (
    2021920218                                E125F8391824104800D84CD9 /* CryptoAlgorithmAesCbcParams.h */,
    20220                                 E19AC3F61824E5D100349426 /* CryptoAlgorithmAesKeyGenParams.h */,
    2022120219                                E19DA29B18189ADD00088BC8 /* CryptoAlgorithmHmacKeyParams.h */,
    2022220220                                E1C6571E1816E50300256CDD /* CryptoAlgorithmHmacParams.h */,
     
    2319423192                                76808B50159DADFA002B5233 /* JSHTMLDialogElement.h in Headers */,
    2319523193                                1A85B1E70A1B240500D8C87C /* JSHTMLDirectoryElement.h in Headers */,
    23196                                 E19AC3F71824E5D100349426 /* CryptoAlgorithmAesKeyGenParams.h in Headers */,
    2319723194                                1A85B2B70A1B2AC700D8C87C /* JSHTMLDivElement.h in Headers */,
    2319823195                                1A85B1E90A1B240500D8C87C /* JSHTMLDListElement.h in Headers */,
     
    2701327010                                E19AC3E51824DC6900349426 /* CryptoAlgorithmSHA512Mac.cpp in Sources */,
    2701427011                                D6E528A3149A926D00EFE1F3 /* MutationObserverInterestGroup.cpp in Sources */,
    27015                                 E19AC3F9182566F700349426 /* CryptoKeyMac.cpp in Sources */,
    2701627012                                D6E276AF14637455001D280A /* MutationObserverRegistration.cpp in Sources */,
    2701727013                                C6F08FBC1430FE8F00685849 /* MutationRecord.cpp in Sources */,
  • trunk/Source/WebCore/bindings/js/JSCryptoAlgorithmDictionary.cpp

    r158526 r158578  
    3030
    3131#include "CryptoAlgorithmAesCbcParams.h"
    32 #include "CryptoAlgorithmAesKeyGenParams.h"
    3332#include "CryptoAlgorithmHmacKeyParams.h"
    3433#include "CryptoAlgorithmHmacParams.h"
     
    128127        return nullptr;
    129128
    130     auto result = std::make_unique<CryptoAlgorithmAesCbcParams>();
     129    std::unique_ptr<CryptoAlgorithmAesCbcParams> result = std::make_unique<CryptoAlgorithmAesCbcParams>();
    131130
    132131    CryptoOperationData ivData;
     
    146145}
    147146
    148 static std::unique_ptr<CryptoAlgorithmParameters> createAesKeyGenParams(JSC::ExecState* exec, JSC::JSValue value)
     147static std::unique_ptr<CryptoAlgorithmParameters> createHmacParams(JSC::ExecState* exec, JSC::JSValue value)
    149148{
    150149    if (!value.isObject()) {
     
    153152    }
    154153
    155     auto result = std::make_unique<CryptoAlgorithmAesKeyGenParams>();
    156 
    157     JSValue lengthValue = getProperty(exec, value.getObject(), "length");
    158     if (exec->hadException())
    159         return nullptr;
    160 
    161     result->length = toUInt16(exec, lengthValue, EnforceRange);
     154    JSDictionary jsDictionary(exec, value.getObject());
     155    std::unique_ptr<CryptoAlgorithmHmacParams> result = std::make_unique<CryptoAlgorithmHmacParams>();
     156
     157    if (!getHashAlgorithm(jsDictionary, result->hash)) {
     158        ASSERT(exec->hadException());
     159        return nullptr;
     160    }
    162161
    163162    return std::move(result);
    164163}
    165164
    166 static std::unique_ptr<CryptoAlgorithmParameters> createHmacParams(JSC::ExecState* exec, JSC::JSValue value)
     165static std::unique_ptr<CryptoAlgorithmParameters> createHmacKeyParams(JSC::ExecState* exec, JSC::JSValue value)
    167166{
    168167    if (!value.isObject()) {
     
    172171
    173172    JSDictionary jsDictionary(exec, value.getObject());
    174     auto result = std::make_unique<CryptoAlgorithmHmacParams>();
     173    std::unique_ptr<CryptoAlgorithmHmacKeyParams> result = std::make_unique<CryptoAlgorithmHmacKeyParams>();
    175174
    176175    if (!getHashAlgorithm(jsDictionary, result->hash)) {
     
    179178    }
    180179
    181     return std::move(result);
    182 }
    183 
    184 static std::unique_ptr<CryptoAlgorithmParameters> createHmacKeyParams(JSC::ExecState* exec, JSC::JSValue value)
    185 {
    186     if (!value.isObject()) {
    187         throwTypeError(exec);
    188         return nullptr;
    189     }
    190 
    191     JSDictionary jsDictionary(exec, value.getObject());
    192     auto result = std::make_unique<CryptoAlgorithmHmacKeyParams>();
    193 
    194     if (!getHashAlgorithm(jsDictionary, result->hash)) {
    195         ASSERT(exec->hadException());
    196         return nullptr;
    197     }
    198 
    199180    result->hasLength = jsDictionary.get("length", result->length);
    200181    if (exec->hadException())
     
    364345}
    365346
    366 std::unique_ptr<CryptoAlgorithmParameters> JSCryptoAlgorithmDictionary::createParametersForGenerateKey(JSC::ExecState* exec, CryptoAlgorithmIdentifier algorithm, JSC::JSValue value)
    367 {
    368     switch (algorithm) {
    369     case CryptoAlgorithmIdentifier::RSAES_PKCS1_v1_5:
    370     case CryptoAlgorithmIdentifier::RSASSA_PKCS1_v1_5:
    371     case CryptoAlgorithmIdentifier::RSA_PSS:
    372     case CryptoAlgorithmIdentifier::RSA_OAEP:
    373     case CryptoAlgorithmIdentifier::ECDSA:
    374     case CryptoAlgorithmIdentifier::ECDH:
    375         setDOMException(exec, NOT_SUPPORTED_ERR);
    376         return nullptr;
    377     case CryptoAlgorithmIdentifier::AES_CTR:
    378     case CryptoAlgorithmIdentifier::AES_CBC:
    379     case CryptoAlgorithmIdentifier::AES_CMAC:
    380     case CryptoAlgorithmIdentifier::AES_GCM:
    381     case CryptoAlgorithmIdentifier::AES_CFB:
    382         return createAesKeyGenParams(exec, value);
     347std::unique_ptr<CryptoAlgorithmParameters> JSCryptoAlgorithmDictionary::createParametersForGenerateKey(JSC::ExecState* exec, CryptoAlgorithmIdentifier algorithm, JSC::JSValue)
     348{
     349    switch (algorithm) {
     350    case CryptoAlgorithmIdentifier::RSAES_PKCS1_v1_5:
     351    case CryptoAlgorithmIdentifier::RSASSA_PKCS1_v1_5:
     352    case CryptoAlgorithmIdentifier::RSA_PSS:
     353    case CryptoAlgorithmIdentifier::RSA_OAEP:
     354    case CryptoAlgorithmIdentifier::ECDSA:
     355    case CryptoAlgorithmIdentifier::ECDH:
     356    case CryptoAlgorithmIdentifier::AES_CTR:
     357    case CryptoAlgorithmIdentifier::AES_CBC:
     358    case CryptoAlgorithmIdentifier::AES_CMAC:
     359    case CryptoAlgorithmIdentifier::AES_GCM:
     360    case CryptoAlgorithmIdentifier::AES_CFB:
     361    case CryptoAlgorithmIdentifier::HMAC:
     362    case CryptoAlgorithmIdentifier::DH:
     363    case CryptoAlgorithmIdentifier::SHA_1:
     364    case CryptoAlgorithmIdentifier::SHA_224:
     365    case CryptoAlgorithmIdentifier::SHA_256:
     366    case CryptoAlgorithmIdentifier::SHA_384:
     367    case CryptoAlgorithmIdentifier::SHA_512:
     368    case CryptoAlgorithmIdentifier::CONCAT:
     369    case CryptoAlgorithmIdentifier::HKDF_CTR:
     370    case CryptoAlgorithmIdentifier::PBKDF2:
     371        setDOMException(exec, NOT_SUPPORTED_ERR);
     372        return nullptr;
     373    }
     374}
     375
     376std::unique_ptr<CryptoAlgorithmParameters> JSCryptoAlgorithmDictionary::createParametersForDeriveKey(JSC::ExecState* exec, CryptoAlgorithmIdentifier algorithm, JSC::JSValue)
     377{
     378    switch (algorithm) {
     379    case CryptoAlgorithmIdentifier::RSAES_PKCS1_v1_5:
     380    case CryptoAlgorithmIdentifier::RSASSA_PKCS1_v1_5:
     381    case CryptoAlgorithmIdentifier::RSA_PSS:
     382    case CryptoAlgorithmIdentifier::RSA_OAEP:
     383    case CryptoAlgorithmIdentifier::ECDSA:
     384    case CryptoAlgorithmIdentifier::ECDH:
     385    case CryptoAlgorithmIdentifier::AES_CTR:
     386    case CryptoAlgorithmIdentifier::AES_CBC:
     387    case CryptoAlgorithmIdentifier::AES_CMAC:
     388    case CryptoAlgorithmIdentifier::AES_GCM:
     389    case CryptoAlgorithmIdentifier::AES_CFB:
     390    case CryptoAlgorithmIdentifier::HMAC:
     391    case CryptoAlgorithmIdentifier::DH:
     392    case CryptoAlgorithmIdentifier::SHA_1:
     393    case CryptoAlgorithmIdentifier::SHA_224:
     394    case CryptoAlgorithmIdentifier::SHA_256:
     395    case CryptoAlgorithmIdentifier::SHA_384:
     396    case CryptoAlgorithmIdentifier::SHA_512:
     397    case CryptoAlgorithmIdentifier::CONCAT:
     398    case CryptoAlgorithmIdentifier::HKDF_CTR:
     399    case CryptoAlgorithmIdentifier::PBKDF2:
     400        setDOMException(exec, NOT_SUPPORTED_ERR);
     401        return nullptr;
     402    }
     403}
     404
     405std::unique_ptr<CryptoAlgorithmParameters> JSCryptoAlgorithmDictionary::createParametersForDeriveBits(JSC::ExecState* exec, CryptoAlgorithmIdentifier algorithm, JSC::JSValue)
     406{
     407    switch (algorithm) {
     408    case CryptoAlgorithmIdentifier::RSAES_PKCS1_v1_5:
     409    case CryptoAlgorithmIdentifier::RSASSA_PKCS1_v1_5:
     410    case CryptoAlgorithmIdentifier::RSA_PSS:
     411    case CryptoAlgorithmIdentifier::RSA_OAEP:
     412    case CryptoAlgorithmIdentifier::ECDSA:
     413    case CryptoAlgorithmIdentifier::ECDH:
     414    case CryptoAlgorithmIdentifier::AES_CTR:
     415    case CryptoAlgorithmIdentifier::AES_CBC:
     416    case CryptoAlgorithmIdentifier::AES_CMAC:
     417    case CryptoAlgorithmIdentifier::AES_GCM:
     418    case CryptoAlgorithmIdentifier::AES_CFB:
     419    case CryptoAlgorithmIdentifier::HMAC:
     420    case CryptoAlgorithmIdentifier::DH:
     421    case CryptoAlgorithmIdentifier::SHA_1:
     422    case CryptoAlgorithmIdentifier::SHA_224:
     423    case CryptoAlgorithmIdentifier::SHA_256:
     424    case CryptoAlgorithmIdentifier::SHA_384:
     425    case CryptoAlgorithmIdentifier::SHA_512:
     426    case CryptoAlgorithmIdentifier::CONCAT:
     427    case CryptoAlgorithmIdentifier::HKDF_CTR:
     428    case CryptoAlgorithmIdentifier::PBKDF2:
     429        setDOMException(exec, NOT_SUPPORTED_ERR);
     430        return nullptr;
     431    }
     432}
     433
     434std::unique_ptr<CryptoAlgorithmParameters> JSCryptoAlgorithmDictionary::createParametersForImportKey(JSC::ExecState* exec, CryptoAlgorithmIdentifier algorithm, JSC::JSValue value)
     435{
     436    switch (algorithm) {
     437    case CryptoAlgorithmIdentifier::RSAES_PKCS1_v1_5:
     438    case CryptoAlgorithmIdentifier::RSASSA_PKCS1_v1_5:
     439    case CryptoAlgorithmIdentifier::RSA_PSS:
     440    case CryptoAlgorithmIdentifier::RSA_OAEP:
     441    case CryptoAlgorithmIdentifier::ECDSA:
     442    case CryptoAlgorithmIdentifier::ECDH:
     443    case CryptoAlgorithmIdentifier::AES_CTR:
     444    case CryptoAlgorithmIdentifier::AES_CBC:
     445    case CryptoAlgorithmIdentifier::AES_CMAC:
     446    case CryptoAlgorithmIdentifier::AES_GCM:
     447    case CryptoAlgorithmIdentifier::AES_CFB:
     448        return std::make_unique<CryptoAlgorithmParameters>();
    383449    case CryptoAlgorithmIdentifier::HMAC:
    384450        return createHmacKeyParams(exec, value);
    385451    case CryptoAlgorithmIdentifier::DH:
    386     case CryptoAlgorithmIdentifier::SHA_1:
    387     case CryptoAlgorithmIdentifier::SHA_224:
    388     case CryptoAlgorithmIdentifier::SHA_256:
    389     case CryptoAlgorithmIdentifier::SHA_384:
    390     case CryptoAlgorithmIdentifier::SHA_512:
    391     case CryptoAlgorithmIdentifier::CONCAT:
    392     case CryptoAlgorithmIdentifier::HKDF_CTR:
    393     case CryptoAlgorithmIdentifier::PBKDF2:
    394         setDOMException(exec, NOT_SUPPORTED_ERR);
    395         return nullptr;
    396     }
    397 }
    398 
    399 std::unique_ptr<CryptoAlgorithmParameters> JSCryptoAlgorithmDictionary::createParametersForDeriveKey(JSC::ExecState* exec, CryptoAlgorithmIdentifier algorithm, JSC::JSValue)
    400 {
    401     switch (algorithm) {
    402     case CryptoAlgorithmIdentifier::RSAES_PKCS1_v1_5:
    403     case CryptoAlgorithmIdentifier::RSASSA_PKCS1_v1_5:
    404     case CryptoAlgorithmIdentifier::RSA_PSS:
    405     case CryptoAlgorithmIdentifier::RSA_OAEP:
    406     case CryptoAlgorithmIdentifier::ECDSA:
    407     case CryptoAlgorithmIdentifier::ECDH:
    408     case CryptoAlgorithmIdentifier::AES_CTR:
    409     case CryptoAlgorithmIdentifier::AES_CBC:
    410     case CryptoAlgorithmIdentifier::AES_CMAC:
    411     case CryptoAlgorithmIdentifier::AES_GCM:
    412     case CryptoAlgorithmIdentifier::AES_CFB:
    413     case CryptoAlgorithmIdentifier::HMAC:
    414     case CryptoAlgorithmIdentifier::DH:
    415     case CryptoAlgorithmIdentifier::SHA_1:
    416     case CryptoAlgorithmIdentifier::SHA_224:
    417     case CryptoAlgorithmIdentifier::SHA_256:
    418     case CryptoAlgorithmIdentifier::SHA_384:
    419     case CryptoAlgorithmIdentifier::SHA_512:
    420     case CryptoAlgorithmIdentifier::CONCAT:
    421     case CryptoAlgorithmIdentifier::HKDF_CTR:
    422     case CryptoAlgorithmIdentifier::PBKDF2:
    423         setDOMException(exec, NOT_SUPPORTED_ERR);
    424         return nullptr;
    425     }
    426 }
    427 
    428 std::unique_ptr<CryptoAlgorithmParameters> JSCryptoAlgorithmDictionary::createParametersForDeriveBits(JSC::ExecState* exec, CryptoAlgorithmIdentifier algorithm, JSC::JSValue)
    429 {
    430     switch (algorithm) {
    431     case CryptoAlgorithmIdentifier::RSAES_PKCS1_v1_5:
    432     case CryptoAlgorithmIdentifier::RSASSA_PKCS1_v1_5:
    433     case CryptoAlgorithmIdentifier::RSA_PSS:
    434     case CryptoAlgorithmIdentifier::RSA_OAEP:
    435     case CryptoAlgorithmIdentifier::ECDSA:
    436     case CryptoAlgorithmIdentifier::ECDH:
    437     case CryptoAlgorithmIdentifier::AES_CTR:
    438     case CryptoAlgorithmIdentifier::AES_CBC:
    439     case CryptoAlgorithmIdentifier::AES_CMAC:
    440     case CryptoAlgorithmIdentifier::AES_GCM:
    441     case CryptoAlgorithmIdentifier::AES_CFB:
    442     case CryptoAlgorithmIdentifier::HMAC:
    443     case CryptoAlgorithmIdentifier::DH:
    444     case CryptoAlgorithmIdentifier::SHA_1:
    445     case CryptoAlgorithmIdentifier::SHA_224:
    446     case CryptoAlgorithmIdentifier::SHA_256:
    447     case CryptoAlgorithmIdentifier::SHA_384:
    448     case CryptoAlgorithmIdentifier::SHA_512:
    449     case CryptoAlgorithmIdentifier::CONCAT:
    450     case CryptoAlgorithmIdentifier::HKDF_CTR:
    451     case CryptoAlgorithmIdentifier::PBKDF2:
    452         setDOMException(exec, NOT_SUPPORTED_ERR);
    453         return nullptr;
    454     }
    455 }
    456 
    457 std::unique_ptr<CryptoAlgorithmParameters> JSCryptoAlgorithmDictionary::createParametersForImportKey(JSC::ExecState* exec, CryptoAlgorithmIdentifier algorithm, JSC::JSValue value)
    458 {
    459     switch (algorithm) {
    460     case CryptoAlgorithmIdentifier::RSAES_PKCS1_v1_5:
    461     case CryptoAlgorithmIdentifier::RSASSA_PKCS1_v1_5:
    462     case CryptoAlgorithmIdentifier::RSA_PSS:
    463     case CryptoAlgorithmIdentifier::RSA_OAEP:
    464     case CryptoAlgorithmIdentifier::ECDSA:
    465     case CryptoAlgorithmIdentifier::ECDH:
    466     case CryptoAlgorithmIdentifier::AES_CTR:
    467     case CryptoAlgorithmIdentifier::AES_CBC:
    468     case CryptoAlgorithmIdentifier::AES_CMAC:
    469     case CryptoAlgorithmIdentifier::AES_GCM:
    470     case CryptoAlgorithmIdentifier::AES_CFB:
    471452        return std::make_unique<CryptoAlgorithmParameters>();
    472     case CryptoAlgorithmIdentifier::HMAC:
    473         return createHmacKeyParams(exec, value);
     453    case CryptoAlgorithmIdentifier::SHA_1:
     454    case CryptoAlgorithmIdentifier::SHA_224:
     455    case CryptoAlgorithmIdentifier::SHA_256:
     456    case CryptoAlgorithmIdentifier::SHA_384:
     457    case CryptoAlgorithmIdentifier::SHA_512:
     458    case CryptoAlgorithmIdentifier::CONCAT:
     459    case CryptoAlgorithmIdentifier::HKDF_CTR:
     460    case CryptoAlgorithmIdentifier::PBKDF2:
     461        setDOMException(exec, NOT_SUPPORTED_ERR);
     462        return nullptr;
     463    }
     464}
     465
     466std::unique_ptr<CryptoAlgorithmParameters> JSCryptoAlgorithmDictionary::createParametersForExportKey(JSC::ExecState* exec, CryptoAlgorithmIdentifier algorithm, JSC::JSValue)
     467{
     468    switch (algorithm) {
     469    case CryptoAlgorithmIdentifier::RSAES_PKCS1_v1_5:
     470    case CryptoAlgorithmIdentifier::RSASSA_PKCS1_v1_5:
     471    case CryptoAlgorithmIdentifier::RSA_PSS:
     472    case CryptoAlgorithmIdentifier::RSA_OAEP:
     473    case CryptoAlgorithmIdentifier::ECDSA:
     474    case CryptoAlgorithmIdentifier::ECDH:
     475    case CryptoAlgorithmIdentifier::AES_CTR:
     476    case CryptoAlgorithmIdentifier::AES_CBC:
     477    case CryptoAlgorithmIdentifier::AES_CMAC:
     478    case CryptoAlgorithmIdentifier::AES_GCM:
     479    case CryptoAlgorithmIdentifier::AES_CFB:
     480    case CryptoAlgorithmIdentifier::HMAC:
    474481    case CryptoAlgorithmIdentifier::DH:
    475482        return std::make_unique<CryptoAlgorithmParameters>();
     
    487494}
    488495
    489 std::unique_ptr<CryptoAlgorithmParameters> JSCryptoAlgorithmDictionary::createParametersForExportKey(JSC::ExecState* exec, CryptoAlgorithmIdentifier algorithm, JSC::JSValue)
    490 {
    491     switch (algorithm) {
    492     case CryptoAlgorithmIdentifier::RSAES_PKCS1_v1_5:
    493     case CryptoAlgorithmIdentifier::RSASSA_PKCS1_v1_5:
    494     case CryptoAlgorithmIdentifier::RSA_PSS:
    495     case CryptoAlgorithmIdentifier::RSA_OAEP:
    496     case CryptoAlgorithmIdentifier::ECDSA:
    497     case CryptoAlgorithmIdentifier::ECDH:
    498     case CryptoAlgorithmIdentifier::AES_CTR:
    499     case CryptoAlgorithmIdentifier::AES_CBC:
    500     case CryptoAlgorithmIdentifier::AES_CMAC:
    501     case CryptoAlgorithmIdentifier::AES_GCM:
    502     case CryptoAlgorithmIdentifier::AES_CFB:
    503     case CryptoAlgorithmIdentifier::HMAC:
    504     case CryptoAlgorithmIdentifier::DH:
    505         return std::make_unique<CryptoAlgorithmParameters>();
    506     case CryptoAlgorithmIdentifier::SHA_1:
    507     case CryptoAlgorithmIdentifier::SHA_224:
    508     case CryptoAlgorithmIdentifier::SHA_256:
    509     case CryptoAlgorithmIdentifier::SHA_384:
    510     case CryptoAlgorithmIdentifier::SHA_512:
    511     case CryptoAlgorithmIdentifier::CONCAT:
    512     case CryptoAlgorithmIdentifier::HKDF_CTR:
    513     case CryptoAlgorithmIdentifier::PBKDF2:
    514         setDOMException(exec, NOT_SUPPORTED_ERR);
    515         return nullptr;
    516     }
    517 }
    518 
    519496std::unique_ptr<CryptoAlgorithmParameters> JSCryptoAlgorithmDictionary::createParametersForWrapKey(JSC::ExecState* exec, CryptoAlgorithmIdentifier algorithm, JSC::JSValue)
    520497{
  • trunk/Source/WebCore/bindings/js/JSSubtleCryptoCustom.cpp

    r158526 r158578  
    338338}
    339339
    340 JSValue JSSubtleCrypto::generateKey(JSC::ExecState* exec)
    341 {
    342     if (exec->argumentCount() < 1)
    343         return exec->vm().throwException(exec, createNotEnoughArgumentsError(exec));
    344 
    345     auto algorithm = createAlgorithmFromJSValue(exec, exec->uncheckedArgument(0));
    346     if (!algorithm) {
    347         ASSERT(exec->hadException());
    348         return jsUndefined();
    349     }
    350 
    351     auto parameters = JSCryptoAlgorithmDictionary::createParametersForGenerateKey(exec, algorithm->identifier(), exec->uncheckedArgument(0));
    352     if (!parameters) {
    353         ASSERT(exec->hadException());
    354         return jsUndefined();
    355     }
    356 
    357     bool extractable = false;
    358     if (exec->argumentCount() >= 2) {
    359         extractable = exec->uncheckedArgument(1).toBoolean(exec);
    360         if (exec->hadException())
    361             return jsUndefined();
    362     }
    363 
    364     CryptoKeyUsage keyUsages = 0;
    365     if (exec->argumentCount() >= 3) {
    366         if (!cryptoKeyUsagesFromJSValue(exec, exec->argument(2), keyUsages)) {
    367             ASSERT(exec->hadException());
    368             return jsUndefined();
    369         }
    370     }
    371 
    372     JSPromise* promise = JSPromise::createWithResolver(exec->vm(), globalObject());
    373     auto promiseWrapper = PromiseWrapper::create(globalObject(), promise);
    374 
    375     ExceptionCode ec = 0;
    376     algorithm->generateKey(*parameters, extractable, keyUsages, std::move(promiseWrapper), ec);
    377     if (ec) {
    378         setDOMException(exec, ec);
    379         return jsUndefined();
    380     }
    381 
    382     return promise;
    383 }
    384 
    385340JSValue JSSubtleCrypto::importKey(JSC::ExecState* exec)
    386341{
  • trunk/Source/WebCore/crypto/CryptoKey.cpp

    r158526 r158578  
    3131#include "CryptoAlgorithmDescriptionBuilder.h"
    3232#include "CryptoAlgorithmRegistry.h"
    33 #include <wtf/CryptographicallyRandomNumber.h>
    3433#include <wtf/text/WTFString.h>
    3534
     
    8988}
    9089
    91 #if !PLATFORM(MAC)
    92 Vector<char> CryptoKey::randomData(size_t size)
    93 {
    94     Vector<char> result(size);
    95     cryptographicallyRandomValues(result.data(), result.size());
    96     return result;
    97 }
    98 #endif
    9990} // namespace WebCore
    10091
  • trunk/Source/WebCore/crypto/CryptoKey.h

    r158526 r158578  
    5959    bool allows(CryptoKeyUsage usage) const { return usage == (m_usages & usage); }
    6060
    61     static Vector<char> randomData(size_t);
    62 
    6361private:
    6462    CryptoAlgorithmIdentifier m_algorithm;
  • trunk/Source/WebCore/crypto/CryptoKeyAES.cpp

    r158526 r158578  
    5050}
    5151
    52 PassRefPtr<CryptoKeyAES> CryptoKeyAES::generate(CryptoAlgorithmIdentifier algorithm, size_t lengthBits, bool extractable, CryptoKeyUsage usages)
    53 {
    54     if (lengthBits % 8)
    55         return nullptr;
    56     return adoptRef(new CryptoKeyAES(algorithm, randomData(lengthBits / 8), extractable, usages));
    57 }
    58 
    5952void CryptoKeyAES::buildAlgorithmDescription(CryptoAlgorithmDescriptionBuilder& builder) const
    6053{
  • trunk/Source/WebCore/crypto/CryptoKeyAES.h

    r158526 r158578  
    4343    virtual ~CryptoKeyAES();
    4444
    45     static PassRefPtr<CryptoKeyAES> generate(CryptoAlgorithmIdentifier, size_t lengthBits, bool extractable, CryptoKeyUsage);
    46 
    4745    virtual CryptoKeyClass keyClass() const OVERRIDE { return CryptoKeyClass::AES; }
    4846
  • trunk/Source/WebCore/crypto/SubtleCrypto.idl

    r158526 r158578  
    3636    [Custom] Promise verify(AlgorithmIdentifier algorithm, Key key, CryptoOperationData signature, sequence<CryptoOperationData> data);
    3737    [Custom] Promise digest(AlgorithmIdentifier algorithm, sequence<CryptoOperationData> data);
    38     [Custom] Promise generateKey(AlgorithmIdentifier algorithm, optional boolean extractable, optional KeyUsage[] keyUsages);
    3938    [Custom] Promise importKey(KeyFormat format, CryptoOperationData keyData, AlgorithmIdentifier? algorithm, optional boolean extractable, optional KeyUsage[] keyUsages);
    4039};
  • trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_CBC.cpp

    r158526 r158578  
    2929#if ENABLE(SUBTLE_CRYPTO)
    3030
    31 #include "CryptoAlgorithmAesKeyGenParams.h"
     31#include "CryptoAlgorithmAesCbcParams.h"
    3232#include "CryptoKeyAES.h"
    3333#include "ExceptionCode.h"
     
    5656}
    5757
    58 void CryptoAlgorithmAES_CBC::generateKey(const CryptoAlgorithmParameters& parameters, bool extractable, CryptoKeyUsage usages, std::unique_ptr<PromiseWrapper> promise, ExceptionCode&)
    59 {
    60     const CryptoAlgorithmAesKeyGenParams& aesParameters = static_cast<const CryptoAlgorithmAesKeyGenParams&>(parameters);
    61 
    62     RefPtr<CryptoKeyAES> result = CryptoKeyAES::generate(CryptoAlgorithmIdentifier::AES_CBC, aesParameters.length, extractable, usages);
    63     if (!result) {
    64         promise->reject(nullptr);
    65         return;
    66     }
    67 
    68     promise->fulfill(result.release());
    69 }
    70 
    7158void CryptoAlgorithmAES_CBC::importKey(const CryptoAlgorithmParameters&, CryptoKeyFormat format, const CryptoOperationData& data, bool extractable, CryptoKeyUsage usage, std::unique_ptr<PromiseWrapper> promise, ExceptionCode& ec)
    7259{
  • trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmHMAC.cpp

    r158526 r158578  
    2929#if ENABLE(SUBTLE_CRYPTO)
    3030
    31 #include "CryptoAlgorithmHmacKeyParams.h"
    3231#include "CryptoAlgorithmHmacParams.h"
    3332#include "CryptoKeyHMAC.h"
     
    5756}
    5857
    59 void CryptoAlgorithmHMAC::generateKey(const CryptoAlgorithmParameters& parameters, bool extractable, CryptoKeyUsage usages, std::unique_ptr<PromiseWrapper> promise, ExceptionCode&)
    60 {
    61     const CryptoAlgorithmHmacKeyParams& hmacParameters = static_cast<const CryptoAlgorithmHmacKeyParams&>(parameters);
    62 
    63     RefPtr<CryptoKeyHMAC> result = CryptoKeyHMAC::generate(hmacParameters.hasLength ? hmacParameters.length : 0, hmacParameters.hash, extractable, usages);
    64     if (!result) {
    65         promise->reject(nullptr);
    66         return;
    67     }
    68 
    69     promise->fulfill(result.release());
    70 }
    71 
    7258void CryptoAlgorithmHMAC::importKey(const CryptoAlgorithmParameters& parameters, CryptoKeyFormat format, const CryptoOperationData& data, bool extractable, CryptoKeyUsage usage, std::unique_ptr<PromiseWrapper> promise, ExceptionCode& ec)
    7359{
  • trunk/Source/WebCore/crypto/keys/CryptoKeyHMAC.cpp

    r158526 r158578  
    4646}
    4747
    48 PassRefPtr<CryptoKeyHMAC> CryptoKeyHMAC::generate(size_t lengthBytes, CryptoAlgorithmIdentifier hash, bool extractable, CryptoKeyUsage usages)
    49 {
    50     if (!lengthBytes) {
    51         switch (hash) {
    52         case CryptoAlgorithmIdentifier::SHA_1:
    53         case CryptoAlgorithmIdentifier::SHA_224:
    54         case CryptoAlgorithmIdentifier::SHA_256:
    55             lengthBytes = 64;
    56             break;
    57         case CryptoAlgorithmIdentifier::SHA_384:
    58         case CryptoAlgorithmIdentifier::SHA_512:
    59             lengthBytes = 128;
    60             break;
    61         default:
    62             return nullptr;
    63         }
    64     }
    65 
    66     return adoptRef(new CryptoKeyHMAC(randomData(lengthBytes), hash, extractable, usages));
    67 }
    68 
    6948void CryptoKeyHMAC::buildAlgorithmDescription(CryptoAlgorithmDescriptionBuilder& builder) const
    7049{
  • trunk/Source/WebCore/crypto/keys/CryptoKeyHMAC.h

    r158526 r158578  
    4242    virtual ~CryptoKeyHMAC();
    4343
    44     // If lengthBytes is 0, a recommended length is used, which is the size of the associated hash function's block size.
    45     static PassRefPtr<CryptoKeyHMAC> generate(size_t lengthBytes, CryptoAlgorithmIdentifier hash, bool extractable, CryptoKeyUsage);
    46 
    4744    virtual CryptoKeyClass keyClass() const OVERRIDE { return CryptoKeyClass::HMAC; }
    4845
  • trunk/Source/WebCore/crypto/mac/CryptoAlgorithmAES_CBCMac.cpp

    r158526 r158578  
    116116}
    117117
     118void CryptoAlgorithmAES_CBC::generateKey(const CryptoAlgorithmParameters&, bool /*extractable*/, CryptoKeyUsage, std::unique_ptr<PromiseWrapper>, ExceptionCode& ec)
     119{
     120    // Not yet implemented.
     121    ec = NOT_SUPPORTED_ERR;
     122}
     123
    118124} // namespace WebCore
    119125
  • trunk/Source/WebCore/crypto/mac/CryptoAlgorithmHMACMac.cpp

    r158526 r158578  
    137137}
    138138
     139void CryptoAlgorithmHMAC::generateKey(const CryptoAlgorithmParameters&, bool /*extractable*/, CryptoKeyUsage, std::unique_ptr<PromiseWrapper>, ExceptionCode& ec)
     140{
     141    // Not yet implemented.
     142    ec = NOT_SUPPORTED_ERR;
     143}
     144
     145
    139146}
    140147
Note: See TracChangeset for help on using the changeset viewer.