• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict';
2const common = require('../common');
3const assert = require('assert');
4
5if (!common.hasCrypto) {
6  common.skip('missing crypto');
7  return;
8}
9const crypto = require('crypto');
10
11// 'ClassName' : ['args', 'for', 'constructor']
12const TEST_CASES = {
13  'Hash': ['sha1'],
14  'Hmac': ['sha1', 'Node'],
15  'Cipheriv': ['des-ede3-cbc', '0123456789abcd0123456789', '12345678'],
16  'Decipheriv': ['des-ede3-cbc', '0123456789abcd0123456789', '12345678'],
17  'Sign': ['RSA-SHA1'],
18  'Verify': ['RSA-SHA1'],
19  'DiffieHellman': [1024],
20  'DiffieHellmanGroup': ['modp5'],
21  'ECDH': ['prime256v1'],
22};
23
24if (!common.hasFipsCrypto) {
25  TEST_CASES.Cipher = ['aes192', 'secret'];
26  TEST_CASES.Decipher = ['aes192', 'secret'];
27  TEST_CASES.DiffieHellman = [256];
28}
29
30for (const [clazz, args] of Object.entries(TEST_CASES)) {
31  assert(crypto[`create${clazz}`](...args) instanceof crypto[clazz]);
32}
33