-
Notifications
You must be signed in to change notification settings - Fork 80
feat: support "verify" with FIPS crypto backend #233
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
base: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -71,13 +71,25 @@ jobs: | |
| - --all-features | ||
| - --features=verify | ||
| - --features=verify-aws | ||
| - --features=verify-aws-fips | ||
| - --features=validate | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - name: Install stable toolchain | ||
| uses: dtolnay/rust-toolchain@stable | ||
| - run: cargo test --locked ${{ matrix.features }} | ||
|
|
||
| test_fips: | ||
| name: verify-aws-fips dependency on FIPS backend only | ||
| needs: check-all-features | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - name: Install stable toolchain | ||
| uses: dtolnay/rust-toolchain@stable | ||
| - run: "if cargo tree --features=verify-aws-fips -i aws-lc-sys; then false; else [ $? -eq 101 ]; fi" | ||
| - run: "cargo tree --features=verify-aws-fips -i aws-lc-fips-sys" | ||
|
|
||
|
Comment on lines
+82
to
+96
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I figured it was a good idea to add a CI step to verify the FIPS backend is used when the fips flag is provided. Specifically:
|
||
| fmt: | ||
| name: Rustfmt | ||
| runs-on: ubuntu-latest | ||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -38,13 +38,14 @@ rustdoc-args = ["--cfg", "docsrs"] | |
|
|
||
| [features] | ||
| default = [] | ||
| verify-aws = ["aws-lc-rs"] | ||
| verify-aws = ["aws-lc-rs/aws-lc-sys"] # Non-FIPS backend | ||
| verify-aws-fips = ["aws-lc-rs/fips"] # FIPS crypto backend | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the new feature flag which switches on the It's either / or for the backends though, and the non-FIPS backend is enabled by default, so I've disabled the default features for aws-lc-rs and let the x509-parser feature flags enable the relevant crypto backend. |
||
| verify = ["ring"] | ||
| validate = [] | ||
|
|
||
| [dependencies] | ||
| aws-lc-rs = { version = "1.0", optional = true } | ||
| asn1-rs = { version = "0.8.0-beta.1", features=["bigint", "datetime"] } | ||
| aws-lc-rs = { version = "1.0", optional = true, default-features = false, features = ["alloc"] } | ||
| data-encoding = "2.2.1" | ||
| lazy_static = "1.4" | ||
| nom = "8.0" | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,7 +5,11 @@ use crate::x509::{ | |
| parse_signature_value, AlgorithmIdentifier, SubjectPublicKeyInfo, X509Name, X509Version, | ||
| }; | ||
|
|
||
| #[cfg(any(feature = "verify", feature = "verify-aws"))] | ||
| #[cfg(any( | ||
| feature = "verify", | ||
| feature = "verify-aws", | ||
| feature = "verify-aws-fips" | ||
| ))] | ||
|
Comment on lines
-8
to
+12
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is basically all the source code changes in this PR: adding a new feature flag in the same place as |
||
| use crate::verify::verify_signature; | ||
| use asn1_rs::{ | ||
| BitString, DerParser, FromDer, Header, Input, Oid, OptTaggedImplicit, Sequence, Tag, Tagged, | ||
|
|
@@ -83,8 +87,19 @@ impl<'a> X509CertificationRequest<'a> { | |
| /// | ||
| /// Uses the public key contained in the CSR, which must be the one of the entity | ||
| /// requesting the certification for this verification to succeed. | ||
| #[cfg(any(feature = "verify", feature = "verify-aws"))] | ||
| #[cfg_attr(docsrs, doc(cfg(any(feature = "verify", feature = "verify-aws"))))] | ||
| #[cfg(any( | ||
| feature = "verify", | ||
| feature = "verify-aws", | ||
| feature = "verify-aws-fips" | ||
| ))] | ||
| #[cfg_attr( | ||
| docsrs, | ||
| doc(cfg(any( | ||
| feature = "verify", | ||
| feature = "verify-aws", | ||
| feature = "verify-aws-fips" | ||
| ))) | ||
| )] | ||
| pub fn verify_signature(&self) -> Result<(), X509Error> { | ||
| let spki = &self.certification_request_info.subject_pki; | ||
| verify_signature( | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.