Botan
1.11.4
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
src
utils
rotate.h
Go to the documentation of this file.
1
/*
2
* Word Rotation Operations
3
* (C) 1999-2008 Jack Lloyd
4
*
5
* Distributed under the terms of the Botan license
6
*/
7
8
#ifndef BOTAN_WORD_ROTATE_H__
9
#define BOTAN_WORD_ROTATE_H__
10
11
#include <botan/types.h>
12
13
namespace
Botan {
14
15
/**
16
* Bit rotation left
17
* @param input the input word
18
* @param rot the number of bits to rotate
19
* @return input rotated left by rot bits
20
*/
21
template
<
typename
T>
inline
T
rotate_left
(T input,
size_t
rot)
22
{
23
return
static_cast<
T
>
((input << rot) | (input >> (8*
sizeof
(T)-rot)));;
24
}
25
26
/**
27
* Bit rotation right
28
* @param input the input word
29
* @param rot the number of bits to rotate
30
* @return input rotated right by rot bits
31
*/
32
template
<
typename
T>
inline
T
rotate_right
(T input,
size_t
rot)
33
{
34
return
static_cast<
T
>
((input >> rot) | (input << (8*
sizeof
(T)-rot)));
35
}
36
37
}
38
39
#endif
Generated on Wed May 1 2013 08:42:16 for Botan by
1.8.3.1