Comments (34)
running 542 tests
test toxcore::crypto_core::tests::crypto_init_test ... ok
alice_pk = PublicKey([127, 71, 215, 228, 18, 40, 100, 184, 186, 158, 178, 170, 102, 5, 177, 21, 105, 82, 207, 123, 8, 6, 230, 142, 123, 192, 140, 27, 108, 197, 150, 123]),
alice_sk = [238, 115, 125, 75, 116, 121, 183, 189, 118, 66, 194, 5, 247, 157, 36, 177, 136, 141, 224, 72, 69, 103, 117, 36, 84, 108, 253, 58, 162, 135, 104, 162],
bob_pk = PublicKey([137, 7, 228, 12, 185, 93, 189, 33, 161, 239, 221, 155, 122, 211, 161, 135, 7, 189, 188, 94, 101, 145, 66, 221, 174, 235, 183, 127, 82, 234, 248, 116]),
bob_sk = [181, 105, 85, 80, 187, 92, 227, 190, 237, 114, 222, 133, 222, 192, 84, 207, 231, 91, 161, 187, 178, 130, 137, 241, 101, 230, 166, 6, 62, 208, 61, 251],
nonce = Nonce([219, 2, 66, 226, 29, 162, 129, 210, 141, 14, 132, 203, 191, 114, 32, 190, 185, 97, 184, 82, 143, 24, 237, 45])
test toxcore::crypto_core::tests::increment_nonce_number_test_zero_plus_0xff00 ... ok
test toxcore::crypto_core::tests::increment_nonce_number_test_0xff0000_plus_0x011000 ... ok
thread 'toxcore::crypto_core::tests::encrypt_precompute_test' panicked at 'called `Result::unwrap()` on an `Err` value: ()', libcore/result.rs:1009:5
Opps! It succeeded. Refer below comment
from tox.
Is it reproducible? If so can you catch generated keys and nonce when this test fails?
from tox.
Nice catch!
from tox.
running 542 tests
encrypt_precompute_test
alice_pk = PublicKey([130, 229, 192, 148, 62, 201, 246, 193, 93, 224, 30, 219, 87, 87, 2, 12, 62, 30, 48, 232, 117, 82, 8, 130, 163, 193, 49, 245, 218, 6, 96, 46]),
alice_sk = [171, 208, 8, 222, 230, 181, 77, 126, 123, 252, 115, 199, 62, 25, 118, 30, 226, 141, 140, 96, 9, 44, 222, 35, 68, 140, 215, 130, 170, 114, 59, 150],
bob_pk = PublicKey([42, 17, 171, 186, 151, 85, 130, 197, 12, 103, 66, 216, 205, 54, 68, 65, 135, 25, 87, 132, 39, 179, 211, 13, 181, 207, 212, 85, 14, 83, 122, 102]),
bob_sk = [97, 30, 222, 95, 222, 225, 16, 217, 220, 125, 253, 76, 81, 148, 83, 82, 23, 123, 180, 120, 176, 48, 1, 6, 96, 5, 61, 147, 124, 11, 78, 209],
nonce = Nonce([243, 128, 244, 180, 215, 104, 117, 98, 88, 250, 155, 217, 110, 165, 210, 188, 185, 18, 138, 238, 59, 80, 207, 211])
This is captured correctly.
from tox.
encrypt_precompute_test
failure alternates with encrypt_data_symmetric_test
failure
from tox.
#[test]
// test uses "bare" functions provided by `sodiumoxide`, with an exception
// of the tested function
fn encrypt_precompute_test() {
let alice_pk = PublicKey([130, 229, 192, 148, 62, 201, 246, 193, 93, 224, 30, 219, 87, 87, 2, 12, 62, 30, 48, 232, 117, 82, 8, 130, 163, 193, 49, 245, 218, 6, 96, 46]);
let alice_sk = SecretKey([171, 208, 8, 222, 230, 181, 77, 126, 123, 252, 115, 199, 62, 25, 118, 30, 226, 141, 140, 96, 9, 44, 222, 35, 68, 140, 215, 130, 170, 114, 59, 150]);
let bob_pk = PublicKey([42, 17, 171, 186, 151, 85, 130, 197, 12, 103, 66, 216, 205, 54, 68, 65, 135, 25, 87, 132, 39, 179, 211, 13, 181, 207, 212, 85, 14, 83, 122, 102]);
let bob_sk = SecretKey([97, 30, 222, 95, 222, 225, 16, 217, 220, 125, 253, 76, 81, 148, 83, 82, 23, 123, 180, 120, 176, 48, 1, 6, 96, 5, 61, 147, 124, 11, 78, 209]);
let alice_plaintext = b"Hi, Bob.";
let alice_precomputed_key = encrypt_precompute(&bob_pk, &alice_sk);
let nonce = Nonce([243, 128, 244, 180, 215, 104, 117, 98, 88, 250, 155, 217, 110, 165, 210, 188, 185, 18, 138, 238, 59, 80, 207, 211]);
let ciphertext = seal_precomputed(alice_plaintext, &nonce, &alice_precomputed_key);
let bob_precomputed_key = encrypt_precompute(&alice_pk, &bob_sk);
let bob_plaintext = open_precomputed(&ciphertext, &nonce, &bob_precomputed_key).unwrap();
assert_eq!(alice_plaintext, &bob_plaintext[..]);
}
$ cargo test encrypt_precompute_test
Compiling tox v0.0.7 (/home/humbug/tox)
Finished dev [unoptimized + debuginfo] target(s) in 8.56s
Running target/debug/deps/tox-d08d73a27a9a5786
running 1 test
test toxcore::crypto_core::tests::encrypt_precompute_test ... ok
from tox.
Perhaps it's mac-specific? @NamsooCho can you try this test that @kpp posted? Does it fail?
from tox.
Do you use system libsodium(with SODIUM_LIB_DIR)?
from tox.
Do you use system libsodium(with SODIUM_LIB_DIR)?
Yes
from tox.
Perhaps it's mac-specific? @NamsooCho can you try this test that @kpp posted? Does it fail?
Yes. I will do it tomorrow.
from tox.
The test that @kpp posted always success on Mac.
But irregularly cargo test
still fails.
failures:
---- toxcore::crypto_core::tests::encrypt_data_symmetric_test stdout ----
thread 'toxcore::crypto_core::tests::encrypt_data_symmetric_test' panicked at 'called `Result::unwrap()` on an `Err` value: ()', libcore/result.rs:1009:5
note: Run with `RUST_BACKTRACE=1` for a backtrace.
failures:
toxcore::crypto_core::tests::encrypt_data_symmetric_test
test result: FAILED. 541 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out
from tox.
@NamsooCho try to put sodium::init()
in the beginning of the test
from tox.
Putting crypto_init()
solves this problem.
from tox.
When making it like this
pub fn crypto_init() -> bool {
// ::sodiumoxide::init().is_ok()
true
}
never fails on cargo test
from tox.
Maybe It is because, one thread do job of sodium, other thread call crypto_init().
from tox.
never fails on
cargo test
Did you remove libsodium from brew and did you build tox
with static && newest libsodium?
from tox.
Did you remove libsodium from brew and did you build tox with static && newest libsodium?
Yes
from tox.
Maybe that's the reason of the fix?
from tox.
No. even after removing libsodium from brew, it fails irregularly.
from tox.
But you said:
When making it like this .... never fails on
cargo test
from tox.
Yes. after making crypto_init() to blank, it always success.
from tox.
Wow... does it fail with cargo test -- --test-threads=1
with non-blank crypto_init
?
from tox.
Test with cargo test -- --test-threads=1
with non-blank crypto_init
never fail.
from tox.
What is the frequency of failing with cargo test -- --test-threads=4
with non-blank crypto_init
?
from tox.
Run 9 times, 1 fails.
from tox.
How many times did you run cargo test -- --test-threads=1
?
from tox.
about 10 times.
from tox.
Run 30 times more =)
from tox.
40 times all success
from tox.
From https://libsodium.gitbook.io/doc/internals :
Thread safety
Initializing the random number generator is the only operation that requires an internal lock.
sodium_init() should be called before any other functions. It picks the best implementations for the current platform, initializes the random number generator and generates the canary for guarded heap allocations.
On POSIX systems, everything in libsodium is guaranteed to always be thread-safe.
from tox.
Maybe that's why tests fail?
from tox.
Yes. I guess.
from tox.
Good catch. I will try to discover how to fix it. One solution is to put crypto_init
in every test fn =(
from tox.
Depends on rust-lang/rfcs#1664
from tox.
Related Issues (20)
- Race in toxcore::tcp::client::client::tests::spawn HOT 3
- Replace IpPort::is_global with IpAddr::is_global from std
- Replace Digest with a plain array in OnionAnnounceResponsePayload HOT 2
- Get rid of byteorder
- Return with custom ErrorKind at nom 5.0
- Remove custom GetPayloadError in favor of macro error_kind!
- ssh HOT 2
- ssh or vpn HOT 1
- Update cookie_factory from 0.2 to 0.3
- Move to async/await HOT 1
- Replace blocking Mutex with future Mutex HOT 8
- Failure is deprecated HOT 3
- AWTCY (AreWeToxClientYet)? HOT 8
- [Question] Can I send friend request with a message? HOT 2
- Replace PrecomputedCache's blocking Mutex with future Mutex
- Get rid of libsodium
- Api
- Question: tox-rs vs. c-toxcore - differences when deployed as server node HOT 4
- How to send file? HOT 1
- Build fails when used as a cargo git dependency HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tox.