@@ -6,15 +6,14 @@ if (!common.hasCrypto)
6
6
common . skip ( 'missing crypto' ) ;
7
7
8
8
const assert = require ( 'assert' ) ;
9
- const { webcrypto } = require ( 'crypto' ) ;
10
- const { subtle } = webcrypto ;
9
+ const { subtle } = globalThis . crypto ;
11
10
12
11
// This is only a partial test. The WebCrypto Web Platform Tests
13
12
// will provide much greater coverage.
14
13
15
14
// Test Encrypt/Decrypt RSA-OAEP
16
15
{
17
- const buf = webcrypto . getRandomValues ( new Uint8Array ( 50 ) ) ;
16
+ const buf = globalThis . crypto . getRandomValues ( new Uint8Array ( 50 ) ) ;
18
17
19
18
async function test ( ) {
20
19
const ec = new TextEncoder ( ) ;
@@ -45,8 +44,8 @@ const { subtle } = webcrypto;
45
44
46
45
// Test Encrypt/Decrypt AES-CTR
47
46
{
48
- const buf = webcrypto . getRandomValues ( new Uint8Array ( 50 ) ) ;
49
- const counter = webcrypto . getRandomValues ( new Uint8Array ( 16 ) ) ;
47
+ const buf = globalThis . crypto . getRandomValues ( new Uint8Array ( 50 ) ) ;
48
+ const counter = globalThis . crypto . getRandomValues ( new Uint8Array ( 16 ) ) ;
50
49
51
50
async function test ( ) {
52
51
const key = await subtle . generateKey ( {
@@ -72,8 +71,8 @@ const { subtle } = webcrypto;
72
71
73
72
// Test Encrypt/Decrypt AES-CBC
74
73
{
75
- const buf = webcrypto . getRandomValues ( new Uint8Array ( 50 ) ) ;
76
- const iv = webcrypto . getRandomValues ( new Uint8Array ( 16 ) ) ;
74
+ const buf = globalThis . crypto . getRandomValues ( new Uint8Array ( 50 ) ) ;
75
+ const iv = globalThis . crypto . getRandomValues ( new Uint8Array ( 16 ) ) ;
77
76
78
77
async function test ( ) {
79
78
const key = await subtle . generateKey ( {
@@ -99,8 +98,8 @@ const { subtle } = webcrypto;
99
98
100
99
// Test Encrypt/Decrypt AES-GCM
101
100
{
102
- const buf = webcrypto . getRandomValues ( new Uint8Array ( 50 ) ) ;
103
- const iv = webcrypto . getRandomValues ( new Uint8Array ( 12 ) ) ;
101
+ const buf = globalThis . crypto . getRandomValues ( new Uint8Array ( 50 ) ) ;
102
+ const iv = globalThis . crypto . getRandomValues ( new Uint8Array ( 12 ) ) ;
104
103
105
104
async function test ( ) {
106
105
const key = await subtle . generateKey ( {
0 commit comments