Changeset 209164 in webkit


Ignore:
Timestamp:
Nov 30, 2016 4:28:04 PM (7 years ago)
Author:
jiewen_tan@apple.com
Message:

Update SubtleCrypto::digest to match the latest spec
https://bugs.webkit.org/show_bug.cgi?id=164742
<rdar://problem/29258037>

Reviewed by Darin Adler.

LayoutTests/imported/w3c:

  • WebCryptoAPI/digest/test_digest-expected.txt:
  • WebCryptoAPI/idlharness-expected.txt:

Source/WebCore:

This patch updates the SubtleCrypto::digest method to match the latest spec:
https://www.w3.org/TR/WebCryptoAPI/#SubtleCrypto-method-digest.
It also refers to the latest Editor's Draft to a certain degree:
https://w3c.github.io/webcrypto/Overview.html#SubtleCrypto-method-digest.
Currently supported digest algorithms are SHA-1, SHA-224, SHA-256, SHA-384,
and SHA-512.

Tests: crypto/subtle/digest-malformed-parameters.html

crypto/subtle/sha1-digest.html
crypto/subtle/sha224-digest.html
crypto/subtle/sha256-digest.html
crypto/subtle/sha384-digest.html
crypto/subtle/sha512-digest.html
crypto/workers/subtle/sha1-digest.html
crypto/workers/subtle/sha224-digest.html
crypto/workers/subtle/sha256-digest.html
crypto/workers/subtle/sha384-digest.html
crypto/workers/subtle/sha512-digest.html

  • bindings/js/JSSubtleCryptoCustom.cpp:

(WebCore::jsSubtleCryptoFunctionDigestPromise):
(WebCore::JSSubtleCrypto::digest):

  • crypto/CryptoAlgorithm.cpp:

(WebCore::CryptoAlgorithm::digest):

  • crypto/CryptoAlgorithm.h:
  • crypto/SubtleCrypto.idl:
  • 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:

LayoutTests:

  • crypto/subtle/digest-malformed-parameters-expected.txt: Added.
  • crypto/subtle/digest-malformed-parameters.html: Added.
  • crypto/subtle/sha1-digest-expected.txt: Added.
  • crypto/subtle/sha1-digest.html: Added.
  • crypto/subtle/sha224-digest-expected.txt: Added.
  • crypto/subtle/sha224-digest.html: Added.
  • crypto/subtle/sha256-digest-expected.txt: Added.
  • crypto/subtle/sha256-digest.html: Added.
  • crypto/subtle/sha384-digest-expected.txt: Added.
  • crypto/subtle/sha384-digest.html: Added.
  • crypto/subtle/sha512-digest-expected.txt: Added.
  • crypto/subtle/sha512-digest.html: Added.
  • crypto/workers/subtle/resources/sha1-digest.js: Added.
  • crypto/workers/subtle/resources/sha224-digest.js: Added.
  • crypto/workers/subtle/resources/sha256-digest.js: Added.
  • crypto/workers/subtle/resources/sha384-digest.js: Added.
  • crypto/workers/subtle/resources/sha512-digest.js: Added.
  • crypto/workers/subtle/sha1-digest-expected.txt: Added.
  • crypto/workers/subtle/sha1-digest.html: Added.
  • crypto/workers/subtle/sha224-digest-expected.txt: Added.
  • crypto/workers/subtle/sha224-digest.html: Added.
  • crypto/workers/subtle/sha256-digest-expected.txt: Added.
  • crypto/workers/subtle/sha256-digest.html: Added.
  • crypto/workers/subtle/sha384-digest-expected.txt: Added.
  • crypto/workers/subtle/sha384-digest.html: Added.
  • crypto/workers/subtle/sha512-digest-expected.txt: Added.
  • crypto/workers/subtle/sha512-digest.html: Added.
Location:
trunk
Files:
27 added
19 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r209163 r209164  
     12016-11-26  Jiewen Tan  <jiewen_tan@apple.com>
     2
     3        Update SubtleCrypto::digest to match the latest spec
     4        https://bugs.webkit.org/show_bug.cgi?id=164742
     5        <rdar://problem/29258037>
     6
     7        Reviewed by Darin Adler.
     8
     9        * crypto/subtle/digest-malformed-parameters-expected.txt: Added.
     10        * crypto/subtle/digest-malformed-parameters.html: Added.
     11        * crypto/subtle/sha1-digest-expected.txt: Added.
     12        * crypto/subtle/sha1-digest.html: Added.
     13        * crypto/subtle/sha224-digest-expected.txt: Added.
     14        * crypto/subtle/sha224-digest.html: Added.
     15        * crypto/subtle/sha256-digest-expected.txt: Added.
     16        * crypto/subtle/sha256-digest.html: Added.
     17        * crypto/subtle/sha384-digest-expected.txt: Added.
     18        * crypto/subtle/sha384-digest.html: Added.
     19        * crypto/subtle/sha512-digest-expected.txt: Added.
     20        * crypto/subtle/sha512-digest.html: Added.
     21        * crypto/workers/subtle/resources/sha1-digest.js: Added.
     22        * crypto/workers/subtle/resources/sha224-digest.js: Added.
     23        * crypto/workers/subtle/resources/sha256-digest.js: Added.
     24        * crypto/workers/subtle/resources/sha384-digest.js: Added.
     25        * crypto/workers/subtle/resources/sha512-digest.js: Added.
     26        * crypto/workers/subtle/sha1-digest-expected.txt: Added.
     27        * crypto/workers/subtle/sha1-digest.html: Added.
     28        * crypto/workers/subtle/sha224-digest-expected.txt: Added.
     29        * crypto/workers/subtle/sha224-digest.html: Added.
     30        * crypto/workers/subtle/sha256-digest-expected.txt: Added.
     31        * crypto/workers/subtle/sha256-digest.html: Added.
     32        * crypto/workers/subtle/sha384-digest-expected.txt: Added.
     33        * crypto/workers/subtle/sha384-digest.html: Added.
     34        * crypto/workers/subtle/sha512-digest-expected.txt: Added.
     35        * crypto/workers/subtle/sha512-digest.html: Added.
     36
    1372016-11-30  Antoine Quint  <graouts@apple.com>
    238
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r209155 r209164  
     12016-11-26  Jiewen Tan  <jiewen_tan@apple.com>
     2
     3        Update SubtleCrypto::digest to match the latest spec
     4        https://bugs.webkit.org/show_bug.cgi?id=164742
     5        <rdar://problem/29258037>
     6
     7        Reviewed by Darin Adler.
     8
     9        * WebCryptoAPI/digest/test_digest-expected.txt:
     10        * WebCryptoAPI/idlharness-expected.txt:
     11
    1122016-11-30  Jiewen Tan  <jiewen_tan@apple.com>
    213
  • trunk/LayoutTests/imported/w3c/WebCryptoAPI/digest/test_digest-expected.txt

    r206883 r209164  
    22
    33
    4 FAIL SHA-1 with empty source data subtle.digest is not a function. (In 'subtle.digest({name: upCase}, sourceData[size])', 'subtle.digest' is undefined)
    5 FAIL sha-1 with empty source data subtle.digest is not a function. (In 'subtle.digest({name: mixedCase}, sourceData[size])', 'subtle.digest' is undefined)
    6 FAIL Sha-1 with empty source data subtle.digest is not a function. (In 'subtle.digest({name: mixedCase}, sourceData[size])', 'subtle.digest' is undefined)
    7 FAIL SHA-1 with empty source data and altered buffer after call subtle.digest is not a function. (In 'subtle.digest({name: upCase}, copiedBuffer)', 'subtle.digest' is undefined)
    8 FAIL SHA-256 with empty source data subtle.digest is not a function. (In 'subtle.digest({name: upCase}, sourceData[size])', 'subtle.digest' is undefined)
    9 FAIL sha-256 with empty source data subtle.digest is not a function. (In 'subtle.digest({name: mixedCase}, sourceData[size])', 'subtle.digest' is undefined)
    10 FAIL Sha-256 with empty source data subtle.digest is not a function. (In 'subtle.digest({name: mixedCase}, sourceData[size])', 'subtle.digest' is undefined)
    11 FAIL SHA-256 with empty source data and altered buffer after call subtle.digest is not a function. (In 'subtle.digest({name: upCase}, copiedBuffer)', 'subtle.digest' is undefined)
    12 FAIL SHA-384 with empty source data subtle.digest is not a function. (In 'subtle.digest({name: upCase}, sourceData[size])', 'subtle.digest' is undefined)
    13 FAIL sha-384 with empty source data subtle.digest is not a function. (In 'subtle.digest({name: mixedCase}, sourceData[size])', 'subtle.digest' is undefined)
    14 FAIL Sha-384 with empty source data subtle.digest is not a function. (In 'subtle.digest({name: mixedCase}, sourceData[size])', 'subtle.digest' is undefined)
    15 FAIL SHA-384 with empty source data and altered buffer after call subtle.digest is not a function. (In 'subtle.digest({name: upCase}, copiedBuffer)', 'subtle.digest' is undefined)
    16 FAIL SHA-512 with empty source data subtle.digest is not a function. (In 'subtle.digest({name: upCase}, sourceData[size])', 'subtle.digest' is undefined)
    17 FAIL sha-512 with empty source data subtle.digest is not a function. (In 'subtle.digest({name: mixedCase}, sourceData[size])', 'subtle.digest' is undefined)
    18 FAIL Sha-512 with empty source data subtle.digest is not a function. (In 'subtle.digest({name: mixedCase}, sourceData[size])', 'subtle.digest' is undefined)
    19 FAIL SHA-512 with empty source data and altered buffer after call subtle.digest is not a function. (In 'subtle.digest({name: upCase}, copiedBuffer)', 'subtle.digest' is undefined)
    20 FAIL SHA-1 with short source data subtle.digest is not a function. (In 'subtle.digest({name: upCase}, sourceData[size])', 'subtle.digest' is undefined)
    21 FAIL sha-1 with short source data subtle.digest is not a function. (In 'subtle.digest({name: mixedCase}, sourceData[size])', 'subtle.digest' is undefined)
    22 FAIL Sha-1 with short source data subtle.digest is not a function. (In 'subtle.digest({name: mixedCase}, sourceData[size])', 'subtle.digest' is undefined)
    23 FAIL SHA-1 with short source data and altered buffer after call subtle.digest is not a function. (In 'subtle.digest({name: upCase}, copiedBuffer)', 'subtle.digest' is undefined)
    24 FAIL SHA-256 with short source data subtle.digest is not a function. (In 'subtle.digest({name: upCase}, sourceData[size])', 'subtle.digest' is undefined)
    25 FAIL sha-256 with short source data subtle.digest is not a function. (In 'subtle.digest({name: mixedCase}, sourceData[size])', 'subtle.digest' is undefined)
    26 FAIL Sha-256 with short source data subtle.digest is not a function. (In 'subtle.digest({name: mixedCase}, sourceData[size])', 'subtle.digest' is undefined)
    27 FAIL SHA-256 with short source data and altered buffer after call subtle.digest is not a function. (In 'subtle.digest({name: upCase}, copiedBuffer)', 'subtle.digest' is undefined)
    28 FAIL SHA-384 with short source data subtle.digest is not a function. (In 'subtle.digest({name: upCase}, sourceData[size])', 'subtle.digest' is undefined)
    29 FAIL sha-384 with short source data subtle.digest is not a function. (In 'subtle.digest({name: mixedCase}, sourceData[size])', 'subtle.digest' is undefined)
    30 FAIL Sha-384 with short source data subtle.digest is not a function. (In 'subtle.digest({name: mixedCase}, sourceData[size])', 'subtle.digest' is undefined)
    31 FAIL SHA-384 with short source data and altered buffer after call subtle.digest is not a function. (In 'subtle.digest({name: upCase}, copiedBuffer)', 'subtle.digest' is undefined)
    32 FAIL SHA-512 with short source data subtle.digest is not a function. (In 'subtle.digest({name: upCase}, sourceData[size])', 'subtle.digest' is undefined)
    33 FAIL sha-512 with short source data subtle.digest is not a function. (In 'subtle.digest({name: mixedCase}, sourceData[size])', 'subtle.digest' is undefined)
    34 FAIL Sha-512 with short source data subtle.digest is not a function. (In 'subtle.digest({name: mixedCase}, sourceData[size])', 'subtle.digest' is undefined)
    35 FAIL SHA-512 with short source data and altered buffer after call subtle.digest is not a function. (In 'subtle.digest({name: upCase}, copiedBuffer)', 'subtle.digest' is undefined)
    36 FAIL SHA-1 with medium source data subtle.digest is not a function. (In 'subtle.digest({name: upCase}, sourceData[size])', 'subtle.digest' is undefined)
    37 FAIL sha-1 with medium source data subtle.digest is not a function. (In 'subtle.digest({name: mixedCase}, sourceData[size])', 'subtle.digest' is undefined)
    38 FAIL Sha-1 with medium source data subtle.digest is not a function. (In 'subtle.digest({name: mixedCase}, sourceData[size])', 'subtle.digest' is undefined)
    39 FAIL SHA-1 with medium source data and altered buffer after call subtle.digest is not a function. (In 'subtle.digest({name: upCase}, copiedBuffer)', 'subtle.digest' is undefined)
    40 FAIL SHA-256 with medium source data subtle.digest is not a function. (In 'subtle.digest({name: upCase}, sourceData[size])', 'subtle.digest' is undefined)
    41 FAIL sha-256 with medium source data subtle.digest is not a function. (In 'subtle.digest({name: mixedCase}, sourceData[size])', 'subtle.digest' is undefined)
    42 FAIL Sha-256 with medium source data subtle.digest is not a function. (In 'subtle.digest({name: mixedCase}, sourceData[size])', 'subtle.digest' is undefined)
    43 FAIL SHA-256 with medium source data and altered buffer after call subtle.digest is not a function. (In 'subtle.digest({name: upCase}, copiedBuffer)', 'subtle.digest' is undefined)
    44 FAIL SHA-384 with medium source data subtle.digest is not a function. (In 'subtle.digest({name: upCase}, sourceData[size])', 'subtle.digest' is undefined)
    45 FAIL sha-384 with medium source data subtle.digest is not a function. (In 'subtle.digest({name: mixedCase}, sourceData[size])', 'subtle.digest' is undefined)
    46 FAIL Sha-384 with medium source data subtle.digest is not a function. (In 'subtle.digest({name: mixedCase}, sourceData[size])', 'subtle.digest' is undefined)
    47 FAIL SHA-384 with medium source data and altered buffer after call subtle.digest is not a function. (In 'subtle.digest({name: upCase}, copiedBuffer)', 'subtle.digest' is undefined)
    48 FAIL SHA-512 with medium source data subtle.digest is not a function. (In 'subtle.digest({name: upCase}, sourceData[size])', 'subtle.digest' is undefined)
    49 FAIL sha-512 with medium source data subtle.digest is not a function. (In 'subtle.digest({name: mixedCase}, sourceData[size])', 'subtle.digest' is undefined)
    50 FAIL Sha-512 with medium source data subtle.digest is not a function. (In 'subtle.digest({name: mixedCase}, sourceData[size])', 'subtle.digest' is undefined)
    51 FAIL SHA-512 with medium source data and altered buffer after call subtle.digest is not a function. (In 'subtle.digest({name: upCase}, copiedBuffer)', 'subtle.digest' is undefined)
    52 FAIL SHA-1 with long source data subtle.digest is not a function. (In 'subtle.digest({name: upCase}, sourceData[size])', 'subtle.digest' is undefined)
    53 FAIL sha-1 with long source data subtle.digest is not a function. (In 'subtle.digest({name: mixedCase}, sourceData[size])', 'subtle.digest' is undefined)
    54 FAIL Sha-1 with long source data subtle.digest is not a function. (In 'subtle.digest({name: mixedCase}, sourceData[size])', 'subtle.digest' is undefined)
    55 FAIL SHA-1 with long source data and altered buffer after call subtle.digest is not a function. (In 'subtle.digest({name: upCase}, copiedBuffer)', 'subtle.digest' is undefined)
    56 FAIL SHA-256 with long source data subtle.digest is not a function. (In 'subtle.digest({name: upCase}, sourceData[size])', 'subtle.digest' is undefined)
    57 FAIL sha-256 with long source data subtle.digest is not a function. (In 'subtle.digest({name: mixedCase}, sourceData[size])', 'subtle.digest' is undefined)
    58 FAIL Sha-256 with long source data subtle.digest is not a function. (In 'subtle.digest({name: mixedCase}, sourceData[size])', 'subtle.digest' is undefined)
    59 FAIL SHA-256 with long source data and altered buffer after call subtle.digest is not a function. (In 'subtle.digest({name: upCase}, copiedBuffer)', 'subtle.digest' is undefined)
    60 FAIL SHA-384 with long source data subtle.digest is not a function. (In 'subtle.digest({name: upCase}, sourceData[size])', 'subtle.digest' is undefined)
    61 FAIL sha-384 with long source data subtle.digest is not a function. (In 'subtle.digest({name: mixedCase}, sourceData[size])', 'subtle.digest' is undefined)
    62 FAIL Sha-384 with long source data subtle.digest is not a function. (In 'subtle.digest({name: mixedCase}, sourceData[size])', 'subtle.digest' is undefined)
    63 FAIL SHA-384 with long source data and altered buffer after call subtle.digest is not a function. (In 'subtle.digest({name: upCase}, copiedBuffer)', 'subtle.digest' is undefined)
    64 FAIL SHA-512 with long source data subtle.digest is not a function. (In 'subtle.digest({name: upCase}, sourceData[size])', 'subtle.digest' is undefined)
    65 FAIL sha-512 with long source data subtle.digest is not a function. (In 'subtle.digest({name: mixedCase}, sourceData[size])', 'subtle.digest' is undefined)
    66 FAIL Sha-512 with long source data subtle.digest is not a function. (In 'subtle.digest({name: mixedCase}, sourceData[size])', 'subtle.digest' is undefined)
    67 FAIL SHA-512 with long source data and altered buffer after call subtle.digest is not a function. (In 'subtle.digest({name: upCase}, copiedBuffer)', 'subtle.digest' is undefined)
    68 FAIL AES-GCM with empty subtle.digest is not a function. (In 'subtle.digest({name: badName}, sourceData[size])', 'subtle.digest' is undefined)
    69 FAIL RSA-OAEP with empty subtle.digest is not a function. (In 'subtle.digest({name: badName}, sourceData[size])', 'subtle.digest' is undefined)
    70 FAIL PBKDF2 with empty subtle.digest is not a function. (In 'subtle.digest({name: badName}, sourceData[size])', 'subtle.digest' is undefined)
    71 FAIL AES-KW with empty subtle.digest is not a function. (In 'subtle.digest({name: badName}, sourceData[size])', 'subtle.digest' is undefined)
    72 FAIL AES-GCM with short subtle.digest is not a function. (In 'subtle.digest({name: badName}, sourceData[size])', 'subtle.digest' is undefined)
    73 FAIL RSA-OAEP with short subtle.digest is not a function. (In 'subtle.digest({name: badName}, sourceData[size])', 'subtle.digest' is undefined)
    74 FAIL PBKDF2 with short subtle.digest is not a function. (In 'subtle.digest({name: badName}, sourceData[size])', 'subtle.digest' is undefined)
    75 FAIL AES-KW with short subtle.digest is not a function. (In 'subtle.digest({name: badName}, sourceData[size])', 'subtle.digest' is undefined)
    76 FAIL AES-GCM with medium subtle.digest is not a function. (In 'subtle.digest({name: badName}, sourceData[size])', 'subtle.digest' is undefined)
    77 FAIL RSA-OAEP with medium subtle.digest is not a function. (In 'subtle.digest({name: badName}, sourceData[size])', 'subtle.digest' is undefined)
    78 FAIL PBKDF2 with medium subtle.digest is not a function. (In 'subtle.digest({name: badName}, sourceData[size])', 'subtle.digest' is undefined)
    79 FAIL AES-KW with medium subtle.digest is not a function. (In 'subtle.digest({name: badName}, sourceData[size])', 'subtle.digest' is undefined)
    80 FAIL AES-GCM with long subtle.digest is not a function. (In 'subtle.digest({name: badName}, sourceData[size])', 'subtle.digest' is undefined)
    81 FAIL RSA-OAEP with long subtle.digest is not a function. (In 'subtle.digest({name: badName}, sourceData[size])', 'subtle.digest' is undefined)
    82 FAIL PBKDF2 with long subtle.digest is not a function. (In 'subtle.digest({name: badName}, sourceData[size])', 'subtle.digest' is undefined)
    83 FAIL AES-KW with long subtle.digest is not a function. (In 'subtle.digest({name: badName}, sourceData[size])', 'subtle.digest' is undefined)
     4PASS SHA-1 with empty source data
     5PASS sha-1 with empty source data
     6PASS Sha-1 with empty source data
     7PASS SHA-1 with empty source data and altered buffer after call
     8PASS SHA-256 with empty source data
     9PASS sha-256 with empty source data
     10PASS Sha-256 with empty source data
     11PASS SHA-256 with empty source data and altered buffer after call
     12PASS SHA-384 with empty source data
     13PASS sha-384 with empty source data
     14PASS Sha-384 with empty source data
     15PASS SHA-384 with empty source data and altered buffer after call
     16PASS SHA-512 with empty source data
     17PASS sha-512 with empty source data
     18PASS Sha-512 with empty source data
     19PASS SHA-512 with empty source data and altered buffer after call
     20PASS SHA-1 with short source data
     21PASS sha-1 with short source data
     22PASS Sha-1 with short source data
     23PASS SHA-1 with short source data and altered buffer after call
     24PASS SHA-256 with short source data
     25PASS sha-256 with short source data
     26PASS Sha-256 with short source data
     27PASS SHA-256 with short source data and altered buffer after call
     28PASS SHA-384 with short source data
     29PASS sha-384 with short source data
     30PASS Sha-384 with short source data
     31PASS SHA-384 with short source data and altered buffer after call
     32PASS SHA-512 with short source data
     33PASS sha-512 with short source data
     34PASS Sha-512 with short source data
     35PASS SHA-512 with short source data and altered buffer after call
     36PASS SHA-1 with medium source data
     37PASS sha-1 with medium source data
     38PASS Sha-1 with medium source data
     39PASS SHA-1 with medium source data and altered buffer after call
     40PASS SHA-256 with medium source data
     41PASS sha-256 with medium source data
     42PASS Sha-256 with medium source data
     43PASS SHA-256 with medium source data and altered buffer after call
     44PASS SHA-384 with medium source data
     45PASS sha-384 with medium source data
     46PASS Sha-384 with medium source data
     47PASS SHA-384 with medium source data and altered buffer after call
     48PASS SHA-512 with medium source data
     49PASS sha-512 with medium source data
     50PASS Sha-512 with medium source data
     51PASS SHA-512 with medium source data and altered buffer after call
     52PASS SHA-1 with long source data
     53PASS sha-1 with long source data
     54PASS Sha-1 with long source data
     55PASS SHA-1 with long source data and altered buffer after call
     56PASS SHA-256 with long source data
     57PASS sha-256 with long source data
     58PASS Sha-256 with long source data
     59PASS SHA-256 with long source data and altered buffer after call
     60PASS SHA-384 with long source data
     61PASS sha-384 with long source data
     62PASS Sha-384 with long source data
     63PASS SHA-384 with long source data and altered buffer after call
     64PASS SHA-512 with long source data
     65PASS sha-512 with long source data
     66PASS Sha-512 with long source data
     67PASS SHA-512 with long source data and altered buffer after call
     68PASS AES-GCM with empty
     69PASS RSA-OAEP with empty
     70PASS PBKDF2 with empty
     71PASS AES-KW with empty
     72PASS AES-GCM with short
     73PASS RSA-OAEP with short
     74PASS PBKDF2 with short
     75PASS AES-KW with short
     76PASS AES-GCM with medium
     77PASS RSA-OAEP with medium
     78PASS PBKDF2 with medium
     79PASS AES-KW with medium
     80PASS AES-GCM with long
     81PASS RSA-OAEP with long
     82PASS PBKDF2 with long
     83PASS AES-KW with long
    8484
  • trunk/LayoutTests/imported/w3c/WebCryptoAPI/idlharness-expected.txt

    r209155 r209164  
    5252PASS SubtleCrypto interface: crypto.subtle must inherit property "verify" with the proper type (3)
    5353PASS SubtleCrypto interface: calling verify(AlgorithmIdentifier,CryptoKey,BufferSource,BufferSource) on crypto.subtle with too few arguments must throw TypeError
    54 FAIL SubtleCrypto interface: crypto.subtle must inherit property "digest" with the proper type (4) assert_inherits: property "digest" not found in prototype chain
    55 FAIL SubtleCrypto interface: calling digest(AlgorithmIdentifier,BufferSource) on crypto.subtle with too few arguments must throw TypeError assert_inherits: property "digest" not found in prototype chain
     54PASS SubtleCrypto interface: crypto.subtle must inherit property "digest" with the proper type (4)
     55PASS SubtleCrypto interface: calling digest(AlgorithmIdentifier,BufferSource) on crypto.subtle with too few arguments must throw TypeError
    5656PASS SubtleCrypto interface: crypto.subtle must inherit property "generateKey" with the proper type (5)
    5757PASS SubtleCrypto interface: calling generateKey(AlgorithmIdentifier,boolean,[object Object]) on crypto.subtle with too few arguments must throw TypeError
  • trunk/Source/WebCore/ChangeLog

    r209163 r209164  
     12016-11-26  Jiewen Tan  <jiewen_tan@apple.com>
     2
     3        Update SubtleCrypto::digest to match the latest spec
     4        https://bugs.webkit.org/show_bug.cgi?id=164742
     5        <rdar://problem/29258037>
     6
     7        Reviewed by Darin Adler.
     8
     9        This patch updates the SubtleCrypto::digest method to match the latest spec:
     10        https://www.w3.org/TR/WebCryptoAPI/#SubtleCrypto-method-digest.
     11        It also refers to the latest Editor's Draft to a certain degree:
     12        https://w3c.github.io/webcrypto/Overview.html#SubtleCrypto-method-digest.
     13        Currently supported digest algorithms are SHA-1, SHA-224, SHA-256, SHA-384,
     14        and SHA-512.
     15
     16        Tests: crypto/subtle/digest-malformed-parameters.html
     17               crypto/subtle/sha1-digest.html
     18               crypto/subtle/sha224-digest.html
     19               crypto/subtle/sha256-digest.html
     20               crypto/subtle/sha384-digest.html
     21               crypto/subtle/sha512-digest.html
     22               crypto/workers/subtle/sha1-digest.html
     23               crypto/workers/subtle/sha224-digest.html
     24               crypto/workers/subtle/sha256-digest.html
     25               crypto/workers/subtle/sha384-digest.html
     26               crypto/workers/subtle/sha512-digest.html
     27
     28        * bindings/js/JSSubtleCryptoCustom.cpp:
     29        (WebCore::jsSubtleCryptoFunctionDigestPromise):
     30        (WebCore::JSSubtleCrypto::digest):
     31        * crypto/CryptoAlgorithm.cpp:
     32        (WebCore::CryptoAlgorithm::digest):
     33        * crypto/CryptoAlgorithm.h:
     34        * crypto/SubtleCrypto.idl:
     35        * crypto/algorithms/CryptoAlgorithmSHA1.cpp:
     36        (WebCore::CryptoAlgorithmSHA1::digest):
     37        * crypto/algorithms/CryptoAlgorithmSHA1.h:
     38        * crypto/algorithms/CryptoAlgorithmSHA224.cpp:
     39        (WebCore::CryptoAlgorithmSHA224::digest):
     40        * crypto/algorithms/CryptoAlgorithmSHA224.h:
     41        * crypto/algorithms/CryptoAlgorithmSHA256.cpp:
     42        (WebCore::CryptoAlgorithmSHA256::digest):
     43        * crypto/algorithms/CryptoAlgorithmSHA256.h:
     44        * crypto/algorithms/CryptoAlgorithmSHA384.cpp:
     45        (WebCore::CryptoAlgorithmSHA384::digest):
     46        * crypto/algorithms/CryptoAlgorithmSHA384.h:
     47        * crypto/algorithms/CryptoAlgorithmSHA512.cpp:
     48        (WebCore::CryptoAlgorithmSHA512::digest):
     49        * crypto/algorithms/CryptoAlgorithmSHA512.h:
     50
    1512016-11-30  Antoine Quint  <graouts@apple.com>
    252
  • trunk/Source/WebCore/bindings/js/JSSubtleCryptoCustom.cpp

    r209155 r209164  
    646646}
    647647
     648static void jsSubtleCryptoFunctionDigestPromise(ExecState& state, Ref<DeferredPromise>&& promise)
     649{
     650    VM& vm = state.vm();
     651    auto scope = DECLARE_THROW_SCOPE(vm);
     652
     653    if (UNLIKELY(state.argumentCount() < 2)) {
     654        promise->reject<JSValue>(createNotEnoughArgumentsError(&state));
     655        return;
     656    }
     657
     658    auto params = normalizeCryptoAlgorithmParameters(state, state.uncheckedArgument(0), Operations::Digest);
     659    RETURN_IF_EXCEPTION(scope, void());
     660
     661    auto data = toVector(state, state.uncheckedArgument(1));
     662    RETURN_IF_EXCEPTION(scope, void());
     663
     664    auto algorithm = createAlgorithm(state, params->identifier);
     665    RETURN_IF_EXCEPTION(scope, void());
     666
     667    auto callback = [capturedPromise = promise.copyRef()](const Vector<uint8_t>& digest) mutable {
     668        fulfillPromiseWithArrayBuffer(WTFMove(capturedPromise), digest.data(), digest.size());
     669        return;
     670    };
     671    auto exceptionCallback = [capturedPromise = WTFMove(promise)](ExceptionCode ec) mutable {
     672        rejectWithException(WTFMove(capturedPromise), ec);
     673    };
     674
     675    auto subtle = jsDynamicDowncast<JSSubtleCrypto*>(state.thisValue());
     676    ASSERT(subtle);
     677    algorithm->digest(WTFMove(data), WTFMove(callback), WTFMove(exceptionCallback), *scriptExecutionContextFromExecState(&state), subtle->wrapped().workQueue());
     678}
     679
    648680static void jsSubtleCryptoFunctionGenerateKeyPromise(ExecState& state, Ref<DeferredPromise>&& promise)
    649681{
     
    911943}
    912944
     945JSValue JSSubtleCrypto::digest(ExecState& state)
     946{
     947    return callPromiseFunction<jsSubtleCryptoFunctionDigestPromise, PromiseExecutionScope::WindowOrWorker>(state);
     948}
     949
    913950JSValue JSSubtleCrypto::generateKey(ExecState& state)
    914951{
  • trunk/Source/WebCore/crypto/CryptoAlgorithm.cpp

    r209155 r209164  
    4949
    5050void CryptoAlgorithm::verify(Ref<CryptoKey>&&, Vector<uint8_t>&&, Vector<uint8_t>&&, BoolCallback&&, ExceptionCallback&& exceptionCallback, ScriptExecutionContext&, WorkQueue&)
     51{
     52    exceptionCallback(NOT_SUPPORTED_ERR);
     53}
     54
     55void CryptoAlgorithm::digest(Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&& exceptionCallback, ScriptExecutionContext&, WorkQueue&)
    5156{
    5257    exceptionCallback(NOT_SUPPORTED_ERR);
  • trunk/Source/WebCore/crypto/CryptoAlgorithm.h

    r209155 r209164  
    6969    virtual void sign(Ref<CryptoKey>&&, Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&);
    7070    virtual void verify(Ref<CryptoKey>&&, Vector<uint8_t>&& signature, Vector<uint8_t>&&, BoolCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&);
     71    virtual void digest(Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&);
    7172    virtual void generateKey(const CryptoAlgorithmParameters&, bool extractable, CryptoKeyUsageBitmap, KeyOrKeyPairCallback&&, ExceptionCallback&&, ScriptExecutionContext&);
    7273    virtual void importKey(SubtleCrypto::KeyFormat, KeyData&&, const std::unique_ptr<CryptoAlgorithmParameters>&&, bool extractable, CryptoKeyUsageBitmap, KeyCallback&&, ExceptionCallback&&);
  • trunk/Source/WebCore/crypto/SubtleCrypto.idl

    r209155 r209164  
    3636    [Custom] Promise<any> sign(AlgorithmIdentifier algorithm, CryptoKey key, BufferSource data);
    3737    [Custom] Promise<any> verify(AlgorithmIdentifier algorithm, CryptoKey key, BufferSource signature, BufferSource data);
     38    [Custom] Promise<any> digest(AlgorithmIdentifier algorithm, BufferSource data);
    3839    // FIXME: Should this return a Promise<(CryptoKey or CryptoKeyPair)>?
    3940    [Custom] Promise<any> generateKey(AlgorithmIdentifier algorithm, boolean extractable, sequence<CryptoKeyUsage> keyUsages);
  • trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmSHA1.cpp

    r208669 r209164  
    3030
    3131#include "CryptoDigest.h"
     32#include "ExceptionCode.h"
     33#include "ScriptExecutionContext.h"
    3234
    3335namespace WebCore {
     
    4143{
    4244    return s_identifier;
     45}
     46
     47void CryptoAlgorithmSHA1::digest(Vector<uint8_t>&& message, VectorCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context, WorkQueue& workQueue)
     48{
     49    auto digest = CryptoDigest::create(CryptoDigest::Algorithm::SHA_1);
     50    if (!digest) {
     51        exceptionCallback(OperationError);
     52        return;
     53    }
     54
     55    context.ref();
     56    workQueue.dispatch([digest = WTFMove(digest), message = WTFMove(message), callback = WTFMove(callback), &context]() mutable {
     57        digest->addBytes(message.data(), message.size());
     58        auto result = digest->computeHash();
     59        context.postTask([callback = WTFMove(callback), result = WTFMove(result)](ScriptExecutionContext& context) {
     60            callback(result);
     61            context.deref();
     62        });
     63    });
    4364}
    4465
  • trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmSHA1.h

    r208669 r209164  
    4141    CryptoAlgorithmSHA1() = default;
    4242    CryptoAlgorithmIdentifier identifier() const final;
     43    void digest(Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&) final;
    4344    ExceptionOr<void> digest(const CryptoAlgorithmParametersDeprecated&, const CryptoOperationData&, VectorCallback&&, VoidCallback&& failureCallback) final;
    4445};
  • trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmSHA224.cpp

    r208669 r209164  
    3030
    3131#include "CryptoDigest.h"
     32#include "ExceptionCode.h"
     33#include "ScriptExecutionContext.h"
    3234
    3335namespace WebCore {
     
    4143{
    4244    return s_identifier;
     45}
     46
     47void CryptoAlgorithmSHA224::digest(Vector<uint8_t>&& message, VectorCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context, WorkQueue& workQueue)
     48{
     49    auto digest = CryptoDigest::create(CryptoDigest::Algorithm::SHA_224);
     50    if (!digest) {
     51        exceptionCallback(OperationError);
     52        return;
     53    }
     54
     55    context.ref();
     56    workQueue.dispatch([digest = WTFMove(digest), message = WTFMove(message), callback = WTFMove(callback), &context]() mutable {
     57        digest->addBytes(message.data(), message.size());
     58        auto result = digest->computeHash();
     59        context.postTask([callback = WTFMove(callback), result = WTFMove(result)](ScriptExecutionContext& context) {
     60            callback(result);
     61            context.deref();
     62        });
     63    });
    4364}
    4465
  • trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmSHA224.h

    r208669 r209164  
    4141    CryptoAlgorithmSHA224() = default;
    4242    CryptoAlgorithmIdentifier identifier() const final;
     43    void digest(Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&) final;
    4344    ExceptionOr<void> digest(const CryptoAlgorithmParametersDeprecated&, const CryptoOperationData&, VectorCallback&&, VoidCallback&& failureCallback) final;
    4445};
  • trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmSHA256.cpp

    r208669 r209164  
    3030
    3131#include "CryptoDigest.h"
     32#include "ExceptionCode.h"
     33#include "ScriptExecutionContext.h"
    3234
    3335namespace WebCore {
     
    4143{
    4244    return s_identifier;
     45}
     46
     47void CryptoAlgorithmSHA256::digest(Vector<uint8_t>&& message, VectorCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context, WorkQueue& workQueue)
     48{
     49    auto digest = CryptoDigest::create(CryptoDigest::Algorithm::SHA_256);
     50    if (!digest) {
     51        exceptionCallback(OperationError);
     52        return;
     53    }
     54
     55    context.ref();
     56    workQueue.dispatch([digest = WTFMove(digest), message = WTFMove(message), callback = WTFMove(callback), &context]() mutable {
     57        digest->addBytes(message.data(), message.size());
     58        auto result = digest->computeHash();
     59        context.postTask([callback = WTFMove(callback), result = WTFMove(result)](ScriptExecutionContext& context) {
     60            callback(result);
     61            context.deref();
     62        });
     63    });
    4364}
    4465
  • trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmSHA256.h

    r208669 r209164  
    4141    CryptoAlgorithmSHA256() = default;
    4242    CryptoAlgorithmIdentifier identifier() const final;
     43    void digest(Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&) final;
    4344    ExceptionOr<void> digest(const CryptoAlgorithmParametersDeprecated&, const CryptoOperationData&, VectorCallback&&, VoidCallback&& failureCallback) final;
    4445};
  • trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmSHA384.cpp

    r208669 r209164  
    3030
    3131#include "CryptoDigest.h"
     32#include "ExceptionCode.h"
     33#include "ScriptExecutionContext.h"
    3234
    3335namespace WebCore {
     
    4143{
    4244    return s_identifier;
     45}
     46
     47void CryptoAlgorithmSHA384::digest(Vector<uint8_t>&& message, VectorCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context, WorkQueue& workQueue)
     48{
     49    auto digest = CryptoDigest::create(CryptoDigest::Algorithm::SHA_384);
     50    if (!digest) {
     51        exceptionCallback(OperationError);
     52        return;
     53    }
     54
     55    context.ref();
     56    workQueue.dispatch([digest = WTFMove(digest), message = WTFMove(message), callback = WTFMove(callback), &context]() mutable {
     57        digest->addBytes(message.data(), message.size());
     58        auto result = digest->computeHash();
     59        context.postTask([callback = WTFMove(callback), result = WTFMove(result)](ScriptExecutionContext& context) {
     60            callback(result);
     61            context.deref();
     62        });
     63    });
    4364}
    4465
  • trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmSHA384.h

    r208669 r209164  
    4141    CryptoAlgorithmSHA384() = default;
    4242    CryptoAlgorithmIdentifier identifier() const final;
     43    void digest(Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&) final;
    4344    ExceptionOr<void> digest(const CryptoAlgorithmParametersDeprecated&, const CryptoOperationData&, VectorCallback&&, VoidCallback&& failureCallback) final;
    4445};
  • trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmSHA512.cpp

    r208669 r209164  
    3030
    3131#include "CryptoDigest.h"
     32#include "ExceptionCode.h"
     33#include "ScriptExecutionContext.h"
    3234
    3335namespace WebCore {
     
    4143{
    4244    return s_identifier;
     45}
     46
     47void CryptoAlgorithmSHA512::digest(Vector<uint8_t>&& message, VectorCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context, WorkQueue& workQueue)
     48{
     49    auto digest = CryptoDigest::create(CryptoDigest::Algorithm::SHA_512);
     50    if (!digest) {
     51        exceptionCallback(OperationError);
     52        return;
     53    }
     54
     55    context.ref();
     56    workQueue.dispatch([digest = WTFMove(digest), message = WTFMove(message), callback = WTFMove(callback), &context]() mutable {
     57        digest->addBytes(message.data(), message.size());
     58        auto result = digest->computeHash();
     59        context.postTask([callback = WTFMove(callback), result = WTFMove(result)](ScriptExecutionContext& context) {
     60            callback(result);
     61            context.deref();
     62        });
     63    });
    4364}
    4465
  • trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmSHA512.h

    r208669 r209164  
    4141    CryptoAlgorithmSHA512() = default;
    4242    CryptoAlgorithmIdentifier identifier() const final;
     43    void digest(Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&) final;
    4344    ExceptionOr<void> digest(const CryptoAlgorithmParametersDeprecated&, const CryptoOperationData&, VectorCallback&&, VoidCallback&& failureCallback) final;
    4445};
Note: See TracChangeset for help on using the changeset viewer.