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

Update to rsa 0.5 in libjose #517

Merged
merged 1 commit into from
Dec 2, 2021

Conversation

olivereanderson
Copy link
Contributor

@olivereanderson olivereanderson commented Nov 30, 2021

Description of change

Upgrades the rsa crate dependency to version 0.5 in our libjose crate. This removes our dependency on simple_asn1 v0.5.4 which is necessary in order to eventually migrate away from the chrono crate (Issue #442).

Links to any relevant issues

Be sure to reference any related issues by adding fixes issue #.

Type of change

Add an x to the boxes that are relevant to your changes.

  • Bug fix (a non-breaking change which fixes an issue)
  • Enhancement (a non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation Fix

How the change has been tested

I successfully managed to run the following test suites in libjose locally:
cargo test --features test-rsa-enc,
cargo test --features test-rsa-sig,
cargo test --all-features --release

Change checklist

Add an x to the boxes that are relevant to your changes.

  • I have followed the contribution guidelines for this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

@cycraig
Copy link
Contributor

cycraig commented Nov 30, 2021

Looks like a deep dependency is breaking the Wasm build due to der 0.4.4. This was fixed in der 0.5.0: RustCrypto/formats#147.

der v0.4.4
├── pkcs1 v0.2.4
│   ├── pkcs8 v0.7.6
│   │   └── rsa v0.5.0
│   │       └── libjose v0.1.0 (C:\Work\iota\identity.rs\libjose)
│   │           └── identity-comm v0.4.0 (C:\Work\iota\identity.rs\identity-comm)
│   │               └── identity v0.4.0 (C:\Work\iota\identity.rs\identity)
│   │                   └── identity-wasm v0.4.0 (C:\Work\iota\identity.rs\bindings\wasm)
│   └── rsa v0.5.0 (*)
├── pkcs8 v0.7.6 (*)
└── spki v0.4.1
    └── pkcs8 v0.7.6 (*) 

Later versions of pkcs1 and pkcs8 have been updated to der 0.5.0, so it would be sufficient to convince rsa to update their dependency versions of pkcs1 and pkcs8 to resolve this issue I think.

Error:

[INFO]: Compiling to Wasm...
   Compiling const-oid v0.6.2
   Compiling base64 v0.13.0
   Compiling base64ct v1.1.1
   Compiling identity-derive v0.4.0 (/home/runner/work/identity.rs/identity.rs/identity-diff/derive)
   Compiling pem-rfc7468 v0.2.4
   Compiling chrono v0.4.19
   Compiling bee-common v0.4.1
   Compiling crypto-bigint v0.2.11
   Compiling bee-message v0.1.5
   Compiling identity-diff v0.4.0 (/home/runner/work/identity.rs/identity.rs/identity-diff)
   Compiling der v0.4.4
   Compiling identity-core v0.4.0 (/home/runner/work/identity.rs/identity.rs/identity-core)
error[E0277]: can't compare `usize` with `()`
Error:    --> /home/runner/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/der-0.4.4/src/encoder.rs:151:43
    |
151 |         if nested_encoder.finish()?.len() == length.try_into()? {
    |                                           ^^ no implementation for `usize == ()`
    |
    = help: the trait `PartialEq<()>` is not implemented for `usize`

error[E0277]: the trait bound `(): From<Length>` is not satisfied
Error:    --> /home/runner/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/der-0.4.4/src/encoder.rs:151:53
    |
151 |         if nested_encoder.finish()?.len() == length.try_into()? {
    |                                                     ^^^^^^^^ the trait `From<Length>` is not implemented for `()`
    |
    = note: required because of the requirements on the impl of `Into<()>` for `Length`
note: required because of the requirements on the impl of `TryFrom<Length>` for `()`
   --> /home/runner/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/der-0.4.4/src/asn1/null.rs:46:6
    |
46  | impl TryFrom<Any<'_>> for () {
    |      ^^^^^^^^^^^^^^^^     ^^
    = note: required because of the requirements on the impl of `TryInto<()>` for `Length`

For more information about this error, try `rustc --explain E0277`.
error: could not compile `der` due to 2 previous errors
Error: warning: build failed, waiting for other jobs to finish...
error: build failed
Error: Error: Compiling your crate to WebAssembly failed
Caused by: failed to execute `cargo build`: exited with exit code: 101
  full command: "cargo" "build" "--lib" "--release" "--target" "wasm32-unknown-unknown"

@olivereanderson
Copy link
Contributor Author

Looks like a deep dependency is breaking the Wasm build due to der 0.4.4. This was fixed in der 0.5.0: RustCrypto/formats#147.

der v0.4.4
├── pkcs1 v0.2.4
│   ├── pkcs8 v0.7.6
│   │   └── rsa v0.5.0
│   │       └── libjose v0.1.0 (C:\Work\iota\identity.rs\libjose)
│   │           └── identity-comm v0.4.0 (C:\Work\iota\identity.rs\identity-comm)
│   │               └── identity v0.4.0 (C:\Work\iota\identity.rs\identity)
│   │                   └── identity-wasm v0.4.0 (C:\Work\iota\identity.rs\bindings\wasm)
│   └── rsa v0.5.0 (*)
├── pkcs8 v0.7.6 (*)
└── spki v0.4.1
    └── pkcs8 v0.7.6 (*) 

Later versions of pkcs1 and pkcs8 have been updated to der 0.5.0, so it would be sufficient to convince rsa to update their dependency versions of pkcs1 and pkcs8 to resolve this issue I think.

Error:

[INFO]: Compiling to Wasm...
   Compiling const-oid v0.6.2
   Compiling base64 v0.13.0
   Compiling base64ct v1.1.1
   Compiling identity-derive v0.4.0 (/home/runner/work/identity.rs/identity.rs/identity-diff/derive)
   Compiling pem-rfc7468 v0.2.4
   Compiling chrono v0.4.19
   Compiling bee-common v0.4.1
   Compiling crypto-bigint v0.2.11
   Compiling bee-message v0.1.5
   Compiling identity-diff v0.4.0 (/home/runner/work/identity.rs/identity.rs/identity-diff)
   Compiling der v0.4.4
   Compiling identity-core v0.4.0 (/home/runner/work/identity.rs/identity.rs/identity-core)
error[E0277]: can't compare `usize` with `()`
Error:    --> /home/runner/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/der-0.4.4/src/encoder.rs:151:43
    |
151 |         if nested_encoder.finish()?.len() == length.try_into()? {
    |                                           ^^ no implementation for `usize == ()`
    |
    = help: the trait `PartialEq<()>` is not implemented for `usize`

error[E0277]: the trait bound `(): From<Length>` is not satisfied
Error:    --> /home/runner/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/der-0.4.4/src/encoder.rs:151:53
    |
151 |         if nested_encoder.finish()?.len() == length.try_into()? {
    |                                                     ^^^^^^^^ the trait `From<Length>` is not implemented for `()`
    |
    = note: required because of the requirements on the impl of `Into<()>` for `Length`
note: required because of the requirements on the impl of `TryFrom<Length>` for `()`
   --> /home/runner/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/der-0.4.4/src/asn1/null.rs:46:6
    |
46  | impl TryFrom<Any<'_>> for () {
    |      ^^^^^^^^^^^^^^^^     ^^
    = note: required because of the requirements on the impl of `TryInto<()>` for `Length`

For more information about this error, try `rustc --explain E0277`.
error: could not compile `der` due to 2 previous errors
Error: warning: build failed, waiting for other jobs to finish...
error: build failed
Error: Error: Compiling your crate to WebAssembly failed
Caused by: failed to execute `cargo build`: exited with exit code: 101
  full command: "cargo" "build" "--lib" "--release" "--target" "wasm32-unknown-unknown"

It looks like someone has already created an issue for this: RustCrypto/RSA#120

@olivereanderson
Copy link
Contributor Author

Converted to Draft until the wasm build gets fixed one way or another.

@olivereanderson olivereanderson marked this pull request as ready for review December 1, 2021 18:09
@cycraig
Copy link
Contributor

cycraig commented Dec 1, 2021

For future reference, the Wasm compilation error was fixed by der releasing 0.4.5 with a backported fix. RustCrypto/formats#146

Copy link
Contributor

@cycraig cycraig left a comment

Choose a reason for hiding this comment

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

Looks good to me.

@olivereanderson olivereanderson merged commit 8b44869 into dev Dec 2, 2021
@olivereanderson olivereanderson added Rust Related to the core Rust code. Becomes part of the Rust changelog. Breaking change A change to the API that requires a major release. Part of "Changed" section in changelog labels Dec 15, 2021
@cycraig cycraig changed the title update to rsa 0.5 in libjose Update to rsa 0.5 in libjose Dec 15, 2021
@cycraig cycraig deleted the chore/upgrade-rsa-version-libjose branch December 15, 2021 10:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Breaking change A change to the API that requires a major release. Part of "Changed" section in changelog Rust Related to the core Rust code. Becomes part of the Rust changelog.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants