symm/...: Reformat encryption mode loops and related code.
[catacomb] / symm / salsa20-core.h
index b27f222..352fec3 100644 (file)
  */
 #define SALSA20_PREPBUF(ctx, a) do {                                   \
   int _i;                                                              \
-  for (_i = 0; _i < 16; _i++) STORE32_L((ctx)->buf + 4*_i, (a)[_i]);   \
-  (ctx)->bufi = 0;                                                     \
+  for (_i = 0; _i < 16; _i++) STORE32_L((ctx)->b + 4*_i, (a)[_i]);     \
+  (ctx)->off = 0;                                                      \
 } while (0)
 
 /* Write at most @n@ bytes of buffered output from the context @ctx@ to the
  * @n@ is decreased appropriately.
  */
 #define SALSA20_OUTBUF(ctx, d, s, n) do {                              \
-  size_t _n = (n), _left = SALSA20_OUTSZ - (ctx)->bufi;                        \
+  size_t _n = (n), _left = SALSA20_OUTSZ - (ctx)->off;                 \
   if (_n > _left) _n = _left;                                          \
   (n) -= _n;                                                           \
-  if (!(d)) (ctx)->bufi += _n;                                         \
-  else if (s) while (_n--) *(d)++ = (ctx)->buf[(ctx)->bufi++] ^ *(s)++;        \
-  else while (_n--) *(d)++ = (ctx)->buf[(ctx)->bufi++];                        \
+  if (!(d)) (ctx)->off += _n;                                          \
+  else if (s) while (_n--) *(d)++ = (ctx)->b[(ctx)->off++] ^ *(s)++;   \
+  else while (_n--) *(d)++ = (ctx)->b[(ctx)->off++];                   \
 } while (0)
 
 /*----- Variants and naming -----------------------------------------------*/