Commit fab55772 authored by Niels Möller's avatar Niels Möller

* macros.h (INCREMENT): New macro, moved from ctr.c. Deleted third

argument.
* ctr.c: Use INCREMENT macro from macros.h, deleted local version.

Rev: nettle/ChangeLog:1.128
Rev: nettle/ctr.c:1.2
Rev: nettle/macros.h:1.3
parent 9ac77d39
2011-02-05 Niels Mller <nisse@lysator.liu.se>
* macros.h (INCREMENT): New macro, moved from ctr.c. Deleted third
argument.
* ctr.c: Use INCREMENT macro from macros.h, deleted local version.
2011-01-07 Niels Mller <nisse@lysator.liu.se>
* testsuite/Makefile.in (check): Add ../.lib to PATH, since that's
......
......@@ -33,18 +33,9 @@
#include "ctr.h"
#include "macros.h"
#include "memxor.h"
#include "nettle-internal.h"
#define INCREMENT(size, counter, i) \
do { \
if (++(ctr)[(size) - 1] == 0) \
{ \
unsigned i = size - 1; \
while (i > 0 && ++(ctr)[--i] == 0) \
; \
} \
} while (0)
void
ctr_crypt(void *ctx, nettle_crypt_func f,
......@@ -61,7 +52,7 @@ ctr_crypt(void *ctx, nettle_crypt_func f,
{
f(ctx, block_size, dst, ctr);
memxor(dst, src, block_size);
INCREMENT(block_size, ctr, i);
INCREMENT(block_size, ctr);
}
}
else
......@@ -70,7 +61,7 @@ ctr_crypt(void *ctx, nettle_crypt_func f,
{
f(ctx, block_size, buffer, ctr);
memxor3(dst, src, buffer, block_size);
INCREMENT(block_size, ctr, i);
INCREMENT(block_size, ctr);
}
}
if (length > 0)
......@@ -79,6 +70,6 @@ ctr_crypt(void *ctx, nettle_crypt_func f,
f(ctx, block_size, buffer, ctr);
memxor3(dst, src, buffer, length);
INCREMENT(block_size, ctr, i);
INCREMENT(block_size, ctr);
}
}
......@@ -119,4 +119,16 @@ do { \
(dst) += (blocksize), \
(src) += (blocksize)) )
/* Requires that size >= 2 */
#define INCREMENT(size, ctr) \
do { \
unsigned increment_i = (size) - 1; \
if (++(ctr)[increment_i] == 0) \
{ \
while (++(ctr)[--increment_i] == 0 \
&& increment_i > 0) \
; \
} \
} while (0)
#endif /* NETTLE_MACROS_H_INCLUDED */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment