Guest User

Untitled

a guest
Jun 22nd, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.43 KB | None | 0 0
  1. humbug@home:~/zetox$ git diff | cat
  2. diff --git a/Cargo.toml b/Cargo.toml
  3. index 9206765..b4f0b15 100644
  4. --- a/Cargo.toml
  5. +++ b/Cargo.toml
  6. @@ -33,7 +33,7 @@ bytes = "0.4"
  7. byteorder = "1"
  8. futures = "0.1"
  9. log = "0.4"
  10. -sodiumoxide = "0.0.16"
  11. +sodiumoxide = "0.1"
  12. tokio = "0.1.7"
  13. tokio-codec = "0.1"
  14. nom = "3.2.1"
  15. diff --git a/src/toxcore/crypto_core.rs b/src/toxcore/crypto_core.rs
  16. index 8a3702b..f7cff64 100644
  17. --- a/src/toxcore/crypto_core.rs
  18. +++ b/src/toxcore/crypto_core.rs
  19. @@ -26,17 +26,12 @@ pub use sodiumoxide::crypto::box_::*;
  20. pub use sodiumoxide::crypto::hash::{sha256, sha512};
  21. pub use sodiumoxide::crypto::secretbox;
  22.  
  23. -use std::sync::{Once, ONCE_INIT};
  24. use byteorder::{ByteOrder, NativeEndian};
  25.  
  26. use toxcore::binary_io::*;
  27.  
  28. // TODO: check if `#[inline]` is actually useful
  29.  
  30. -
  31. -static CRYPTO_INIT_ONCE: Once = ONCE_INIT;
  32. -static mut CRYPTO_INIT: bool = false;
  33. -
  34. /** Run before using crypto.
  35.  
  36. Runs [`sodiumoxide::init()`](../../../sodiumoxide/fn.init.html).
  37. @@ -54,14 +49,7 @@ assert_eq!(true, crypto_init());
  38. ```
  39. */
  40. pub fn crypto_init() -> bool {
  41. - // NOTE: `init()` could be run more than once, but not in parallel, and
  42. - // `CRYPTO_INIT` *can't* be modified while it may be read by
  43. - // something else.
  44. - CRYPTO_INIT_ONCE.call_once(|| {
  45. - let initialized = ::sodiumoxide::init();
  46. - unsafe { CRYPTO_INIT = initialized; }
  47. - });
  48. - unsafe { CRYPTO_INIT }
  49. + ::sodiumoxide::init().is_ok()
  50. }
Add Comment
Please, Sign In to add comment