-static int ring_mod (const int number, const int mod_amt)
-{
- int temp = number;
-
- while (temp < 0)
- temp += mod_amt;
-
- return temp;
-}
-
-/* ROL all of the bytes in @bytes by @shift_amt */
-static void circular_left_shift (byteArray &bytes, int shift_amt)
-{
- int i;
- byteArray temp (bytes.size(), 0);
-
-#if 0
- std::printf ("BEFORE CLS(%d): ", shift_amt);
- for (i=0; i<bytes.size(); ++i)
- std::printf ("%.2x", bytes[i]);
- std::printf ("\n");
-#endif
-
- for (i=0; i<temp.size(); ++i)
- {
- int tindex = i;
- int bindex = (i+shift_amt) % bytes.size();
- //std::printf ("temp[%d] = bytes[%d] = %.2x\n", tindex, bindex, bytes[bindex]);
- temp[i] = bytes[(i+shift_amt) % bytes.size()];
- }
-
-#if 0
- std::printf ("AFTER CLS(%d): ", shift_amt);
- for (i=0; i<temp.size(); ++i)
- std::printf ("%.2x", temp[i]);
- std::printf ("\n");
-#endif
-
- for (i=0; i<bytes.size(); ++i)
- bytes.at(i) = temp.at(i);
-}
-
-/* ROR all of the bytes in @bytes by @shift_amt */
-static void circular_right_shift (byteArray &bytes, int shift_amt)
-{
- int i;
- byteArray temp (bytes.size(), 0);
-
- for (i=0; i<temp.size(); ++i)
- temp[i] = bytes[ring_mod (i-shift_amt, bytes.size())];
-
- for (i=0; i<bytes.size(); ++i)
- bytes[i] = temp[i];
-}
-