Sanitize assert usage and refuse to compile with NDEBUG.

There were quite a few places where assert() was used with side effects,
 making operation with NDEBUG non-functional.  This commit fixes all the
 cases I know about, but also adds an  #error on NDEBUG because the code
 is untested without assertions and may still have vulnerabilities if
 used without assert.
This commit is contained in:
Gregory Maxwell
2013-12-02 11:33:44 -08:00
parent 9ab7a0609e
commit 9b59e3bda8
3 changed files with 23 additions and 7 deletions

View File

@@ -148,10 +148,13 @@ public:
}
void SetSecretBytes(const unsigned char vch[32]) {
bool ret;
BIGNUM bn;
BN_init(&bn);
assert(BN_bin2bn(vch, 32, &bn));
assert(EC_KEY_regenerate_key(pkey, &bn));
ret = BN_bin2bn(vch, 32, &bn);
assert(ret);
ret = EC_KEY_regenerate_key(pkey, &bn);
assert(ret);
BN_clear_free(&bn);
}