|
1 | 1 | 'use strict';
|
2 | 2 |
|
3 |
| -require('../common'); |
| 3 | +const common = require('../common'); |
4 | 4 | const assert = require('assert');
|
5 | 5 | const util = require('util');
|
6 | 6 | const { AssertionError } = assert;
|
@@ -1220,3 +1220,60 @@ assert.throws(
|
1220 | 1220 |
|
1221 | 1221 | assertNotDeepOrStrict(a, b);
|
1222 | 1222 | }
|
| 1223 | + |
| 1224 | +// eslint-disable-next-line node-core/crypto-check |
| 1225 | +if (common.hasCrypto) { |
| 1226 | + const crypto = require('crypto'); |
| 1227 | + const { subtle } = globalThis.crypto; |
| 1228 | + |
| 1229 | + { |
| 1230 | + const a = crypto.createSecretKey(Buffer.alloc(1, 0)); |
| 1231 | + const b = crypto.createSecretKey(Buffer.alloc(1, 1)); |
| 1232 | + |
| 1233 | + assertNotDeepOrStrict(a, b); |
| 1234 | + } |
| 1235 | + |
| 1236 | + { |
| 1237 | + const a = crypto.createSecretKey(Buffer.alloc(0)); |
| 1238 | + const b = crypto.createSecretKey(Buffer.alloc(0)); |
| 1239 | + |
| 1240 | + assertDeepAndStrictEqual(a, b); |
| 1241 | + } |
| 1242 | + |
| 1243 | + (async () => { |
| 1244 | + { |
| 1245 | + const a = await subtle.importKey('raw', Buffer.alloc(1, 0), { name: 'HMAC', hash: 'SHA-256' }, true, ['sign']); |
| 1246 | + const b = await subtle.importKey('raw', Buffer.alloc(1, 1), { name: 'HMAC', hash: 'SHA-256' }, true, ['sign']); |
| 1247 | + |
| 1248 | + assertNotDeepOrStrict(a, b); |
| 1249 | + } |
| 1250 | + |
| 1251 | + { |
| 1252 | + const a = await subtle.importKey('raw', Buffer.alloc(1), { name: 'HMAC', hash: 'SHA-256' }, true, ['sign']); |
| 1253 | + const b = await subtle.importKey('raw', Buffer.alloc(1), { name: 'HMAC', hash: 'SHA-256' }, false, ['sign']); |
| 1254 | + |
| 1255 | + assertNotDeepOrStrict(a, b); |
| 1256 | + } |
| 1257 | + |
| 1258 | + { |
| 1259 | + const a = await subtle.importKey('raw', Buffer.alloc(1), { name: 'HMAC', hash: 'SHA-256' }, true, ['sign']); |
| 1260 | + const b = await subtle.importKey('raw', Buffer.alloc(1), { name: 'HMAC', hash: 'SHA-384' }, true, ['sign']); |
| 1261 | + |
| 1262 | + assertNotDeepOrStrict(a, b); |
| 1263 | + } |
| 1264 | + |
| 1265 | + { |
| 1266 | + const a = await subtle.importKey('raw', Buffer.alloc(1), { name: 'HMAC', hash: 'SHA-256' }, true, ['sign']); |
| 1267 | + const b = await subtle.importKey('raw', Buffer.alloc(1), { name: 'HMAC', hash: 'SHA-256' }, true, ['verify']); |
| 1268 | + |
| 1269 | + assertNotDeepOrStrict(a, b); |
| 1270 | + } |
| 1271 | + |
| 1272 | + { |
| 1273 | + const a = await subtle.importKey('raw', Buffer.alloc(1), { name: 'HMAC', hash: 'SHA-256' }, true, ['sign']); |
| 1274 | + const b = await subtle.importKey('raw', Buffer.alloc(1), { name: 'HMAC', hash: 'SHA-256' }, true, ['sign']); |
| 1275 | + |
| 1276 | + assertDeepAndStrictEqual(a, b); |
| 1277 | + } |
| 1278 | + })().then(common.mustCall()); |
| 1279 | +} |
0 commit comments