Changeset 159966 in webkit


Ignore:
Timestamp:
Dec 2, 2013, 2:36:07 PM (11 years ago)
Author:
ap@apple.com
Message:

Support WebCrypto AES-KW
https://bugs.webkit.org/show_bug.cgi?id=125105

Reviewed by Sam Weinig.

Source/WebCore:

Tests: crypto/subtle/aes-kw-key-manipulation.html

crypto/subtle/aes-kw-wrap-unwrap-aes.html

  • WebCore.xcodeproj/project.pbxproj: Added new files.
  • crypto/CryptoAlgorithmIdentifier.h: (WebCore::CryptoAlgorithmIdentifier): Added AES-KW.

It's not standardized yet, but there appears to be a consensus that it will be specified.

  • bindings/js/JSCryptoAlgorithmDictionary.cpp:

(WebCore::JSCryptoAlgorithmDictionary::createParametersForEncrypt):
(WebCore::JSCryptoAlgorithmDictionary::createParametersForDecrypt):
(WebCore::JSCryptoAlgorithmDictionary::createParametersForSign):
(WebCore::JSCryptoAlgorithmDictionary::createParametersForVerify):
(WebCore::JSCryptoAlgorithmDictionary::createParametersForDigest):
(WebCore::JSCryptoAlgorithmDictionary::createParametersForGenerateKey):
(WebCore::JSCryptoAlgorithmDictionary::createParametersForDeriveKey):
(WebCore::JSCryptoAlgorithmDictionary::createParametersForDeriveBits):
(WebCore::JSCryptoAlgorithmDictionary::createParametersForImportKey):
(WebCore::JSCryptoAlgorithmDictionary::createParametersForExportKey):
Added AES-KW cases everywhere.

  • bindings/js/JSCryptoKeySerializationJWK.cpp:

(WebCore::JSCryptoKeySerializationJWK::reconcileAlgorithm):
(WebCore::JSCryptoKeySerializationJWK::keySizeIsValid):
(WebCore::JSCryptoKeySerializationJWK::addJWKAlgorithmToJSON):
Support importing/exporting AES-KW keys in JWK.

  • bindings/js/JSSubtleCryptoCustom.cpp:

(WebCore::JSSubtleCrypto::importKey):
(WebCore::JSSubtleCrypto::exportKey):
(WebCore::JSSubtleCrypto::wrapKey):
(WebCore::JSSubtleCrypto::unwrapKey):
Added some accidentally forgotten std::moves.

  • crypto/algorithms/CryptoAlgorithmAES_KW.cpp: Added.
  • crypto/algorithms/CryptoAlgorithmAES_KW.h: Added.
  • crypto/mac/CryptoAlgorithmAES_KWMac.cpp: Added.
  • crypto/keys/CryptoKeyAES.cpp: (WebCore::CryptoKeyAES::CryptoKeyAES): Allow AES-KW

as valid algorithm for AES keys.

  • crypto/mac/CryptoAlgorithmRegistryMac.cpp:

(WebCore::CryptoAlgorithmRegistry::platformRegisterAlgorithms): Register AES-KW.

LayoutTests:

  • crypto/subtle/aes-kw-key-manipulation-expected.txt: Added.
  • crypto/subtle/aes-kw-key-manipulation.html: Added.
  • crypto/subtle/aes-kw-wrap-unwrap-aes-expected.txt: Added.
  • crypto/subtle/aes-kw-wrap-unwrap-aes.html: Added.
Location:
trunk
Files:
7 added
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r159954 r159966  
     12013-12-02  Alexey Proskuryakov  <ap@apple.com>
     2
     3        Support WebCrypto AES-KW
     4        https://bugs.webkit.org/show_bug.cgi?id=125105
     5
     6        Reviewed by Sam Weinig.
     7
     8        * crypto/subtle/aes-kw-key-manipulation-expected.txt: Added.
     9        * crypto/subtle/aes-kw-key-manipulation.html: Added.
     10        * crypto/subtle/aes-kw-wrap-unwrap-aes-expected.txt: Added.
     11        * crypto/subtle/aes-kw-wrap-unwrap-aes.html: Added.
     12
    1132013-12-02  Rob Buis  <rob.buis@samsung.com>
    214
  • trunk/Source/WebCore/ChangeLog

    r159960 r159966  
     12013-12-02  Alexey Proskuryakov  <ap@apple.com>
     2
     3        Support WebCrypto AES-KW
     4        https://bugs.webkit.org/show_bug.cgi?id=125105
     5
     6        Reviewed by Sam Weinig.
     7
     8        Tests: crypto/subtle/aes-kw-key-manipulation.html
     9               crypto/subtle/aes-kw-wrap-unwrap-aes.html
     10
     11        * WebCore.xcodeproj/project.pbxproj: Added new files.
     12
     13        * crypto/CryptoAlgorithmIdentifier.h: (WebCore::CryptoAlgorithmIdentifier): Added AES-KW.
     14        It's not standardized yet, but there appears to be a consensus that it will be specified.
     15
     16        * bindings/js/JSCryptoAlgorithmDictionary.cpp:
     17        (WebCore::JSCryptoAlgorithmDictionary::createParametersForEncrypt):
     18        (WebCore::JSCryptoAlgorithmDictionary::createParametersForDecrypt):
     19        (WebCore::JSCryptoAlgorithmDictionary::createParametersForSign):
     20        (WebCore::JSCryptoAlgorithmDictionary::createParametersForVerify):
     21        (WebCore::JSCryptoAlgorithmDictionary::createParametersForDigest):
     22        (WebCore::JSCryptoAlgorithmDictionary::createParametersForGenerateKey):
     23        (WebCore::JSCryptoAlgorithmDictionary::createParametersForDeriveKey):
     24        (WebCore::JSCryptoAlgorithmDictionary::createParametersForDeriveBits):
     25        (WebCore::JSCryptoAlgorithmDictionary::createParametersForImportKey):
     26        (WebCore::JSCryptoAlgorithmDictionary::createParametersForExportKey):
     27        Added AES-KW cases everywhere.
     28
     29        * bindings/js/JSCryptoKeySerializationJWK.cpp:
     30        (WebCore::JSCryptoKeySerializationJWK::reconcileAlgorithm):
     31        (WebCore::JSCryptoKeySerializationJWK::keySizeIsValid):
     32        (WebCore::JSCryptoKeySerializationJWK::addJWKAlgorithmToJSON):
     33        Support importing/exporting AES-KW keys in JWK.
     34
     35        * bindings/js/JSSubtleCryptoCustom.cpp:
     36        (WebCore::JSSubtleCrypto::importKey):
     37        (WebCore::JSSubtleCrypto::exportKey):
     38        (WebCore::JSSubtleCrypto::wrapKey):
     39        (WebCore::JSSubtleCrypto::unwrapKey):
     40        Added some accidentally forgotten std::moves.
     41
     42        * crypto/algorithms/CryptoAlgorithmAES_KW.cpp: Added.
     43        * crypto/algorithms/CryptoAlgorithmAES_KW.h: Added.
     44        * crypto/mac/CryptoAlgorithmAES_KWMac.cpp: Added.
     45
     46        * crypto/keys/CryptoKeyAES.cpp: (WebCore::CryptoKeyAES::CryptoKeyAES): Allow AES-KW
     47        as valid algorithm for AES keys.
     48
     49        * crypto/mac/CryptoAlgorithmRegistryMac.cpp:
     50        (WebCore::CryptoAlgorithmRegistry::platformRegisterAlgorithms): Register AES-KW.
     51
    1522013-12-02  Beth Dakin  <bdakin@apple.com>
    253
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r159949 r159966  
    57355735                E1FE137518402A6700892F13 /* CommonCryptoUtilities.h in Headers */ = {isa = PBXBuildFile; fileRef = E1FE137318402A6700892F13 /* CommonCryptoUtilities.h */; };
    57365736                E1FE1377184D1E3300892F13 /* CryptoAlgorithmRsaOaepParams.h in Headers */ = {isa = PBXBuildFile; fileRef = E1FE1376184D1E3300892F13 /* CryptoAlgorithmRsaOaepParams.h */; };
     5737                E1FE137A184D21BB00892F13 /* CryptoAlgorithmAES_KW.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E1FE1378184D21BB00892F13 /* CryptoAlgorithmAES_KW.cpp */; };
     5738                E1FE137B184D21BB00892F13 /* CryptoAlgorithmAES_KW.h in Headers */ = {isa = PBXBuildFile; fileRef = E1FE1379184D21BB00892F13 /* CryptoAlgorithmAES_KW.h */; };
     5739                E1FE137E184D270200892F13 /* CryptoAlgorithmAES_KWMac.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E1FE137C184D270200892F13 /* CryptoAlgorithmAES_KWMac.cpp */; };
    57375740                E1FF57A30F01255B00891EBB /* ThreadGlobalData.h in Headers */ = {isa = PBXBuildFile; fileRef = E1FF57A20F01255B00891EBB /* ThreadGlobalData.h */; settings = {ATTRIBUTES = (Private, ); }; };
    57385741                E1FF57A60F01256B00891EBB /* ThreadGlobalData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E1FF57A50F01256B00891EBB /* ThreadGlobalData.cpp */; };
     
    1286112864                E1FE137318402A6700892F13 /* CommonCryptoUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CommonCryptoUtilities.h; sourceTree = "<group>"; };
    1286212865                E1FE1376184D1E3300892F13 /* CryptoAlgorithmRsaOaepParams.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CryptoAlgorithmRsaOaepParams.h; path = parameters/CryptoAlgorithmRsaOaepParams.h; sourceTree = "<group>"; };
     12866                E1FE1378184D21BB00892F13 /* CryptoAlgorithmAES_KW.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CryptoAlgorithmAES_KW.cpp; sourceTree = "<group>"; };
     12867                E1FE1379184D21BB00892F13 /* CryptoAlgorithmAES_KW.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CryptoAlgorithmAES_KW.h; sourceTree = "<group>"; };
     12868                E1FE137C184D270200892F13 /* CryptoAlgorithmAES_KWMac.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CryptoAlgorithmAES_KWMac.cpp; path = mac/CryptoAlgorithmAES_KWMac.cpp; sourceTree = "<group>"; };
    1286312869                E1FF57A20F01255B00891EBB /* ThreadGlobalData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ThreadGlobalData.h; sourceTree = "<group>"; };
    1286412870                E1FF57A50F01256B00891EBB /* ThreadGlobalData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ThreadGlobalData.cpp; sourceTree = "<group>"; };
     
    2042220428                                E1FE137318402A6700892F13 /* CommonCryptoUtilities.h */,
    2042320429                                E125F843182425C900D84CD9 /* CryptoAlgorithmAES_CBCMac.cpp */,
     20430                                E1FE137C184D270200892F13 /* CryptoAlgorithmAES_KWMac.cpp */,
    2042420431                                E125F8371822F1EB00D84CD9 /* CryptoAlgorithmHMACMac.cpp */,
    2042520432                                E1BB84AC1822CA7400525043 /* CryptoAlgorithmRegistryMac.cpp */,
     
    2043820445                                E125F83F1824253A00D84CD9 /* CryptoAlgorithmAES_CBC.cpp */,
    2043920446                                E125F8401824253A00D84CD9 /* CryptoAlgorithmAES_CBC.h */,
     20447                                E1FE1378184D21BB00892F13 /* CryptoAlgorithmAES_KW.cpp */,
     20448                                E1FE1379184D21BB00892F13 /* CryptoAlgorithmAES_KW.h */,
    2044020449                                E125F82F1822F11B00D84CD9 /* CryptoAlgorithmHMAC.cpp */,
    2044120450                                E125F8301822F11B00D84CD9 /* CryptoAlgorithmHMAC.h */,
     
    2432724336                                1A3586E015264C450022A659 /* RenderMultiColumnFlowThread.h in Headers */,
    2432824337                                BCE32B9C1517C0B200F542EC /* RenderMultiColumnSet.h in Headers */,
     24338                                E1FE137B184D21BB00892F13 /* CryptoAlgorithmAES_KW.h in Headers */,
    2432924339                                BC85F23D151915E000BC17BE /* RenderNamedFlowThread.h in Headers */,
    2433024340                                BCEA4880097D93020094C9E4 /* RenderObject.h in Headers */,
     
    2563725647                                512DD8FA0D91E6AF000F89EE /* ArchiveFactory.cpp in Sources */,
    2563825648                                512DD8FB0D91E6AF000F89EE /* ArchiveResource.cpp in Sources */,
     25649                                E1FE137A184D21BB00892F13 /* CryptoAlgorithmAES_KW.cpp in Sources */,
    2563925650                                512DD8F70D91E6AF000F89EE /* ArchiveResourceCollection.cpp in Sources */,
    2564025651                                49B3760C15C6C6840059131D /* ArrayValue.cpp in Sources */,
     
    2829528306                                379919961200DDF400EA041C /* WOFFFileFormat.cpp in Sources */,
    2829628307                                2E4346450F546A8200B0F1BA /* Worker.cpp in Sources */,
     28308                                E1FE137E184D270200892F13 /* CryptoAlgorithmAES_KWMac.cpp in Sources */,
    2829728309                                51059DDD1820B17600DFF9B1 /* IDBTransactionBackendOperations.cpp in Sources */,
    2829828310                                F3820896147D35F90010BC06 /* WorkerConsoleAgent.cpp in Sources */,
  • trunk/Source/WebCore/bindings/js/JSCryptoAlgorithmDictionary.cpp

    r159944 r159966  
    330330        setDOMException(exec, NOT_SUPPORTED_ERR);
    331331        return nullptr;
     332    case CryptoAlgorithmIdentifier::AES_KW:
     333        return std::make_unique<CryptoAlgorithmParameters>();
    332334    }
    333335}
     
    365367        setDOMException(exec, NOT_SUPPORTED_ERR);
    366368        return nullptr;
     369    case CryptoAlgorithmIdentifier::AES_KW:
     370        return std::make_unique<CryptoAlgorithmParameters>();
    367371    }
    368372}
     
    398402    case CryptoAlgorithmIdentifier::HKDF_CTR:
    399403    case CryptoAlgorithmIdentifier::PBKDF2:
     404    case CryptoAlgorithmIdentifier::AES_KW:
    400405        setDOMException(exec, NOT_SUPPORTED_ERR);
    401406        return nullptr;
     
    433438    case CryptoAlgorithmIdentifier::HKDF_CTR:
    434439    case CryptoAlgorithmIdentifier::PBKDF2:
     440    case CryptoAlgorithmIdentifier::AES_KW:
    435441        setDOMException(exec, NOT_SUPPORTED_ERR);
    436442        return nullptr;
     
    465471    case CryptoAlgorithmIdentifier::HKDF_CTR:
    466472    case CryptoAlgorithmIdentifier::PBKDF2:
     473    case CryptoAlgorithmIdentifier::AES_KW:
    467474        setDOMException(exec, NOT_SUPPORTED_ERR);
    468475        return nullptr;
     
    501508        setDOMException(exec, NOT_SUPPORTED_ERR);
    502509        return nullptr;
     510    case CryptoAlgorithmIdentifier::AES_KW:
     511        return createAesKeyGenParams(exec, value);
    503512    }
    504513}
     
    528537    case CryptoAlgorithmIdentifier::HKDF_CTR:
    529538    case CryptoAlgorithmIdentifier::PBKDF2:
     539    case CryptoAlgorithmIdentifier::AES_KW:
    530540        setDOMException(exec, NOT_SUPPORTED_ERR);
    531541        return nullptr;
     
    557567    case CryptoAlgorithmIdentifier::HKDF_CTR:
    558568    case CryptoAlgorithmIdentifier::PBKDF2:
     569    case CryptoAlgorithmIdentifier::AES_KW:
    559570        setDOMException(exec, NOT_SUPPORTED_ERR);
    560571        return nullptr;
     
    595606        setDOMException(exec, NOT_SUPPORTED_ERR);
    596607        return nullptr;
     608    case CryptoAlgorithmIdentifier::AES_KW:
     609        return std::make_unique<CryptoAlgorithmParameters>();
    597610    }
    598611}
     
    625638        setDOMException(exec, NOT_SUPPORTED_ERR);
    626639        return nullptr;
     640    case CryptoAlgorithmIdentifier::AES_KW:
     641        return std::make_unique<CryptoAlgorithmParameters>();
    627642    }
    628643}
  • trunk/Source/WebCore/bindings/js/JSCryptoKeySerializationJWK.cpp

    r159944 r159966  
    203203        algorithm = CryptoAlgorithmRegistry::shared().create(CryptoAlgorithmIdentifier::AES_CBC);
    204204        parameters = std::make_unique<CryptoAlgorithmParameters>();
     205    } else if (m_jwkAlgorithmName == "A128KW") {
     206        algorithm = CryptoAlgorithmRegistry::shared().create(CryptoAlgorithmIdentifier::AES_KW);
     207        parameters = std::make_unique<CryptoAlgorithmParameters>();
     208    } else if (m_jwkAlgorithmName == "A192KW") {
     209        algorithm = CryptoAlgorithmRegistry::shared().create(CryptoAlgorithmIdentifier::AES_KW);
     210        parameters = std::make_unique<CryptoAlgorithmParameters>();
     211    } else if (m_jwkAlgorithmName == "A256KW") {
     212        algorithm = CryptoAlgorithmRegistry::shared().create(CryptoAlgorithmIdentifier::AES_KW);
     213        parameters = std::make_unique<CryptoAlgorithmParameters>();
    205214    } else {
    206215        throwTypeError(m_exec, "Unsupported JWK algorithm " + m_jwkAlgorithmName);
     
    282291    if (m_jwkAlgorithmName == "A256CBC")
    283292        return sizeInBits == 256;
     293    if (m_jwkAlgorithmName == "A128KW")
     294        return sizeInBits == 128;
     295    if (m_jwkAlgorithmName == "A192KW")
     296        return sizeInBits == 192;
     297    if (m_jwkAlgorithmName == "A256KW")
     298        return sizeInBits == 256;
    284299    if (m_jwkAlgorithmName == "RS256")
    285300        return sizeInBits >= 2048;
     
    523538        }
    524539        break;
     540    case CryptoAlgorithmIdentifier::AES_KW:
     541        switch (toCryptoKeyAES(key).key().size() * 8) {
     542        case 128:
     543            jwkAlgorithm = "A128KW";
     544            break;
     545        case 192:
     546            jwkAlgorithm = "A192KW";
     547            break;
     548        case 256:
     549            jwkAlgorithm = "A256KW";
     550            break;
     551        }
     552        break;
    525553    case CryptoAlgorithmIdentifier::RSASSA_PKCS1_v1_5: {
    526554        const CryptoKeyRSA& rsaKey = toCryptoKeyRSA(key);
  • trunk/Source/WebCore/bindings/js/JSSubtleCryptoCustom.cpp

    r159644 r159966  
    557557    };
    558558
    559     WebCore::importKey(exec, keyFormat, data, algorithm.release(), parameters.release(), extractable, keyUsages, successCallback, failureCallback);
     559    WebCore::importKey(exec, keyFormat, data, algorithm.release(), parameters.release(), extractable, keyUsages, std::move(successCallback), std::move(failureCallback));
    560560    if (exec->hadException())
    561561        return jsUndefined();
     
    621621    };
    622622
    623     WebCore::exportKey(exec, keyFormat, *key, successCallback, failureCallback);
     623    WebCore::exportKey(exec, keyFormat, *key, std::move(successCallback), std::move(failureCallback));
    624624    if (exec->hadException())
    625625        return jsUndefined();
     
    688688
    689689    ExceptionCode ec = 0;
    690     WebCore::exportKey(exec, keyFormat, *key, exportSuccessCallback, exportFailureCallback);
     690    WebCore::exportKey(exec, keyFormat, *key, std::move(exportSuccessCallback), std::move(exportFailureCallback));
    691691    if (ec) {
    692692        setDOMException(exec, ec);
     
    782782        };
    783783        ExecState* exec = domGlobalObject->globalExec();
    784         WebCore::importKey(exec, keyFormat, std::make_pair(result.data(), result.size()), unwrappedKeyAlgorithmPtr, unwrappedKeyAlgorithmParametersPtr, extractable, keyUsages, importSuccessCallback, importFailureCallback);
     784        WebCore::importKey(exec, keyFormat, std::make_pair(result.data(), result.size()), unwrappedKeyAlgorithmPtr, unwrappedKeyAlgorithmParametersPtr, extractable, keyUsages, std::move(importSuccessCallback), std::move(importFailureCallback));
    785785        if (exec->hadException()) {
    786786            // FIXME: Report exception details to console, and possibly to calling script once there is a standardized way to pass errors to WebCrypto promise reject functions.
  • trunk/Source/WebCore/crypto/CryptoAlgorithmIdentifier.h

    r158236 r159966  
    5252    CONCAT,
    5353    HKDF_CTR,
    54     PBKDF2
     54    PBKDF2,
     55    AES_KW // Not yet standardized.
    5556};
    5657
  • trunk/Source/WebCore/crypto/keys/CryptoKeyAES.cpp

    r159390 r159966  
    4444        || algorithm == CryptoAlgorithmIdentifier::AES_CMAC
    4545        || algorithm == CryptoAlgorithmIdentifier::AES_GCM
    46         || algorithm == CryptoAlgorithmIdentifier::AES_CFB);
     46        || algorithm == CryptoAlgorithmIdentifier::AES_CFB
     47        || algorithm == CryptoAlgorithmIdentifier::AES_KW);
    4748}
    4849
  • trunk/Source/WebCore/crypto/mac/CryptoAlgorithmRegistryMac.cpp

    r159944 r159966  
    3030
    3131#include "CryptoAlgorithmAES_CBC.h"
     32#include "CryptoAlgorithmAES_KW.h"
    3233#include "CryptoAlgorithmHMAC.h"
    3334#include "CryptoAlgorithmRSASSA_PKCS1_v1_5.h"
     
    4445{
    4546    registerAlgorithm<CryptoAlgorithmAES_CBC>();
     47    registerAlgorithm<CryptoAlgorithmAES_KW>();
    4648    registerAlgorithm<CryptoAlgorithmHMAC>();
    4749    registerAlgorithm<CryptoAlgorithmRSASSA_PKCS1_v1_5>();
Note: See TracChangeset for help on using the changeset viewer.