From 38bf4ac01502e655a942a5c77df1ec0b054917e5 Mon Sep 17 00:00:00 2001
From: Brian Warner <warner@lothar.com>
Date: Wed, 25 Jun 2014 23:12:17 -0700
Subject: [PATCH] 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.
---
 src/nacl/c/crypto_scalarmult.py | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/src/nacl/c/crypto_scalarmult.py b/src/nacl/c/crypto_scalarmult.py
index f5ba2bac..f8a37387 100644
--- a/src/nacl/c/crypto_scalarmult.py
+++ b/src/nacl/c/crypto_scalarmult.py
@@ -14,7 +14,6 @@
 from __future__ import absolute_import, division, print_function
 
 from nacl._lib import lib
-from nacl.exceptions import CryptoError
 
 
 crypto_scalarmult_BYTES = lib.crypto_scalarmult_bytes()
@@ -31,9 +30,8 @@ def crypto_scalarmult_base(n):
     """
     q = lib.ffi.new("unsigned char[]", crypto_scalarmult_BYTES)
 
-    if lib.crypto_scalarmult_base(q, n) != 0:
-        raise CryptoError(
-            "An error occurred while computing the scalar product")
+    rc = lib.crypto_scalarmult_base(q, n)
+    assert rc == 0
 
     return lib.ffi.buffer(q, crypto_scalarmult_SCALARBYTES)[:]
 
@@ -49,8 +47,7 @@ def crypto_scalarmult(n, p):
     """
     q = lib.ffi.new("unsigned char[]", crypto_scalarmult_BYTES)
 
-    if lib.crypto_scalarmult(q, n, p) != 0:
-        raise CryptoError(
-            "An error occurred while computing the scalar product")
+    rc = lib.crypto_scalarmult(q, n, p)
+    assert rc == 0
 
     return lib.ffi.buffer(q, crypto_scalarmult_SCALARBYTES)[:]
-- 
GitLab