Skip to content
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

PKCS#12 / PFX support #3

Closed
Tracked by #1
jklong opened this issue Sep 14, 2021 · 12 comments
Closed
Tracked by #1

PKCS#12 / PFX support #3

jklong opened this issue Sep 14, 2021 · 12 comments

Comments

@jklong
Copy link
Contributor

jklong commented Sep 14, 2021

Thoughts on adding PKCS12/RFC7292 and (eventually) complete or near complete PFX support? It's a monster and it sucks but it's in wide use thanks to Windows' use of the format.

I'm happy to take ownership of the feature and start work but can't guarantee any timelines on it

@tarcieri tarcieri transferred this issue from RustCrypto/utils Sep 14, 2021
@tarcieri tarcieri changed the title PKCS12 / PFX support PKCS#12 / PFX support Sep 14, 2021
@tarcieri tarcieri mentioned this issue Sep 14, 2021
8 tasks
@tarcieri
Copy link
Member

tarcieri commented Sep 14, 2021

This is definitely something we'd love to have, thanks for volunteering! We also happen to be the owners of the pkcs12 crate.

(Also FYI, we have a brand new "formats" repo, and I've just transferred the issue there)

It's a monster and it sucks

My main recommendation would be to keep the scope of the initial implementation small rather than try to provide a comprehensive implementation of the full specification.

I would suggest supporting a single private key and its associated certificate chain in an initial implementation.

Also I believe someone has already implemented the PKCS#12 KDF and wanted to upstream it to this project, but offhand I don't remember where I discussed that. I can attempt to track that work down.

@jklong
Copy link
Contributor Author

jklong commented Sep 15, 2021

My main recommendation would be to keep the scope of the initial implementation small rather than try to provide a comprehensive implementation of the full specification.

Absolutely. I was just gauging appetite overall before starting.

Also I believe someone has already implemented the PKCS#12 KDF and wanted to upstream it to this project, but offhand I don't remember where I discussed that. I can attempt to track that work down.

If you do have something that would be great.

@xemwebe
Copy link
Contributor

xemwebe commented Jul 5, 2023

Also I believe someone has already implemented the PKCS#12 KDF and wanted to upstream it to this project, but offhand I don't remember where I discussed that. I can attempt to track that work down.

I require exactly the PKCS#12 KDF to support communication with some legacy system. Is this already somewhere else implemented or still an open issue?

@tarcieri
Copy link
Member

tarcieri commented Jul 7, 2023

Unfortunately I wasn't able to find where I saw that. Perhaps it can be found with GitHub Code Search

@xemwebe
Copy link
Contributor

xemwebe commented Jul 9, 2023

I searched GitHub already, but without success. Meanwhile, I implemented the KDF in rust myself. It is not that complicated. If you think this is interesting enough, I could prepare a PR for that. Should it go here or would the KDF repository the better place for that.

@tarcieri
Copy link
Member

Could go either way on that. Maybe start here and we can factor it out if it makes sense.

@xemwebe
Copy link
Contributor

xemwebe commented Jul 12, 2023

The POC for that can be found here: https://github.com/xemwebe/formats/tree/pkcs12_kdf/pkcs12
The code needs to be generalized for accepting arbitrary digest methods, and I probably need some time to understand how to fit this in the existing framework.

The KDF accepts in general passwords (which needs to be converted to unicode) and IVs of arbitrary lengths and returns a key of arbitrary length. This seems to require feature "alloc" to be enabled. Is this acceptable, or would you prefer some variant with predefined arrays of fixed length (returning an error if the size does not fit)?

@carl-wallace
Copy link
Contributor

FYI, I am going to try to move #836 from the pkcs7 crate to the cms crate and generally align it with current. Can give a look at the KDF in context once that is done. It may be next week before I get to that though.

@xemwebe
Copy link
Contributor

xemwebe commented Jul 15, 2023

The KDF works now with various digest methods and I have prepared a PR #1154.
All test cases have been checked against openssl.
If you have any suggestions or improvements, please let me know.

@xemwebe
Copy link
Contributor

xemwebe commented Jul 16, 2023

I have posted an update: zeroizing intermediate secrets, removing the unused error type and add test case for very long output keys that check some code regions not covered in the other tests.

@xemwebe
Copy link
Contributor

xemwebe commented Jul 19, 2023

I believe to have addressed all reviewer's remarks regarding PR #1154 so far and will wait for further reviewer suggestions, if any.

@tarcieri
Copy link
Member

We've merged #1154 and published a pkcs12 crate, so I'd say we can close this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants