4 <script src=
"../../../resources/js-test.js"></script>
5 <script src=
"../resources/common.js"></script>
8 <p id=
"description"></p>
9 <div id=
"console"></div>
12 description("Tests bad algorithm inputs for AES-CBC");
16 var keyData
= hexStringToUint8Array("2b7e151628aed2a6abf7158809cf4f3c");
17 var data
= asciiToUint8Array("hello");
20 Promise
.resolve(null).then(function(result
) {
21 var usages
= ['encrypt', 'decrypt'];
22 var extractable
= false;
23 var algorithm
= {name
: 'aes-cbc'};
25 debug('\nImporting AES-CBC key...');
26 return crypto
.subtle
.importKey('raw', keyData
, algorithm
, extractable
, usages
);
27 }).then(function(result
) {
30 debug('\nencrypt() with iv that is null...');
31 return crypto
.subtle
.encrypt({name
: 'AES-CBC', iv
: null}, key
, data
);
32 }).then(failAndFinishJSTest
, function(result
) {
35 debug('\nencrypt() without iv...');
36 return crypto
.subtle
.decrypt({name
: 'AES-CBC'}, key
, data
);
37 }).then(failAndFinishJSTest
, function(result
) {
40 debug('\nencrypt() with iv that is a number...');
41 return crypto
.subtle
.encrypt({name
: 'AES-CBC', iv
: 3}, key
, data
);
42 }).then(failAndFinishJSTest
, function(result
) {
45 debug('\nencrypt() with an iv containing 0 bytes...');
46 return crypto
.subtle
.encrypt({name
: 'AES-CBC', iv
: new Uint8Array(0)}, key
, data
);
47 }).then(failAndFinishJSTest
, function(result
) {
50 debug('\nencrypt() with an iv containing 17 bytes...');
51 return crypto
.subtle
.encrypt({name
: 'AES-CBC', iv
: new ArrayBuffer(17)}, key
, data
);
52 }).then(failAndFinishJSTest
, function(result
) {
54 }).then(finishJSTest
, failAndFinishJSTest
);