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

can't call foreign function sha256_compress on OS linux #3066

Closed
simonsan opened this issue Sep 19, 2023 · 2 comments
Closed

can't call foreign function sha256_compress on OS linux #3066

simonsan opened this issue Sep 19, 2023 · 2 comments

Comments

@simonsan
Copy link

Ran into this today:

can't call foreign function `sha256_compress` on OS `linux`

https://github.com/RustCrypto/asm-hashes/blob/master/sha2/src/lib.rs#L18

error: unsupported operation: can't call foreign function `sha256_compress` on OS `linux`
Error:    --> /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/sha2-asm-0.6.3/src/lib.rs:25:18
    |
25  |         unsafe { sha256_compress(state, block) }
    |                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't call foreign function `sha256_compress` on OS `linux`
    |
    = help: this is likely not a bug in the program; it indicates that the program performed an operation that the interpreter does not support
    = note: BACKTRACE:
    = note: inside `sha2_asm::compress256` at /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/sha2-asm-0.6.3/src/lib.rs:25:18: 25:47
    = note: inside `sha2::sha256::x86::compress` at /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/sha2-0.10.7/src/sha256/x86.rs:110:9: 110:45
    = note: inside `sha2::sha256::compress256` at /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/sha2-0.10.7/src/sha256.rs:36:5: 36:28
    = note: inside `<sha2::core_api::Sha256VarCore as digest::core_api::UpdateCore>::update_blocks` at /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/sha2-0.10.7/src/core_api.rs:37:9: 37:45
    = note: inside `<digest::core_api::ct_variable::CtVariableCoreWrapper<sha2::core_api::Sha256VarCore, typenum::uint::UInt<typenum::uint::UInt<typenum::uint::UInt<typenum::uint::UInt<typenum::uint::UInt<typenum::uint::UInt<typenum::uint::UTerm, typenum::bit::B1>, typenum::bit::B0>, typenum::bit::B0>, typenum::bit::B0>, typenum::bit::B0>, typenum::bit::B0>, sha2::OidSha256> as digest::core_api::UpdateCore>::update_blocks` at /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/digest-0.10.7/src/core_api/ct_variable.rs:79:9: 79:41
    = note: inside `<hmac::optim::HmacCore<digest::core_api::wrapper::CoreWrapper<digest::core_api::ct_variable::CtVariableCoreWrapper<sha2::core_api::Sha256VarCore, typenum::uint::UInt<typenum::uint::UInt<typenum::uint::UInt<typenum::uint::UInt<typenum::uint::UInt<typenum::uint::UInt<typenum::uint::UTerm, typenum::bit::B1>, typenum::bit::B0>, typenum::bit::B0>, typenum::bit::B0>, typenum::bit::B0>, typenum::bit::B0>, sha2::OidSha256>>> as crypto_common::KeyInit>::new_from_slice` at /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/hmac-0.12.1/src/optim.rs:158:9: 158:52
    = note: inside `<digest::core_api::wrapper::CoreWrapper<hmac::optim::HmacCore<digest::core_api::wrapper::CoreWrapper<digest::core_api::ct_variable::CtVariableCoreWrapper<sha2::core_api::Sha256VarCore, typenum::uint::UInt<typenum::uint::UInt<typenum::uint::UInt<typenum::uint::UInt<typenum::uint::UInt<typenum::uint::UInt<typenum::uint::UTerm, typenum::bit::B1>, typenum::bit::B0>, typenum::bit::B0>, typenum::bit::B0>, typenum::bit::B0>, typenum::bit::B0>, sha2::OidSha256>>>> as crypto_common::KeyInit>::new_from_slice` at /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/digest-0.10.7/src/core_api/wrapper.rs:109:19: 109:41
    = note: inside `pbkdf2::pbkdf2::<digest::core_api::wrapper::CoreWrapper<hmac::optim::HmacCore<digest::core_api::wrapper::CoreWrapper<digest::core_api::ct_variable::CtVariableCoreWrapper<sha2::core_api::Sha256VarCore, typenum::uint::UInt<typenum::uint::UInt<typenum::uint::UInt<typenum::uint::UInt<typenum::uint::UInt<typenum::uint::UInt<typenum::uint::UTerm, typenum::bit::B1>, typenum::bit::B0>, typenum::bit::B0>, typenum::bit::B0>, typenum::bit::B0>, typenum::bit::B0>, sha2::OidSha256>>>>>` at /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/pbkdf2-0.12.2/src/lib.rs:176:15: 176:44
    = note: inside `pbkdf2::pbkdf2_hmac::<digest::core_api::wrapper::CoreWrapper<digest::core_api::ct_variable::CtVariableCoreWrapper<sha2::core_api::Sha256VarCore, typenum::uint::UInt<typenum::uint::UInt<typenum::uint::UInt<typenum::uint::UInt<typenum::uint::UInt<typenum::uint::UInt<typenum::uint::UTerm, typenum::bit::B1>, typenum::bit::B0>, typenum::bit::B0>, typenum::bit::B0>, typenum::bit::B0>, typenum::bit::B0>, sha2::OidSha256>>>` at /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/pbkdf2-0.12.2/src/lib.rs:247:5: 247:64
    = note: inside `scrypt::scrypt` at /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/scrypt-0.11.0/src/lib.rs:109:5: 109:53
note: inside `rustic_core::repofile::KeyFile::generate::<&str>`
   --> /home/runner/work/rustic_core/rustic_core/src/repofile/keyfile.rs:165:9
    |
165 |         scrypt::scrypt(passwd.as_ref(), &salt, &params, &mut key)
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: inside `rustic_core::KeyOptions::add::<rustic_core::NoProgressBars, ()>`
   --> /home/runner/work/rustic_core/rustic_core/src/commands/key.rs:108:23
    |
108 |         let keyfile = KeyFile::generate(key, &pass, ko.hostname, ko.username, ko.with_created)?;
    |                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: inside `rustic_core::KeyOptions::init_key::<rustic_core::NoProgressBars, ()>`
   --> /home/runner/work/rustic_core/rustic_core/src/commands/key.rs:86:18
    |
86  |         Ok((key, self.add(repo, pass, key)?))
    |                  ^^^^^^^^^^^^^^^^^^^^^^^^^
note: inside `rustic_core::commands::init::init_with_config::<rustic_core::NoProgressBars, ()>`
   --> /home/runner/work/rustic_core/rustic_core/src/commands/init.rs:82:21
    |
82  |     let (key, id) = key_opts.init_key(repo, pass)?;
    |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: inside `rustic_core::commands::init::init::<rustic_core::NoProgressBars, ()>`
   --> /home/runner/work/rustic_core/rustic_core/src/commands/init.rs:52:15
    |
52  |     let key = init_with_config(repo, pass, key_opts, &config)?;
    |               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: inside `rustic_core::Repository::<rustic_core::NoProgressBars, ()>::init_with_password`
   --> /home/runner/work/rustic_core/rustic_core/src/repository.rs:606:29
    |
606 |         let (key, config) = commands::init::init(&self, pass, key_opts, config_opts)?;
    |                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: inside `rustic_core::Repository::<rustic_core::NoProgressBars, ()>::init`
   --> /home/runner/work/rustic_core/rustic_core/src/repository.rs:571:9
    |
571 |         self.init_with_password(&password, key_opts, config_opts)
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: inside `main::_doctest_main_src_lib_rs_25_0`
   --> src/lib.rs:36:17
    |
14  |     let _repo = Repository::new(&repo_opts).unwrap().init(&key_opts, &config_opts).unwrap();
    |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: inside `main`
   --> src/lib.rs:68:3
    |
46  | } _doctest_main_src_lib_rs_25_0() }
    |   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
simonsan added a commit to rustic-rs/rustic_core that referenced this issue Sep 19, 2023
@bjorn3
Copy link
Member

bjorn3 commented Sep 19, 2023

sha256_compress is implemented in assembly, which miri doesn't interpret. If you disable the asm cargo feature for the sha2 crate it should use a pure rust implementation instead.

@RalfJung
Copy link
Member

This is not a widely-existing function but specific to that crate, so we won't add a shim for it in Miri. Looks like a work-around exists, so this can be closed.

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

No branches or pull requests

3 participants