Changeset 159393 in webkit


Ignore:
Timestamp:
Nov 17, 2013 5:18:43 PM (10 years ago)
Author:
ap@apple.com
Message:

RSASSA-PKCS1-v1_5 JWK import doesn't check key size
https://bugs.webkit.org/show_bug.cgi?id=124472

Reviewed by Sam Weinig.

Source/WebCore:

Test: crypto/subtle/rsassa-pkcs1-v1_5-import-jwk-small-key.html

  • bindings/js/JSCryptoKeySerializationJWK.cpp:

(WebCore::JSCryptoKeySerializationJWK::keySizeIsValid): Added the checks.
(WebCore::JSCryptoKeySerializationJWK::keyDataRSAComponents): Check key size when
importing.
(WebCore::JSCryptoKeySerializationJWK::serialize): Updated a comment.

  • crypto/keys/CryptoKeySerializationRaw.cpp: (WebCore::CryptoKeySerializationRaw::serialize):

Updated a comment.

LayoutTests:

  • crypto/subtle/rsassa-pkcs1-v1_5-import-jwk-small-key-expected.txt: Added.
  • crypto/subtle/rsassa-pkcs1-v1_5-import-jwk-small-key.html: Added.
Location:
trunk
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r159392 r159393  
     12013-11-17  Alexey Proskuryakov  <ap@apple.com>
     2
     3        RSASSA-PKCS1-v1_5 JWK import doesn't check key size
     4        https://bugs.webkit.org/show_bug.cgi?id=124472
     5
     6        Reviewed by Sam Weinig.
     7
     8        * crypto/subtle/rsassa-pkcs1-v1_5-import-jwk-small-key-expected.txt: Added.
     9        * crypto/subtle/rsassa-pkcs1-v1_5-import-jwk-small-key.html: Added.
     10
    1112013-11-17  Alexey Proskuryakov  <ap@apple.com>
    212
  • trunk/Source/WebCore/ChangeLog

    r159392 r159393  
     12013-11-17  Alexey Proskuryakov  <ap@apple.com>
     2
     3        RSASSA-PKCS1-v1_5 JWK import doesn't check key size
     4        https://bugs.webkit.org/show_bug.cgi?id=124472
     5
     6        Reviewed by Sam Weinig.
     7
     8        Test: crypto/subtle/rsassa-pkcs1-v1_5-import-jwk-small-key.html
     9
     10        * bindings/js/JSCryptoKeySerializationJWK.cpp:
     11        (WebCore::JSCryptoKeySerializationJWK::keySizeIsValid): Added the checks.
     12        (WebCore::JSCryptoKeySerializationJWK::keyDataRSAComponents): Check key size when
     13        importing.
     14        (WebCore::JSCryptoKeySerializationJWK::serialize): Updated a comment.
     15
     16        * crypto/keys/CryptoKeySerializationRaw.cpp: (WebCore::CryptoKeySerializationRaw::serialize):
     17        Updated a comment.
     18
    1192013-11-17  Alexey Proskuryakov  <ap@apple.com>
    220
  • trunk/Source/WebCore/bindings/js/JSCryptoKeySerializationJWK.cpp

    r159390 r159393  
    278278    if (m_jwkAlgorithmName == "A256CBC")
    279279        return sizeInBits == 256;
     280    if (m_jwkAlgorithmName == "RS256")
     281        return sizeInBits >= 2048;
     282    if (m_jwkAlgorithmName == "RS384")
     283        return sizeInBits >= 2048;
     284    if (m_jwkAlgorithmName == "RS512")
     285        return sizeInBits >= 2048;
    280286    return true;
    281287}
     
    313319        if (!m_exec->hadException())
    314320            throwTypeError(m_exec, "Required JWK \"n\" member is missing");
     321        return nullptr;
     322    }
     323
     324    if (!keySizeIsValid(modulus.size() * 8)) {
     325        throwTypeError(m_exec, "Key size is not valid for " + m_jwkAlgorithmName);
    315326        return nullptr;
    316327    }
     
    505516    std::unique_ptr<CryptoKeyData> keyData = key.exportData();
    506517    if (!keyData) {
    507         // FIXME: Shouldn't happen once all key types implement exportData().
    508         throwTypeError(exec, "Key doesn't support exportKey");
     518        // This generally shouldn't happen as long as all key types implement exportData(), but as underlying libraries return errors, there may be some rare failure conditions.
     519        throwTypeError(exec, "Couldn't export key material");
    509520        return String();
    510521    }
  • trunk/Source/WebCore/crypto/keys/CryptoKeySerializationRaw.cpp

    r159390 r159393  
    6666    std::unique_ptr<CryptoKeyData> keyData = key.exportData();
    6767    if (!keyData) {
    68         // FIXME: Shouldn't happen once all key types implement exportData().
     68        // This generally shouldn't happen as long as all key types implement exportData(), but as underlying libraries return errors, there may be some rare failure conditions.
    6969        return false;
    7070    }
Note: See TracChangeset for help on using the changeset viewer.