Skip to content

Lightpanda: the headless browser designed for AI and automation

Merge pull request #4060 from orezraey/algorithm-name

Karl Seguin016af6b6430b
diff --cc src/browser/webapi/SubtleCrypto.zig
index bc1fe52f6,e082c53c8..d50068511
--- a/src/browser/webapi/SubtleCrypto.zig
+++ b/src/browser/webapi/SubtleCrypto.zig
@@@ -134,20 -135,14 +135,20 @@@ pub fn importKey
// Public keys may have empty usages; secret/private keys may not.
const mask = try common.usageMaskInner(allowed, key_usages, is_private);
if (EC.canonicalName(name) != null) {
- const der = switch (key_data) {
- .bytes => |b| b.values,
- .jwk => return error.NotSupported,
- };
- return EC.import(name, algo.namedCurve(), format, der, is_private, extractable, mask, exec);
+ const is_jwk = std.mem.eql(u8, format, "jwk");
+ switch (key_data) {
+ .bytes => |b| {
+ if (is_jwk) return local.typeError("jwk format expects an object");
+ return EC.import(name, algo.namedCurve(), format, b.values, is_private, extractable, mask, exec);
+ },
+ .jwk => |jwk| {
+ if (!is_jwk) return local.typeError("this format expects a BufferSource");
+ return EC.importJwk(name, algo.namedCurve(), jwk, extractable, mask, exec);
+ },
+ }
}
if (RSA.scheme(name)) |scheme| {
- const hash_name = importHash(algo) orelse return local.typeError("RSA import requires a hash");
+ const hash_name = try importHash(algo, local) orelse return local.typeError("RSA import requires a hash");
const is_jwk = std.mem.eql(u8, format, "jwk");
switch (key_data) {
.bytes => |b| {