Skip to content

Ed25519/Ed448 does not throw when used with invalid digest in crypto.createSign #52097

Closed
@xicilion

Description

@xicilion

What is the problem this feature will solve?

The following example:

const crypto = require('crypto');

const key = crypto.generateKeyPairSync("ed25519");

var signature = crypto.sign(null, "hello", key.privateKey);
console.log("crypto.sign:", signature.toString('hex'));

var signer = crypto.createSign('SHA256');
signer.update('hello');
var signature = signer.sign(key.privateKey);
console.log("signer.sign:", signature.toString('hex'));

will output the following:

crypto.sign: d58fdfa69f9d0bf4fd5358a6ed22031af3585ce9812b2bde5a5045a4e3cefd719a5af771af85e5a0c406fd48852574debe4deb32845785b761c59978b21fa903
signer.sign: 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000

When Signer is used for Ed25519 signing, Signer does not report any errors, but returns an all-zero Buffer as the signature result.
This can be confusing for programmers who think they have signed successfully, but in fact the returned signature is not available.

What is the feature you are proposing to solve the problem?

I think in this case Signer.sign should throw an error so that the programmer can deal with the problem early on.

What alternatives have you considered?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    confirmed-bugIssues with confirmed bugs.cryptoIssues and PRs related to the crypto subsystem.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions