Commit 238907e2 authored by Jesper Louis Andersen's avatar Jesper Louis Andersen
Browse files

Fix bug in box_open_afternm + Improve readability of C code.

If we write

	EXP != 0

and EXP is a very large term, it is hard to see what it gets checked against, so we rewrite it as

	0 != EXP

so we instanly see what we check against. While here, teset against 0 != crypto_box_afternm(…)
parent e456f4ea
......@@ -191,7 +191,7 @@ ERL_NIF_TERM enif_crypto_box_open(ErlNifEnv *env, int argc, ERL_NIF_TERM const a
return nacl_error_tuple(env, "alloc_failed");
}
if (crypto_box_open(result.data, padded_ciphertext.data, padded_ciphertext.size, nonce.data, pk.data, sk.data) != 0) {
if (0 != crypto_box_open(result.data, padded_ciphertext.data, padded_ciphertext.size, nonce.data, pk.data, sk.data)) {
enif_release_binary(&result);
return nacl_error_tuple(env, "failed_verification");
}
......@@ -274,7 +274,7 @@ ERL_NIF_TERM enif_crypto_box_open_afternm(ErlNifEnv *env, int argc, ERL_NIF_TERM
return nacl_error_tuple(env, "alloc_failed");
}
if (crypto_box_open_afternm(result.data, m.data, m.size, nonce.data, k.data)) {
if (0 != crypto_box_open_afternm(result.data, m.data, m.size, nonce.data, k.data)) {
enif_release_binary(&result);
return nacl_error_tuple(env, "failed_verification");
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment