/
niceSOFT
/
njs
ОбзорДокументацияВойти
/
niceSOFT
/
njs
Код
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
ДокументацияПоддержка
Политика конфиденциальностиПользовательское соглашениеПолитика использования «cookies»Согласие субъекта персональных данных
2026 ©
njs/
test/webcrypto/
..
README.rst

WebCrypto: added Ed25519 and X25519 support.

4 месяца назад
aes.t.mjs

QuickJS: added WebCrypto import tests forgotten in 75ca26f.

год назад
aes_decoding.t.mjs

Test262: making "fs" module required.

2 года назад
aes_gcm_enc.js

Introduced WebCrypto API according to W3C spec.

5 лет назад
aes_kw.t.mjs

WebCrypto: added AES-KW algorithm support.

4 месяца назад
asn12ieeep1336.c

WebCrypto: fixed sign and verify methods for ECDSA.

4 года назад
derive.t.mjs

WebCrypto: fixed extractable handling for crypto.subtle.deriveKey().

год назад
derive_ecdh.t.mjs

WebCrypto: added ECDH support.

год назад
digest.t.mjs

Test262: allowing to omit empty default option argument.

год назад
ec.jwk

WebCrypto: extended support for asymmetric keys.

4 года назад
ec.pkcs8

Introduced WebCrypto API according to W3C spec.

5 лет назад
ec.pub.jwk

WebCrypto: extended support for asymmetric keys.

4 года назад
ec.spki

Introduced WebCrypto API according to W3C spec.

5 лет назад
ec2.pkcs8

Introduced WebCrypto API according to W3C spec.

5 лет назад
ec2.spki

Introduced WebCrypto API according to W3C spec.

5 лет назад
ec2_secp384r1.pkcs8

WebCrypto: added ECDH support.

год назад
ec2_secp384r1.spki

WebCrypto: added ECDH support.

год назад
ec2_secp521r1.pkcs8

WebCrypto: added ECDH support.

год назад
ec2_secp521r1.spki

WebCrypto: added ECDH support.

год назад
ec_secp384r1.pkcs8

WebCrypto: added ECDH support.

год назад
ec_secp384r1.spki

WebCrypto: added ECDH support.

год назад
ec_secp521r1.pkcs8

WebCrypto: added ECDH support.

год назад
ec_secp521r1.spki

WebCrypto: added ECDH support.

год назад
ed25519.t.mjs

WebCrypto: added Ed25519 and X25519 support.

4 месяца назад
export.t.mjs

WebCrypto: added ECDH support.

год назад
import.t.mjs

WebCrypto: fixed RSA JWK test data for Node.js compatibility.

4 месяца назад
random_uuid.t.mjs

WebCrypto: added crypto.randomUUID().

4 месяца назад
rsa.dec.jwk

WebCrypto: fixed RSA JWK test data for Node.js compatibility.

4 месяца назад
rsa.enc.pub.jwk

WebCrypto: fixed RSA JWK test data for Node.js compatibility.

4 месяца назад
rsa.jwk

WebCrypto: fixed RSA JWK test data for Node.js compatibility.

4 месяца назад
rsa.pkcs8

Introduced WebCrypto API according to W3C spec.

5 лет назад
rsa.pkcs8.broken

Introduced WebCrypto API according to W3C spec.

5 лет назад
rsa.pkcs8.broken2

QuickJS: added WebCrypto import tests forgotten in 75ca26f.

год назад
rsa.pub.jwk

WebCrypto: fixed RSA JWK test data for Node.js compatibility.

4 месяца назад
rsa.spki

Introduced WebCrypto API according to W3C spec.

5 лет назад
rsa.spki.broken

Introduced WebCrypto API according to W3C spec.

5 лет назад
rsa.t.mjs

QuickJS: added WebCrypto import tests forgotten in 75ca26f.

год назад
rsa2.pkcs8

Introduced WebCrypto API according to W3C spec.

5 лет назад
rsa2.spki

Introduced WebCrypto API according to W3C spec.

5 лет назад
rsa_decoding.t.mjs

Webcrypto: fix RSA-OAEP digest being ignored for non-SHA-1 hashes

21 час назад
sign.t.mjs

QuickJS: added WebCrypto import tests forgotten in 75ca26f.

год назад
text.base64.aes-cbc128.enc

Introduced WebCrypto API according to W3C spec.

5 лет назад
text.base64.aes-cbc256.enc

Introduced WebCrypto API according to W3C spec.

5 лет назад
text.base64.aes-ctr128.enc

Introduced WebCrypto API according to W3C spec.

5 лет назад
text.base64.aes-ctr256.enc

Introduced WebCrypto API according to W3C spec.

5 лет назад
text.base64.aes-gcm128-96.enc

Introduced WebCrypto API according to W3C spec.

5 лет назад
text.base64.aes-gcm128-extra.enc

Introduced WebCrypto API according to W3C spec.

5 лет назад
text.base64.aes-gcm128.enc

Introduced WebCrypto API according to W3C spec.

5 лет назад
text.base64.aes-gcm256.enc

Introduced WebCrypto API according to W3C spec.

5 лет назад
text.base64.rsa-oaep-sha256.enc

Webcrypto: fix RSA-OAEP digest being ignored for non-SHA-1 hashes

21 час назад
text.base64.rsa-oaep-sha384.enc

Webcrypto: fix RSA-OAEP digest being ignored for non-SHA-1 hashes

21 час назад
text.base64.rsa-oaep.enc

Introduced WebCrypto API according to W3C spec.

5 лет назад
text.base64.sha1.ecdsa.sig

WebCrypto: fixed sign and verify methods for ECDSA.

4 года назад
text.base64.sha1.hmac.sig

Introduced WebCrypto API according to W3C spec.

5 лет назад
text.base64.sha1.pkcs1.sig

Introduced WebCrypto API according to W3C spec.

5 лет назад
text.base64.sha1.rsa-pss.16.sig

Introduced WebCrypto API according to W3C spec.

5 лет назад
text.base64.sha256.ecdsa.sig

WebCrypto: fixed sign and verify methods for ECDSA.

4 года назад
text.base64.sha256.hmac.sig

Introduced WebCrypto API according to W3C spec.

5 лет назад
text.base64.sha256.hmac.sig.broken

Introduced WebCrypto API according to W3C spec.

5 лет назад
text.base64.sha256.pkcs1.sig

Introduced WebCrypto API according to W3C spec.

5 лет назад
text.base64.sha256.rsa-pss.0.sig

Introduced WebCrypto API according to W3C spec.

5 лет назад
text.base64.sha256.rsa-pss.32.sig

Introduced WebCrypto API according to W3C spec.

5 лет назад
verify.t.mjs

QuickJS: added WebCrypto module.

2 года назад
wrap.t.mjs

WebCrypto: added JWK unwrap() support.

4 месяца назад
x25519.t.mjs

WebCrypto: added Ed25519 and X25519 support.

4 месяца назад
README.rst
===============
WebCrypto tests
===============
 
Intro
=====
 
Tests in this folder are expected to be compatible with node.js
 
Tested versions
---------------
 
node: v25.2.1
openssl: OpenSSL 3.0.13 30 Jan 2024
 
Keys generation
===============
 
Generating RSA PKCS8/SPKI key files
-----------------------------------
 
.. code-block:: shell
 
openssl genrsa -out rsa.pem 1024
openssl pkcs8 -inform PEM -in rsa.pem -nocrypt -topk8 -outform PEM -out rsa.pkcs8
openssl rsa -in rsa.pkcs8 -pubout > rsa.spki
 
Generating EC PKCS8/SPKI key files
----------------------------------
 
.. code-block:: shell
 
openssl ecparam -name prime256v1 -genkey -noout -out ec.pem
openssl pkcs8 -inform PEM -in ec.pem -nocrypt -topk8 -outform PEM -out ec.pkcs8
openssl ec -in ec.pkcs8 -pubout > ec.spki
 
Generating Ed25519 PKCS8/SPKI key files
---------------------------------------
 
.. code-block:: shell
 
openssl genpkey -algorithm Ed25519 -out ed25519.pem
openssl pkcs8 -inform PEM -in ed25519.pem -nocrypt -topk8 -outform PEM -out ed25519.pkcs8
openssl pkey -in ed25519.pkcs8 -pubout > ed25519.spki
 
Generating X25519 PKCS8/SPKI key files
--------------------------------------
 
.. code-block:: shell
 
openssl genpkey -algorithm X25519 -out x25519.pem
openssl pkcs8 -inform PEM -in x25519.pem -nocrypt -topk8 -outform PEM -out x25519.pkcs8
openssl pkey -in x25519.pkcs8 -pubout > x25519.spki
 
Encoding
========
 
Encoding data using RSA-OAEP
----------------------------
 
.. code-block:: shell
 
echo -n "WAKAWAKA" > text.txt
openssl rsautl -inkey key.spki -pubin -in text.txt -out - -oaep -encrypt | \
base64 > text.base64.rsa-oaep.enc
 
Decoding ciphertext using RSA-OAEP
----------------------------------
 
.. code-block:: shell
 
base64 -d text.base64.rsa-oaep.enc | openssl rsautl -inkey key.pkcs8 -in - -out - -oaep -decrypt
WAKAWAKA
 
Encoding data using AES-GCM
---------------------------
 
.. code-block:: shell
 
echo -n "AES-GCM-SECRET-TEXT" > text.txt
node ./test/webcrypto/aes_gcm_enc.js '{"in":"text.txt"}' > text.base64.aes-gcm128.enc
 
echo -n "AES-GCM-96-TAG-LENGTH-SECRET-TEXT" > text.txt
node ./test/webcrypto/aes_gcm_enc.js '{"in":"text.txt","tagLength":96}' > text.base64.aes-gcm128-96.enc
 
Encoding data using AES-CTR
---------------------------
 
.. code-block:: shell
 
echo -n "AES-CTR-SECRET-TEXT" | \
openssl enc -aes-128-ctr -K 00112233001122330011223300112233 -iv 44556677445566774455667744556677 | \
base64 > text.base64.aes-ctr128.enc
 
Encoding data using AES-CBC
---------------------------
 
.. code-block:: shell
 
echo -n "AES-CBC-SECRET-TEXT" | \
openssl enc -aes-128-cbc -K 00112233001122330011223300112233 -iv 44556677445566774455667744556677 | \
base64 > text.base64.aes-cbc128.enc
 
Signing
=======
 
Signing data using HMAC
-----------------------
 
.. code-block:: shell
 
echo -n "SigneD-TExt" > text.txt
openssl dgst -sha256 -mac hmac -macopt hexkey:aabbcc -binary text.txt | \
base64 > test/webcrypto/text.base64.sha256.hmac.sig
 
Signing data using RSASSA-PKCS1-v1_5
------------------------------------
 
.. code-block:: shell
 
echo -n "SigneD-TExt" > text.txt
openssl dgst -sha256 -sigopt rsa_padding_mode:pkcs1 -sign test/webcrypto/rsa.pkcs8 text.txt | \
base64 > test/webcrypto/text.base64.sha256.pkcs1.sig
base64 -d test/webcrypto/text.base64.sha256.pkcs1.sig > text.sha256.pkcs1.sig
openssl dgst -sha256 -sigopt rsa_padding_mode:pkcs1 -verify test/webcrypto/rsa.spki \
-signature text.sha256.pkcs1.sig text.txt
Verified OK
 
Signing data using RSA-PSS
--------------------------
 
.. code-block:: shell
 
echo -n "SigneD-TExt" > text.txt
openssl dgst -sha256 -sigopt rsa_padding_mode:pss -sigopt rsa_pss_saltlen:32 -sign test/webcrypto/rsa.pkcs8 text.txt | \
base64 > test/webcrypto/text.base64.sha256.rsa-pss.32.sig
base64 -d test/webcrypto/text.base64.sha256.rsa-pss.32.sig > text.sha256.rsa-pss.32.sig
openssl dgst -sha256 -sigopt rsa_padding_mode:pss -sigopt rsa_pss_saltlen:32 \
-verify test/webcrypto/rsa.spki -signature text.sha256.rsa-pss.sig text.txt
Verified OK
 
Signing data using ECDSA
------------------------
 
Note: there are two types of ECDSA signatures: ASN.1 and IEEE P1363
Webcrypto requires IEEE P1363, but OpenSSL outputs only ASN.1 variety.
To create P1363, we build an auxilary program asn12IEEEP1336
 
.. code-block:: shell
 
echo -n "SigneD-TExt" > text.txt
openssl dgst -sha256 -binary text.txt > text.sha256
openssl pkeyutl -sign -in text.sha256 -inkey test/webcrypto/ec.pkcs8 | \
base64 > test/webcrypto/text.base64.sha256.ecdsa.asn1.sig
base64 -d test/webcrypto/text.base64.sha256.ecdsa.asn1.sig > text.sha256.ecdsa.sig
openssl pkeyutl -verify -in text.sha256 -pubin -inkey test/webcrypto/ec.spki -sigfile text.sha256.ecdsa.sig
Signature Verified Successfully
 
# convert to IEEE P1363
gcc test/webcrypto/asn12ieeep1336.c -lcrypto -o test/webcrypto/asn12ieeep1336
base64 -d test/webcrypto/text.base64.sha256.ecdsa.asn1.sig | ./test/webcrypto/asn12IEEEP1336 | \
base64 > test/webcrypto/text.base64.sha256.ecdsa.sig