Skip to content

Build fails due to RustCrypto Trait changes #515

@AvivNaaman

Description

@AvivNaaman

Hi,

This is a similar duplicate of Devolutions/picky-rs#416 - seems like the same issue raised when building latest sspi:

error[E0277]: the trait bound `rsa::RsaPrivateKey: TryFrom<&PrivateKey>` is not satisfied
   --> /Users/avivnaaman/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/sspi-0.16.1/src/kerberos/client/mod.rs:183:51
    |
183 | ...                   let rsa_private_key = RsaPrivateKey::try_from(&private_key)?;
    |                                             ^^^^^^^^^^^^^ the trait `From<&PrivateKey>` is not implemented for `rsa::RsaPrivateKey`
    |
    = help: the following other types implement trait `From<T>`:
              `rsa::RsaPrivateKey` implements `From<BlindedSigningKey<D>>`
              `rsa::RsaPrivateKey` implements `From<rsa::pkcs1v15::SigningKey<D>>`
              `rsa::RsaPrivateKey` implements `From<rsa::pss::SigningKey<D>>`
    = note: required for `&PrivateKey` to implement `Into<rsa::RsaPrivateKey>`
    = note: required for `rsa::RsaPrivateKey` to implement `TryFrom<&PrivateKey>`

error[E0277]: `?` couldn't convert the error to `Error`
   --> /Users/avivnaaman/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/sspi-0.16.1/src/kerberos/client/mod.rs:183:88
    |
183 | ...                   let rsa_private_key = RsaPrivateKey::try_from(&private_key)?;
    |                                                                                  ^ the trait `From<Infallible>` is not implemented for `Error`
    |
    = note: the question mark operation (`?`) implicitly performs a conversion on the error value using the `From` trait
    = help: the following other types implement trait `From<T>`:
              `Error` implements `From<ApplicationTag<KrbErrorInner, 30>>`
              `Error` implements `From<Asn1DerError>`
              `Error` implements `From<CharSetError>`
              `Error` implements `From<DiffieHellmanError>`
              `Error` implements `From<FromUtf16Error>`
              `Error` implements `From<FromUtf8Error>`
              `Error` implements `From<GssApiMessageError>`
              `Error` implements `From<KerberosCryptoError>`
            and 8 others
    = note: required for `std::result::Result<Vec<u8>, Error>` to implement `FromResidual<std::result::Result<Infallible, Infallible>>`

error[E0277]: the trait bound `rsa::RsaPrivateKey: From<&PrivateKey>` is not satisfied
   --> /Users/avivnaaman/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/sspi-0.16.1/src/kerberos/client/mod.rs:183:51
    |
183 | ...                   let rsa_private_key = RsaPrivateKey::try_from(&private_key)?;
    |                                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `From<&PrivateKey>` is not implemented for `rsa::RsaPrivateKey`
    |
    = help: the following other types implement trait `From<T>`:
              `rsa::RsaPrivateKey` implements `From<BlindedSigningKey<D>>`
              `rsa::RsaPrivateKey` implements `From<rsa::pkcs1v15::SigningKey<D>>`
              `rsa::RsaPrivateKey` implements `From<rsa::pss::SigningKey<D>>`
    = note: required for `&PrivateKey` to implement `Into<rsa::RsaPrivateKey>`
    = note: required for `rsa::RsaPrivateKey` to implement `TryFrom<&PrivateKey>`

error[E0277]: the trait bound `IntegerAsn1: From<std::result::Result<Vec<u8>, DiffieHellmanError>>` is not satisfied
   --> /Users/avivnaaman/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/sspi-0.16.1/src/pk_init.rs:140:90
    |
140 |             key_value: BitStringAsn1::from(BitString::with_bytes(picky_asn1_der::to_vec(&IntegerAsn1::from(
    |                                                                                          ^^^^^^^^^^^ the trait `From<std::result::Result<Vec<u8>, DiffieHellmanError>>` is not implemented for `IntegerAsn1`
    |
    = help: the trait `From<std::result::Result<Vec<_>, DiffieHellmanError>>` is not implemented for `IntegerAsn1`
            but trait `From<Vec<_>>` is implemented for it
    = help: for that trait implementation, expected `Vec<u8>`, found `std::result::Result<Vec<u8>, DiffieHellmanError>`

error[E0308]: arguments to this function are incorrect
   --> /Users/avivnaaman/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/sspi-0.16.1/src/pku2u/cert_utils/validation.rs:43:19
    |
43  |         return Ok(RsaPublicKey::from_rsa_components(
    |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
44  |             &BigUint::from_bytes_be(&public_key.modulus.0),
    |             ---------------------------------------------- expected `&BoxedUint`, found `&BigUint`
45  |             &BigUint::from_bytes_be(&public_key.public_exponent.0),
    |             ------------------------------------------------------ expected `&BoxedUint`, found `&BigUint`
    |
    = note: expected reference `&crypto_bigint::uint::boxed::BoxedUint`
               found reference `&BigUint`
    = note: expected reference `&crypto_bigint::uint::boxed::BoxedUint`
               found reference `&BigUint`
note: associated function defined here
   --> /Users/avivnaaman/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/picky-7.0.0-rc.19/src/key/mod.rs:895:12
    |
895 |     pub fn from_rsa_components(modulus: &BoxedUint, public_exponent: &BoxedUint) -> Self {
    |            ^^^^^^^^^^^^^^^^^^^

error[E0277]: the trait bound `OsRng: rand_core::TryCryptoRng` is not satisfied
   --> /Users/avivnaaman/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/sspi-0.16.1/src/pku2u/generators.rs:163:48
    |
163 |     let private_key = generate_private_key(&q, rng);
    |                       --------------------     ^^^ the trait `DerefMut` is not implemented for `OsRng`
    |                       |
    |                       required by a bound introduced by this call
    |
note: there are multiple different versions of crate `rand_core` in the dependency graph
   --> /Users/avivnaaman/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/rand_core-0.9.3/src/lib.rs:291:1
    |
291 | pub trait TryCryptoRng: TryRngCore {}
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this is the required trait
    |
   ::: /Users/avivnaaman/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/sspi-0.16.1/src/credssp/ts_request/mod.rs:11:5
    |
11  | use picky_krb::constants::cred_ssp::{AT_KEYEXCHANGE, TS_PASSWORD_CREDS};
    |     ---------
    |     |
    |     one version of crate `rand_core` used here, as a dependency of crate `rand`
    |     one version of crate `rand_core` used here, as a dependency of crate `rand`
    |
   ::: /Users/avivnaaman/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/rand_core-0.6.4/src/os.rs:48:1
    |
48  | pub struct OsRng;
    | ---------------- this type doesn't implement the required trait
    |
   ::: /Users/avivnaaman/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/rand_core-0.9.3/src/os.rs:47:1
    |
47  | pub struct OsRng;
    | ---------------- this type implements the required trait
    |
   ::: /Users/avivnaaman/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/rand_core-0.6.4/src/block.rs:68:1
    |
68  | pub trait BlockRngCore {
    | ---------------------- this is the found trait
    = note: two types coming from two different versions of the same crate are different types even if they look the same
    = help: you can use `cargo tree` to explore your dependency tree
    = note: required for `OsRng` to implement `rand_core::CryptoRng`
    = note: required for `OsRng` to implement `rand_core::TryCryptoRng`
note: required by a bound in `generate_private_key`
   --> /Users/avivnaaman/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/picky-krb-0.11.3/src/crypto/diffie_hellman.rs:128:32
    |
128 | pub fn generate_private_key<R: TryCryptoRng>(q: &[u8], rng: &mut R) -> Result<Vec<u8>, R::Error> {
    |                                ^^^^^^^^^^^^ required by this bound in `generate_private_key`

error[E0308]: mismatched types
   --> /Users/avivnaaman/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/sspi-0.16.1/src/pku2u/generators.rs:169:9
    |
169 |         private_key,
    |         ^^^^^^^^^^^ expected `Vec<u8>`, found `Result<Vec<u8>, Infallible>`
    |
    = note: expected struct `Vec<_>`
                 found enum `std::result::Result<Vec<_>, Infallible>`
help: use the `?` operator to extract the `std::result::Result<Vec<u8>, Infallible>` value, propagating a `Result::Err` value to the caller
    |
169 |         private_key: private_key?,
    |                    ++++++++++++++

error[E0277]: the trait bound `OsRng: rand_core::RngCore` is not satisfied
   --> /Users/avivnaaman/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/sspi-0.16.1/src/pku2u/generators.rs:163:23
    |
163 |     let private_key = generate_private_key(&q, rng);
    |                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `DerefMut` is not implemented for `OsRng`
    |
note: there are multiple different versions of crate `rand_core` in the dependency graph
   --> /Users/avivnaaman/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/rand_core-0.9.3/src/lib.rs:220:1
    |
220 | pub trait TryRngCore {
    | ^^^^^^^^^^^^^^^^^^^^ this is the required trait
    |
   ::: /Users/avivnaaman/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/sspi-0.16.1/src/credssp/ts_request/mod.rs:11:5
    |
11  | use picky_krb::constants::cred_ssp::{AT_KEYEXCHANGE, TS_PASSWORD_CREDS};
    |     ---------
    |     |
    |     one version of crate `rand_core` used here, as a dependency of crate `rand`
    |     one version of crate `rand_core` used here, as a dependency of crate `rand`
    |
   ::: /Users/avivnaaman/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/rand_core-0.6.4/src/os.rs:48:1
    |
48  | pub struct OsRng;
    | ---------------- this type doesn't implement the required trait
    |
   ::: /Users/avivnaaman/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/rand_core-0.9.3/src/os.rs:47:1
    |
47  | pub struct OsRng;
    | ---------------- this type implements the required trait
    |
   ::: /Users/avivnaaman/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/rand_core-0.6.4/src/block.rs:68:1
    |
68  | pub trait BlockRngCore {
    | ---------------------- this is the found trait
    = note: two types coming from two different versions of the same crate are different types even if they look the same
    = help: you can use `cargo tree` to explore your dependency tree
    = note: required for `OsRng` to implement `rand_core::RngCore`
    = note: required for `OsRng` to implement `rand_core::TryRngCore`

error[E0004]: non-exhaustive patterns: `KerberosCryptoError::RandError(_)`, `KerberosCryptoError::TooSmallBuffer(_)` and `KerberosCryptoError::ArrayTryFromSliceError(_)` not covered
    --> /Users/avivnaaman/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/sspi-0.16.1/src/lib.rs:2239:15
     |
2239 |         match err {
     |               ^^^ patterns `KerberosCryptoError::RandError(_)`, `KerberosCryptoError::TooSmallBuffer(_)` and `KerberosCryptoError::ArrayTryFromSliceError(_)` not covered
     |
note: `KerberosCryptoError` defined here
    --> /Users/avivnaaman/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/picky-krb-0.11.3/src/crypto/mod.rs:19:1
     |
19   | pub enum KerberosCryptoError {
     | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...
39   |     RandError(#[from] rand::rand_core::OsError),
     |     --------- not covered
40   |     #[error(transparent)]
41   |     TooSmallBuffer(#[from] inout::OutIsTooSmallError),
     |     -------------- not covered
42   |     #[error(transparent)]
43   |     ArrayTryFromSliceError(#[from] std::array::TryFromSliceError),
     |     ---------------------- not covered
     = note: the matched value is of type `KerberosCryptoError`
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms
     |
2264 ~             ),
2265 ~             KerberosCryptoError::RandError(_) | KerberosCryptoError::TooSmallBuffer(_) | KerberosCryptoError::ArrayTryFromSliceError(_) => todo!(),
     |

Some errors have detailed explanations: E0004, E0277, E0308.
For more information about an error, try `rustc --explain E0004`.
error: could not compile `sspi` (lib) due to 9 previous errors

Would love to get your help in this matter :)

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions