libi22pd: convert several loops to range based ones

Found with clang-tidy's modernize-loop-convert.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
This commit is contained in:
Rosen Penev 2020-01-19 18:50:20 -08:00
parent 6cc388c1bc
commit 0dabc88eeb
No known key found for this signature in database
GPG key ID: 36D31CFA845F0E3B
4 changed files with 12 additions and 12 deletions

View file

@ -188,10 +188,10 @@ namespace crypto
static void DestroyElggTable (BIGNUM * table[][255], int len)
{
for (int i = 0; i < len; i++)
for (int j = 0; j < 255; j++)
for (auto & j : table[i])
{
BN_free (table[i][j]);
table[i][j] = nullptr;
BN_free (j);
j = nullptr;
}
BN_MONT_CTX_free (g_MontCtx);
}

View file

@ -54,14 +54,14 @@ namespace crypto
// precalculate Bi256 table
Bi256Carry = { Bx, By }; // B
for (int i = 0; i < 32; i++)
for (auto & i : Bi256)
{
Bi256[i][0] = Bi256Carry; // first point
i[0] = Bi256Carry; // first point
for (int j = 1; j < 128; j++)
Bi256[i][j] = Sum (Bi256[i][j-1], Bi256[i][0], ctx); // (256+j+1)^i*B
Bi256Carry = Bi256[i][127];
i[j] = Sum (i[j-1], i[0], ctx); // (256+j+1)^i*B
Bi256Carry = i[127];
for (int j = 0; j < 128; j++) // add first point 128 more times
Bi256Carry = Sum (Bi256Carry, Bi256[i][0], ctx);
Bi256Carry = Sum (Bi256Carry, i[0], ctx);
}
BN_CTX_free (ctx);

View file

@ -838,10 +838,10 @@ namespace crypto
{
GOST3411Block k = *this;
GOST3411Block res = k^m;
for (int i = 0; i < 12; i++)
for (const auto & i : C_)
{
res.F ();
k = k^C_[i];
k = k^i;
k.F ();
res = k^res;
}

View file

@ -14,8 +14,8 @@ namespace tunnel
m_CurrentTunnelDataMsg (nullptr), m_RemainingSize (0)
{
RAND_bytes (m_NonZeroRandomBuffer, TUNNEL_DATA_MAX_PAYLOAD_SIZE);
for (size_t i = 0; i < TUNNEL_DATA_MAX_PAYLOAD_SIZE; i++)
if (!m_NonZeroRandomBuffer[i]) m_NonZeroRandomBuffer[i] = 1;
for (unsigned char & i : m_NonZeroRandomBuffer)
if (!i) i = 1;
}
TunnelGatewayBuffer::~TunnelGatewayBuffer ()