(publicKey, privateKey)
| 59 | |
| 60 | // Tests that a key pair can be used for signing / verification. |
| 61 | function testSignVerify(publicKey, privateKey) { |
| 62 | const message = Buffer.from('Hello Node.js world!'); |
| 63 | |
| 64 | function oldSign(algo, data, key) { |
| 65 | return createSign(algo).update(data).sign(key); |
| 66 | } |
| 67 | |
| 68 | function oldVerify(algo, data, key, signature) { |
| 69 | return createVerify(algo).update(data).verify(key, signature); |
| 70 | } |
| 71 | |
| 72 | for (const signFn of [sign, oldSign]) { |
| 73 | const signature = signFn('SHA256', message, privateKey); |
| 74 | for (const verifyFn of [verify, oldVerify]) { |
| 75 | for (const key of [publicKey, privateKey]) { |
| 76 | const okay = verifyFn('SHA256', message, key, signature); |
| 77 | assert(okay); |
| 78 | } |
| 79 | } |
| 80 | } |
| 81 | } |
| 82 | |
| 83 | // Constructs a regular expression for a PEM-encoded key with the given label. |
| 84 | function getRegExpForPEM(label, cipher) { |
no test coverage detected