-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaes-key-algorithm-mismatch.html
executable file
·56 lines (50 loc) · 2.34 KB
/
aes-key-algorithm-mismatch.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<html>
<head>
<script type="text/javascript" src="DJS/encoding.js"></script>
<script type="text/javascript" src="DJS/hashing.js"></script>
<script type="text/javascript" src="DJS/aes.js"></script>
<script type="text/javascript" src="DJS/rsa.js"></script>
<script type="text/javascript" src="asn1JS.js"></script>
<script type="text/javascript" src="functions.js"></script>
<script type="text/javascript" src="algorithms.js"></script>
<script type="text/javascript" src="Key.js"></script>
<script type="text/javascript" src="generateKey.js"></script>
<script type="text/javascript" src="sign.js"></script>
<script type="text/javascript" src="decrypt.js"></script>
<script type="text/javascript" src="encrypt.js"></script>
<script type="text/javascript" src="exportKey.js"></script>
<script type="text/javascript" src="importKey.js"></script>
<script type="text/javascript" src="verify.js"></script>
<script type="text/javascript" src="digest.js"></script>
<script type="text/javascript" src="deriveKey.js"></script>
<script type="text/javascript" src="wrapKey.js"></script>
<script type="text/javascript" src="unwrapKey.js"></script>
<script type="text/javascript" src="resources/common.js"></script>
<script type="text/javascript" src="resources/js-test.js"></script>
<script type="text/javascript" src="subtleinriacrypto.js"></script>
<script type="text/javascript">
function init(){
var start = new Date().getTime();
window.crypto = inriacrypto;
var keyData = hexStringToUint8Array("2b7e151628aed2a6abf7158809cf4f3c");
var data = asciiToUint8Array("hello");
var aesCbcKey = null;
Promise.resolve(null).then(function(result) {
var usages = ['encrypt', 'decrypt'];
var extractable = false;
var algorithm = {name: 'AES-CBC'};
return inriacrypto.subtle.importKey('raw', keyData, algorithm, extractable, usages);
}).then(function(result) {
key = result;
shouldEvaluateAs("key.algorithm.name", "AES-CBC");
// Can't use an AES-KW key for AES-CBC (even though both are AES keys).
return inriacrypto.subtle.encrypt({name: 'AES-GCM', iv: new Uint8Array(16)}, key, data);
}).then(failAndFinishJSTest, function(result) {
logError(result);
}).then(finishJSTest, failAndFinishJSTest);
}
</script>
</head>
<body onload="init()">
</body>
</html>