-
Notifications
You must be signed in to change notification settings - Fork 730
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
Add support for fuchsia's CPRNG source #765
Conversation
Hi, although when I was reviewing #634 I was initially resistant to pulling in the Rust crate, my understanding is that somebody fixed the issue in The second issue I had with the original PR was the way it handled the short read behavior of the older Fuchsia PRNG API. My understanding is that there are no short reads to worry about any more, right? The final issue with the original PR was that it isn't clear, to me, how to test this. Originally I was hoping somebody would provide a way to have Fuchsia builds and tests done automatically in CI just like we have for all other platforms. I think that should be a long-term goal. But for now, could you share the minimal instructions for running the ring tests on Fucshia, so I can do it manually? |
Hello Brian!
If you want to use ccache, throw in a
Those tests are failing because fargo doesn't know that it has to copy around artifacts like
Hurrah! It worked! But that wasn't super pleasant. Hopefully we can find some better way to do this. Oh and one thing to note if you do get into fuchsia, ctrl-c doesn't work. It'll just kill your session, rather than interrupt something that's running. The joys of writing a new operating system :) Please let me know if you run into any trouble. |
Also, if you aren't used to qemu, to quit, do |
fyi, we need to do a bump of fuchsia-zircon, so that'll push this PR into next week at the earliest. |
@briansmith I've updated the PR to use a new crate we just published called fuchsia-cprng that only exposes the CPRNG syscall. This reduces your exposure to us changing syscalls, since we don't expect to change this particular syscall. Please let me know if there's anything else you need from us. Also, if you do accept this, would it be possible to get a new release cut so that we can use ring on fuchsia? Thanks so much for everything! |
Thanks. Please update the Now I see I don't understand what's going on with Will you be contributing the Aarch64 (And ARM, if you support 32-bit ARM) CPU feature detection for Fuchsia in a separate PR? My understanding is that Fuchsia has its own |
To further clarify what I'm getting at: It seems like ring needs to access two Fuchsia-specific functions: |
Hello Brian! You can find the source in our repository here, or you can see it on docs.rs. Good idea about pointing the crate repo link deeper in the tree. I'll make that update. Regarding our licensing, I'm told that SPDX does not yet cover our license with our patent grant, so I was told we were supposed to use the Regarding CPU feature detection, shucks, I didn't realize you'd need that. I'll have to do some investigation. Regarding 32bit vs 64bit, we only support arm64 and x86-64. |
@briansmith I talked with our team, and at the moment we are still really interested in removing our dependencies on fuchsia-zircon so we can make some breaking changes to it (that are unrelated to these syscalls) without having to push changes through our external dependencies. For now, I suggest that either we skip having acceleration on aarch64 for now, or you just explicitly call out to Any luck getting the tests inside fuchsia up and running? |
OK, I will spend some time today trying to get If we're going to use FFI to call |
I updated the PR to switch back to directly calling Is there a particular reason to block this PR on getting |
Ah, because you just merged in the cpu feature detection. I'll see what I can do on a patch for that. |
I opened a separate PR for feature detection in #776. |
OK, thanks for the instructions for testing. Even before applying this PR, I get this bad behavior using your instructions:
I edited that file to add some |
If I reduce the value of |
That's wonderful it worked! I'll do some digging into why the release build is running into issues. |
This adds support for detecting arm features on a fuchsia device, which uses the `zx_system_get_features` syscall to extract out this information, which is described here: https://fuchsia.googlesource.com/zircon/+/master/docs/syscalls/system_get_features.md The feature constants can be found here: https://fuchsia.googlesource.com/zircon/+/master/system/public/zircon/features.h The type `zx_status_t` and ZX_OK are defined here: https://fuchsia.googlesource.com/zircon/+/master/system/public/zircon/types.h#39 https://fuchsia.googlesource.com/zircon/+/master/system/public/zircon/errors.h#14 I agree to license my contributions to each file under the terms given at the top of each file I changed.
This is another attempt for ring to support fuchsia, by directly calling `zx_cprng_draw` to generate random byte strings. This avoids having to pull in an extra dependency (which briansmith#634 did). With this change, all the ring tests pass on fuchsia. I agree to license my contributions to each file under the terms given at the top of each file I changed. Closes briansmith#428
I just pushed up a fix for getting the build to work on x86, but I wasn't able to reproduce the issue you ran into with
Hopefully that'll get the tests to pass. Also, if for some reason you want to use straight cargo, you can use |
The problem seems to be that
Otherwise, without manually setting
Similarly, previously I was getting linking errors for X86_64 builds, and |
As of ab0726d, this is no longer necessary. |
Actually, the test never timed out. Instead the test driver reports "test aead::chacha::tests::chacha20_tests has been running for over 60 seconds" but if you wait a long time the test will complete successfully. This happens for other tests too sometimes. Simply, QEMU is much slower than a real machine. (32-bit ARM and 32-bit x86 are special cased in this test to avoid part of the test that isn't relevant for them.)
This was caused by me not setting |
Wonderful! Thanks @briansmith for helping me get this landed! |
This is another attempt for ring to support fuchsia, by directly calling
zx_cprng_draw
to generate random byte strings. This avoids having to pull in an extra dependency (which #634 did). With this change, all the ring tests pass on fuchsia.Closes #428