diff options
Diffstat (limited to 'src/utils/rotate.h')
-rw-r--r-- | src/utils/rotate.h | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/utils/rotate.h b/src/utils/rotate.h index 5e3eef304..465746e0b 100644 --- a/src/utils/rotate.h +++ b/src/utils/rotate.h @@ -12,14 +12,23 @@ namespace Botan { -/* -* Word Rotation Functions +/** +* Bit rotation left +* @param input the input word +* @param rot the number of bits to rotate +* @return input rotated left by rot bits */ template<typename T> inline T rotate_left(T input, size_t rot) { return static_cast<T>((input << rot) | (input >> (8*sizeof(T)-rot)));; } +/** +* Bit rotation right +* @param input the input word +* @param rot the number of bits to rotate +* @return input rotated right by rot bits +*/ template<typename T> inline T rotate_right(T input, size_t rot) { return static_cast<T>((input >> rot) | (input << (8*sizeof(T)-rot))); |