test_WebCrypto_Normalize.html (2207B)
1 <!DOCTYPE html> 2 <html> 3 4 <head> 5 <title>WebCrypto Test Suite</title> 6 <meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> 7 <link rel="stylesheet" href="./test_WebCrypto.css"/> 8 <script src="/tests/SimpleTest/SimpleTest.js"></script> 9 10 <!-- Utilities for manipulating ABVs --> 11 <script src="util.js"></script> 12 13 <!-- A simple wrapper around IndexedDB --> 14 <script src="simpledb.js"></script> 15 16 <!-- Test vectors drawn from the literature --> 17 <script src="./test-vectors.js"></script> 18 19 <!-- General testing framework --> 20 <script src="./test-array.js"></script> 21 22 <script>/* <![CDATA[*/ 23 "use strict"; 24 25 TestArray.addTest( 26 "Test that we properly normalize algorithm names", 27 function() { 28 var that = this; 29 var alg = { name: "hmac", hash: {name: "sHa-256"} }; 30 31 function doGenerateAesKey() { 32 return crypto.subtle.generateKey({ name: "AES-gcm", length: 192 }, false, ["encrypt"]); 33 } 34 35 function doGenerateRsaOaepKey() { 36 var algo = { 37 name: "rsa-OAEP", 38 hash: "sha-1", 39 modulusLength: 2048, 40 publicExponent: new Uint8Array([0x01, 0x00, 0x01]), 41 }; 42 return crypto.subtle.generateKey(algo, false, ["encrypt", "decrypt"]); 43 } 44 45 function doGenerateRsaSsaPkcs1Key() { 46 return crypto.subtle.importKey("pkcs8", tv.pkcs8, { name: "RSASSA-pkcs1-V1_5", hash: "SHA-1" }, true, ["sign"]); 47 } 48 49 crypto.subtle.generateKey(alg, false, ["sign"]) 50 .then(doGenerateAesKey) 51 .then(doGenerateRsaOaepKey) 52 .then(doGenerateRsaSsaPkcs1Key) 53 .then(complete(that), error(that)); 54 } 55 ); 56 57 /* ]]>*/</script> 58 </head> 59 60 <body> 61 62 <div id="content"> 63 <div id="head"> 64 <b>Web</b>Crypto<br> 65 </div> 66 67 <div id="start" onclick="start();">RUN ALL</div> 68 69 <div id="resultDiv" class="content"> 70 Summary: 71 <span class="pass"><span id="passN">0</span> passed, </span> 72 <span class="fail"><span id="failN">0</span> failed, </span> 73 <span class="pending"><span id="pendingN">0</span> pending.</span> 74 <br/> 75 <br/> 76 77 <table id="results"> 78 <tr> 79 <th>Test</th> 80 <th>Result</th> 81 <th>Time</th> 82 </tr> 83 </table> 84 85 </div> 86 87 <div id="foot"></div> 88 </div> 89 90 </body> 91 </html>