Skip to content
Snippets Groups Projects
Commit 38bf4ac0 authored by Brian Warner's avatar Brian Warner
Browse files

scalarmult: remove unreachable error-handling code

The two scalarmult functions always return 0 (they should really have
been declared as 'void'). So simply assert that they've returned 0
instead of trying to raise an exception in a code path that will never
be exercised or tested.
parent 068e8820
No related branches found
No related tags found
No related merge requests found
...@@ -14,7 +14,6 @@ ...@@ -14,7 +14,6 @@
from __future__ import absolute_import, division, print_function from __future__ import absolute_import, division, print_function
from nacl._lib import lib from nacl._lib import lib
from nacl.exceptions import CryptoError
crypto_scalarmult_BYTES = lib.crypto_scalarmult_bytes() crypto_scalarmult_BYTES = lib.crypto_scalarmult_bytes()
...@@ -31,9 +30,8 @@ def crypto_scalarmult_base(n): ...@@ -31,9 +30,8 @@ def crypto_scalarmult_base(n):
""" """
q = lib.ffi.new("unsigned char[]", crypto_scalarmult_BYTES) q = lib.ffi.new("unsigned char[]", crypto_scalarmult_BYTES)
if lib.crypto_scalarmult_base(q, n) != 0: rc = lib.crypto_scalarmult_base(q, n)
raise CryptoError( assert rc == 0
"An error occurred while computing the scalar product")
return lib.ffi.buffer(q, crypto_scalarmult_SCALARBYTES)[:] return lib.ffi.buffer(q, crypto_scalarmult_SCALARBYTES)[:]
...@@ -49,8 +47,7 @@ def crypto_scalarmult(n, p): ...@@ -49,8 +47,7 @@ def crypto_scalarmult(n, p):
""" """
q = lib.ffi.new("unsigned char[]", crypto_scalarmult_BYTES) q = lib.ffi.new("unsigned char[]", crypto_scalarmult_BYTES)
if lib.crypto_scalarmult(q, n, p) != 0: rc = lib.crypto_scalarmult(q, n, p)
raise CryptoError( assert rc == 0
"An error occurred while computing the scalar product")
return lib.ffi.buffer(q, crypto_scalarmult_SCALARBYTES)[:] return lib.ffi.buffer(q, crypto_scalarmult_SCALARBYTES)[:]
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment