Uh oh!
There was an error while loading. Please reload this page.
Build SignedData CMS (and PKCS #7) - #1051
Conversation
Uh oh!
There was an error while loading. Please reload this page.
tarcieri
commented
May 5, 2023
See also #1045 where we are discussing the future of the |
| /// This method returns a `ContentInfo` of type `signedData`. After this call, the builder cannot | ||
| /// be used any more. However, as the signature(s) are stored in the builder, the builder object | ||
| /// must be kept until the message is dropped. | ||
| pub fn build(&'s mut self) -> Result<ContentInfo<'s>> { |
There was a problem hiding this comment.
Just wondering, would it make sense to reuse the Builder trait from x509-cert, it's a dependency already.
There was a problem hiding this comment.
This would also hold for CertificateBuilder, right?
As for the PKCS #7 builder: how would we handle multiple signers? My current solution is to add a SignerInfo including the signature with each call of SignedDataBuilder::sign(). Idea: I could possibly rename sign() to add_signer() and just add the SignerInfo without the signature. The signatures would then be calculated when building the message with SignedDataBuilder::build().
There was a problem hiding this comment.
Yeah, I guess you would need an owned structure to be able to use it.
There was a problem hiding this comment.
@baloo I'm currently moving my implementations to the cms crate, which uses owned types. It looks like I will be able to reuse your Builder trait for the SignerInfo objects. 🙂
bkstein
commented
May 6, 2023
Yes, I will definitely check the cms crate. But first I'd like to solve my lifetime problem. |
tarcieri
commented
May 6, 2023
@bkstein the https://docs.rs/cms/0.2.1/cms/content_info/struct.ContentInfo.html |
bkstein
commented
May 7, 2023
I had a look into the |
tarcieri
commented
May 7, 2023
@bkstein some past discussion here: #765 We ended up moving many of the crates to use all owned types. This makes things like builders easier (as you are experiencing), but also makes one-pass deserialization from PEM possible. The |
bkstein
commented
May 7, 2023
That sounds reasonable to me, too. The only difference between CMS and PKCS #7 I could find ist the coding of encapsulated content (RFC 5652, 5.2.1) and that should be manageable. |
tarcieri
commented
May 13, 2023
bkstein
commented
May 14, 2023
Yes, I worked exactly on this during the last week. But I'm not ready, yet. |
bkstein
commented
May 24, 2023
I moved the code from crate pkcs7 (which is deprecated) to cms. I used |
tarcieri
commented
May 24, 2023
Unless I'm missing something, all you're doing is calling it before That's unnecessary, as |
bkstein
commented
May 24, 2023
I added |
tarcieri
commented
May 24, 2023
That still looks like a newtype of I still don't see why you need |
Uh oh!
There was an error while loading. Please reload this page.
| /// SignedAttributes ::= SET SIZE (1..MAX) OF Attribute | ||
| /// ``` | ||
| type SignedAttributes<'a> = SetOfVec<Attribute>; | ||
| pub type SignedAttributes<'a> = SetOfVec<Attribute>; |
There was a problem hiding this comment.
I believe changes in pkcs7 need to be dropped (deprecated).
There was a problem hiding this comment.
Right, I will check pkcs7 for remainders of my changes.
Uh oh!
There was an error while loading. Please reload this page.
baloo
commented
May 24, 2023
looks great! Thank you for doing that! |
bkstein
commented
May 30, 2023
tarcieri
commented
May 30, 2023
@bkstein can you split out the |
bkstein
commented
May 30, 2023
Sure, I already expected this 🙂. |
baloo
commented
May 30, 2023
We also merged #1071 this weekend which bring back the |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Co-authored-by: Arthur Gautier <superbaloo+registrations.github@superbaloo.net>
Co-authored-by: Arthur Gautier <superbaloo+registrations.github@superbaloo.net>
Co-authored-by: Arthur Gautier <superbaloo+registrations.github@superbaloo.net>
Just realized, that resolving does not automatically accept the suggested changes. 🙄 |
we'll still need you to send the Sorry for the extra work. |
bkstein
commented
May 31, 2023
I checked the |
Uh oh!
There was an error while loading. Please reload this page.
baloo
commented
May 31, 2023
(lastly, I think we'll want you to squash those commits if you could) |
tarcieri
commented
May 31, 2023
@baloo we use squash-and-merge so we don't depend on developers to squash their own PRs |
carl-wallace
commented
Jun 26, 2023
Sorry I missed this request somehow last month (was very busy then and just missed it). I reviewed now in prep of reviewing the EnvelopedData changes and had a couple of comments. None of this is essential (though fixing the test case probably ought be done). SignerInfoBuilder.assemble
SignedDataBuilder.build
Test comments
Questions
Nits
|
bkstein
commented
Jun 28, 2023
@carl-wallace Thanks for reviewing this. I have some questions/remarks. SignedDataBuilder.build/assemble Could you give an example, how you would interrogate the info? Test comments
Questions
Nits
|
carl-wallace
commented
Jun 29, 2023
Re: interrogation, adding a trait bound to S is what I was thinking. At present it is Re: hash algorithm and signature algorithm, you're right they can move independently, but accumulating the full list in the SignedData later is required (as a SHOULD). The consistency check suggestion is likely too much, just ignore that. Here's a certs only test case: |
Added - `SignedData` builder (RustCrypto#1051) Changed - Deprecate `pkcs7` in favor of `cms` (RustCrypto#1062) - der: add `SetOf(Vec)::insert(_ordered)`; deprecate `add` (RustCrypto#1067) - Re-enable all minimal-versions checks (RustCrypto#1071) Fixed - Don't insert signing time attribute by default (RustCrypto#1148) - Fixed encoding of `SubjectKeyIdentifier` (RustCrypto#1152)
Added - `SignedData` builder (#1051) Changed - Deprecate `pkcs7` in favor of `cms` (#1062) - der: add `SetOf(Vec)::insert(_ordered)`; deprecate `add` (#1067) - Re-enable all minimal-versions checks (#1071) Fixed - Don't insert signing time attribute by default (#1148) - Fixed encoding of `SubjectKeyIdentifier` (#1152)
This branch adds a builder for SignedData PKCS #7 messages.