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

Cannot build with no-std #574

Closed
Martinits opened this issue Feb 4, 2024 · 1 comment
Closed

Cannot build with no-std #574

Martinits opened this issue Feb 4, 2024 · 1 comment

Comments

@Martinits
Copy link

I'm adding some code using aes-gcm/aes/cmac into a large project which is built with no-std and its own std implementation. So my code has to be no-std. But there's error:

error[E0152]: duplicate lang item in crate `std` (which `crypto_common` depends on): `panic_impl`.

How to configure that crypto_common dependency to be no-std?
Here's some part of my code, it's no more than the examples:

    let k = Key::<Aes128Gcm>::from_slice(key);
    let cipher = Aes128Gcm::new(&k);
    let nonce = Nonce::from_slice(...);
    cipher.decrypt_in_place_detached(...).map_errr(...)

    let mut nonce = [0u8; 16];
    rand::thread_rng().fill_bytes(&mut nonce);
    let mut mac = Cmac::<Aes128>::new_from_slice(...).unwrap();
    mac.update(...);
@tarcieri
Copy link
Member

tarcieri commented Feb 4, 2024

You are likely not disabling default features somewhere that's enabling crypto-common/std. Try adding default-features = false to all of your crate imports.

Note that all of our crates are tested in CI on no_std targets, e.g.:

https://github.com/RustCrypto/AEADs/actions/runs/7422268132/job/20197225732

https://github.com/RustCrypto/MACs/actions/runs/7746508860/job/21124872030

...so it's definitely something in your project which is enabling the std feature somehow.

@tarcieri tarcieri closed this as not planned Won't fix, can't repro, duplicate, stale Feb 4, 2024
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

2 participants