Changeset 256425 in webkit


Ignore:
Timestamp:
Feb 11, 2020 9:41:20 PM (4 years ago)
Author:
commit-queue@webkit.org
Message:

Add WebCrypto LayoutTests to check if PKCS#7 padding is correctly implemented in AES-CBC
https://bugs.webkit.org/show_bug.cgi?id=207174

Patch by Tomoki Imai <Tomoki Imai> on 2020-02-11
Reviewed by Jiewen Tan.

WebCrypto AES-CBC specification requires PKCS#7 padding,

Add decrypt/encrypt test cases for 0 ~ 33 bytes data.
It covers the boundary values where the padding size are changed, namely, 0, 1, 15, 16, 17, 31, 32, and 33.

  • crypto/subtle/aes-cbc-import-key-decrypt-expected.txt:
  • crypto/subtle/aes-cbc-import-key-decrypt.html:
  • crypto/subtle/aes-cbc-import-key-encrypt-expected.txt:
  • crypto/subtle/aes-cbc-import-key-encrypt.html:
Location:
trunk/LayoutTests
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r256422 r256425  
     12020-02-11  Tomoki Imai  <Tomoki.Imai@sony.com>
     2
     3        Add WebCrypto LayoutTests to check if PKCS#7 padding is correctly implemented in AES-CBC
     4        https://bugs.webkit.org/show_bug.cgi?id=207174
     5
     6        Reviewed by Jiewen Tan.
     7
     8        WebCrypto AES-CBC specification requires PKCS#7 padding,
     9
     10        Add decrypt/encrypt test cases for 0 ~ 33 bytes data.
     11        It covers the boundary values where the padding size are changed, namely, 0, 1, 15, 16, 17, 31, 32, and 33.
     12
     13        * crypto/subtle/aes-cbc-import-key-decrypt-expected.txt:
     14        * crypto/subtle/aes-cbc-import-key-decrypt.html:
     15        * crypto/subtle/aes-cbc-import-key-encrypt-expected.txt:
     16        * crypto/subtle/aes-cbc-import-key-encrypt.html:
     17
    1182020-02-11  Lauro Moura  <lmoura@igalia.com>
    219
  • trunk/LayoutTests/crypto/subtle/aes-cbc-import-key-decrypt-expected.txt

    r208918 r256425  
    44
    55
     6Expected plain text:
     7PASS bytesToASCIIString(plainText) is expectedPlainText
     8Expected plain text: A
     9PASS bytesToASCIIString(plainText) is expectedPlainText
     10Expected plain text: AB
     11PASS bytesToASCIIString(plainText) is expectedPlainText
     12Expected plain text: ABC
     13PASS bytesToASCIIString(plainText) is expectedPlainText
     14Expected plain text: ABCD
     15PASS bytesToASCIIString(plainText) is expectedPlainText
     16Expected plain text: ABCDE
     17PASS bytesToASCIIString(plainText) is expectedPlainText
     18Expected plain text: ABCDEF
     19PASS bytesToASCIIString(plainText) is expectedPlainText
     20Expected plain text: ABCDEFG
     21PASS bytesToASCIIString(plainText) is expectedPlainText
     22Expected plain text: ABCDEFGH
     23PASS bytesToASCIIString(plainText) is expectedPlainText
     24Expected plain text: ABCDEFGHI
     25PASS bytesToASCIIString(plainText) is expectedPlainText
     26Expected plain text: ABCDEFGHIJ
     27PASS bytesToASCIIString(plainText) is expectedPlainText
     28Expected plain text: ABCDEFGHIJK
     29PASS bytesToASCIIString(plainText) is expectedPlainText
     30Expected plain text: ABCDEFGHIJKL
     31PASS bytesToASCIIString(plainText) is expectedPlainText
     32Expected plain text: ABCDEFGHIJKLM
     33PASS bytesToASCIIString(plainText) is expectedPlainText
     34Expected plain text: ABCDEFGHIJKLMN
     35PASS bytesToASCIIString(plainText) is expectedPlainText
     36Expected plain text: ABCDEFGHIJKLMNO
     37PASS bytesToASCIIString(plainText) is expectedPlainText
     38Expected plain text: ABCDEFGHIJKLMNOP
     39PASS bytesToASCIIString(plainText) is expectedPlainText
     40Expected plain text: ABCDEFGHIJKLMNOPQ
     41PASS bytesToASCIIString(plainText) is expectedPlainText
     42Expected plain text: ABCDEFGHIJKLMNOPQR
     43PASS bytesToASCIIString(plainText) is expectedPlainText
     44Expected plain text: ABCDEFGHIJKLMNOPQRS
     45PASS bytesToASCIIString(plainText) is expectedPlainText
     46Expected plain text: ABCDEFGHIJKLMNOPQRST
     47PASS bytesToASCIIString(plainText) is expectedPlainText
     48Expected plain text: ABCDEFGHIJKLMNOPQRSTU
     49PASS bytesToASCIIString(plainText) is expectedPlainText
     50Expected plain text: ABCDEFGHIJKLMNOPQRSTUV
     51PASS bytesToASCIIString(plainText) is expectedPlainText
     52Expected plain text: ABCDEFGHIJKLMNOPQRSTUVW
     53PASS bytesToASCIIString(plainText) is expectedPlainText
     54Expected plain text: ABCDEFGHIJKLMNOPQRSTUVWX
     55PASS bytesToASCIIString(plainText) is expectedPlainText
     56Expected plain text: ABCDEFGHIJKLMNOPQRSTUVWXY
     57PASS bytesToASCIIString(plainText) is expectedPlainText
     58Expected plain text: ABCDEFGHIJKLMNOPQRSTUVWXYZ
     59PASS bytesToASCIIString(plainText) is expectedPlainText
     60Expected plain text: ABCDEFGHIJKLMNOPQRSTUVWXYZA
     61PASS bytesToASCIIString(plainText) is expectedPlainText
     62Expected plain text: ABCDEFGHIJKLMNOPQRSTUVWXYZAB
     63PASS bytesToASCIIString(plainText) is expectedPlainText
     64Expected plain text: ABCDEFGHIJKLMNOPQRSTUVWXYZABC
     65PASS bytesToASCIIString(plainText) is expectedPlainText
     66Expected plain text: ABCDEFGHIJKLMNOPQRSTUVWXYZABCD
     67PASS bytesToASCIIString(plainText) is expectedPlainText
     68Expected plain text: ABCDEFGHIJKLMNOPQRSTUVWXYZABCDE
     69PASS bytesToASCIIString(plainText) is expectedPlainText
     70Expected plain text: ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEF
     71PASS bytesToASCIIString(plainText) is expectedPlainText
     72Expected plain text: ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFG
    673PASS bytesToASCIIString(plainText) is expectedPlainText
    774PASS successfullyParsed is true
  • trunk/LayoutTests/crypto/subtle/aes-cbc-import-key-decrypt.html

    r208918 r256425  
    1515
    1616var extractable = false;
    17 var cipherText = hexStringToUint8Array("2ffa4618784dfd414b22c40c6330d022");
    1817var aesCbcParams = {
    1918    name: "aes-cbc",
     
    2120}
    2221var rawKey = asciiToUint8Array("jnOw99oOZFLIEPMr");
    23 var expectedPlainText = "Hello, World!";
    2422
    25 crypto.subtle.importKey("raw", rawKey, "aes-cbc", extractable, ["decrypt"]).then(function(key) {
    26     return crypto.subtle.decrypt(aesCbcParams, key, cipherText);
    27 }).then(function(result) {
    28     plainText = result;
    2923
    30     shouldBe("bytesToASCIIString(plainText)", "expectedPlainText");
     24// Test 0 ~ 33 bytes plain text data.
     25// It covers the boundary values where the padding size are changed, namely, 0, 1, 15, 16, 17, 31, 32, and 33.
     26// 16 comes from the AES-CBC block size, which is 128bit = 16 bytes.
    3127
     28// Pair of expected plain text and cipher text
     29var testCases = [
     30  [
     31    "",
     32    "54695f2b49d2c35b5f4675c59669c7d5"
     33  ],
     34  [
     35    "A",
     36    "7f3224da4b207bd3b55a3ba55f95c8dd"
     37  ],
     38  [
     39    "AB",
     40    "05b7b4caa28897ff5fa0b8cac9821070"
     41  ],
     42  [
     43    "ABC",
     44    "c5fcd82c93ca70630e77871408cb60a5"
     45  ],
     46  [
     47    "ABCD",
     48    "8c68b0ba2952761877f30e26eb43e98b"
     49  ],
     50  [
     51    "ABCDE",
     52    "6e5845ce085801492ecdb3da47e54e0d"
     53  ],
     54  [
     55    "ABCDEF",
     56    "a2bf7011f0560504fd2d3f6f4fa85179"
     57  ],
     58  [
     59    "ABCDEFG",
     60    "bfbe3717d97b8e8dbb362aa32a5d6715"
     61  ],
     62  [
     63    "ABCDEFGH",
     64    "ac55dadf6d3d1be1fede0e33e9de021a"
     65  ],
     66  [
     67    "ABCDEFGHI",
     68    "f5adfd70b6a907441aa1e1b8d03138b8"
     69  ],
     70  [
     71    "ABCDEFGHIJ",
     72    "b4a2d688f3a9bd307efe62643d80ead0"
     73  ],
     74  [
     75    "ABCDEFGHIJK",
     76    "d5cce76a9416b3c00c4d2e0bb2879134"
     77  ],
     78  [
     79    "ABCDEFGHIJKL",
     80    "7b87f2b55433d595ed02cd3417c510a4"
     81  ],
     82  [
     83    "ABCDEFGHIJKLM",
     84    "29f5af157bda78fdde9550aaadfc467d"
     85  ],
     86  [
     87    "ABCDEFGHIJKLMN",
     88    "bd86ff3b780b56d4faf98bd7f818de59"
     89  ],
     90  [
     91    "ABCDEFGHIJKLMNO",
     92    "8f7d4ffd08155e67b2f936aa7eedd918"
     93  ],
     94  [
     95    "ABCDEFGHIJKLMNOP",
     96    "bb57e6bd078639a31e3762035652ddba8b641840a083e33027a0aea305e95a64"
     97  ],
     98  [
     99    "ABCDEFGHIJKLMNOPQ",
     100    "bb57e6bd078639a31e3762035652ddbaad705f7fda061c4486fbce2b3a470b59"
     101  ],
     102  [
     103    "ABCDEFGHIJKLMNOPQR",
     104    "bb57e6bd078639a31e3762035652ddbad5c1de41aa0a5d2f03dd129e419b99b9"
     105  ],
     106  [
     107    "ABCDEFGHIJKLMNOPQRS",
     108    "bb57e6bd078639a31e3762035652ddba9ca7c65d2137e0e4e1b752d7d5a7619a"
     109  ],
     110  [
     111    "ABCDEFGHIJKLMNOPQRST",
     112    "bb57e6bd078639a31e3762035652ddba946ca5063ae30b7b068b7a0ddb573143"
     113  ],
     114  [
     115    "ABCDEFGHIJKLMNOPQRSTU",
     116    "bb57e6bd078639a31e3762035652ddba3e53d6b22634ba2d0033aa1f74984017"
     117  ],
     118  [
     119    "ABCDEFGHIJKLMNOPQRSTUV",
     120    "bb57e6bd078639a31e3762035652ddba9be121a85ec7b87d14d069821f241817"
     121  ],
     122  [
     123    "ABCDEFGHIJKLMNOPQRSTUVW",
     124    "bb57e6bd078639a31e3762035652ddbaeb91126c4649fbf256d2698a8b3cd108"
     125  ],
     126  [
     127    "ABCDEFGHIJKLMNOPQRSTUVWX",
     128    "bb57e6bd078639a31e3762035652ddba5fda70f10d9c190691a58c8014226b09"
     129  ],
     130  [
     131    "ABCDEFGHIJKLMNOPQRSTUVWXY",
     132    "bb57e6bd078639a31e3762035652ddbaca22ea606b337f0e549bd6c8134026c2"
     133  ],
     134  [
     135    "ABCDEFGHIJKLMNOPQRSTUVWXYZ",
     136    "bb57e6bd078639a31e3762035652ddbac5883abd9ff470ad8d5aefe0726131b8"
     137  ],
     138  [
     139    "ABCDEFGHIJKLMNOPQRSTUVWXYZA",
     140    "bb57e6bd078639a31e3762035652ddba0ba1680b7ca9ca18f9bdc30a2213e138"
     141  ],
     142  [
     143    "ABCDEFGHIJKLMNOPQRSTUVWXYZAB",
     144    "bb57e6bd078639a31e3762035652ddba34795f08b688add2ac28d579c1e4a735"
     145  ],
     146  [
     147    "ABCDEFGHIJKLMNOPQRSTUVWXYZABC",
     148    "bb57e6bd078639a31e3762035652ddba5e6174bbd7d9848e19dadc7316a51905"
     149  ],
     150  [
     151    "ABCDEFGHIJKLMNOPQRSTUVWXYZABCD",
     152    "bb57e6bd078639a31e3762035652ddba758897c9b84584efaf7bba27e80e2971"
     153  ],
     154  [
     155    "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDE",
     156    "bb57e6bd078639a31e3762035652ddba23aecf5b5981c3a0b9967c6d5faf2f44"
     157  ],
     158  [
     159    "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEF",
     160    "bb57e6bd078639a31e3762035652ddbace7c8364cc84b579dbb16765cba58de65123694ddc958e0c9436f6687338fc6e"
     161  ],
     162  [
     163    "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFG",
     164    "bb57e6bd078639a31e3762035652ddbace7c8364cc84b579dbb16765cba58de659650a237cd9a2764e9b92749843fd22"
     165  ]
     166];
     167
     168Promise.all(testCases.map(function(testCase){
     169    var expectedPlainText = testCase[0];
     170    var cipherText = testCase[1];
     171    return crypto.subtle.importKey("raw", rawKey, "aes-cbc", extractable, ["decrypt"]).then(function(key) {
     172        return crypto.subtle.decrypt(aesCbcParams, key, hexStringToUint8Array(cipherText));
     173    }).then(function(plainText) {
     174        return {
     175            plainText: plainText,
     176            cipherText: cipherText,
     177            expectedPlainText: expectedPlainText
     178        };
     179    });
     180})).then(function(results) {
     181    for (var result of results) {
     182        plainText = result.plainText;
     183        cipherText = result.cipherText;
     184        expectedPlainText = result.expectedPlainText;
     185        debug("Expected plain text: " + expectedPlainText);
     186        shouldBe("bytesToASCIIString(plainText)", "expectedPlainText");
     187    }
    32188    finishJSTest();
    33189});
  • trunk/LayoutTests/crypto/subtle/aes-cbc-import-key-encrypt-expected.txt

    r208891 r256425  
    44
    55
     6Plain text:
     7PASS bytesToHexString(cipherText) is expectedCipherText
     8Plain text: A
     9PASS bytesToHexString(cipherText) is expectedCipherText
     10Plain text: AB
     11PASS bytesToHexString(cipherText) is expectedCipherText
     12Plain text: ABC
     13PASS bytesToHexString(cipherText) is expectedCipherText
     14Plain text: ABCD
     15PASS bytesToHexString(cipherText) is expectedCipherText
     16Plain text: ABCDE
     17PASS bytesToHexString(cipherText) is expectedCipherText
     18Plain text: ABCDEF
     19PASS bytesToHexString(cipherText) is expectedCipherText
     20Plain text: ABCDEFG
     21PASS bytesToHexString(cipherText) is expectedCipherText
     22Plain text: ABCDEFGH
     23PASS bytesToHexString(cipherText) is expectedCipherText
     24Plain text: ABCDEFGHI
     25PASS bytesToHexString(cipherText) is expectedCipherText
     26Plain text: ABCDEFGHIJ
     27PASS bytesToHexString(cipherText) is expectedCipherText
     28Plain text: ABCDEFGHIJK
     29PASS bytesToHexString(cipherText) is expectedCipherText
     30Plain text: ABCDEFGHIJKL
     31PASS bytesToHexString(cipherText) is expectedCipherText
     32Plain text: ABCDEFGHIJKLM
     33PASS bytesToHexString(cipherText) is expectedCipherText
     34Plain text: ABCDEFGHIJKLMN
     35PASS bytesToHexString(cipherText) is expectedCipherText
     36Plain text: ABCDEFGHIJKLMNO
     37PASS bytesToHexString(cipherText) is expectedCipherText
     38Plain text: ABCDEFGHIJKLMNOP
     39PASS bytesToHexString(cipherText) is expectedCipherText
     40Plain text: ABCDEFGHIJKLMNOPQ
     41PASS bytesToHexString(cipherText) is expectedCipherText
     42Plain text: ABCDEFGHIJKLMNOPQR
     43PASS bytesToHexString(cipherText) is expectedCipherText
     44Plain text: ABCDEFGHIJKLMNOPQRS
     45PASS bytesToHexString(cipherText) is expectedCipherText
     46Plain text: ABCDEFGHIJKLMNOPQRST
     47PASS bytesToHexString(cipherText) is expectedCipherText
     48Plain text: ABCDEFGHIJKLMNOPQRSTU
     49PASS bytesToHexString(cipherText) is expectedCipherText
     50Plain text: ABCDEFGHIJKLMNOPQRSTUV
     51PASS bytesToHexString(cipherText) is expectedCipherText
     52Plain text: ABCDEFGHIJKLMNOPQRSTUVW
     53PASS bytesToHexString(cipherText) is expectedCipherText
     54Plain text: ABCDEFGHIJKLMNOPQRSTUVWX
     55PASS bytesToHexString(cipherText) is expectedCipherText
     56Plain text: ABCDEFGHIJKLMNOPQRSTUVWXY
     57PASS bytesToHexString(cipherText) is expectedCipherText
     58Plain text: ABCDEFGHIJKLMNOPQRSTUVWXYZ
     59PASS bytesToHexString(cipherText) is expectedCipherText
     60Plain text: ABCDEFGHIJKLMNOPQRSTUVWXYZA
     61PASS bytesToHexString(cipherText) is expectedCipherText
     62Plain text: ABCDEFGHIJKLMNOPQRSTUVWXYZAB
     63PASS bytesToHexString(cipherText) is expectedCipherText
     64Plain text: ABCDEFGHIJKLMNOPQRSTUVWXYZABC
     65PASS bytesToHexString(cipherText) is expectedCipherText
     66Plain text: ABCDEFGHIJKLMNOPQRSTUVWXYZABCD
     67PASS bytesToHexString(cipherText) is expectedCipherText
     68Plain text: ABCDEFGHIJKLMNOPQRSTUVWXYZABCDE
     69PASS bytesToHexString(cipherText) is expectedCipherText
     70Plain text: ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEF
     71PASS bytesToHexString(cipherText) is expectedCipherText
     72Plain text: ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFG
    673PASS bytesToHexString(cipherText) is expectedCipherText
    774PASS successfullyParsed is true
  • trunk/LayoutTests/crypto/subtle/aes-cbc-import-key-encrypt.html

    r208891 r256425  
    1515
    1616var extractable = false;
    17 var plainText = asciiToUint8Array("Hello, World!");
     17
    1818var aesCbcParams = {
    1919    name: "aes-cbc",
     
    2121}
    2222var rawKey = asciiToUint8Array("jnOw99oOZFLIEPMr");
    23 var expectedCipherText = "2ffa4618784dfd414b22c40c6330d022";
    2423
    25 crypto.subtle.importKey("raw", rawKey, "aes-cbc", extractable, ["encrypt"]).then(function(key) {
    26     return crypto.subtle.encrypt(aesCbcParams, key, plainText);
    27 }).then(function(result) {
    28     cipherText = result;
     24// Test 0 ~ 33 bytes plain text data.
     25// It covers the boundary values where the padding size are changed, namely, 0, 1, 15, 16, 17, 31, 32, and 33.
     26// 16 comes from the AES-CBC block size, which is 128bit = 16 bytes.
    2927
    30     shouldBe("bytesToHexString(cipherText)", "expectedCipherText");
     28// Pair of plain text and expected cipher text
     29var testCases = [
     30  [
     31    "",
     32    "54695f2b49d2c35b5f4675c59669c7d5"
     33  ],
     34  [
     35    "A",
     36    "7f3224da4b207bd3b55a3ba55f95c8dd"
     37  ],
     38  [
     39    "AB",
     40    "05b7b4caa28897ff5fa0b8cac9821070"
     41  ],
     42  [
     43    "ABC",
     44    "c5fcd82c93ca70630e77871408cb60a5"
     45  ],
     46  [
     47    "ABCD",
     48    "8c68b0ba2952761877f30e26eb43e98b"
     49  ],
     50  [
     51    "ABCDE",
     52    "6e5845ce085801492ecdb3da47e54e0d"
     53  ],
     54  [
     55    "ABCDEF",
     56    "a2bf7011f0560504fd2d3f6f4fa85179"
     57  ],
     58  [
     59    "ABCDEFG",
     60    "bfbe3717d97b8e8dbb362aa32a5d6715"
     61  ],
     62  [
     63    "ABCDEFGH",
     64    "ac55dadf6d3d1be1fede0e33e9de021a"
     65  ],
     66  [
     67    "ABCDEFGHI",
     68    "f5adfd70b6a907441aa1e1b8d03138b8"
     69  ],
     70  [
     71    "ABCDEFGHIJ",
     72    "b4a2d688f3a9bd307efe62643d80ead0"
     73  ],
     74  [
     75    "ABCDEFGHIJK",
     76    "d5cce76a9416b3c00c4d2e0bb2879134"
     77  ],
     78  [
     79    "ABCDEFGHIJKL",
     80    "7b87f2b55433d595ed02cd3417c510a4"
     81  ],
     82  [
     83    "ABCDEFGHIJKLM",
     84    "29f5af157bda78fdde9550aaadfc467d"
     85  ],
     86  [
     87    "ABCDEFGHIJKLMN",
     88    "bd86ff3b780b56d4faf98bd7f818de59"
     89  ],
     90  [
     91    "ABCDEFGHIJKLMNO",
     92    "8f7d4ffd08155e67b2f936aa7eedd918"
     93  ],
     94  [
     95    "ABCDEFGHIJKLMNOP",
     96    "bb57e6bd078639a31e3762035652ddba8b641840a083e33027a0aea305e95a64"
     97  ],
     98  [
     99    "ABCDEFGHIJKLMNOPQ",
     100    "bb57e6bd078639a31e3762035652ddbaad705f7fda061c4486fbce2b3a470b59"
     101  ],
     102  [
     103    "ABCDEFGHIJKLMNOPQR",
     104    "bb57e6bd078639a31e3762035652ddbad5c1de41aa0a5d2f03dd129e419b99b9"
     105  ],
     106  [
     107    "ABCDEFGHIJKLMNOPQRS",
     108    "bb57e6bd078639a31e3762035652ddba9ca7c65d2137e0e4e1b752d7d5a7619a"
     109  ],
     110  [
     111    "ABCDEFGHIJKLMNOPQRST",
     112    "bb57e6bd078639a31e3762035652ddba946ca5063ae30b7b068b7a0ddb573143"
     113  ],
     114  [
     115    "ABCDEFGHIJKLMNOPQRSTU",
     116    "bb57e6bd078639a31e3762035652ddba3e53d6b22634ba2d0033aa1f74984017"
     117  ],
     118  [
     119    "ABCDEFGHIJKLMNOPQRSTUV",
     120    "bb57e6bd078639a31e3762035652ddba9be121a85ec7b87d14d069821f241817"
     121  ],
     122  [
     123    "ABCDEFGHIJKLMNOPQRSTUVW",
     124    "bb57e6bd078639a31e3762035652ddbaeb91126c4649fbf256d2698a8b3cd108"
     125  ],
     126  [
     127    "ABCDEFGHIJKLMNOPQRSTUVWX",
     128    "bb57e6bd078639a31e3762035652ddba5fda70f10d9c190691a58c8014226b09"
     129  ],
     130  [
     131    "ABCDEFGHIJKLMNOPQRSTUVWXY",
     132    "bb57e6bd078639a31e3762035652ddbaca22ea606b337f0e549bd6c8134026c2"
     133  ],
     134  [
     135    "ABCDEFGHIJKLMNOPQRSTUVWXYZ",
     136    "bb57e6bd078639a31e3762035652ddbac5883abd9ff470ad8d5aefe0726131b8"
     137  ],
     138  [
     139    "ABCDEFGHIJKLMNOPQRSTUVWXYZA",
     140    "bb57e6bd078639a31e3762035652ddba0ba1680b7ca9ca18f9bdc30a2213e138"
     141  ],
     142  [
     143    "ABCDEFGHIJKLMNOPQRSTUVWXYZAB",
     144    "bb57e6bd078639a31e3762035652ddba34795f08b688add2ac28d579c1e4a735"
     145  ],
     146  [
     147    "ABCDEFGHIJKLMNOPQRSTUVWXYZABC",
     148    "bb57e6bd078639a31e3762035652ddba5e6174bbd7d9848e19dadc7316a51905"
     149  ],
     150  [
     151    "ABCDEFGHIJKLMNOPQRSTUVWXYZABCD",
     152    "bb57e6bd078639a31e3762035652ddba758897c9b84584efaf7bba27e80e2971"
     153  ],
     154  [
     155    "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDE",
     156    "bb57e6bd078639a31e3762035652ddba23aecf5b5981c3a0b9967c6d5faf2f44"
     157  ],
     158  [
     159    "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEF",
     160    "bb57e6bd078639a31e3762035652ddbace7c8364cc84b579dbb16765cba58de65123694ddc958e0c9436f6687338fc6e"
     161  ],
     162  [
     163    "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFG",
     164    "bb57e6bd078639a31e3762035652ddbace7c8364cc84b579dbb16765cba58de659650a237cd9a2764e9b92749843fd22"
     165  ]
     166];
    31167
     168Promise.all(testCases.map(function(testCase){
     169    var plainText = testCase[0];
     170    var expectedCipherText = testCase[1];
     171    return crypto.subtle.importKey("raw", rawKey, "aes-cbc", extractable, ["encrypt"]).then(function(key) {
     172        return crypto.subtle.encrypt(aesCbcParams, key, asciiToUint8Array(plainText));
     173    }).then(function(cipherText) {
     174        return {
     175            plainText: plainText,
     176            cipherText: cipherText,
     177            expectedCipherText: expectedCipherText
     178        };
     179    });
     180})).then(function(results) {
     181    for (var result of results) {
     182        plainText = result.plainText;
     183        cipherText = result.cipherText;
     184        expectedCipherText = result.expectedCipherText;
     185        debug("Plain text: " + plainText);
     186        shouldBe("bytesToHexString(cipherText)", "expectedCipherText");
     187    }
    32188    finishJSTest();
    33189});
Note: See TracChangeset for help on using the changeset viewer.