Skip to content

Introduce SerialNumber type#103

Merged
est31 merged 1 commit into
rustls:masterfrom
andrenth:serial-number
Apr 5, 2023
Merged

Introduce SerialNumber type#103
est31 merged 1 commit into
rustls:masterfrom
andrenth:serial-number

Conversation

@andrenth

@andrenth andrenth commented Nov 3, 2022

Copy link
Copy Markdown
Contributor

No description provided.

@andrenth andrenth force-pushed the serial-number branch 2 times, most recently from f7e4369 to 6e2efdb Compare November 3, 2022 15:38
@est31

est31 commented Dec 5, 2022

Copy link
Copy Markdown
Member

Sorry for the late review, i was sick during a long period in November. The PR looks good except for the fact that it introduces a dependency. Could you use write_bitvec_bytes from yasna instead?

@andrenth

andrenth commented Dec 5, 2022

Copy link
Copy Markdown
Contributor Author

Hey, no problem. Hope you're feeling better now.

I've removed the bigint dependency in the latest version of the PR.

@andrenth

andrenth commented Dec 5, 2022

Copy link
Copy Markdown
Contributor Author

So, the tests are failing because x509_parser expects the serial number to be tagged as INTEGER, which write_biguint does, but write_bitvec_bytes uses the BITSTRING tag, causing x509_parser::parse_x509_certificate() to fail.

Not sure how to solve this without introducing the bigint dependency. Any suggestions?

@est31 est31 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks!

@est31

est31 commented Dec 5, 2022

Copy link
Copy Markdown
Member

Wait, CI is giving an error:

 thread 'tests::test_with_key_usages' panicked at 'called `Result::unwrap()` on an `Err` value: Error(InvalidSerial)', src/lib.rs:2432:70

Also, maybe it would be good to have a test with a long 20 byte serial in the test suite. E.g. you create a cert, then read it back and ensure the serial number still has 20 bytes (and matches the initial array with 20 bytes).

@andrenth

andrenth commented Dec 5, 2022

Copy link
Copy Markdown
Contributor Author

Yes, please see the comment above about the failed tests.

@est31

est31 commented Dec 5, 2022

Copy link
Copy Markdown
Member

Oh good point, we can't use write_bitvec_bytes. I guess we need a write_biguint_bytes function in yasna then... This is the PR that added it: qnighy/yasna.rs#44

@est31

est31 commented Dec 15, 2022

Copy link
Copy Markdown
Member

@andrenth can you check if your PR will work with qnighy/yasna.rs#66 applied?

@andrenth

Copy link
Copy Markdown
Contributor Author

Yeah, it does work after replacing the two calls of write_bitvec_bytes with write_bigint_bytes:

-                               writer.next().write_bitvec_bytes(serial.as_ref(), serial.len() * 8);
+                               writer.next().write_bigint_bytes(serial.as_ref(), true);

@est31

est31 commented Dec 16, 2022

Copy link
Copy Markdown
Member

@andrenth I have released a version of yasna with that function added. You can increase the requirement in Cargo.toml now and update your PR to use it.

@est31

est31 commented Jan 31, 2023

Copy link
Copy Markdown
Member

@andrenth friendly ping

@est31

est31 commented Apr 5, 2023

Copy link
Copy Markdown
Member

Okay, merging anyways, I will fix it once it's merged.

@est31 est31 merged commit e8dc6cd into rustls:master Apr 5, 2023
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

Successfully merging this pull request may close these issues.

2 participants