Skip to content

Commit

Permalink
test: update OpenSSL 3.0.0-alpha15 error messages
Browse files Browse the repository at this point in the history
PR-URL: #38451
Fixes: #38373
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
danbev authored and richardlau committed May 14, 2021
1 parent 786ed4d commit db5ee23
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 18 deletions.
2 changes: 1 addition & 1 deletion test/parallel/test-crypto-dh-stateless.js
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ assert.throws(() => {
crypto.generateKeyPairSync('ec', { namedCurve: not256k1 }));
}, common.hasOpenSSL3 ? {
name: 'Error',
code: 'ERR_OSSL_EC_INCOMPATIBLE_OBJECTS'
code: 'ERR_OSSL_MISMATCHING_SHARED_PARAMETERS'
} : {
name: 'Error',
code: 'ERR_OSSL_EVP_DIFFERENT_PARAMETERS'
Expand Down
10 changes: 7 additions & 3 deletions test/parallel/test-crypto-key-objects.js
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,10 @@ const privateDsa = fixtures.readKey('dsa_private_encrypted_1025.pem',
type: 'pkcs1'
});
createPrivateKey({ key, format: 'der', type: 'pkcs1' });
}, {
}, common.hasOpenSSL3 ? {
message: /error:1E08010C:DECODER routines::unsupported/,
library: 'DECODER routines'
} : {
message: /asn1 encoding/,
library: 'asn1 encoding routines'
});
Expand Down Expand Up @@ -514,7 +517,8 @@ const privateDsa = fixtures.readKey('dsa_private_encrypted_1025.pem',
// Reading an encrypted key without a passphrase should fail.
assert.throws(() => createPrivateKey(privateDsa), common.hasOpenSSL3 ? {
name: 'Error',
message: 'Failed to read private key',
message: 'error:07880109:common libcrypto routines::interrupted or ' +
'cancelled',
} : {
name: 'TypeError',
code: 'ERR_MISSING_PASSPHRASE',
Expand All @@ -540,7 +544,7 @@ const privateDsa = fixtures.readKey('dsa_private_encrypted_1025.pem',
passphrase: Buffer.alloc(1024, 'a')
}), {
message: common.hasOpenSSL3 ?
'Failed to read private key' :
'error:07880109:common libcrypto routines::interrupted or cancelled' :
/bad decrypt/
});

Expand Down
15 changes: 10 additions & 5 deletions test/parallel/test-crypto-keygen.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,8 @@ const sec1EncExp = (cipher) => getRegExpForPEM('EC PRIVATE KEY', cipher);
const publicKey = { key: publicKeyDER, ...publicKeyEncoding };
const expectedError = common.hasOpenSSL3 ? {
name: 'Error',
message: 'Failed to read private key'
message: 'error:07880109:common libcrypto routines::interrupted or ' +
'cancelled'
} : {
name: 'TypeError',
code: 'ERR_MISSING_PASSPHRASE',
Expand Down Expand Up @@ -477,7 +478,8 @@ const sec1EncExp = (cipher) => getRegExpForPEM('EC PRIVATE KEY', cipher);
// Since the private key is encrypted, signing shouldn't work anymore.
assert.throws(() => testSignVerify(publicKey, privateKey),
common.hasOpenSSL3 ? {
message: 'Failed to read private key'
message: 'error:07880109:common libcrypto ' +
'routines::interrupted or cancelled'
} : {
name: 'TypeError',
code: 'ERR_MISSING_PASSPHRASE',
Expand Down Expand Up @@ -510,7 +512,8 @@ const sec1EncExp = (cipher) => getRegExpForPEM('EC PRIVATE KEY', cipher);
// Since the private key is encrypted, signing shouldn't work anymore.
assert.throws(() => testSignVerify(publicKey, privateKey),
common.hasOpenSSL3 ? {
message: 'Failed to read private key'
message: 'error:07880109:common libcrypto ' +
'routines::interrupted or cancelled'
} : {
name: 'TypeError',
code: 'ERR_MISSING_PASSPHRASE',
Expand Down Expand Up @@ -546,7 +549,8 @@ const sec1EncExp = (cipher) => getRegExpForPEM('EC PRIVATE KEY', cipher);
// Since the private key is encrypted, signing shouldn't work anymore.
assert.throws(() => testSignVerify(publicKey, privateKey),
common.hasOpenSSL3 ? {
message: 'Failed to read private key'
message: 'error:07880109:common libcrypto ' +
'routines::interrupted or cancelled'
} : {
name: 'TypeError',
code: 'ERR_MISSING_PASSPHRASE',
Expand Down Expand Up @@ -583,7 +587,8 @@ const sec1EncExp = (cipher) => getRegExpForPEM('EC PRIVATE KEY', cipher);
// Since the private key is encrypted, signing shouldn't work anymore.
assert.throws(() => testSignVerify(publicKey, privateKey),
common.hasOpenSSL3 ? {
message: 'Failed to read private key'
message: 'error:07880109:common libcrypto ' +
'routines::interrupted or cancelled'
} : {
name: 'TypeError',
code: 'ERR_MISSING_PASSPHRASE',
Expand Down
3 changes: 2 additions & 1 deletion test/parallel/test-crypto-private-decrypt-gh32240.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ function decrypt(key) {

decrypt(pkey);
assert.throws(() => decrypt(pkeyEncrypted), common.hasOpenSSL3 ?
{ message: 'Failed to read asymmetric key' } :
{ message: 'error:07880109:common libcrypto routines::interrupted or ' +
'cancelled' } :
{ code: 'ERR_MISSING_PASSPHRASE' });
decrypt(pkey); // Should not throw.
5 changes: 3 additions & 2 deletions test/parallel/test-crypto-rsa-dsa.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,11 @@ const openssl1DecryptError = {
};

const decryptError = common.hasOpenSSL3 ?
{ message: 'Failed to read asymmetric key' } : openssl1DecryptError;
{ message: 'error:1C800064:Provider routines::bad decrypt' } :
openssl1DecryptError;

const decryptPrivateKeyError = common.hasOpenSSL3 ? {
message: 'Failed to read private key',
message: 'error:1C800064:Provider routines::bad decrypt',
} : openssl1DecryptError;

function getBufferCopy(buf) {
Expand Down
4 changes: 1 addition & 3 deletions test/parallel/test-crypto-sign-verify.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,7 @@ const keySize = 2048;
`-----BEGIN RSA PRIVATE KEY-----
AAAAAAAAAAAA
-----END RSA PRIVATE KEY-----`);
}, { message: common.hasOpenSSL3 ?
'Failed to read private key' :
'bye, bye, library' });
}, { message: 'bye, bye, library' });

delete Object.prototype.library;

Expand Down
5 changes: 2 additions & 3 deletions test/parallel/test-tls-passphrase.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ server.listen(0, common.mustCall(function() {
})).unref();

const errMessagePassword = common.hasOpenSSL3 ?
/Error: PEM_read_bio_PrivateKey/ : /bad decrypt/;
/Error: error:1400006B:UI routines::processing error/ : /bad decrypt/;

// Missing passphrase
assert.throws(function() {
Expand Down Expand Up @@ -254,8 +254,7 @@ assert.throws(function() {
});
}, errMessagePassword);

const errMessageDecrypt = common.hasOpenSSL3 ?
/Error: PEM_read_bio_PrivateKey/ : /bad decrypt/;
const errMessageDecrypt = /bad decrypt/;

// Invalid passphrase
assert.throws(function() {
Expand Down

0 comments on commit db5ee23

Please sign in to comment.