diff --git a/test/fixtures/keys/I_AM_THE_WALRUS_sha256_signature_signedby_rsa_private_b.sha256 b/test/fixtures/keys/I_AM_THE_WALRUS_sha256_signature_signedby_rsa_private_b.sha256 new file mode 100644 index 00000000000000..59eb6c7c8831cc Binary files /dev/null and b/test/fixtures/keys/I_AM_THE_WALRUS_sha256_signature_signedby_rsa_private_b.sha256 differ diff --git a/test/fixtures/keys/Makefile b/test/fixtures/keys/Makefile index 85253ad967b0d5..c51991575edcf7 100644 --- a/test/fixtures/keys/Makefile +++ b/test/fixtures/keys/Makefile @@ -31,6 +31,16 @@ all: \ ec-cert.pem \ ec.pfx \ fake-cnnic-root-cert.pem \ + rsa_private.pem \ + rsa_private_encrypted.pem \ + rsa_private_pkcs8.pem \ + rsa_private_pkcs8_bad.pem \ + rsa_public.pem \ + rsa_public_sha1_signature_signedby_rsa_private.sha1 \ + rsa_public_sha1_signature_signedby_rsa_private_pkcs8.sha1 \ + rsa_private_b.pem \ + I_AM_THE_WALRUS_sha256_signature_signedby_rsa_private_b.sha256 \ + rsa_public_b.pem \ rsa_private_1024.pem \ rsa_private_2048.pem \ rsa_private_4096.pem \ @@ -566,6 +576,36 @@ dsa_private_encrypted_1025.pem: dsa_public_1025.pem: openssl dsa -in dsa_private_1025.pem -pubout -out dsa_public_1025.pem +rsa_private.pem: + openssl genrsa -out rsa_private.pem 2048 + +rsa_private_encrypted.pem: rsa_private.pem + openssl rsa -aes256 -in rsa_private.pem -passout 'pass:password' -out rsa_private_encrypted.pem + +rsa_private_pkcs8.pem: rsa_private.pem + openssl pkcs8 -topk8 -inform PEM -outform PEM -in rsa_private.pem -out rsa_private_pkcs8.pem -nocrypt + +rsa_private_pkcs8_bad.pem: rsa_private_pkcs8.pem + sed 's/PRIVATE/RSA PRIVATE/g' rsa_private_pkcs8.pem > rsa_private_pkcs8_bad.pem + +rsa_public.pem: rsa_private.pem + openssl rsa -in rsa_private.pem -pubout -out rsa_public.pem + +rsa_public_sha1_signature_signedby_rsa_private.sha1: rsa_public.pem rsa_private.pem + openssl dgst -sha1 -sign rsa_private.pem -out rsa_public_sha1_signature_signedby_rsa_private.sha1 rsa_public.pem + +rsa_public_sha1_signature_signedby_rsa_private_pkcs8.sha1: rsa_public.pem rsa_private_pkcs8.pem + openssl dgst -sha1 -sign rsa_private_pkcs8.pem -out rsa_public_sha1_signature_signedby_rsa_private_pkcs8.sha1 rsa_public.pem + +rsa_private_b.pem: + openssl genrsa -out rsa_private_b.pem 2048 + +I_AM_THE_WALRUS_sha256_signature_signedby_rsa_private_b.sha256: rsa_private_b.pem + echo -n "I AM THE WALRUS" | openssl dgst -sha256 -sign rsa_private_b.pem -out I_AM_THE_WALRUS_sha256_signature_signedby_rsa_private_b.sha256 + +rsa_public_b.pem: rsa_private_b.pem + openssl rsa -in rsa_private_b.pem -pubout -out rsa_public_b.pem + rsa_private_1024.pem: openssl genrsa -out rsa_private_1024.pem 1024 diff --git a/test/fixtures/keys/rsa_private.pem b/test/fixtures/keys/rsa_private.pem new file mode 100644 index 00000000000000..215e5cc5131251 --- /dev/null +++ b/test/fixtures/keys/rsa_private.pem @@ -0,0 +1,27 @@ +-----BEGIN RSA PRIVATE KEY----- +MIIEpQIBAAKCAQEAt9xYiIonscC3vz/A2ceR7KhZZlDu/5bye53nCVTcKnWd2seY +6UAdKersX6njr83Dd5OVe1BW/wJvp5EjWTAGYbFswlNmeD44edEGM939B6Lq+/8i +BkrTi8mGN4YCytivE24YI0D4XZMPfkLSpab2y/Hy4DjQKBq1ThZ0UBnK+9IhX37J +u/ZoGYSlTIGIhzyaiYBh7wrZBoPczIEu6et/kN2VnnbRUtkYTF97ggcv5h+hDpUQ +jQW0ZgOMcTc8n+RkGpIt0/iM/bTjI3Tz/gsFdi6hHcpZgbopPL630296iByyigQC +PJVzdusFrQN5DeC+zT/nGypQkZanLb4ZspSx9QIDAQABAoIBAQCS2erYu8gyoGPi +3E/zYgQ6ishFAZWzDWSFubwD5wSm4SSAzvViL/RbO6kqS25xR569DmLRiH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XWPTAlazdnpYUyw/CzogM/PN+qNwMRXn5 +uXFFhmlP2mVg2EdELTahXch8kWqHaCSX53yvqCtRKu/j76V31TfQZGM= +-----END RSA PRIVATE KEY----- diff --git a/test/fixtures/keys/rsa_private_b.pem b/test/fixtures/keys/rsa_private_b.pem new file mode 100644 index 00000000000000..96d82ae2e24a3c --- /dev/null +++ b/test/fixtures/keys/rsa_private_b.pem @@ -0,0 +1,27 @@ +-----BEGIN RSA PRIVATE KEY----- +MIIEpAIBAAKCAQEAyb1grrN+29fxeeEbTaSEja6TKDTpT/WXnqrFCS+h7IYcnDoA +VwcsPU5FZeUPvLKMzi9NHSJ34LQCurqHgH8X+cw0YT3gdYS/7qoQiXs+zKv615Nc +ttD3xlQLceY+NwznoPXyyZwOeZqyU5Hiqbrqu6hdr6gQYogMNLn2NxBW2pGegd6+ +ZGMCX3+/BtMP/6tXmttYjY+yhN2SrGz5cKhWpcHiC6X+B7uCKoKZy+t2jUxYVKUw +Wr1ZuM8kpSnuVCcv1OoMGEimEHA7v/eaF/y+z/VdQ4Y88GhTnVN4KbtgZ+o9Pohj +xLFU62VeTALixU5mPQKSgSICKfjev0FUUurF6wIDAQABAoIBAQCs11C/PM/iYNfl +mSSAWAStMrWni/Wc6QhXC2422ZV8hMZ8XwEtjtqrR6UTkLXz8HHMsR/7Zy2X2gJA +o1E2mS0ceoUiDxaA+RRL0W7Lq0j5qBsImZukkdLHG/iWRDJnjenhsParHsYUD6Lb +ELFGw/safjyOI4quMGtsvSqisKAJL5ZCPD5JHLhnNP8HXT6icSZrsqGhunb2tsa+ +Ogcx1+bZzqdTsbvXdbw07Lnd/LRU0NDhjeEVl4J2yFNYY+OIj7/qrxSnZnGLLG0Y +DFxiD+HCMvTBSooqvWI6FAipfyCGjUznGsVaRv7TuzHPuKE4LtbIC/Ac3Q10rKWq +PmHALir5AoGBAOhGUCToWfYnj2zH0GIZQxnkrv9iRqmdGeCDX6ZM00Bs5tASnRo0 +o90UtLbhWjHe1PKRKFyD4I7a8iIWxcWWun2XHgOtItctPN+lbjpTHTyE2yA1iZhe +dKCV3bAo4t+puKrPkZmaBqFD/fQx7DNxYdRERa1giiZGhlMUN3l7/S21AoGBAN5Y +nZ68NkTgklk4YBzsxwsMpQbgbihyG79gtDFxWonxZUQ29EsL01yd30pJNhg1LxDN +0fADfHVzkZ3qYz9knge9a75Yk8UBM3DM+xu+DRkjKhK5mPX5oLvj6061u3Scs6tj +orpU/mV1amz5gqrkefMaelsdHRuGGZQVx9KTV2kfAoGBAN7EAL1E8nK4Qj/r6xkK +bWZ6ArQABxFJELZYiPWvnLOfPka0c2PctIOmBiOXQa+urMDvIqyH9mhL6Al1mbwE +8VreAfU4qb+BLW649FyPteyC5r2fWxV9EZGp6fG3ZM9psShw5o1QQaeM1BTNhGFa +Dp9L0x+TBSvsW4t2SjYDCjA5AoGASzxxGWVWd7gFzWrmGuOD9pkwvkLzA3yZJwjx +8EkK+eJVAeAWic5WluBUzi43v7k/U9BRWYXUd2nDvEuziZ/iWXwfGSmf1umxHlo+ +HgURKZBcjDmBKLpvSSS2WsvjwnHD2hq81ZAtBOfWO0myjWECYuByxqHzV3zo6tLz +6q0wxsECgYA26twPrAoRqvfvPnNj6o0LrsE39Tj6jHIVijT7Lbcf2xVnaDiQ18PQ +RC6Tgkz5KZf8GKfMRMA3WopGn9QE2luI4RLIbhLozEDrkk2L7wSYqI9DZ1Hd26wf +v3+3jdpsXkzHwWYz1a2+FhCF5mJJRQl6kd/B0wu00vdfwviK9OVO7w== +-----END RSA PRIVATE KEY----- diff --git a/test/fixtures/keys/rsa_private_encrypted.pem b/test/fixtures/keys/rsa_private_encrypted.pem new file mode 100644 index 00000000000000..f1914289ec4f7f --- /dev/null +++ b/test/fixtures/keys/rsa_private_encrypted.pem @@ -0,0 +1,30 @@ +-----BEGIN RSA PRIVATE KEY----- +Proc-Type: 4,ENCRYPTED +DEK-Info: AES-256-CBC,DB3D20E60E8FDC3356BD79712FF8EF7E + +K+vu0U3IFTJBBi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DIf0BVtm9U4BJoOkPStFIfF +Kof7OVv7izyL8R/GIil9VQs9ftwkIUPeXx2Hw0bE3HJ3C8K4+mbLg3tKhGnBDU5Z +Xm5mLHoCRBa3ZRFWZtigX7POszdLAzftYo8o65Be4OtPS+tQAORk9gHsXATv7dDB +OGw61x5KA55LHVHhWaRvu3J8E7nhxw0q/HskyZhDC+Y+Xs6vmQSb4nO4ET4NYX1P +m3PMdgGoqRDJ2jZw4eoQdRKCM0EHSepSAYpO1tcAXhPZS4ITogoRgPpVgOebEQUL +nKNeNu/BxMSH/IH15jjDLF3TiEoguF9xdTaCxIBzE1SFpVO0u9m9vXpWdPThVgsb +VcEI487p7v9iImP3BYPT8ZYvytC26EH0hyOrwhahTvTb4vXghkLIyvPUg1lZHc6e +aPHb2AzYAHLnp/ehDQGKWrCOJ1JE2vBv8ZkLa+XZo7YASXBRZitPOMlvykEyzxmR +QAmNhKGvFmeM2mmHAp0aC03rgF3lxNsXQ1CyfEdq3UV9ReSnttq8gtrJfCwxV+wY +-----END RSA PRIVATE KEY----- diff --git a/test/fixtures/keys/rsa_private_pkcs8.pem b/test/fixtures/keys/rsa_private_pkcs8.pem new file mode 100644 index 00000000000000..cd274ae6d9071d --- /dev/null +++ b/test/fixtures/keys/rsa_private_pkcs8.pem @@ -0,0 +1,28 @@ +-----BEGIN PRIVATE KEY----- +MIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQC33FiIiiexwLe/ +P8DZx5HsqFlmUO7/lvJ7necJVNwqdZ3ax5jpQB0p6uxfqeOvzcN3k5V7UFb/Am+n +kSNZMAZhsWzCU2Z4Pjh50QYz3f0Hour7/yIGStOLyYY3hgLK2K8TbhgjQPhdkw9+ +QtKlpvbL8fLgONAoGrVOFnRQGcr70iFffsm79mgZhKVMgYiHPJqJgGHvCtkGg9zM +gS7p63+Q3ZWedtFS2RhMX3uCBy/mH6EOlRCNBbRmA4xxNzyf5GQaki3T+Iz9tOMj +dPP+CwV2LqEd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NcU90bQbeHNCi/H/19qOJFXgNaCE +sd5P3DMl9lptFGIjRVBHjvbfTQBUR5fi+BusMGfrTQKBgQCTtzMEJP2sef883AJr +XuGVPLzwLi9eTBvPzc5r5pfkvh7mDDmWFxHZm5kctvavqgy32uUPsQgMi1Kz67bU +s5dY9MCVrN2elhTLD8LOiAz8836o3AxFefm5cUWGaU/aZWDYR0QtNqFdyHyRaodo +JJfnfK+oK1Eq7+PvpXfVN9BkYw== +-----END PRIVATE KEY----- diff --git a/test/fixtures/keys/rsa_private_pkcs8_bad.pem b/test/fixtures/keys/rsa_private_pkcs8_bad.pem new file mode 100644 index 00000000000000..ca36972e3a6503 --- /dev/null +++ b/test/fixtures/keys/rsa_private_pkcs8_bad.pem @@ -0,0 +1,28 @@ +-----BEGIN RSA PRIVATE KEY----- +MIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQC33FiIiiexwLe/ +P8DZx5HsqFlmUO7/lvJ7necJVNwqdZ3ax5jpQB0p6uxfqeOvzcN3k5V7UFb/Am+n +kSNZMAZhsWzCU2Z4Pjh50QYz3f0Hour7/yIGStOLyYY3hgLK2K8TbhgjQPhdkw9+ +QtKlpvbL8fLgONAoGrVOFnRQGcr70iFffsm79mgZhKVMgYiHPJqJgGHvCtkGg9zM +gS7p63+Q3ZWedtFS2RhMX3uCBy/mH6EOlRCNBbRmA4xxNzyf5GQaki3T+Iz9tOMj +dPP+CwV2LqEdylmBuik8vrfTb3qIHLKKBAI8lXN26wWtA3kN4L7NP+cbKlCRlqct +vhmylLH1AgMBAAECggEBAJLZ6ti7yDKgY+LcT/NiBDqKyEUBlbMNZIW5vAPnBKbh +JIDO9WIv9Fs7qSpLbnFHnr0OYtGIfMPXtUiYkyw0QJSc+upHZMvbno4llpes0eHc +jWVTBWETON4oywvj/Kz53vRc9eiKhxVuVWyagNcQgYSprjzLA+9UTcWeB67Guyrf +8YJUE2LC23RiMA5nGYoSHfVRl0c75gj7A0X9nwpAI+xw3kc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em b/test/fixtures/keys/rsa_public.pem new file mode 100644 index 00000000000000..8c30cfa52d47af --- /dev/null +++ b/test/fixtures/keys/rsa_public.pem @@ -0,0 +1,9 @@ +-----BEGIN PUBLIC KEY----- +MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAt9xYiIonscC3vz/A2ceR +7KhZZlDu/5bye53nCVTcKnWd2seY6UAdKersX6njr83Dd5OVe1BW/wJvp5EjWTAG +YbFswlNmeD44edEGM939B6Lq+/8iBkrTi8mGN4YCytivE24YI0D4XZMPfkLSpab2 +y/Hy4DjQKBq1ThZ0UBnK+9IhX37Ju/ZoGYSlTIGIhzyaiYBh7wrZBoPczIEu6et/ +kN2VnnbRUtkYTF97ggcv5h+hDpUQjQW0ZgOMcTc8n+RkGpIt0/iM/bTjI3Tz/gsF +di6hHcpZgbopPL630296iByyigQCPJVzdusFrQN5DeC+zT/nGypQkZanLb4ZspSx +9QIDAQAB +-----END PUBLIC KEY----- diff --git a/test/fixtures/keys/rsa_public_b.pem b/test/fixtures/keys/rsa_public_b.pem new file mode 100644 index 00000000000000..bce0804617fcb6 --- /dev/null +++ b/test/fixtures/keys/rsa_public_b.pem @@ -0,0 +1,9 @@ +-----BEGIN PUBLIC KEY----- +MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAyb1grrN+29fxeeEbTaSE +ja6TKDTpT/WXnqrFCS+h7IYcnDoAVwcsPU5FZeUPvLKMzi9NHSJ34LQCurqHgH8X ++cw0YT3gdYS/7qoQiXs+zKv615NcttD3xlQLceY+NwznoPXyyZwOeZqyU5Hiqbrq +u6hdr6gQYogMNLn2NxBW2pGegd6+ZGMCX3+/BtMP/6tXmttYjY+yhN2SrGz5cKhW +pcHiC6X+B7uCKoKZy+t2jUxYVKUwWr1ZuM8kpSnuVCcv1OoMGEimEHA7v/eaF/y+ +z/VdQ4Y88GhTnVN4KbtgZ+o9PohjxLFU62VeTALixU5mPQKSgSICKfjev0FUUurF +6wIDAQAB +-----END PUBLIC KEY----- diff --git a/test/fixtures/keys/rsa_public_sha1_signature_signedby_rsa_private.sha1 b/test/fixtures/keys/rsa_public_sha1_signature_signedby_rsa_private.sha1 new file mode 100644 index 00000000000000..0b5947929a6895 --- /dev/null +++ b/test/fixtures/keys/rsa_public_sha1_signature_signedby_rsa_private.sha1 @@ -0,0 +1,2 @@ +�yf�F���4}�x=�e Z'`a%�Z>Yt�mxd4E�c(�9��ȴ� �k��L�����2��+��q�Si��2:���[dfj/���5П�9�O<���8��'. O��eL�8���2�t�ӟ/��3�K����,��Њ�l��Zڅ�t�[��4�f��#�* �Y� ��餡w/���2ߗfꢅ�X��h�aYt�mxd4E�c(�9��ȴ� �k��L�����2��+��q�Si��2:���[dfj/���5П�9�O<���8��'. O��eL�8���2�t�ӟ/��3�K����,��Њ�l��Zڅ�t�[��4�f��#�* �Y� ��餡w/���2ߗfꢅ�X��h�a { // Test RSA signing and verification // { - const privateKey = fixtures.readSync('test_rsa_privkey_2.pem'); - const publicKey = fixtures.readSync('test_rsa_pubkey_2.pem'); + const privateKey = fixtures.readKey('rsa_private_b.pem'); + const publicKey = fixtures.readKey('rsa_public_b.pem'); const input = 'I AM THE WALRUS'; - const signature = - '79d59d34f56d0e94aa6a3e306882b52ed4191f07521f25f505a078dc2f89' + - '396e0c8ac89e996fde5717f4cb89199d8fec249961fcb07b74cd3d2a4ffa' + - '235417b69618e4bcd76b97e29975b7ce862299410e1b522a328e44ac9bb2' + - '8195e0268da7eda23d9825ac43c724e86ceeee0d0d4465678652ccaf6501' + - '0ddfb299bedeb1ad'; + const signature = fixtures.readKey( + 'I_AM_THE_WALRUS_sha256_signature_signedby_rsa_private_b.sha256', + 'hex' + ); const sign = crypto.createSign('SHA256'); sign.update(input); const output = sign.sign(privateKey, 'hex'); - assert.strictEqual(signature, output); + assert.strictEqual(output, signature); const verify = crypto.createVerify('SHA256'); verify.update(input); @@ -263,7 +260,7 @@ assert.throws(() => { sign2.update(input); const output2 = sign2.sign(privateKey, 'hex'); - assert.strictEqual(signature, output2); + assert.strictEqual(output2, signature); const verify2 = crypto.createVerify('SHA256'); verify2.update(input); diff --git a/test/parallel/test-crypto.js b/test/parallel/test-crypto.js index 1952f8908acb03..86c617815f2726 100644 --- a/test/parallel/test-crypto.js +++ b/test/parallel/test-crypto.js @@ -224,17 +224,12 @@ assert.throws(function() { }); assert.throws(function() { - // The correct header inside `test_bad_rsa_privkey.pem` should have been + // The correct header inside `rsa_private_pkcs8_bad.pem` should have been // -----BEGIN PRIVATE KEY----- and -----END PRIVATE KEY----- // instead of // -----BEGIN RSA PRIVATE KEY----- and -----END RSA PRIVATE KEY----- - // It is generated in this way: - // $ openssl genrsa -out mykey.pem 512; - // $ openssl pkcs8 -topk8 -inform PEM -outform PEM -in mykey.pem \ - // -out private_key.pem -nocrypt; - // Then open private_key.pem and change its header and footer. - const sha1_privateKey = fixtures.readSync('test_bad_rsa_privkey.pem', - 'ascii'); + const sha1_privateKey = fixtures.readKey('rsa_private_pkcs8_bad.pem', + 'ascii'); // This would inject errors onto OpenSSL's error stack crypto.createSign('sha1').sign(sha1_privateKey); }, (err) => {