alexcrichton / wasm-sodium

PoC of libsodium being used in Rust on wasm32-unknown-unknown
25 stars 3 forks source link

Crypto.getRandomValues? #1

Closed ghost closed 6 years ago

ghost commented 6 years ago

Hey, nice work porting this to wasm! I see that it's currently using Math.random though, so it's not fit for secure use unless someone brings their own keys?

I don't know how this interacts with wasm's concept of arrays, but I figure it should be possible to use Crypto.getRandomValues instead of Math.random. Is this something you explored already and ruled out, for now?

Thanks!

alexcrichton commented 6 years ago

Oh I initially selected Math.random because there's not a great way to natively use Crypto.getRandomValues from #[wasm_bindgen] today, although I think I see a possible way to do that so I'll see if I can get that implemented and then I can update this!

alexcrichton commented 6 years ago

With https://github.com/rustwasm/wasm-bindgen/pull/183 wasm-bindgen now supports JS writing directly into wasm memory with slices and I've updated this in https://github.com/alexcrichton/wasm-sodium/commit/ccbfd8f7a0655653b03cc0d36961b5660ea29dd1 to show off how it can be used

That'll need some tweaks for a browser but if you need any guidance for that just let me know!

ghost commented 6 years ago

Thank you! Great to see WASM maturing so fast. :)

On 1 May 2018 19:31:18 GMT+01:00, Alex Crichton notifications@github.com wrote:

With https://github.com/rustwasm/wasm-bindgen/pull/183 wasm-bindgen now supports JS writing directly into wasm memory with slices and I've updated this in https://github.com/alexcrichton/wasm-sodium/commit/ccbfd8f7a0655653b03cc0d36961b5660ea29dd1 to show off how it can be used

That'll need some tweaks for a browser but if you need any guidance for that just let me know!

-- You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub: https://github.com/alexcrichton/wasm-sodium/issues/1#issuecomment-385749844

-- Sent from my Android device with K-9 Mail. Please excuse my brevity.