sha-384.html 1.39 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
<!DOCTYPE html>
<html>
<head>
<script src="../../resources/js-test-pre.js"></script>
<script src="resources/common.js"></script>
</head>
<body>
<p id="description"></p>
<div id="console"></div>

<script>
description("Test crypto.subtle.digest.");

jsTestIsAsync = true;

16
Promise.resolve(null).then(function() {
17
    debug("SHA384 of []");
18
    return crypto.subtle.digest('sha-384', new Uint8Array([]));
19
}).then(function(result) {
ap@apple.com's avatar
ap@apple.com committed
20 21
    digest = result;
    shouldBe("bytesToHexString(new Uint8Array(digest))", "'38b060a751ac96384cd9327eb1b1e36a21fdb71114be07434c0cc7bf63f6e1da274edebfe76f65fbd51ad2f14898b95b'");
22 23

    debug("SHA384 of [0x0]")
24
    return crypto.subtle.digest({name: 'sha-384'}, new Uint8Array([0]));
25
}).then(function(result) {
ap@apple.com's avatar
ap@apple.com committed
26 27
    digest = result;
    shouldBe("bytesToHexString(new Uint8Array(digest))", "'bec021b4f368e3069134e012c2b4307083d3a9bdd206e24e5f0d86e13d6636655933ec2b413465966817a9c208a11717'");
28 29 30

    debug("SHA384 of [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]");
    var data = new Uint8Array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);
31
    return crypto.subtle.digest({name: 'sha-384'}, data);
32
}).then(function(result) {
ap@apple.com's avatar
ap@apple.com committed
33 34
    digest = result;
    shouldBe("bytesToHexString(new Uint8Array(digest))", "'89bfcf569ae4af718510da78c67414109f5739bb5c40d51c9c8c50e2b2cee86f2f80c8b9d68f7c01201a0714572fe602'");
35 36 37 38 39 40 41
    finishJSTest();
});
</script>

<script src="../../resources/js-test-post.js"></script>
</body>
</html>