blob: 3d28864e445380e05fced53b8d41ca633249dbb4 [file] [log] [blame]
<!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 type="text/javascript">
description("Test importing a HKDF raw key with malformed parameters");
var nonExtractable = false;
var rawKey = asciiToUint8Array("jnOw99oOZFLIEPMr");
var jwkKey = {
kty: "EC",
crv: "P-256",
x: "1FSVWieTvikFkG1NOyhkUCaMbdQhxwH6aCu4Ez-sRtA",
y: "9jmNTLqM4cjBhdAnHcNI9YQV3O8LFmo-EdZWk8ntAaI",
};
// Non raw format
shouldReject('crypto.subtle.importKey("spki", rawKey, { name: "HKDF" }, nonExtractable, ["deriveKey", "deriveBits"])');
shouldReject('crypto.subtle.importKey("pkcs8", rawKey, { name: "HKDF" }, nonExtractable, ["deriveKey", "deriveBits"])');
shouldReject('crypto.subtle.importKey("jwk", jwkKey, { name: "HKDF" }, nonExtractable, ["deriveKey", "deriveBits"])');
// Wrong usages
shouldReject('crypto.subtle.importKey("raw", rawKey, { name: "HKDF" }, nonExtractable, ["encrypt"])');
shouldReject('crypto.subtle.importKey("raw", rawKey, { name: "HKDF" }, nonExtractable, ["decrypt"])');
shouldReject('crypto.subtle.importKey("raw", rawKey, { name: "HKDF" }, nonExtractable, ["sign"])');
shouldReject('crypto.subtle.importKey("raw", rawKey, { name: "HKDF" }, nonExtractable, ["verify"])');
shouldReject('crypto.subtle.importKey("raw", rawKey, { name: "HKDF" }, nonExtractable, ["wrapKey"])');
shouldReject('crypto.subtle.importKey("raw", rawKey, { name: "HKDF" }, nonExtractable, ["unwrapKey"])');
// Extractable
shouldReject('crypto.subtle.importKey("raw", rawKey, { name: "HKDF" }, true, ["deriveKey", "deriveBits"])');
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>