digitalbazaar / forge

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

optional digest of message content ( Hash sign ) #929

Open blackkus opened 2 years ago

blackkus commented 2 years ago

Sometime you want to sign based on a Hash instead of a content (document). it means that you may not have the document, just the hash. Could it be possible to "digest" the content message only id "messageDigest" not provided :

https://github.com/digitalbazaar/forge/blob/c0bb359afca73bb0f3ba6feb3f93bbcb9166af2e/lib/pkcs7.js#L513

blackkus commented 2 years ago

Something like this :

if(attr.type === forge.pki.oids.messageDigest) {
    // use content message digest as value if not already set
    if(!attr.value) {
        attr.value = mds[signer.digestAlgorithm].digest();
    }
}