if (!hmac) {
dgst = njs_vm_external(vm, njs_crypto_hash_proto_id, this);
if (njs_slow_path(dgst == NULL)) {
- njs_vm_error(vm, "\"this\" is not a hash object");
+ njs_vm_type_error(vm, "\"this\" is not a hash object");
return NJS_ERROR;
}
} else {
ctx = njs_vm_external(vm, njs_crypto_hmac_proto_id, this);
if (njs_slow_path(ctx == NULL)) {
- njs_vm_error(vm, "\"this\" is not a hmac object");
+ njs_vm_type_error(vm, "\"this\" is not a hmac object");
return NJS_ERROR;
}
}
} else {
- njs_vm_error(vm, "data is not a string or Buffer-like object");
+ njs_vm_type_error(vm, "data is not a string or Buffer-like object");
return NJS_ERROR;
}
if (!hmac) {
dgst = njs_vm_external(vm, njs_crypto_hash_proto_id, this);
if (njs_slow_path(dgst == NULL)) {
- njs_vm_error(vm, "\"this\" is not a hash object");
+ njs_vm_type_error(vm, "\"this\" is not a hash object");
return NJS_ERROR;
}
} else {
ctx = njs_vm_external(vm, njs_crypto_hmac_proto_id, this);
if (njs_slow_path(ctx == NULL)) {
- njs_vm_error(vm, "\"this\" is not a hmac object");
+ njs_vm_type_error(vm, "\"this\" is not a hmac object");
return NJS_ERROR;
}
dgst = njs_vm_external(vm, njs_crypto_hash_proto_id, njs_argument(args, 0));
if (njs_slow_path(dgst == NULL)) {
- njs_vm_error(vm, "\"this\" is not a hash object");
+ njs_vm_type_error(vm, "\"this\" is not a hash object");
return NJS_ERROR;
}
}
} else {
- njs_vm_error(vm, "key is not a string or Buffer-like object");
+ njs_vm_type_error(vm, "key is not a string or Buffer-like object");
return NJS_ERROR;
}
njs_hash_alg_t *e;
if (njs_slow_path(!njs_value_is_string(value))) {
- njs_vm_error(vm, "algorithm must be a string");
+ njs_vm_type_error(vm, "algorithm must be a string");
return NULL;
}
}
}
- njs_vm_error(vm, "not supported algorithm: \"%V\"", &name);
+ njs_vm_type_error(vm, "not supported algorithm: \"%V\"", &name);
return NULL;
}
if (njs_slow_path(!njs_value_is_string(value))) {
if (!njs_value_is_undefined(value)) {
- njs_vm_error(vm, "encoding must be a string");
+ njs_vm_type_error(vm, "encoding must be a string");
return NULL;
}
}
}
- njs_vm_error(vm, "Unknown digest encoding: \"%V\"", &name);
+ njs_vm_type_error(vm, "Unknown digest encoding: \"%V\"", &name);
return NULL;
}
"'d9f5aeb06abebb3be3f38adec9a2e3b94228d52193be923eb4e24c9b56ee0930']]") },
{ njs_str("var h = require('crypto').createHash()"),
- njs_str("Error: algorithm must be a string") },
+ njs_str("TypeError: algorithm must be a string") },
{ njs_str("var h = require('crypto').createHash([])"),
- njs_str("Error: algorithm must be a string") },
+ njs_str("TypeError: algorithm must be a string") },
{ njs_str("var h = require('crypto').createHash('sha512')"),
- njs_str("Error: not supported algorithm: \"sha512\"") },
+ njs_str("TypeError: not supported algorithm: \"sha512\"") },
{ njs_str("var h = require('crypto').createHash('sha1');"
"h.update()"),
- njs_str("Error: data is not a string or Buffer-like object") },
+ njs_str("TypeError: data is not a string or Buffer-like object") },
{ njs_str("var h = require('crypto').createHash('sha1');"
"h.update({})"),
- njs_str("Error: data is not a string or Buffer-like object") },
+ njs_str("TypeError: data is not a string or Buffer-like object") },
{ njs_str("var h = require('crypto').createHash('sha1');"
"h.update('A').digest('latin1')"),
- njs_str("Error: Unknown digest encoding: \"latin1\"") },
+ njs_str("TypeError: Unknown digest encoding: \"latin1\"") },
{ njs_str("require('crypto').createHash('sha1').digest() instanceof Buffer"),
njs_str("true") },
njs_str("5647b6c429701ff512f0f18232b4507065d2376ca8899a816a0a6e721bf8ddcc") },
{ njs_str("var h = require('crypto').createHmac()"),
- njs_str("Error: algorithm must be a string") },
+ njs_str("TypeError: algorithm must be a string") },
{ njs_str("var h = require('crypto').createHmac([])"),
- njs_str("Error: algorithm must be a string") },
+ njs_str("TypeError: algorithm must be a string") },
{ njs_str("var h = require('crypto').createHmac('sha512', '')"),
- njs_str("Error: not supported algorithm: \"sha512\"") },
+ njs_str("TypeError: not supported algorithm: \"sha512\"") },
{ njs_str("var h = require('crypto').createHmac('sha1', [])"),
- njs_str("Error: key is not a string or Buffer-like object") },
+ njs_str("TypeError: key is not a string or Buffer-like object") },
{ njs_str("var h = require('crypto').createHmac('sha1', 'secret key');"
"h.update('A').digest('hex'); h.digest('hex')"),
{ njs_str("var cr = require('crypto'); var h = cr.createHash('sha1');"
"h.update.call(cr.createHmac('sha1', 's'), '')"),
- njs_str("Error: \"this\" is not a hash object") },
+ njs_str("TypeError: \"this\" is not a hash object") },
};
static njs_unit_test_t njs_querystring_module_test[] =
" at main (:1)\n") },
{ njs_str("require('crypto').createHash('sha')"),
- njs_str("Error: not supported algorithm: \"sha\"\n"
+ njs_str("TypeError: not supported algorithm: \"sha\"\n"
" at crypto.createHash (native)\n"
" at main (:1)\n") },
{ njs_str("var h = require('crypto').createHash('sha1');"
"h.update([])"),
- njs_str("Error: data is not a string or Buffer-like object\n"
+ njs_str("TypeError: data is not a string or Buffer-like object\n"
" at Hash.update (native)\n"
" at main (:1)\n") },
{ njs_str("require('crypto').createHmac('sha1', [])"),
- njs_str("Error: key is not a string or Buffer-like object\n"
+ njs_str("TypeError: key is not a string or Buffer-like object\n"
" at crypto.createHmac (native)\n"
" at main (:1)\n") },
{ njs_str("var h = require('crypto').createHmac('sha1', 'secret');"
"h.update([])"),
- njs_str("Error: data is not a string or Buffer-like object\n"
+ njs_str("TypeError: data is not a string or Buffer-like object\n"
" at Hmac.update (native)\n"
" at main (:1)\n") },