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

parse certificates with pure rust #6147

Merged
merged 5 commits into from
Jul 25, 2021
Merged

parse certificates with pure rust #6147

merged 5 commits into from
Jul 25, 2021

Conversation

reaperhulk
Copy link
Member

No description provided.

CHANGELOG.rst Outdated Show resolved Hide resolved
src/cryptography/hazmat/backends/openssl/backend.py Outdated Show resolved Hide resolved
src/cryptography/hazmat/backends/openssl/backend.py Outdated Show resolved Hide resolved
src/cryptography/hazmat/bindings/_rust/x509.pyi Outdated Show resolved Hide resolved
src/rust/Cargo.toml Outdated Show resolved Hide resolved
src/rust/src/x509.rs Outdated Show resolved Hide resolved
src/rust/src/x509.rs Show resolved Hide resolved
src/rust/src/x509.rs Outdated Show resolved Hide resolved
src/rust/src/x509.rs Outdated Show resolved Hide resolved
@reaperhulk reaperhulk force-pushed the rust-cert branch 12 times, most recently from d5f04e3 to 8b2f8b5 Compare July 1, 2021 13:14
@reaperhulk reaperhulk force-pushed the rust-cert branch 2 times, most recently from 060f0b6 to 0ebdc04 Compare July 14, 2021 23:09
@reaperhulk reaperhulk marked this pull request as ready for review July 17, 2021 17:55
src/cryptography/hazmat/backends/openssl/backend.py Outdated Show resolved Hide resolved
src/cryptography/hazmat/backends/openssl/backend.py Outdated Show resolved Hide resolved
src/rust/src/x509.rs Outdated Show resolved Hide resolved
src/rust/src/x509.rs Outdated Show resolved Hide resolved
src/rust/src/x509.rs Outdated Show resolved Hide resolved
tests/hazmat/backends/test_openssl.py Show resolved Hide resolved
src/cryptography/hazmat/backends/openssl/x509.py Outdated Show resolved Hide resolved
src/cryptography/hazmat/backends/openssl/x509.py Outdated Show resolved Hide resolved
) -> pyo3::PyResult<bool> {
match op {
pyo3::class::basic::CompareOp::Eq => {
Ok(self.raw.borrow_data() == other.raw.borrow_data())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mmm, is comparing by bytes always correct, or are there ever cases where different bytes are really the same?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/openssl/openssl/blob/10af976962b2383bb3044120a764037361b8bff7/crypto/x509/x509_cmp.c#L155

OpenSSL generates a hash and verifies that the "encoding" hasn't changed. Digging through the layers it looks like byte for byte comparison probably is fine? It's also the case that the only bytes that could ever be different would be the ones outside of tbsCertificateBytes of course.

src/rust/src/x509.rs Show resolved Hide resolved
src/rust/src/x509.rs Show resolved Hide resolved
@alex alex merged commit 87f43fb into pyca:main Jul 25, 2021
@reaperhulk reaperhulk deleted the rust-cert branch July 25, 2021 22:04
@intgr
Copy link
Contributor

intgr commented Aug 5, 2021

Hi! I since the changelog drew attention to it, I just happened to read the API stability and versioning doc:

  • The behavior of existing APIs will not change.
    • One exception to our API stability policy is for security.

Deprecation

  • In cryptography X.0.0 the feature exists.
  • In cryptography (X + 1).0.0 using that feature will emit a UserWarning.

However, this change breaks "the behavior of existing APIs" with no warning. And I don't think it's a "security" fix either -- while stricter validation can improve security, that reasoning would be a slippery slope by which all sorts of undue API breaks could be justified.

What's the cryptography project's opinion on this? It seems to me that the document is simply overpromising on stability. Maybe it's time to change the stability claims?

@reaperhulk
Copy link
Member Author

Stricter and looser validation are properties that we have historically flexed on (sometimes due to our own dependency changing its behavior, sometimes for other reasons). I'm not sure how to capture the reality of our policy without making it sound like we break APIs frequently rather than "we have changed an unusual parsing/serialization edge case that 99.99% of our callers will never see".

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

Successfully merging this pull request may close these issues.

3 participants