Changeset 160502 in webkit


Ignore:
Timestamp:
Dec 12, 2013, 12:12:10 PM (11 years ago)
Author:
ap@apple.com
Message:

Add support for RSAES-PKCS1-v1_5
https://bugs.webkit.org/show_bug.cgi?id=125647

Reviewed by Anders Carlsson.

Source/WebCore:

Tests: crypto/subtle/rsaes-pkcs1-v1_5-decrypt.html

crypto/subtle/rsaes-pkcs1-v1_5-wrap-unwrap-aes.html

  • crypto/algorithms/CryptoAlgorithmAES_KW.cpp:
  • crypto/algorithms/CryptoAlgorithmAES_KW.h:

Removed meaningless parameters arguments from private functions. The base arguments
class is always empty.

  • WebCore.xcodeproj/project.pbxproj:
  • bindings/js/JSCryptoAlgorithmDictionary.cpp:

(WebCore::JSCryptoAlgorithmDictionary::createParametersForEncrypt):
(WebCore::JSCryptoAlgorithmDictionary::createParametersForDecrypt):

  • bindings/js/JSCryptoKeySerializationJWK.cpp:

(WebCore::JSCryptoKeySerializationJWK::reconcileAlgorithm):
(WebCore::JSCryptoKeySerializationJWK::keySizeIsValid):
(WebCore::JSCryptoKeySerializationJWK::addJWKAlgorithmToJSON):

  • crypto/algorithms/CryptoAlgorithmRSAES_PKCS1_v1_5.cpp: Added.

(WebCore::CryptoAlgorithmRSAES_PKCS1_v1_5::CryptoAlgorithmRSAES_PKCS1_v1_5):
(WebCore::CryptoAlgorithmRSAES_PKCS1_v1_5::~CryptoAlgorithmRSAES_PKCS1_v1_5):
(WebCore::CryptoAlgorithmRSAES_PKCS1_v1_5::create):
(WebCore::CryptoAlgorithmRSAES_PKCS1_v1_5::identifier):
(WebCore::CryptoAlgorithmRSAES_PKCS1_v1_5::keyAlgorithmMatches):
(WebCore::CryptoAlgorithmRSAES_PKCS1_v1_5::encrypt):
(WebCore::CryptoAlgorithmRSAES_PKCS1_v1_5::decrypt):
(WebCore::CryptoAlgorithmRSAES_PKCS1_v1_5::generateKey):
(WebCore::CryptoAlgorithmRSAES_PKCS1_v1_5::importKey):

  • crypto/algorithms/CryptoAlgorithmRSAES_PKCS1_v1_5.h: Added.
  • crypto/mac/CryptoAlgorithmRSAES_PKCS1_v1_5Mac.cpp: Added.

(WebCore::CryptoAlgorithmRSAES_PKCS1_v1_5::platformEncrypt):
(WebCore::CryptoAlgorithmRSAES_PKCS1_v1_5::platformDecrypt):

  • crypto/mac/CryptoAlgorithmRegistryMac.cpp:

(WebCore::CryptoAlgorithmRegistry::platformRegisterAlgorithms):
Added support for this algorithm.

LayoutTests:

  • crypto/subtle/rsaes-pkcs1-v1_5-decrypt-expected.txt: Added.
  • crypto/subtle/rsaes-pkcs1-v1_5-decrypt.html: Added.
  • crypto/subtle/rsaes-pkcs1-v1_5-wrap-unwrap-aes-expected.txt: Added.
  • crypto/subtle/rsaes-pkcs1-v1_5-wrap-unwrap-aes.html: Added.
Location:
trunk
Files:
7 added
8 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified trunk/LayoutTests/ChangeLog

    r160496 r160502  
     12013-12-12  Alexey Proskuryakov  <ap@apple.com>
     2
     3        Add support for RSAES-PKCS1-v1_5
     4        https://bugs.webkit.org/show_bug.cgi?id=125647
     5
     6        Reviewed by Anders Carlsson.
     7
     8        * crypto/subtle/rsaes-pkcs1-v1_5-decrypt-expected.txt: Added.
     9        * crypto/subtle/rsaes-pkcs1-v1_5-decrypt.html: Added.
     10        * crypto/subtle/rsaes-pkcs1-v1_5-wrap-unwrap-aes-expected.txt: Added.
     11        * crypto/subtle/rsaes-pkcs1-v1_5-wrap-unwrap-aes.html: Added.
     12
    1132013-12-12  Alexey Proskuryakov  <ap@apple.com>
    214
  • TabularUnified trunk/Source/WebCore/ChangeLog

    r160498 r160502  
     12013-12-12  Alexey Proskuryakov  <ap@apple.com>
     2
     3        Add support for RSAES-PKCS1-v1_5
     4        https://bugs.webkit.org/show_bug.cgi?id=125647
     5
     6        Reviewed by Anders Carlsson.
     7
     8        Tests: crypto/subtle/rsaes-pkcs1-v1_5-decrypt.html
     9               crypto/subtle/rsaes-pkcs1-v1_5-wrap-unwrap-aes.html
     10
     11        * crypto/algorithms/CryptoAlgorithmAES_KW.cpp:
     12        * crypto/algorithms/CryptoAlgorithmAES_KW.h:
     13        Removed meaningless parameters arguments from private functions. The base arguments
     14        class is always empty.
     15
     16        * WebCore.xcodeproj/project.pbxproj:
     17        * bindings/js/JSCryptoAlgorithmDictionary.cpp:
     18        (WebCore::JSCryptoAlgorithmDictionary::createParametersForEncrypt):
     19        (WebCore::JSCryptoAlgorithmDictionary::createParametersForDecrypt):
     20        * bindings/js/JSCryptoKeySerializationJWK.cpp:
     21        (WebCore::JSCryptoKeySerializationJWK::reconcileAlgorithm):
     22        (WebCore::JSCryptoKeySerializationJWK::keySizeIsValid):
     23        (WebCore::JSCryptoKeySerializationJWK::addJWKAlgorithmToJSON):
     24        * crypto/algorithms/CryptoAlgorithmRSAES_PKCS1_v1_5.cpp: Added.
     25        (WebCore::CryptoAlgorithmRSAES_PKCS1_v1_5::CryptoAlgorithmRSAES_PKCS1_v1_5):
     26        (WebCore::CryptoAlgorithmRSAES_PKCS1_v1_5::~CryptoAlgorithmRSAES_PKCS1_v1_5):
     27        (WebCore::CryptoAlgorithmRSAES_PKCS1_v1_5::create):
     28        (WebCore::CryptoAlgorithmRSAES_PKCS1_v1_5::identifier):
     29        (WebCore::CryptoAlgorithmRSAES_PKCS1_v1_5::keyAlgorithmMatches):
     30        (WebCore::CryptoAlgorithmRSAES_PKCS1_v1_5::encrypt):
     31        (WebCore::CryptoAlgorithmRSAES_PKCS1_v1_5::decrypt):
     32        (WebCore::CryptoAlgorithmRSAES_PKCS1_v1_5::generateKey):
     33        (WebCore::CryptoAlgorithmRSAES_PKCS1_v1_5::importKey):
     34        * crypto/algorithms/CryptoAlgorithmRSAES_PKCS1_v1_5.h: Added.
     35        * crypto/mac/CryptoAlgorithmRSAES_PKCS1_v1_5Mac.cpp: Added.
     36        (WebCore::CryptoAlgorithmRSAES_PKCS1_v1_5::platformEncrypt):
     37        (WebCore::CryptoAlgorithmRSAES_PKCS1_v1_5::platformDecrypt):
     38        * crypto/mac/CryptoAlgorithmRegistryMac.cpp:
     39        (WebCore::CryptoAlgorithmRegistry::platformRegisterAlgorithms):
     40        Added support for this algorithm.
     41
    1422013-12-12  Andreas Kling  <akling@apple.com>
    243
  • TabularUnified trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r160487 r160502  
    55565556                E11C9D9B0EB3681200E409DB /* ScriptExecutionContext.h in Headers */ = {isa = PBXBuildFile; fileRef = E11C9D9A0EB3681200E409DB /* ScriptExecutionContext.h */; settings = {ATTRIBUTES = (Private, ); }; };
    55575557                E11C9DB00EB3699500E409DB /* ScriptExecutionContext.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E11C9DAF0EB3699500E409DB /* ScriptExecutionContext.cpp */; };
     5558                E1233F0C185A3E3B008DFAF5 /* CryptoAlgorithmRSAES_PKCS1_v1_5.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E1233F0A185A3E3B008DFAF5 /* CryptoAlgorithmRSAES_PKCS1_v1_5.cpp */; };
     5559                E1233F0D185A3E3B008DFAF5 /* CryptoAlgorithmRSAES_PKCS1_v1_5.h in Headers */ = {isa = PBXBuildFile; fileRef = E1233F0B185A3E3B008DFAF5 /* CryptoAlgorithmRSAES_PKCS1_v1_5.h */; };
     5560                E1233F10185A4130008DFAF5 /* CryptoAlgorithmRSAES_PKCS1_v1_5Mac.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E1233F0E185A4130008DFAF5 /* CryptoAlgorithmRSAES_PKCS1_v1_5Mac.cpp */; };
    55585561                E124748410AA161D00B79493 /* AuthenticationClient.h in Headers */ = {isa = PBXBuildFile; fileRef = E124748310AA161D00B79493 /* AuthenticationClient.h */; settings = {ATTRIBUTES = (Private, ); }; };
    55595562                E125F82B1822CFEC00D84CD9 /* CryptoAlgorithmSHA1.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E125F8291822CFEC00D84CD9 /* CryptoAlgorithmSHA1.cpp */; };
     
    1269812701                E11C9D9A0EB3681200E409DB /* ScriptExecutionContext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScriptExecutionContext.h; sourceTree = "<group>"; };
    1269912702                E11C9DAF0EB3699500E409DB /* ScriptExecutionContext.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScriptExecutionContext.cpp; sourceTree = "<group>"; };
     12703                E1233F0A185A3E3B008DFAF5 /* CryptoAlgorithmRSAES_PKCS1_v1_5.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CryptoAlgorithmRSAES_PKCS1_v1_5.cpp; sourceTree = "<group>"; };
     12704                E1233F0B185A3E3B008DFAF5 /* CryptoAlgorithmRSAES_PKCS1_v1_5.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CryptoAlgorithmRSAES_PKCS1_v1_5.h; sourceTree = "<group>"; };
     12705                E1233F0E185A4130008DFAF5 /* CryptoAlgorithmRSAES_PKCS1_v1_5Mac.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CryptoAlgorithmRSAES_PKCS1_v1_5Mac.cpp; path = mac/CryptoAlgorithmRSAES_PKCS1_v1_5Mac.cpp; sourceTree = "<group>"; };
    1270012706                E124748310AA161D00B79493 /* AuthenticationClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AuthenticationClient.h; sourceTree = "<group>"; };
    1270112707                E125F8291822CFEC00D84CD9 /* CryptoAlgorithmSHA1.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CryptoAlgorithmSHA1.cpp; sourceTree = "<group>"; };
     
    2050320509                                E1BB84AC1822CA7400525043 /* CryptoAlgorithmRegistryMac.cpp */,
    2050420510                                E1C266D618317AB4003F8B33 /* CryptoAlgorithmRSASSA_PKCS1_v1_5Mac.cpp */,
     20511                                E1233F0E185A4130008DFAF5 /* CryptoAlgorithmRSAES_PKCS1_v1_5Mac.cpp */,
    2050520512                                E1FE136E183FECF000892F13 /* CryptoAlgorithmRSA_OAEPMac.cpp */,
    2050620513                                E19AC3F8182566F700349426 /* CryptoKeyMac.cpp */,
     
    2052220529                                E1FE1368183FE1AB00892F13 /* CryptoAlgorithmRSA_OAEP.cpp */,
    2052320530                                E1FE1369183FE1AB00892F13 /* CryptoAlgorithmRSA_OAEP.h */,
     20531                                E1233F0A185A3E3B008DFAF5 /* CryptoAlgorithmRSAES_PKCS1_v1_5.cpp */,
     20532                                E1233F0B185A3E3B008DFAF5 /* CryptoAlgorithmRSAES_PKCS1_v1_5.h */,
    2052420533                                E1BD3317182D8DDD00C05D9F /* CryptoAlgorithmRSASSA_PKCS1_v1_5.cpp */,
    2052520534                                E1BD3318182D8DDD00C05D9F /* CryptoAlgorithmRSASSA_PKCS1_v1_5.h */,
     
    2442224431                                BCEA4880097D93020094C9E4 /* RenderObject.h in Headers */,
    2442324432                                BCFA930810333193007B25D1 /* RenderOverflow.h in Headers */,
     24433                                E1233F0D185A3E3B008DFAF5 /* CryptoAlgorithmRSAES_PKCS1_v1_5.h in Headers */,
    2442424434                                A43BF59D1149292800C643CA /* RenderProgress.h in Headers */,
    2442524435                                5A574F25131DB93900471B88 /* RenderQuote.h in Headers */,
     
    2785327863                                14C9A5EA0B3D105F005A0232 /* Settings.cpp in Sources */,
    2785427864                                E1C2F24A1533A2120083F974 /* SettingsMac.mm in Sources */,
     27865                                E1233F0C185A3E3B008DFAF5 /* CryptoAlgorithmRSAES_PKCS1_v1_5.cpp in Sources */,
    2785527866                                0F3DD44F12F5EA1B000D9190 /* ShadowBlur.cpp in Sources */,
    2785627867                                BC5EB8C30E82031B00B25965 /* ShadowData.cpp in Sources */,
     
    2820828219                                B2AFFC990D00A5DF0030074D /* TextCodecMac.cpp in Sources */,
    2820928220                                B2C3DA3F0D006C1D00EF6F26 /* TextCodecUserDefined.cpp in Sources */,
     28221                                E1233F10185A4130008DFAF5 /* CryptoAlgorithmRSAES_PKCS1_v1_5Mac.cpp in Sources */,
    2821028222                                B2C3DA410D006C1D00EF6F26 /* TextCodecUTF16.cpp in Sources */,
    2821128223                                E1FF8F6C180DB5BE00132674 /* CryptoAlgorithmRegistry.cpp in Sources */,
  • TabularUnified trunk/Source/WebCore/bindings/js/JSCryptoAlgorithmDictionary.cpp

    r160455 r160502  
    302302    switch (algorithm) {
    303303    case CryptoAlgorithmIdentifier::RSAES_PKCS1_v1_5:
     304        return std::make_unique<CryptoAlgorithmParameters>();
    304305    case CryptoAlgorithmIdentifier::RSASSA_PKCS1_v1_5:
    305306    case CryptoAlgorithmIdentifier::RSA_PSS:
     
    341342    switch (algorithm) {
    342343    case CryptoAlgorithmIdentifier::RSAES_PKCS1_v1_5:
     344        return std::make_unique<CryptoAlgorithmParameters>();
    343345    case CryptoAlgorithmIdentifier::RSASSA_PKCS1_v1_5:
    344346    case CryptoAlgorithmIdentifier::RSA_PSS:
  • TabularUnified trunk/Source/WebCore/bindings/js/JSCryptoKeySerializationJWK.cpp

    r160061 r160502  
    191191        algorithm = CryptoAlgorithmRegistry::shared().create(CryptoAlgorithmIdentifier::RSASSA_PKCS1_v1_5);
    192192        parameters = createRSAKeyParametersWithHash(CryptoAlgorithmIdentifier::SHA_512);
     193    } else if (m_jwkAlgorithmName == "RSA1_5") {
     194        algorithm = CryptoAlgorithmRegistry::shared().create(CryptoAlgorithmIdentifier::RSAES_PKCS1_v1_5);
     195        parameters = std::make_unique<CryptoAlgorithmParameters>();
    193196    } else if (m_jwkAlgorithmName == "RSA-OAEP") {
    194197        algorithm = CryptoAlgorithmRegistry::shared().create(CryptoAlgorithmIdentifier::RSA_OAEP);
     
    322325    if (m_jwkAlgorithmName == "RS512")
    323326        return sizeInBits >= 2048;
     327    if (m_jwkAlgorithmName == "RSA1_5")
     328        return sizeInBits >= 2048;
    324329    if (m_jwkAlgorithmName == "RSA_OAEP")
    325330        return sizeInBits >= 2048;
     
    592597        break;
    593598    }
     599    case CryptoAlgorithmIdentifier::RSAES_PKCS1_v1_5: {
     600        const CryptoKeyRSA& rsaKey = toCryptoKeyRSA(key);
     601        if (rsaKey.keySizeInBits() < 2048)
     602            break;
     603        jwkAlgorithm = "RSA1_5";
     604        break;
     605    }
    594606    case CryptoAlgorithmIdentifier::RSA_OAEP: {
    595607        const CryptoKeyRSA& rsaKey = toCryptoKeyRSA(key);
  • TabularUnified trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_KW.cpp

    r160491 r160502  
    5656}
    5757
    58 bool CryptoAlgorithmAES_KW::keyAlgorithmMatches(const CryptoAlgorithmParameters&, const CryptoKey& key) const
     58bool CryptoAlgorithmAES_KW::keyAlgorithmMatches(const CryptoKey& key) const
    5959{
    6060    if (key.algorithmIdentifier() != s_identifier)
     
    6565}
    6666
    67 void CryptoAlgorithmAES_KW::encryptForWrapKey(const CryptoAlgorithmParameters& parameters, const CryptoKey& key, const CryptoOperationData& data, VectorCallback callback, VoidCallback failureCallback, ExceptionCode& ec)
     67void CryptoAlgorithmAES_KW::encryptForWrapKey(const CryptoAlgorithmParameters&, const CryptoKey& key, const CryptoOperationData& data, VectorCallback callback, VoidCallback failureCallback, ExceptionCode& ec)
    6868{
    69     if (!keyAlgorithmMatches(parameters, key)) {
     69    if (!keyAlgorithmMatches(key)) {
    7070        ec = NOT_SUPPORTED_ERR;
    7171        return;
     
    7575}
    7676
    77 void CryptoAlgorithmAES_KW::decryptForUnwrapKey(const CryptoAlgorithmParameters& parameters, const CryptoKey& key, const CryptoOperationData& data, VectorCallback callback, VoidCallback failureCallback, ExceptionCode& ec)
     77void CryptoAlgorithmAES_KW::decryptForUnwrapKey(const CryptoAlgorithmParameters&, const CryptoKey& key, const CryptoOperationData& data, VectorCallback callback, VoidCallback failureCallback, ExceptionCode& ec)
    7878{
    79     if (!keyAlgorithmMatches(parameters, key)) {
     79    if (!keyAlgorithmMatches(key)) {
    8080        ec = NOT_SUPPORTED_ERR;
    8181        return;
  • TabularUnified trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_KW.h

    r159966 r160502  
    5353    virtual ~CryptoAlgorithmAES_KW();
    5454
    55     bool keyAlgorithmMatches(const CryptoAlgorithmParameters&, const CryptoKey&) const;
     55    bool keyAlgorithmMatches(const CryptoKey&) const;
    5656    void platformEncrypt(const CryptoKeyAES&, const CryptoOperationData&, VectorCallback, VoidCallback failureCallback, ExceptionCode&);
    5757    void platformDecrypt(const CryptoKeyAES&, const CryptoOperationData&, VectorCallback, VoidCallback failureCallback, ExceptionCode&);
  • TabularUnified trunk/Source/WebCore/crypto/mac/CryptoAlgorithmRegistryMac.cpp

    r159966 r160502  
    3232#include "CryptoAlgorithmAES_KW.h"
    3333#include "CryptoAlgorithmHMAC.h"
     34#include "CryptoAlgorithmRSAES_PKCS1_v1_5.h"
    3435#include "CryptoAlgorithmRSASSA_PKCS1_v1_5.h"
    3536#include "CryptoAlgorithmRSA_OAEP.h"
     
    4748    registerAlgorithm<CryptoAlgorithmAES_KW>();
    4849    registerAlgorithm<CryptoAlgorithmHMAC>();
     50    registerAlgorithm<CryptoAlgorithmRSAES_PKCS1_v1_5>();
    4951    registerAlgorithm<CryptoAlgorithmRSASSA_PKCS1_v1_5>();
    5052    registerAlgorithm<CryptoAlgorithmRSA_OAEP>();
Note: See TracChangeset for help on using the changeset viewer.