| <!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 unwrapping a JWK key with AES-CFB using an imported key"); |
| |
| jsTestIsAsync = true; |
| |
| var extractable = true; |
| var rawKey = asciiToUint8Array("jnOw99oOZFLIEPMr"); |
| var jwkKey = { |
| kty: "oct", |
| alg: "A128CBC", |
| use: "enc", |
| key_ops: ["encrypt"], |
| ext: true, |
| k: "am5Pdzk5b09aRkxJRVBNcg", |
| }; |
| var aesCfbParams = { |
| name: "aes-cfb-8", |
| iv: asciiToUint8Array("jnOw99oOZFLIEPMr"), |
| } |
| var wrappedKey = hexStringToUint8Array("96a1740c58cb039ce9d3f77c4031efc6e3c16adbc1ce9a1b0d5bc5b953e2d9de3f5413b01b940477fd80cee9f49e09c38ce965c2040a3fc1449ba4f2b6c03386acd2b2a145e335e1890c4ac351b4702d07b6ea330cce9d44af7e2a"); |
| |
| |
| crypto.subtle.importKey("raw", rawKey, "aes-cfb-8", extractable, ["unwrapKey"]).then(function(unwrappingKey) { |
| return crypto.subtle.unwrapKey("jwk", wrappedKey, unwrappingKey, aesCfbParams, {name: "aes-cbc"}, extractable, ["encrypt"]); |
| }).then(function(cryptoKey) { |
| return crypto.subtle.exportKey("jwk", cryptoKey); |
| }).then(function(result) { |
| unwrappedKey = result; |
| |
| shouldBe("unwrappedKey.kty", "jwkKey.kty"); |
| shouldBe("unwrappedKey.alg", "jwkKey.alg"); |
| shouldBe("unwrappedKey.key_ops", "jwkKey.key_ops"); |
| shouldBe("unwrappedKey.ext", "jwkKey.ext"); |
| shouldBe("unwrappedKey.k", "jwkKey.k"); |
| |
| finishJSTest(); |
| }); |
| |
| </script> |
| |
| <script src="../../resources/js-test-post.js"></script> |
| </body> |
| </html> |