Skip to content

Commit aa1bdbe

Browse files
committed
QuickJS: added WebCrypto import tests forgotten in 75ca26f.
Import related tests are consolidated from other WebCrypto tests.
1 parent 772f8d0 commit aa1bdbe

File tree

7 files changed

+664
-157
lines changed

7 files changed

+664
-157
lines changed

external/qjs_webcrypto_module.c

+2-15
Original file line numberDiff line numberDiff line change
@@ -4167,20 +4167,7 @@ qjs_webcrypto_key_algorithm(JSContext *cx, JSValueConst this_val)
41674167
return JS_EXCEPTION;
41684168
}
41694169

4170-
ret = JS_NewObject(cx);
4171-
if (JS_IsException(ret)) {
4172-
JS_FreeValue(cx, obj);
4173-
return JS_EXCEPTION;
4174-
}
4175-
4176-
if (JS_DefinePropertyValueStr(cx, ret, "name", hash, JS_PROP_C_W_E)
4177-
< 0)
4178-
{
4179-
JS_FreeValue(cx, obj);
4180-
return JS_EXCEPTION;
4181-
}
4182-
4183-
if (JS_DefinePropertyValueStr(cx, obj, "hash", ret, JS_PROP_C_W_E)
4170+
if (JS_DefinePropertyValueStr(cx, obj, "hash", hash, JS_PROP_C_W_E)
41844171
< 0)
41854172
{
41864173
JS_FreeValue(cx, obj);
@@ -4377,7 +4364,7 @@ qjs_jwk_kty(JSContext *cx, JSValueConst value)
43774364
}
43784365
}
43794366

4380-
JS_ThrowTypeError(cx, "invalid JWK key type: %s", kty.start);
4367+
JS_ThrowTypeError(cx, "invalid JWK key type: \"%s\"", kty.start);
43814368
JS_FreeCString(cx, (char *) kty.start);
43824369

43834370
return QJS_KEY_JWK_KTY_UNKNOWN;

test/webcrypto/aes.t.mjs

-3
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ let aes_tsuite = {
6565
{ name: "AES-GCM", data: "aabbcc", tagLength: 96 },
6666
{ name: "AES-GCM", data: "aabbcc", tagLength: 112 },
6767
{ name: "AES-GCM", data: "aabbcc", tagLength: 113, exception: "TypeError: AES-GCM Invalid tagLength" },
68-
{ name: "AES-GCM", data: "aabbcc", key: "aabbcc", exception: "TypeError: Invalid key length" },
6968
{ name: "AES-GCM", data: "aabbcc", key: "001122330011223300112233001122330011223300112233" },
7069
{ name: "AES-GCM", data: "aabbccdd".repeat(4096) },
7170

@@ -88,14 +87,12 @@ let aes_tsuite = {
8887
{ name: "AES-CTR", data: "aabbcc", key: "001122330011223300112233001122330011223300112233" },
8988
{ name: "AES-CTR", data: "aabbccdd", length: 129,
9089
exception: "TypeError: AES-CTR algorithm.length must be between 1 and 128" },
91-
{ name: "AES-CTR", data: "aabbcc", key: "aabbcc", exception: "TypeError: Invalid key length" },
9290

9391
{ name: "AES-CBC", data: "aa" },
9492
{ name: "AES-CBC", data: "aabbccdd".repeat(4) },
9593
{ name: "AES-CBC", data: "aabbccdd".repeat(4096) },
9694
{ name: "AES-CBC", data: "aabbccdd".repeat(5), iv: "ffffffffffffffffffffffffffffffff" },
9795
{ name: "AES-CBC", data: "aabbcc", key: "001122330011223300112233001122330011223300112233" },
98-
{ name: "AES-CBC", data: "aabbcc", key: "aabbcc", exception: "TypeError: Invalid key length" },
9996
]};
10097

10198
run([aes_tsuite])

0 commit comments

Comments
 (0)