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

compiling to wasm fails due to clear_on_drop without no_cc ? #281

Closed
warner opened this issue Sep 1, 2019 · 5 comments
Closed

compiling to wasm fails due to clear_on_drop without no_cc ? #281

warner opened this issue Sep 1, 2019 · 5 comments

Comments

@warner
Copy link

warner commented Sep 1, 2019

I'm experimenting with using magic-wormhole.rs in a browser context, for which I'm compiling it to WASM (https://github.com/warner/magic-wormhole.rs/issues/2). This is my first attempt at doing anything with WASM, so please tell me if I'm missing something obvious, but I'm seeing the wasm-pack build fail because clear_on_drop is trying to compile a C file, and I guess that doesn't work when the target is WASM. The dependency chain is magic-wormhole -> spake2 -> curve25519-dalek -> clear_on_drop.

It looks like clear_on_drop has a feature (no_cc) that would disable the C compilation, which might allow this to work. But there's no way for magic-wormhole to ask curve25519-dalek to ask clear_on_drop to use that feature.

So I think what I'm asking for is some curve25519-dalek feature that would then modify its clear_on_drop dependency's features to avoid this C compile. Then I could add a similar feature to spake2 that affects its dependency upon curve25519-dalek, and then again with magic-wormhole affecting its dependency upon spake2 to pass the request along.

Does that make sense? It sounds like a lot of work spread over many crates, and I have to imagine that every "feature" added to a Cargo.toml is a long-lived maintenance burden, so I don't really want to make a high-cost feature request for a fringe use case. And clear-on-drop is obviously the right thing to be doing, I don't want to see it become harder to achieve that security property. Is there a better way that people deal with this cross-crate feature handling?

For magic-wormhole's own clear-the-old-secrets purposes, I'm considering the zeroize crate, which I think is pure-Rust. But I don't really know what the tradeoffs are; I have to imagine clear_on_drop is more reliable or more thorough when it can use lower-level tools.

@tarcieri
Copy link
Contributor

tarcieri commented Sep 1, 2019

@warner re: zeroize, I think they're waiting for zeroize 1.0, since it's part of the public API.

Barring any unforeseen circumstances, the next release of zeroize will be 1.0. I can probably cut a 1.0 prerelease soon.

@warner
Copy link
Author

warner commented Sep 1, 2019

Cool, thanks, that sounds like the best solution. I'll wait for that update.

@burdges
Copy link
Contributor

burdges commented Sep 1, 2019

As cargo features are additive then it might help if you add clear_on_drop as your own dependency with the no_cc feature. I suppose clear_on_drop might be violating feature additivity by using no_cc this way, but hey yet another problem with clear_on_drop.

@warner
Copy link
Author

warner commented Sep 1, 2019

Oh, thank you! That at least gets me a quick workaround I can use to move forward with testing.

@hdevalence
Copy link
Contributor

@warner clear_on_drop doesn't require a C compiler when using its nightly feature, so you can alternately prevent its use by enabling the curve25519-dalek/nightly feature.

The issue with zeroize is that it works using a public trait, rather than an internal implementation detail, so while we can drop clear_on_drop at any time to switch to zeroize, once we do, we're stuck supporting it until making a breaking change.

tarcieri added a commit to tarcieri/curve25519-dalek that referenced this issue Sep 30, 2019
`zeroize` is WASM-friendly as it has no dependencies on C compilers.

Instead uses Rust's own volatile write semantics and compiler fences to
ensure zeroization is not elided by the compiler.
tarcieri added a commit to tarcieri/curve25519-dalek that referenced this issue Oct 5, 2019
`zeroize` is WASM-friendly as it has no dependencies on C compilers.

Instead uses Rust's own volatile write semantics and compiler fences to
ensure zeroization is not elided by the compiler.
tarcieri added a commit to tarcieri/curve25519-dalek that referenced this issue Oct 5, 2019
`zeroize` is WASM-friendly as it has no dependencies on C compilers.

Instead uses Rust's own volatile write semantics and compiler fences to
ensure zeroization is not elided by the compiler.
tarcieri added a commit to tarcieri/curve25519-dalek that referenced this issue Oct 13, 2019
`zeroize` is WASM-friendly as it has no dependencies on C compilers.

Instead uses Rust's own volatile write semantics and compiler fences to
ensure zeroization is not elided by the compiler.
hdevalence pushed a commit that referenced this issue Oct 23, 2019
`zeroize` is WASM-friendly as it has no dependencies on C compilers.

Instead uses Rust's own volatile write semantics and compiler fences to
ensure zeroization is not elided by the compiler.
hdevalence added a commit that referenced this issue Oct 24, 2019
Switch from `clear_on_drop` to `zeroize` (fixes #281)
pinkforest pushed a commit to pinkforest/curve25519-dalek that referenced this issue Jun 27, 2023
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

4 participants