aboutsummaryrefslogtreecommitdiff
path: root/nginx/ngx_js.c
diff options
context:
space:
mode:
authorDmitry Volyntsev <xeioex@nginx.com>2021-10-11 15:06:15 +0000
committerDmitry Volyntsev <xeioex@nginx.com>2021-10-11 15:06:15 +0000
commit7b2b7612dc4ee6370b93462602a9892f97d155b9 (patch)
treec7066f5f81755376e2a688397274d73cf78d7ba6 /nginx/ngx_js.c
parent648e89a6ac5106426edf8825790fa9c50d9caf3e (diff)
downloadnjs-7b2b7612dc4ee6370b93462602a9892f97d155b9.tar.gz
njs-7b2b7612dc4ee6370b93462602a9892f97d155b9.zip
Introduced WebCrypto API according to W3C spec.
The following methods were implemented: crypto.getRandomValues() crypto.subtle.importKey() format: raw, pkcs8, spki algorithm: AES-CBC, AES-CTR, AES-GCM, ECDSA, HKDF, HMAC, PBKDF2, RSASSA-PKCS1-v1_5, RSA-OAEP, RSA-PSS crypto.subtle.decrypt() crypto.subtle.encrypt() algorithm: AES-CBC, AES-CTR, AES-GCM, RSA-OAEP crypto.subtle.deriveBits() crypto.subtle.deriveKey() algorithm: HKDF, PBKDF2 crypto.subtle.digest() algorithm: SHA-1, SHA-256, SHA-384, SHA-512 crypto.subtle.sign() crypto.subtle.verify() algorithm: ECDSA, HMAC, RSASSA-PKCS1-v1_5, RSA-PSS
Diffstat (limited to 'nginx/ngx_js.c')
-rw-r--r--nginx/ngx_js.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/nginx/ngx_js.c b/nginx/ngx_js.c
index ae7955ec..012adb48 100644
--- a/nginx/ngx_js.c
+++ b/nginx/ngx_js.c
@@ -10,6 +10,7 @@
#include <ngx_core.h>
#include "ngx_js.h"
#include "ngx_js_fetch.h"
+#include "../external/njs_webcrypto.h"
static njs_external_t ngx_js_ext_core[] = {
@@ -176,6 +177,12 @@ ngx_js_core_init(njs_vm_t *vm, ngx_log_t *log)
return NGX_ERROR;
}
+ ret = njs_external_webcrypto_init(vm);
+ if (ret != NJS_OK) {
+ ngx_log_error(NGX_LOG_EMERG, log, 0, "failed to add webcrypto object");
+ return NGX_ERROR;
+ }
+
proto_id = njs_vm_external_prototype(vm, ngx_js_ext_core,
njs_nitems(ngx_js_ext_core));
if (proto_id < 0) {