-
Notifications
You must be signed in to change notification settings - Fork 832
Add sign({detached: true}) to PKCS#7 #605
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
awesome! |
mattcollier
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR!
lib/pkcs7.js
Outdated
| }, | ||
|
|
||
| /** | ||
| * Signs the content. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please add @param etc to the function docs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 09afde4
lib/pkcs7.js
Outdated
| /** | ||
| * Signs the content. | ||
| */ | ||
| baseSign: function(detached) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be _baseSign? Do we want this API to be part of the public API?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Totally correct. Fixed in 09afde4
| // the content field and is optional for a ContentInfo but required here | ||
| // since signers are present | ||
| if(msg.contentInfo.value.length < 2) { | ||
| if(!content) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since contentInfo is no longer being used here, the above comment becomes irrelevant. Can it be moved to some other useful location?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved the comment where it makes sense in 09afde4
lib/pkcs7.js
Outdated
| * @param detached If signing should be done in detached mode | ||
| */ | ||
| baseSign: function(detached) { | ||
| _baseSign: function(detached) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vbuch I don't know what the future holds for _baseSign. I really don't like the look of msg._baseSign(true). How do you feel about the signature being msg._baseSign({detached: true}), and for the default case, it can just be msg._baseSign()?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would introduce a couple of lines of more code, but would look much better, yes. Will do it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm... I'm thinking, now that I see the code... baseSign could be needless in this case. As long as sing() has an optional options parameter we could call sign() and sign({detached: true}) instead of sign() and signDetached() What do you think @mattcollier ?
See: https://github.com/vbuch/forge/blob/master/lib/pkcs7.js#L352
I will also include a line in the README in the PKCS#7 section once you confirm either _baseSign(options) or sign(options).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vbuch good point. It will be up to @dlongley and @davidlehn to answer this question.
|
I'll be a buzzkill and suggest the commit descriptions could be rewritten to remove the emoji. We haven't done that elsewhere and sparkles and ok_hand don't really mean anything in this context. |
|
@davidlehn Agreed. I'm just used to gitmoji. I'll create another PR once I'm done with @mattcollier's remarks. |
|
@vbuch Huh, I didn't realize gitmoji was a "spec". I just thought emoji were random and people doing that were crazy. :-) It's not a bad idea I guess, but kind of weird to just use it for a few commits. Also seems a "spec" mapping keywords like ":bugfix:" to emoji would make lots more sense. But I'm getting off topic. Could just rewrite the commit message history on your branch and force push. Or we could just not worry about it. Sorry for the hassle and thanks for the patch. |
|
@davidlehn Will do that. And what about this #605 (comment) |
|
@vbuch Was the test case generated by some other app or by the new code itself? Just wondering where to look to see if the detached sig construction is correct. Not quite sure where spec text is for that. |
|
What I am using detached signatures for is signing PDFs. The one in the test is generated by the code. I'm working on an actual test for its validity here https://github.com/vbuch/node-signpdf Once I'm done I could possibly have better testing for the code here thou I'm not sure more is really needed. |
|
Ok. Testing against itself is good for regressions, but hard to say if it's compatible with other tools. I'm not keen on reading that whole adobe pdf doc about this stuff. ;-) Once that options api issue is addressed will likely just merge and release this. Can fix and/or improve testing later if there are issues. |
* baseSign() should not be public. sign() and signDetached() are the public ones; * Fix comments in addSignerInfos(); * Added jsDoc @param to _baseSign();
|
@davidlehn @mattcollier @dlongley I think I did all the things we agreed on. CI passed. Seems to me this piece is good to go. 🎉 |
|
0.7.6 released with these changes. Thanks. |
|
@vbuch A bit of an odd issue - using your detached:true I am still seeing the payload in the PKCS#7. I.e running |
|
Sorry @dirkx. I won't be able to help. I see the lib has gone 2 versions ahead since my addition was released. Maybe something changed meanwhile. |
Adds
signDetached()to the PKCS#7 implementation (see #279) as in my usecase it worked perfectly fine the way it was proposed 3 years ago by @fadlijuniarso. The same piece of code is being used in a number of repos on GitHub but what lead me here was the piece used in pdfsign.js so thanks to @tbocek as well.I've also added a test to cover
signDetached().