piknik icon indicating copy to clipboard operation
piknik copied to clipboard

Content-Type with protected-headers="v1"

Open jayay opened this issue 2 years ago • 4 comments

Is your feature request related to a problem? Please describe. I would like to add protected-headers="v1" to the Content-Type header. What I'm trying to accomplish is to encrypt the headers alongside with the message. In order to get the headers replaced with their encrypted counterpart, I need to add protected-headers="v1" to the encrypted payload. Specifically to the message part, which contains the header replacements.

Describe the solution you'd like It'd be nice if any variant of MultiPartKind and ContentType could hold additional values. I'm not sure if holding the values in a structured way (like key/value) would be best. In my case, I need MultiPartKind::Signed to write this out, alongside the protocol and micalg values.

Describe alternatives you've considered I'm afraid I couldn't think of any different approach

Additional context None

jayay avatar Jun 07 '22 20:06 jayay

I've started working on this in a fork. Is this something you'd say appears to be an OK approach, @paolobarbolini?

jayay avatar Jun 11 '22 19:06 jayay

Sure. I see your change contains a breaking change, so either it gets merged before 0.10.0 or we'll have to wait for the next breaking release which hopefully (after how long 0.10 took) won't be made in a long while.

paolobarbolini avatar Jun 15 '22 01:06 paolobarbolini

The breaking change is very unfortunate and it wouldn't help in case more parameters to the headers are desired in the future. Wouldn't a more generic solution be more future-proof? I'm not in a rush, so if you wanted to take your time and think things through, I'm fine with just using my fork.

jayay avatar Jun 16 '22 09:06 jayay

I tried a second approach (which I like a lot more), but it would require the Mime crate to allow the modification of MIME parameters programmatically. The enum MultiPartKind would have to be restructured to hold the Mime object, instead of creating an instance of itself by reading from the Mime object. MultiPartKind would essentially become a tuple struct that holds a Mime.

jayay avatar Jun 16 '22 16:06 jayay