digitalbazaar / forge

A native implementation of TLS in Javascript and tools to write crypto-based and network-heavy webapps
https://digitalbazaar.com/
Other
5.01k stars 767 forks source link

Signature compliant to http://www.w3.org/2007/05/xmldsig-more#sha256-rsa-MGF1 #1039

Open rahxam opened 1 year ago

rahxam commented 1 year ago

I am trying to create a http://www.w3.org/2007/05/xmldsig-more#sha256-rsa-MGF1 Signature as described in rfc6931 RSASSA-PSS without Parameters here: https://www.rfc-editor.org/rfc/rfc6931.html#section-2.3.10

Unfortunately, the result does not seem to be compliant with the standard. Any help what I am doing wrong?

    forge = require('node-forge')
    var md = forge.md.sha256.create();
    md.update(signedInfo, 'utf8');
    var pss = forge.pss.create({
      md: forge.md.sha1.create(),
      mgf: forge.mgf.mgf1.create(forge.md.sha1.create()),
      saltLength: 20
    });

    var privateKey = forge.pki.privateKeyFromPem(signingKey);

    var signature = privateKey.sign(md, pss);
    signature = forge.util.encode64(signature);

Thanks in advance, Maximilian