]> git.kaiwu.me - njs.git/commitdiff
WebCrypto: making SHA-256 the default hash algorithm.
authorDmitry Volyntsev <xeioex@nginx.com>
Fri, 9 May 2025 01:03:21 +0000 (18:03 -0700)
committerDmitry Volyntsev <xeioexception@gmail.com>
Fri, 16 May 2025 19:15:29 +0000 (12:15 -0700)
external/njs_webcrypto_module.c
external/qjs_webcrypto_module.c

index dcca91cee90425d963404a551828e52ca97cad26..8cc172cca37947a402b8e28a62b8f17094841148 100644 (file)
@@ -4642,8 +4642,8 @@ njs_algorithm_hash(njs_vm_t *vm, njs_value_t *options,
 
     if (njs_value_is_object(options)) {
         val = njs_vm_object_prop(vm, options, &string_hash, &value);
-        if (njs_slow_path(val == NULL)) {
-            njs_value_undefined_set(njs_value_arg(&value));
+        if (val == NULL) {
+            return NJS_HASH_SHA256;
         }
 
     } else {
index 937f96c3ca579065380a584df68084ffaebd479c..f26b650590c34b90296f7383590dd37cd433c843 100644 (file)
@@ -4437,6 +4437,11 @@ qjs_algorithm_hash(JSContext *cx, JSValue options, qjs_webcrypto_hash_t *hash)
 
     if (JS_IsObject(options)) {
         v = JS_GetPropertyStr(cx, options, "hash");
+        if (JS_IsUndefined(v)) {
+            *hash = QJS_HASH_SHA256;
+            return JS_UNDEFINED;
+        }
+
         if (JS_IsException(v)) {
             return JS_EXCEPTION;
         }