turned assert into TORRENT_ASSERT

This commit is contained in:
Arvid Norberg 2007-12-27 03:43:02 +00:00
parent 5e089f01d6
commit 86de8b8bf6
2 changed files with 9 additions and 9 deletions

View File

@ -62,7 +62,7 @@ namespace libtorrent
private: private:
int get_local_key_size () const int get_local_key_size () const
{ {
assert (m_DH); TORRENT_ASSERT(m_DH);
return BN_num_bytes (m_DH->pub_key); return BN_num_bytes (m_DH->pub_key);
} }
@ -97,8 +97,8 @@ namespace libtorrent
void encrypt (char* pos, int len) void encrypt (char* pos, int len)
{ {
assert (len >= 0); TORRENT_ASSERT(len >= 0);
assert (pos); TORRENT_ASSERT(pos);
RC4 (&m_local_key, len, reinterpret_cast<unsigned char const*>(pos), RC4 (&m_local_key, len, reinterpret_cast<unsigned char const*>(pos),
reinterpret_cast<unsigned char*>(pos)); reinterpret_cast<unsigned char*>(pos));
@ -106,8 +106,8 @@ namespace libtorrent
void decrypt (char* pos, int len) void decrypt (char* pos, int len)
{ {
assert (len >= 0); TORRENT_ASSERT(len >= 0);
assert (pos); TORRENT_ASSERT(pos);
RC4 (&m_remote_key, len, reinterpret_cast<unsigned char const*>(pos), RC4 (&m_remote_key, len, reinterpret_cast<unsigned char const*>(pos),
reinterpret_cast<unsigned char*>(pos)); reinterpret_cast<unsigned char*>(pos));

View File

@ -52,11 +52,11 @@ namespace libtorrent {
m_DH->g = BN_bin2bn (m_dh_generator, sizeof(m_dh_generator), NULL); m_DH->g = BN_bin2bn (m_dh_generator, sizeof(m_dh_generator), NULL);
m_DH->length = 160l; m_DH->length = 160l;
assert (sizeof(m_dh_prime) == DH_size(m_DH)); TORRENT_ASSERT(sizeof(m_dh_prime) == DH_size(m_DH));
DH_generate_key (m_DH); // TODO Check != 0 DH_generate_key (m_DH); // TODO Check != 0
assert (m_DH->pub_key); TORRENT_ASSERT(m_DH->pub_key);
// DH can generate key sizes that are smaller than the size of // DH can generate key sizes that are smaller than the size of
// P with exponentially decreasing probability, in which case // P with exponentially decreasing probability, in which case
@ -78,7 +78,7 @@ namespace libtorrent {
DH_key_exchange::~DH_key_exchange () DH_key_exchange::~DH_key_exchange ()
{ {
assert (m_DH); TORRENT_ASSERT(m_DH);
DH_free (m_DH); DH_free (m_DH);
} }
@ -91,7 +91,7 @@ namespace libtorrent {
// compute shared secret given remote public key // compute shared secret given remote public key
void DH_key_exchange::compute_secret (char const* remote_pubkey) void DH_key_exchange::compute_secret (char const* remote_pubkey)
{ {
assert (remote_pubkey); TORRENT_ASSERT(remote_pubkey);
BIGNUM* bn_remote_pubkey = BN_bin2bn ((unsigned char*)remote_pubkey, 96, NULL); BIGNUM* bn_remote_pubkey = BN_bin2bn ((unsigned char*)remote_pubkey, 96, NULL);
char dh_secret[96]; char dh_secret[96];