| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent bbcb2a2 commit e129d83
9 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -324,11 +324,13 @@ var rfc2202_sha1 = [ | |||
| 324 | 324 | ]; | |
| 325 | 325 | ||
| 326 | 326 | for (var i = 0, l = rfc2202_md5.length; i < l; i++) { | |
| 327 | - assert.equal(rfc2202_md5[i]['hmac'], | ||
| 328 | - crypto.createHmac('md5', rfc2202_md5[i]['key']) | ||
| 329 | - .update(rfc2202_md5[i]['data']) | ||
| 330 | - .digest('hex'), | ||
| 331 | - 'Test HMAC-MD5 : Test case ' + (i + 1) + ' rfc 2202'); | ||
| 327 | + if (!common.hasFipsCrypto) { | ||
| 328 | + assert.equal(rfc2202_md5[i]['hmac'], | ||
| 329 | + crypto.createHmac('md5', rfc2202_md5[i]['key']) | ||
| 330 | + .update(rfc2202_md5[i]['data']) | ||
| 331 | + .digest('hex'), | ||
| 332 | + 'Test HMAC-MD5 : Test case ' + (i + 1) + ' rfc 2202'); | ||
| 333 | + } | ||
| 332 | 334 | } | |
| 333 | 335 | for (var i = 0, l = rfc2202_sha1.length; i < l; i++) { | |
| 334 | 336 | assert.equal(rfc2202_sha1[i]['hmac'], | |
@@ -339,15 +341,19 @@ for (var i = 0, l = rfc2202_sha1.length; i < l; i++) { | |||
| 339 | 341 | } | |
| 340 | 342 | ||
| 341 | 343 | // Test hashing | |
| 342 | - var a0 = crypto.createHash('sha1').update('Test123').digest('hex'); | ||
| 343 | - var a1 = crypto.createHash('md5').update('Test123').digest('binary'); | ||
| 344 | + var a1 = crypto.createHash('sha1').update('Test123').digest('hex'); | ||
| 344 | 345 | var a2 = crypto.createHash('sha256').update('Test123').digest('base64'); | |
| 345 | 346 | var a3 = crypto.createHash('sha512').update('Test123').digest(); // binary | |
| 346 | 347 | var a4 = crypto.createHash('sha1').update('Test123').digest('buffer'); | |
| 347 | 348 | ||
| 348 | - assert.equal(a0, '8308651804facb7b9af8ffc53a33a22d6a1c8ac2', 'Test SHA1'); | ||
| 349 | - assert.equal(a1, 'h\u00ea\u00cb\u0097\u00d8o\fF!\u00fa+\u000e\u0017\u00ca' + | ||
| 350 | - '\u00bd\u008c', 'Test MD5 as binary'); | ||
| 349 | + if (!common.hasFipsCrypto) { | ||
| 350 | + var a0 = crypto.createHash('md5').update('Test123').digest('binary'); | ||
| 351 | + assert.equal(a0, 'h\u00ea\u00cb\u0097\u00d8o\fF!\u00fa+\u000e\u0017\u00ca' + | ||
| 352 | + '\u00bd\u008c', 'Test MD5 as binary'); | ||
| 353 | + } | ||
| 354 | + | ||
| 355 | + assert.equal(a1, '8308651804facb7b9af8ffc53a33a22d6a1c8ac2', 'Test SHA1'); | ||
| 356 | + | ||
| 351 | 357 | assert.equal(a2, '2bX1jws4GYKTlxhloUB09Z66PoJZW+y+hq5R8dnx9l4=', | |
| 352 | 358 | 'Test SHA256 as base64'); | |
| 353 | 359 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -11,8 +11,7 @@ if (!common.hasCrypto) { | |||
| 11 | 11 | var crypto = require('crypto'); | |
| 12 | 12 | ||
| 13 | 13 | // Test hashing | |
| 14 | - var a0 = crypto.createHash('sha1').update('Test123').digest('hex'); | ||
| 15 | - var a1 = crypto.createHash('md5').update('Test123').digest('binary'); | ||
| 14 | + var a1 = crypto.createHash('sha1').update('Test123').digest('hex'); | ||
| 16 | 15 | var a2 = crypto.createHash('sha256').update('Test123').digest('base64'); | |
| 17 | 16 | var a3 = crypto.createHash('sha512').update('Test123').digest(); // binary | |
| 18 | 17 | var a4 = crypto.createHash('sha1').update('Test123').digest('buffer'); | |
@@ -38,9 +37,12 @@ a8.write(''); | |||
| 38 | 37 | a8.end(); | |
| 39 | 38 | a8 = a8.read(); | |
| 40 | 39 | ||
| 41 | - assert.equal(a0, '8308651804facb7b9af8ffc53a33a22d6a1c8ac2', 'Test SHA1'); | ||
| 42 | - assert.equal(a1, 'h\u00ea\u00cb\u0097\u00d8o\fF!\u00fa+\u000e\u0017\u00ca' + | ||
| 43 | - '\u00bd\u008c', 'Test MD5 as binary'); | ||
| 40 | + if (!common.hasFipsCrypto) { | ||
| 41 | + var a0 = crypto.createHash('md5').update('Test123').digest('binary'); | ||
| 42 | + assert.equal(a0, 'h\u00ea\u00cb\u0097\u00d8o\fF!\u00fa+\u000e\u0017\u00ca' + | ||
| 43 | + '\u00bd\u008c', 'Test MD5 as binary'); | ||
| 44 | + } | ||
| 45 | + assert.equal(a1, '8308651804facb7b9af8ffc53a33a22d6a1c8ac2', 'Test SHA1'); | ||
| 44 | 46 | assert.equal(a2, '2bX1jws4GYKTlxhloUB09Z66PoJZW+y+hq5R8dnx9l4=', | |
| 45 | 47 | 'Test SHA256 as base64'); | |
| 46 | 48 | assert.deepEqual( | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -61,6 +61,9 @@ var wikipedia = [ | |||
| 61 | 61 | ||
| 62 | 62 | for (var i = 0, l = wikipedia.length; i < l; i++) { | |
| 63 | 63 | for (var hash in wikipedia[i]['hmac']) { | |
| 64 | + // FIPS does not support MD5. | ||
| 65 | + if (common.hasFipsCrypto && hash == 'md5' ) | ||
| 66 | + continue; | ||
| 64 | 67 | var result = crypto.createHmac(hash, wikipedia[i]['key']) | |
| 65 | 68 | .update(wikipedia[i]['data']) | |
| 66 | 69 | .digest('hex'); | |
@@ -346,12 +349,14 @@ var rfc2202_sha1 = [ | |||
| 346 | 349 | } | |
| 347 | 350 | ]; | |
| 348 | 351 | ||
| 349 | - for (var i = 0, l = rfc2202_md5.length; i < l; i++) { | ||
| 350 | - assert.equal(rfc2202_md5[i]['hmac'], | ||
| 351 | - crypto.createHmac('md5', rfc2202_md5[i]['key']) | ||
| 352 | - .update(rfc2202_md5[i]['data']) | ||
| 353 | - .digest('hex'), | ||
| 354 | - 'Test HMAC-MD5 : Test case ' + (i + 1) + ' rfc 2202'); | ||
| 352 | + if (!common.hasFipsCrypto) { | ||
| 353 | + for (var i = 0, l = rfc2202_md5.length; i < l; i++) { | ||
| 354 | + assert.equal(rfc2202_md5[i]['hmac'], | ||
| 355 | + crypto.createHmac('md5', rfc2202_md5[i]['key']) | ||
| 356 | + .update(rfc2202_md5[i]['data']) | ||
| 357 | + .digest('hex'), | ||
| 358 | + 'Test HMAC-MD5 : Test case ' + (i + 1) + ' rfc 2202'); | ||
| 359 | + } | ||
| 355 | 360 | } | |
| 356 | 361 | for (var i = 0, l = rfc2202_sha1.length; i < l; i++) { | |
| 357 | 362 | assert.equal(rfc2202_sha1[i]['hmac'], | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -26,19 +26,21 @@ Stream2buffer.prototype._write = function(data, encodeing, done) { | |||
| 26 | 26 | return done(null); | |
| 27 | 27 | }; | |
| 28 | 28 | ||
| 29 | - // Create an md5 hash of "Hallo world" | ||
| 30 | - var hasher1 = crypto.createHash('md5'); | ||
| 31 | - hasher1.pipe(new Stream2buffer(common.mustCall(function end(err, hash) { | ||
| 32 | - assert.equal(err, null); | ||
| 33 | - assert.equal(hash.toString('hex'), '06460dadb35d3d503047ce750ceb2d07'); | ||
| 34 | - }))); | ||
| 35 | - hasher1.end('Hallo world'); | ||
| 36 | - | ||
| 37 | - // Simpler check for unpipe, setEncoding, pause and resume | ||
| 38 | - crypto.createHash('md5').unpipe({}); | ||
| 39 | - crypto.createHash('md5').setEncoding('utf8'); | ||
| 40 | - crypto.createHash('md5').pause(); | ||
| 41 | - crypto.createHash('md5').resume(); | ||
| 29 | + if (!common.hasFipsCrypto) { | ||
| 30 | + // Create an md5 hash of "Hallo world" | ||
| 31 | + var hasher1 = crypto.createHash('md5'); | ||
| 32 | + hasher1.pipe(new Stream2buffer(common.mustCall(function end(err, hash) { | ||
| 33 | + assert.equal(err, null); | ||
| 34 | + assert.equal(hash.toString('hex'), '06460dadb35d3d503047ce750ceb2d07'); | ||
| 35 | + }))); | ||
| 36 | + hasher1.end('Hallo world'); | ||
| 37 | + | ||
| 38 | + // Simpler check for unpipe, setEncoding, pause and resume | ||
| 39 | + crypto.createHash('md5').unpipe({}); | ||
| 40 | + crypto.createHash('md5').setEncoding('utf8'); | ||
| 41 | + crypto.createHash('md5').pause(); | ||
| 42 | + crypto.createHash('md5').resume(); | ||
| 43 | + } | ||
| 42 | 44 | ||
| 43 | 45 | // Decipher._flush() should emit an error event, not an exception. | |
| 44 | 46 | var key = new Buffer('48fb56eb10ffeb13fc0ef551bbca3b1b', 'hex'), | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -14,7 +14,7 @@ var fs = require('fs'); | |||
| 14 | 14 | var options = { | |
| 15 | 15 | key: fs.readFileSync(common.fixturesDir + '/keys/agent2-key.pem'), | |
| 16 | 16 | cert: fs.readFileSync(common.fixturesDir + '/keys/agent2-cert.pem'), | |
| 17 | - ciphers: '-ALL:ECDHE-RSA-RC4-SHA', | ||
| 17 | + ciphers: '-ALL:ECDHE-RSA-AES128-SHA256', | ||
| 18 | 18 | ecdhCurve: 'prime256v1' | |
| 19 | 19 | }; | |
| 20 | 20 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -9,7 +9,7 @@ if (!common.hasCrypto) { | |||
| 9 | 9 | var tls = require('tls'); | |
| 10 | 10 | ||
| 11 | 11 | var fs = require('fs'); | |
| 12 | - var cipher_list = ['RC4-SHA', 'AES256-SHA']; | ||
| 12 | + var cipher_list = ['AES128-SHA256', 'AES256-SHA256']; | ||
| 13 | 13 | var cipher_version_pattern = /TLS|SSL/; | |
| 14 | 14 | var options = { | |
| 15 | 15 | key: fs.readFileSync(common.fixturesDir + '/keys/agent2-key.pem'), | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -19,7 +19,7 @@ var fs = require('fs'); | |||
| 19 | 19 | var options = { | |
| 20 | 20 | key: fs.readFileSync(common.fixturesDir + '/keys/agent2-key.pem'), | |
| 21 | 21 | cert: fs.readFileSync(common.fixturesDir + '/keys/agent2-cert.pem'), | |
| 22 | - ciphers: 'RC4-MD5' | ||
| 22 | + ciphers: 'DES-CBC3-SHA' | ||
| 23 | 23 | }; | |
| 24 | 24 | ||
| 25 | 25 | var reply = 'I AM THE WALRUS'; // something recognizable | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -20,27 +20,30 @@ assert.throws(function() { | |||
| 20 | 20 | }); | |
| 21 | 21 | ||
| 22 | 22 | var hashes = { | |
| 23 | - modp1 : 'b4b330a6ffeacfbd861e7fe2135b4431', | ||
| 24 | - modp2 : '7c3c5cad8b9f378d88f1dd64a4b6413a', | ||
| 25 | - modp5 : 'b1d2acc22c542e08669a5c5ae812694d', | ||
| 26 | - modp14 : '8d041538cecc1a7d915ba4b718f8ad20', | ||
| 27 | - modp15 : 'dc3b93def24e078c4fbf92d5e14ba69b', | ||
| 28 | - modp16 : 'a273487f46f699461f613b3878d9dfd9', | ||
| 29 | - modp17 : 'dc76e09935310348c492de9bd82014d0', | ||
| 30 | - modp18 : 'db08973bfd2371758a69db180871c993' | ||
| 23 | + modp1 : '630e9acd2cc63f7e80d8507624ba60ac0757201a', | ||
| 24 | + modp2 : '18f7aa964484137f57bca64b21917a385b6a0b60', | ||
| 25 | + modp5 : 'c0a8eec0c2c8a5ec2f9c26f9661eb339a010ec61', | ||
| 26 | + modp14 : 'af5455606fe74cec49782bb374e4c63c9b1d132c', | ||
| 27 | + modp15 : '7bdd39e5cdbb9748113933e5c2623b559c534e74', | ||
| 28 | + modp16 : 'daea5277a7ad0116e734a8e0d2f297ef759d1161', | ||
| 29 | + modp17 : '3b62aaf0142c2720f0bf26a9589b0432c00eadc1', | ||
| 30 | + modp18 : 'a870b491bbbec9b131ae9878d07449d32e54f160' | ||
| 31 | 31 | }; | |
| 32 | 32 | ||
| 33 | 33 | for (var name in hashes) { | |
| 34 | 34 | var group = crypto.getDiffieHellman(name); | |
| 35 | 35 | var private_key = group.getPrime('hex'); | |
| 36 | 36 | var hash1 = hashes[name]; | |
| 37 | - var hash2 = crypto.createHash('md5') | ||
| 37 | + var hash2 = crypto.createHash('sha1') | ||
| 38 | 38 | .update(private_key.toUpperCase()).digest('hex'); | |
| 39 | 39 | assert.equal(hash1, hash2); | |
| 40 | 40 | assert.equal(group.getGenerator('hex'), '02'); | |
| 41 | 41 | } | |
| 42 | 42 | ||
| 43 | 43 | for (var name in hashes) { | |
| 44 | + // modp1 is 768 bits, FIPS requires >= 1024 | ||
| 45 | + if (name == 'modp1' && common.hasFipsCrypto) | ||
| 46 | + continue; | ||
| 44 | 47 | var group1 = crypto.getDiffieHellman(name); | |
| 45 | 48 | var group2 = crypto.getDiffieHellman(name); | |
| 46 | 49 | group1.generateKeys(); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -10,9 +10,10 @@ var tls = require('tls'); | |||
| 10 | 10 | ||
| 11 | 11 | var fs = require('fs'); | |
| 12 | 12 | var nconns = 0; | |
| 13 | - // test only in TLSv1 to use DES which is no longer supported TLSv1.2 | ||
| 14 | - // to be safe when the default method is updated in the future | ||
| 15 | - var SSL_Method = 'TLSv1_method'; | ||
| 13 | + | ||
| 14 | + // We explicitly set TLS version to 1.2 so as to be safe when the | ||
| 15 | + // default method is updated in the future | ||
| 16 | + var SSL_Method = 'TLSv1_2_method'; | ||
| 16 | 17 | var localhost = '127.0.0.1'; | |
| 17 | 18 | ||
| 18 | 19 | process.on('exit', function() { | |
@@ -24,7 +25,8 @@ function test(honorCipherOrder, clientCipher, expectedCipher, cb) { | |||
| 24 | 25 | secureProtocol: SSL_Method, | |
| 25 | 26 | key: fs.readFileSync(common.fixturesDir + '/keys/agent2-key.pem'), | |
| 26 | 27 | cert: fs.readFileSync(common.fixturesDir + '/keys/agent2-cert.pem'), | |
| 27 | - ciphers: 'DES-CBC-SHA:AES256-SHA:RC4-SHA:ECDHE-RSA-AES256-SHA', | ||
| 28 | + ciphers: 'AES256-SHA256:AES128-GCM-SHA256:AES128-SHA256:' + | ||
| 29 | + 'ECDHE-RSA-AES128-GCM-SHA256', | ||
| 28 | 30 | honorCipherOrder: !!honorCipherOrder | |
| 29 | 31 | }; | |
| 30 | 32 | ||
@@ -57,37 +59,40 @@ test1(); | |||
| 57 | 59 | ||
| 58 | 60 | function test1() { | |
| 59 | 61 | // Client has the preference of cipher suites by default | |
| 60 | - test(false, 'AES256-SHA:DES-CBC-SHA:RC4-SHA', 'AES256-SHA', test2); | ||
| 62 | + test(false, 'AES128-GCM-SHA256:AES256-SHA256:AES128-SHA256', | ||
| 63 | + 'AES128-GCM-SHA256', test2); | ||
| 61 | 64 | } | |
| 62 | 65 | ||
| 63 | 66 | function test2() { | |
| 64 | - // Server has the preference of cipher suites where DES-CBC-SHA is in | ||
| 65 | - // the first. | ||
| 66 | - test(true, 'AES256-SHA:DES-CBC-SHA:RC4-SHA', 'DES-CBC-SHA', test3); | ||
| 67 | + // Server has the preference of cipher suites, and AES256-SHA256 is | ||
| 68 | + // the server's top choice. | ||
| 69 | + test(true, 'AES128-GCM-SHA256:AES256-SHA256:AES128-SHA256', | ||
| 70 | + 'AES256-SHA256', test3); | ||
| 67 | 71 | } | |
| 68 | 72 | ||
| 69 | 73 | function test3() { | |
| 70 | - // Server has the preference of cipher suites. RC4-SHA is given | ||
| 71 | - // higher priority over DES-CBC-SHA among client cipher suites. | ||
| 72 | - test(true, 'RC4-SHA:AES256-SHA', 'AES256-SHA', test4); | ||
| 74 | + // Server has the preference of cipher suites. AES128-GCM-SHA256 is given | ||
| 75 | + // higher priority over AES128-SHA256 among client cipher suites. | ||
| 76 | + test(true, 'AES128-SHA256:AES128-GCM-SHA256', 'AES128-GCM-SHA256', test4); | ||
| 77 | + | ||
| 73 | 78 | } | |
| 74 | 79 | ||
| 75 | 80 | function test4() { | |
| 76 | - // As client has only one cipher, server has no choice in regardless | ||
| 81 | + // As client has only one cipher, server has no choice, irrespective | ||
| 77 | 82 | // of honorCipherOrder. | |
| 78 | - test(true, 'RC4-SHA', 'RC4-SHA', test5); | ||
| 83 | + test(true, 'AES128-SHA256', 'AES128-SHA256', test5); | ||
| 79 | 84 | } | |
| 80 | 85 | ||
| 81 | 86 | function test5() { | |
| 82 | - // Client did not explicitly set ciphers. Ensure that client defaults to | ||
| 83 | - // sane ciphers. Even though server gives top priority to DES-CBC-SHA | ||
| 84 | - // it should not be negotiated because it's not in default client ciphers. | ||
| 85 | - test(true, null, 'AES256-SHA', test6); | ||
| 87 | + // Client did not explicitly set ciphers and client offers | ||
| 88 | + // tls.DEFAULT_CIPHERS. All ciphers of the server are included in the | ||
| 89 | + // default list so the negotiated cipher is selected according to the | ||
| 90 | + // server's top preference of AES256-SHA256. | ||
| 91 | + test(true, null, 'AES256-SHA256', test6); | ||
| 86 | 92 | } | |
| 87 | 93 | ||
| 88 | 94 | function test6() { | |
| 89 | 95 | // Ensure that `tls.DEFAULT_CIPHERS` is used | |
| 90 | - SSL_Method = 'TLSv1_2_method'; | ||
| 91 | - tls.DEFAULT_CIPHERS = 'ECDHE-RSA-AES256-SHA'; | ||
| 92 | - test(true, null, 'ECDHE-RSA-AES256-SHA'); | ||
| 96 | + tls.DEFAULT_CIPHERS = 'ECDHE-RSA-AES128-GCM-SHA256'; | ||
| 97 | + test(true, null, 'ECDHE-RSA-AES128-GCM-SHA256'); | ||
| 93 | 98 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments