aboutsummaryrefslogtreecommitdiffstats
path: root/src/utils/rotate.h
diff options
context:
space:
mode:
authorlloyd <[email protected]>2013-07-31 13:27:12 +0000
committerlloyd <[email protected]>2013-07-31 13:27:12 +0000
commite672994f7072e4082da880a6200e0ec93afb7c0b (patch)
treeb1690d7cab72cdf3f721317db8d3d6164b61060f /src/utils/rotate.h
parent7818291494c0dbc159c9dc8bd301ba9c6139156a (diff)
Avoid undefined operation in rotation operations
Diffstat (limited to 'src/utils/rotate.h')
-rw-r--r--src/utils/rotate.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/utils/rotate.h b/src/utils/rotate.h
index 465746e0b..2593010b4 100644
--- a/src/utils/rotate.h
+++ b/src/utils/rotate.h
@@ -20,6 +20,8 @@ namespace Botan {
*/
template<typename T> inline T rotate_left(T input, size_t rot)
{
+ if(rot == 0)
+ return input;
return static_cast<T>((input << rot) | (input >> (8*sizeof(T)-rot)));;
}
@@ -31,6 +33,8 @@ template<typename T> inline T rotate_left(T input, size_t rot)
*/
template<typename T> inline T rotate_right(T input, size_t rot)
{
+ if(rot == 0)
+ return input;
return static_cast<T>((input >> rot) | (input << (8*sizeof(T)-rot)));
}