Browse Source

test: add test for invalid DSA key size

Check that invalid DSA key sizes are rejected in FIPS mode.

PR-URL: https://github.com/nodejs/node/pull/3756
Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com>
Reviewed-By: Shigeki Ohtsu <ohtsu@iij.ad.jp>
Reviewed-By: James M Snell <jasnell@gmail.com>
v5.x
Stefan Budeanu 9 years ago
committed by Jeremiah Senkpiel
parent
commit
828b786e48
  1. 11
      test/fixtures/keys/Makefile
  2. 9
      test/fixtures/keys/dsa1025.pem
  3. 12
      test/fixtures/keys/dsa_private_1025.pem
  4. 12
      test/fixtures/keys/dsa_public_1025.pem
  5. 24
      test/parallel/test-dsa-fips-invalid-key.js

11
test/fixtures/keys/Makefile

@ -1,4 +1,4 @@
all: agent1-cert.pem agent2-cert.pem agent3-cert.pem agent4-cert.pem agent5-cert.pem ca2-crl.pem ec-cert.pem dh512.pem dh1024.pem dh2048.pem rsa_private_1024.pem rsa_private_2048.pem rsa_private_4096.pem rsa_public_1024.pem rsa_public_2048.pem rsa_public_4096.pem
all: agent1-cert.pem agent2-cert.pem agent3-cert.pem agent4-cert.pem agent5-cert.pem ca2-crl.pem ec-cert.pem dh512.pem dh1024.pem dh2048.pem dsa1025.pem dsa_private_1025.pem dsa_public_1025.pem rsa_private_1024.pem rsa_private_2048.pem rsa_private_4096.pem rsa_public_1024.pem rsa_public_2048.pem rsa_public_4096.pem
#
@ -267,6 +267,15 @@ dh1024.pem:
dh2048.pem:
openssl dhparam -out dh2048.pem 2048
dsa1025.pem:
openssl dsaparam -out dsa1025.pem 1025
dsa_private_1025.pem:
openssl gendsa -out dsa_private_1025.pem dsa1025.pem
dsa_public_1025.pem:
openssl dsa -in dsa_private_1025.pem -pubout -out dsa_public_1025.pem
rsa_private_1024.pem:
openssl genrsa -out rsa_private_1024.pem 1024

9
test/fixtures/keys/dsa1025.pem

@ -0,0 +1,9 @@
-----BEGIN DSA PARAMETERS-----
MIIBLgKBiQCtjGXOH3Rq+lM09nwe6nbShOduCyfj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+CInYqsDR2ha+UcwXmGJSg==
-----END DSA PRIVATE KEY-----

12
test/fixtures/keys/dsa_public_1025.pem

@ -0,0 +1,12 @@
-----BEGIN PUBLIC KEY-----
MIIBzTCCATsGByqGSM44BAEwggEuAoGJAK2MZc4fdGr6UzT2fB7qdtKE524LJ+OB
mGAxnZZ9jo9gtbeA2eE1hPvzytlsQJzIqXLNECkWCz0ox+KpZ9YiFCf4WaiWZ5Q1
1FemaQbIkCpjrcahsjxLUmfFhvB0fs+xXUjAznrKWuel1QOFIfv5j3muAQhRdf04
dLnTeDMUUQcKZCXX9FLtDGkCFQCmZs1S9GKx2OfKOEMrpE7elp833QKBiFAscn6q
r6fEtf+WpAv+0IVjc/oOVhzd7NPchz7caEQwxcwEwn5ZGZGQJbm+HWCtDItVr8wt
a9iA2ShQA7x4YSVyWhR6ujyblOndsUCsSpvysldZgzWwCWeX9jS4WnDUDIcu5kLb
rP5JJ4NtX1ES3PXgSSeQVeSy7hA3nllAqiIG/ZwUMywh/1sDgYsAAoGHFPpl8uRj
7sNjsnIPPI9CuqlIoZXFNXeMX9Yu7T3s5mn5Q2ATcgnryDXwqpqle630wy1LZjjm
tyE84oVJd4W6YTlzHNwIv2qlymMzWBE5+BrRXtqIndvkaWJRSUwtZ7XPPeeCzqR5
uXRAsy54azoFDoisuOO5dVOmVZERfp4Up+Duvws5+Gq2
-----END PUBLIC KEY-----

24
test/parallel/test-dsa-fips-invalid-key.js

@ -0,0 +1,24 @@
'use strict';
var common = require('../common');
var assert = require('assert');
if (!common.hasFipsCrypto) {
console.log('1..0 # Skipped: node compiled without FIPS OpenSSL.');
return;
}
var crypto = require('crypto');
var fs = require('fs');
var input = 'hello';
var dsapub = fs.readFileSync(common.fixturesDir +
'/keys/dsa_public_1025.pem');
var dsapri = fs.readFileSync(common.fixturesDir +
'/keys/dsa_private_1025.pem');
var sign = crypto.createSign('DSS1');
sign.update(input);
assert.throws(function() {
sign.sign(dsapri);
}, /PEM_read_bio_PrivateKey failed/);
Loading…
Cancel
Save