/src/botan/build/include/botan/rotate.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | * Word Rotation Operations |
3 | | * (C) 1999-2008,2017 Jack Lloyd |
4 | | * |
5 | | * Botan is released under the Simplified BSD License (see license.txt) |
6 | | */ |
7 | | |
8 | | #ifndef BOTAN_WORD_ROTATE_H_ |
9 | | #define BOTAN_WORD_ROTATE_H_ |
10 | | |
11 | | #include <botan/types.h> |
12 | | |
13 | | BOTAN_FUTURE_INTERNAL_HEADER(rotate.h) |
14 | | |
15 | | namespace Botan { |
16 | | |
17 | | /** |
18 | | * Bit rotation left by a compile-time constant amount |
19 | | * @param input the input word |
20 | | * @return input rotated left by ROT bits |
21 | | */ |
22 | | template<size_t ROT, typename T> |
23 | | inline constexpr T rotl(T input) |
24 | 31.5M | { |
25 | 31.5M | static_assert(ROT > 0 && ROT < 8*sizeof(T), "Invalid rotation constant"); |
26 | 31.5M | return static_cast<T>((input << ROT) | (input >> (8*sizeof(T) - ROT))); |
27 | 31.5M | } unsigned char Botan::rotl<1ul, unsigned char>(unsigned char) Line | Count | Source | 24 | 286k | { | 25 | 286k | static_assert(ROT > 0 && ROT < 8*sizeof(T), "Invalid rotation constant"); | 26 | 286k | return static_cast<T>((input << ROT) | (input >> (8*sizeof(T) - ROT))); | 27 | 286k | } |
unsigned char Botan::rotl<7ul, unsigned char>(unsigned char) Line | Count | Source | 24 | 143k | { | 25 | 143k | static_assert(ROT > 0 && ROT < 8*sizeof(T), "Invalid rotation constant"); | 26 | 143k | return static_cast<T>((input << ROT) | (input >> (8*sizeof(T) - ROT))); | 27 | 143k | } |
unsigned int Botan::rotl<1ul, unsigned int>(unsigned int) Line | Count | Source | 24 | 117k | { | 25 | 117k | static_assert(ROT > 0 && ROT < 8*sizeof(T), "Invalid rotation constant"); | 26 | 117k | return static_cast<T>((input << ROT) | (input >> (8*sizeof(T) - ROT))); | 27 | 117k | } |
unsigned int Botan::rotl<4ul, unsigned int>(unsigned int) Line | Count | Source | 24 | 23.7k | { | 25 | 23.7k | static_assert(ROT > 0 && ROT < 8*sizeof(T), "Invalid rotation constant"); | 26 | 23.7k | return static_cast<T>((input << ROT) | (input >> (8*sizeof(T) - ROT))); | 27 | 23.7k | } |
unsigned int Botan::rotl<9ul, unsigned int>(unsigned int) Line | Count | Source | 24 | 23.7k | { | 25 | 23.7k | static_assert(ROT > 0 && ROT < 8*sizeof(T), "Invalid rotation constant"); | 26 | 23.7k | return static_cast<T>((input << ROT) | (input >> (8*sizeof(T) - ROT))); | 27 | 23.7k | } |
unsigned int Botan::rotl<6ul, unsigned int>(unsigned int) Line | Count | Source | 24 | 23.7k | { | 25 | 23.7k | static_assert(ROT > 0 && ROT < 8*sizeof(T), "Invalid rotation constant"); | 26 | 23.7k | return static_cast<T>((input << ROT) | (input >> (8*sizeof(T) - ROT))); | 27 | 23.7k | } |
unsigned int Botan::rotl<18ul, unsigned int>(unsigned int) Line | Count | Source | 24 | 21.6k | { | 25 | 21.6k | static_assert(ROT > 0 && ROT < 8*sizeof(T), "Invalid rotation constant"); | 26 | 21.6k | return static_cast<T>((input << ROT) | (input >> (8*sizeof(T) - ROT))); | 27 | 21.6k | } |
unsigned int Botan::rotl<20ul, unsigned int>(unsigned int) Line | Count | Source | 24 | 23.7k | { | 25 | 23.7k | static_assert(ROT > 0 && ROT < 8*sizeof(T), "Invalid rotation constant"); | 26 | 23.7k | return static_cast<T>((input << ROT) | (input >> (8*sizeof(T) - ROT))); | 27 | 23.7k | } |
unsigned int Botan::rotl<11ul, unsigned int>(unsigned int) Line | Count | Source | 24 | 2.12k | { | 25 | 2.12k | static_assert(ROT > 0 && ROT < 8*sizeof(T), "Invalid rotation constant"); | 26 | 2.12k | return static_cast<T>((input << ROT) | (input >> (8*sizeof(T) - ROT))); | 27 | 2.12k | } |
Unexecuted instantiation: unsigned int Botan::rotl<19ul, unsigned int>(unsigned int) Unexecuted instantiation: unsigned int Botan::rotl<27ul, unsigned int>(unsigned int) Unexecuted instantiation: unsigned int Botan::rotl<3ul, unsigned int>(unsigned int) Unexecuted instantiation: unsigned short Botan::rotl<1ul, unsigned short>(unsigned short) Unexecuted instantiation: unsigned short Botan::rotl<2ul, unsigned short>(unsigned short) Unexecuted instantiation: unsigned short Botan::rotl<5ul, unsigned short>(unsigned short) Unexecuted instantiation: unsigned short Botan::rotl<8ul, unsigned short>(unsigned short) Unexecuted instantiation: unsigned short Botan::rotl<13ul, unsigned short>(unsigned short) Unexecuted instantiation: unsigned int Botan::rotl<8ul, unsigned int>(unsigned int) unsigned int Botan::rotl<5ul, unsigned int>(unsigned int) Line | Count | Source | 24 | 15.4M | { | 25 | 15.4M | static_assert(ROT > 0 && ROT < 8*sizeof(T), "Invalid rotation constant"); | 26 | 15.4M | return static_cast<T>((input << ROT) | (input >> (8*sizeof(T) - ROT))); | 27 | 15.4M | } |
Unexecuted instantiation: unsigned int Botan::rotl<2ul, unsigned int>(unsigned int) Unexecuted instantiation: unsigned int Botan::rotl<13ul, unsigned int>(unsigned int) unsigned int Botan::rotl<7ul, unsigned int>(unsigned int) Line | Count | Source | 24 | 2.12k | { | 25 | 2.12k | static_assert(ROT > 0 && ROT < 8*sizeof(T), "Invalid rotation constant"); | 26 | 2.12k | return static_cast<T>((input << ROT) | (input >> (8*sizeof(T) - ROT))); | 27 | 2.12k | } |
unsigned int Botan::rotl<22ul, unsigned int>(unsigned int) Line | Count | Source | 24 | 2.12k | { | 25 | 2.12k | static_assert(ROT > 0 && ROT < 8*sizeof(T), "Invalid rotation constant"); | 26 | 2.12k | return static_cast<T>((input << ROT) | (input >> (8*sizeof(T) - ROT))); | 27 | 2.12k | } |
unsigned int Botan::rotl<10ul, unsigned int>(unsigned int) Line | Count | Source | 24 | 2.12k | { | 25 | 2.12k | static_assert(ROT > 0 && ROT < 8*sizeof(T), "Invalid rotation constant"); | 26 | 2.12k | return static_cast<T>((input << ROT) | (input >> (8*sizeof(T) - ROT))); | 27 | 2.12k | } |
Unexecuted instantiation: unsigned int Botan::rotl<24ul, unsigned int>(unsigned int) unsigned int Botan::rotl<23ul, unsigned int>(unsigned int) Line | Count | Source | 24 | 2.12k | { | 25 | 2.12k | static_assert(ROT > 0 && ROT < 8*sizeof(T), "Invalid rotation constant"); | 26 | 2.12k | return static_cast<T>((input << ROT) | (input >> (8*sizeof(T) - ROT))); | 27 | 2.12k | } |
Unexecuted instantiation: unsigned long Botan::rotl<46ul, unsigned long>(unsigned long) Unexecuted instantiation: unsigned long Botan::rotl<36ul, unsigned long>(unsigned long) Unexecuted instantiation: unsigned long Botan::rotl<19ul, unsigned long>(unsigned long) Unexecuted instantiation: unsigned long Botan::rotl<37ul, unsigned long>(unsigned long) Unexecuted instantiation: unsigned long Botan::rotl<33ul, unsigned long>(unsigned long) Unexecuted instantiation: unsigned long Botan::rotl<27ul, unsigned long>(unsigned long) Unexecuted instantiation: unsigned long Botan::rotl<14ul, unsigned long>(unsigned long) Unexecuted instantiation: unsigned long Botan::rotl<42ul, unsigned long>(unsigned long) Unexecuted instantiation: unsigned long Botan::rotl<17ul, unsigned long>(unsigned long) Unexecuted instantiation: unsigned long Botan::rotl<49ul, unsigned long>(unsigned long) Unexecuted instantiation: unsigned long Botan::rotl<39ul, unsigned long>(unsigned long) Unexecuted instantiation: unsigned long Botan::rotl<44ul, unsigned long>(unsigned long) Unexecuted instantiation: unsigned long Botan::rotl<9ul, unsigned long>(unsigned long) Unexecuted instantiation: unsigned long Botan::rotl<54ul, unsigned long>(unsigned long) Unexecuted instantiation: unsigned long Botan::rotl<56ul, unsigned long>(unsigned long) Unexecuted instantiation: unsigned long Botan::rotl<30ul, unsigned long>(unsigned long) Unexecuted instantiation: unsigned long Botan::rotl<34ul, unsigned long>(unsigned long) Unexecuted instantiation: unsigned long Botan::rotl<24ul, unsigned long>(unsigned long) Unexecuted instantiation: unsigned long Botan::rotl<13ul, unsigned long>(unsigned long) Unexecuted instantiation: unsigned long Botan::rotl<50ul, unsigned long>(unsigned long) Unexecuted instantiation: unsigned long Botan::rotl<10ul, unsigned long>(unsigned long) Unexecuted instantiation: unsigned long Botan::rotl<25ul, unsigned long>(unsigned long) Unexecuted instantiation: unsigned long Botan::rotl<29ul, unsigned long>(unsigned long) Unexecuted instantiation: unsigned long Botan::rotl<43ul, unsigned long>(unsigned long) Unexecuted instantiation: unsigned long Botan::rotl<8ul, unsigned long>(unsigned long) Unexecuted instantiation: unsigned long Botan::rotl<35ul, unsigned long>(unsigned long) Unexecuted instantiation: unsigned long Botan::rotl<22ul, unsigned long>(unsigned long) unsigned int Botan::rotl<15ul, unsigned int>(unsigned int) Line | Count | Source | 24 | 2.12k | { | 25 | 2.12k | static_assert(ROT > 0 && ROT < 8*sizeof(T), "Invalid rotation constant"); | 26 | 2.12k | return static_cast<T>((input << ROT) | (input >> (8*sizeof(T) - ROT))); | 27 | 2.12k | } |
unsigned int Botan::rotl<12ul, unsigned int>(unsigned int) Line | Count | Source | 24 | 2.12k | { | 25 | 2.12k | static_assert(ROT > 0 && ROT < 8*sizeof(T), "Invalid rotation constant"); | 26 | 2.12k | return static_cast<T>((input << ROT) | (input >> (8*sizeof(T) - ROT))); | 27 | 2.12k | } |
unsigned int Botan::rotl<17ul, unsigned int>(unsigned int) Line | Count | Source | 24 | 2.12k | { | 25 | 2.12k | static_assert(ROT > 0 && ROT < 8*sizeof(T), "Invalid rotation constant"); | 26 | 2.12k | return static_cast<T>((input << ROT) | (input >> (8*sizeof(T) - ROT))); | 27 | 2.12k | } |
unsigned int Botan::rotl<14ul, unsigned int>(unsigned int) Line | Count | Source | 24 | 2.12k | { | 25 | 2.12k | static_assert(ROT > 0 && ROT < 8*sizeof(T), "Invalid rotation constant"); | 26 | 2.12k | return static_cast<T>((input << ROT) | (input >> (8*sizeof(T) - ROT))); | 27 | 2.12k | } |
unsigned int Botan::rotl<16ul, unsigned int>(unsigned int) Line | Count | Source | 24 | 2.12k | { | 25 | 2.12k | static_assert(ROT > 0 && ROT < 8*sizeof(T), "Invalid rotation constant"); | 26 | 2.12k | return static_cast<T>((input << ROT) | (input >> (8*sizeof(T) - ROT))); | 27 | 2.12k | } |
unsigned int Botan::rotl<21ul, unsigned int>(unsigned int) Line | Count | Source | 24 | 2.12k | { | 25 | 2.12k | static_assert(ROT > 0 && ROT < 8*sizeof(T), "Invalid rotation constant"); | 26 | 2.12k | return static_cast<T>((input << ROT) | (input >> (8*sizeof(T) - ROT))); | 27 | 2.12k | } |
unsigned int Botan::rotl<30ul, unsigned int>(unsigned int) Line | Count | Source | 24 | 15.4M | { | 25 | 15.4M | static_assert(ROT > 0 && ROT < 8*sizeof(T), "Invalid rotation constant"); | 26 | 15.4M | return static_cast<T>((input << ROT) | (input >> (8*sizeof(T) - ROT))); | 27 | 15.4M | } |
Unexecuted instantiation: unsigned long Botan::rotl<1ul, unsigned long>(unsigned long) Unexecuted instantiation: unsigned long Botan::rotl<21ul, unsigned long>(unsigned long) Unexecuted instantiation: unsigned long Botan::rotl<28ul, unsigned long>(unsigned long) Unexecuted instantiation: unsigned long Botan::rotl<20ul, unsigned long>(unsigned long) Unexecuted instantiation: unsigned long Botan::rotl<3ul, unsigned long>(unsigned long) Unexecuted instantiation: unsigned long Botan::rotl<45ul, unsigned long>(unsigned long) Unexecuted instantiation: unsigned long Botan::rotl<61ul, unsigned long>(unsigned long) Unexecuted instantiation: unsigned long Botan::rotl<6ul, unsigned long>(unsigned long) Unexecuted instantiation: unsigned long Botan::rotl<18ul, unsigned long>(unsigned long) Unexecuted instantiation: unsigned long Botan::rotl<15ul, unsigned long>(unsigned long) Unexecuted instantiation: unsigned long Botan::rotl<62ul, unsigned long>(unsigned long) Unexecuted instantiation: unsigned long Botan::rotl<55ul, unsigned long>(unsigned long) Unexecuted instantiation: unsigned long Botan::rotl<41ul, unsigned long>(unsigned long) Unexecuted instantiation: unsigned long Botan::rotl<2ul, unsigned long>(unsigned long) Unexecuted instantiation: unsigned long Botan::rotl<16ul, unsigned long>(unsigned long) Unexecuted instantiation: unsigned long Botan::rotl<32ul, unsigned long>(unsigned long) |
28 | | |
29 | | /** |
30 | | * Bit rotation right by a compile-time constant amount |
31 | | * @param input the input word |
32 | | * @return input rotated right by ROT bits |
33 | | */ |
34 | | template<size_t ROT, typename T> |
35 | | inline constexpr T rotr(T input) |
36 | 749M | { |
37 | 749M | static_assert(ROT > 0 && ROT < 8*sizeof(T), "Invalid rotation constant"); |
38 | 749M | return static_cast<T>((input >> ROT) | (input << (8*sizeof(T) - ROT))); |
39 | 749M | } unsigned int Botan::rotr<20ul, unsigned int>(unsigned int) Line | Count | Source | 36 | 21.6k | { | 37 | 21.6k | static_assert(ROT > 0 && ROT < 8*sizeof(T), "Invalid rotation constant"); | 38 | 21.6k | return static_cast<T>((input >> ROT) | (input << (8*sizeof(T) - ROT))); | 39 | 21.6k | } |
unsigned int Botan::rotr<18ul, unsigned int>(unsigned int) Line | Count | Source | 36 | 56.5M | { | 37 | 56.5M | static_assert(ROT > 0 && ROT < 8*sizeof(T), "Invalid rotation constant"); | 38 | 56.5M | return static_cast<T>((input >> ROT) | (input << (8*sizeof(T) - ROT))); | 39 | 56.5M | } |
unsigned int Botan::rotr<6ul, unsigned int>(unsigned int) Line | Count | Source | 36 | 56.5M | { | 37 | 56.5M | static_assert(ROT > 0 && ROT < 8*sizeof(T), "Invalid rotation constant"); | 38 | 56.5M | return static_cast<T>((input >> ROT) | (input << (8*sizeof(T) - ROT))); | 39 | 56.5M | } |
unsigned int Botan::rotr<4ul, unsigned int>(unsigned int) Line | Count | Source | 36 | 1.06M | { | 37 | 1.06M | static_assert(ROT > 0 && ROT < 8*sizeof(T), "Invalid rotation constant"); | 38 | 1.06M | return static_cast<T>((input >> ROT) | (input << (8*sizeof(T) - ROT))); | 39 | 1.06M | } |
unsigned int Botan::rotr<1ul, unsigned int>(unsigned int) Line | Count | Source | 36 | 21.6k | { | 37 | 21.6k | static_assert(ROT > 0 && ROT < 8*sizeof(T), "Invalid rotation constant"); | 38 | 21.6k | return static_cast<T>((input >> ROT) | (input << (8*sizeof(T) - ROT))); | 39 | 21.6k | } |
unsigned int Botan::rotr<9ul, unsigned int>(unsigned int) Line | Count | Source | 36 | 21.6k | { | 37 | 21.6k | static_assert(ROT > 0 && ROT < 8*sizeof(T), "Invalid rotation constant"); | 38 | 21.6k | return static_cast<T>((input >> ROT) | (input << (8*sizeof(T) - ROT))); | 39 | 21.6k | } |
unsigned int Botan::rotr<8ul, unsigned int>(unsigned int) Line | Count | Source | 36 | 17.9k | { | 37 | 17.9k | static_assert(ROT > 0 && ROT < 8*sizeof(T), "Invalid rotation constant"); | 38 | 17.9k | return static_cast<T>((input >> ROT) | (input << (8*sizeof(T) - ROT))); | 39 | 17.9k | } |
Unexecuted instantiation: unsigned int Botan::rotr<5ul, unsigned int>(unsigned int) unsigned int Botan::rotr<2ul, unsigned int>(unsigned int) Line | Count | Source | 36 | 56.5M | { | 37 | 56.5M | static_assert(ROT > 0 && ROT < 8*sizeof(T), "Invalid rotation constant"); | 38 | 56.5M | return static_cast<T>((input >> ROT) | (input << (8*sizeof(T) - ROT))); | 39 | 56.5M | } |
unsigned int Botan::rotr<22ul, unsigned int>(unsigned int) Line | Count | Source | 36 | 56.5M | { | 37 | 56.5M | static_assert(ROT > 0 && ROT < 8*sizeof(T), "Invalid rotation constant"); | 38 | 56.5M | return static_cast<T>((input >> ROT) | (input << (8*sizeof(T) - ROT))); | 39 | 56.5M | } |
unsigned int Botan::rotr<7ul, unsigned int>(unsigned int) Line | Count | Source | 36 | 56.5M | { | 37 | 56.5M | static_assert(ROT > 0 && ROT < 8*sizeof(T), "Invalid rotation constant"); | 38 | 56.5M | return static_cast<T>((input >> ROT) | (input << (8*sizeof(T) - ROT))); | 39 | 56.5M | } |
Unexecuted instantiation: unsigned int Botan::rotr<3ul, unsigned int>(unsigned int) unsigned int Botan::rotr<13ul, unsigned int>(unsigned int) Line | Count | Source | 36 | 56.5M | { | 37 | 56.5M | static_assert(ROT > 0 && ROT < 8*sizeof(T), "Invalid rotation constant"); | 38 | 56.5M | return static_cast<T>((input >> ROT) | (input << (8*sizeof(T) - ROT))); | 39 | 56.5M | } |
unsigned int Botan::rotr<11ul, unsigned int>(unsigned int) Line | Count | Source | 36 | 56.5M | { | 37 | 56.5M | static_assert(ROT > 0 && ROT < 8*sizeof(T), "Invalid rotation constant"); | 38 | 56.5M | return static_cast<T>((input >> ROT) | (input << (8*sizeof(T) - ROT))); | 39 | 56.5M | } |
unsigned int Botan::rotr<25ul, unsigned int>(unsigned int) Line | Count | Source | 36 | 56.5M | { | 37 | 56.5M | static_assert(ROT > 0 && ROT < 8*sizeof(T), "Invalid rotation constant"); | 38 | 56.5M | return static_cast<T>((input >> ROT) | (input << (8*sizeof(T) - ROT))); | 39 | 56.5M | } |
unsigned int Botan::rotr<17ul, unsigned int>(unsigned int) Line | Count | Source | 36 | 56.5M | { | 37 | 56.5M | static_assert(ROT > 0 && ROT < 8*sizeof(T), "Invalid rotation constant"); | 38 | 56.5M | return static_cast<T>((input >> ROT) | (input << (8*sizeof(T) - ROT))); | 39 | 56.5M | } |
unsigned int Botan::rotr<19ul, unsigned int>(unsigned int) Line | Count | Source | 36 | 56.5M | { | 37 | 56.5M | static_assert(ROT > 0 && ROT < 8*sizeof(T), "Invalid rotation constant"); | 38 | 56.5M | return static_cast<T>((input >> ROT) | (input << (8*sizeof(T) - ROT))); | 39 | 56.5M | } |
unsigned int Botan::rotr<16ul, unsigned int>(unsigned int) Line | Count | Source | 36 | 254k | { | 37 | 254k | static_assert(ROT > 0 && ROT < 8*sizeof(T), "Invalid rotation constant"); | 38 | 254k | return static_cast<T>((input >> ROT) | (input << (8*sizeof(T) - ROT))); | 39 | 254k | } |
unsigned int Botan::rotr<24ul, unsigned int>(unsigned int) Line | Count | Source | 36 | 17.9k | { | 37 | 17.9k | static_assert(ROT > 0 && ROT < 8*sizeof(T), "Invalid rotation constant"); | 38 | 17.9k | return static_cast<T>((input >> ROT) | (input << (8*sizeof(T) - ROT))); | 39 | 17.9k | } |
unsigned long Botan::rotr<8ul, unsigned long>(unsigned long) Line | Count | Source | 36 | 18.2M | { | 37 | 18.2M | static_assert(ROT > 0 && ROT < 8*sizeof(T), "Invalid rotation constant"); | 38 | 18.2M | return static_cast<T>((input >> ROT) | (input << (8*sizeof(T) - ROT))); | 39 | 18.2M | } |
Unexecuted instantiation: unsigned long Botan::rotr<35ul, unsigned long>(unsigned long) Unexecuted instantiation: unsigned long Botan::rotr<56ul, unsigned long>(unsigned long) Unexecuted instantiation: unsigned long Botan::rotr<22ul, unsigned long>(unsigned long) Unexecuted instantiation: unsigned long Botan::rotr<25ul, unsigned long>(unsigned long) Unexecuted instantiation: unsigned long Botan::rotr<29ul, unsigned long>(unsigned long) unsigned long Botan::rotr<39ul, unsigned long>(unsigned long) Line | Count | Source | 36 | 18.2M | { | 37 | 18.2M | static_assert(ROT > 0 && ROT < 8*sizeof(T), "Invalid rotation constant"); | 38 | 18.2M | return static_cast<T>((input >> ROT) | (input << (8*sizeof(T) - ROT))); | 39 | 18.2M | } |
Unexecuted instantiation: unsigned long Botan::rotr<43ul, unsigned long>(unsigned long) Unexecuted instantiation: unsigned long Botan::rotr<13ul, unsigned long>(unsigned long) Unexecuted instantiation: unsigned long Botan::rotr<50ul, unsigned long>(unsigned long) Unexecuted instantiation: unsigned long Botan::rotr<10ul, unsigned long>(unsigned long) Unexecuted instantiation: unsigned long Botan::rotr<17ul, unsigned long>(unsigned long) Unexecuted instantiation: unsigned long Botan::rotr<30ul, unsigned long>(unsigned long) unsigned long Botan::rotr<34ul, unsigned long>(unsigned long) Line | Count | Source | 36 | 18.2M | { | 37 | 18.2M | static_assert(ROT > 0 && ROT < 8*sizeof(T), "Invalid rotation constant"); | 38 | 18.2M | return static_cast<T>((input >> ROT) | (input << (8*sizeof(T) - ROT))); | 39 | 18.2M | } |
Unexecuted instantiation: unsigned long Botan::rotr<24ul, unsigned long>(unsigned long) Unexecuted instantiation: unsigned long Botan::rotr<44ul, unsigned long>(unsigned long) Unexecuted instantiation: unsigned long Botan::rotr<9ul, unsigned long>(unsigned long) Unexecuted instantiation: unsigned long Botan::rotr<54ul, unsigned long>(unsigned long) Unexecuted instantiation: unsigned long Botan::rotr<49ul, unsigned long>(unsigned long) Unexecuted instantiation: unsigned long Botan::rotr<36ul, unsigned long>(unsigned long) Unexecuted instantiation: unsigned long Botan::rotr<33ul, unsigned long>(unsigned long) Unexecuted instantiation: unsigned long Botan::rotr<27ul, unsigned long>(unsigned long) unsigned long Botan::rotr<14ul, unsigned long>(unsigned long) Line | Count | Source | 36 | 18.2M | { | 37 | 18.2M | static_assert(ROT > 0 && ROT < 8*sizeof(T), "Invalid rotation constant"); | 38 | 18.2M | return static_cast<T>((input >> ROT) | (input << (8*sizeof(T) - ROT))); | 39 | 18.2M | } |
Unexecuted instantiation: unsigned long Botan::rotr<42ul, unsigned long>(unsigned long) Unexecuted instantiation: unsigned long Botan::rotr<46ul, unsigned long>(unsigned long) unsigned long Botan::rotr<19ul, unsigned long>(unsigned long) Line | Count | Source | 36 | 18.2M | { | 37 | 18.2M | static_assert(ROT > 0 && ROT < 8*sizeof(T), "Invalid rotation constant"); | 38 | 18.2M | return static_cast<T>((input >> ROT) | (input << (8*sizeof(T) - ROT))); | 39 | 18.2M | } |
Unexecuted instantiation: unsigned long Botan::rotr<37ul, unsigned long>(unsigned long) unsigned long Botan::rotr<18ul, unsigned long>(unsigned long) Line | Count | Source | 36 | 18.2M | { | 37 | 18.2M | static_assert(ROT > 0 && ROT < 8*sizeof(T), "Invalid rotation constant"); | 38 | 18.2M | return static_cast<T>((input >> ROT) | (input << (8*sizeof(T) - ROT))); | 39 | 18.2M | } |
unsigned long Botan::rotr<41ul, unsigned long>(unsigned long) Line | Count | Source | 36 | 18.2M | { | 37 | 18.2M | static_assert(ROT > 0 && ROT < 8*sizeof(T), "Invalid rotation constant"); | 38 | 18.2M | return static_cast<T>((input >> ROT) | (input << (8*sizeof(T) - ROT))); | 39 | 18.2M | } |
unsigned long Botan::rotr<28ul, unsigned long>(unsigned long) Line | Count | Source | 36 | 18.2M | { | 37 | 18.2M | static_assert(ROT > 0 && ROT < 8*sizeof(T), "Invalid rotation constant"); | 38 | 18.2M | return static_cast<T>((input >> ROT) | (input << (8*sizeof(T) - ROT))); | 39 | 18.2M | } |
unsigned long Botan::rotr<61ul, unsigned long>(unsigned long) Line | Count | Source | 36 | 18.2M | { | 37 | 18.2M | static_assert(ROT > 0 && ROT < 8*sizeof(T), "Invalid rotation constant"); | 38 | 18.2M | return static_cast<T>((input >> ROT) | (input << (8*sizeof(T) - ROT))); | 39 | 18.2M | } |
unsigned long Botan::rotr<1ul, unsigned long>(unsigned long) Line | Count | Source | 36 | 18.2M | { | 37 | 18.2M | static_assert(ROT > 0 && ROT < 8*sizeof(T), "Invalid rotation constant"); | 38 | 18.2M | return static_cast<T>((input >> ROT) | (input << (8*sizeof(T) - ROT))); | 39 | 18.2M | } |
Unexecuted instantiation: unsigned long Botan::rotr<32ul, unsigned long>(unsigned long) Unexecuted instantiation: unsigned long Botan::rotr<16ul, unsigned long>(unsigned long) Unexecuted instantiation: unsigned long Botan::rotr<63ul, unsigned long>(unsigned long) |
40 | | |
41 | | /** |
42 | | * Bit rotation left, variable rotation amount |
43 | | * @param input the input word |
44 | | * @param rot the number of bits to rotate, must be between 0 and sizeof(T)*8-1 |
45 | | * @return input rotated left by rot bits |
46 | | */ |
47 | | template<typename T> |
48 | | inline T rotl_var(T input, size_t rot) |
49 | | { |
50 | | return rot ? static_cast<T>((input << rot) | (input >> (sizeof(T)*8 - rot))) : input; |
51 | | } |
52 | | |
53 | | /** |
54 | | * Bit rotation right, variable rotation amount |
55 | | * @param input the input word |
56 | | * @param rot the number of bits to rotate, must be between 0 and sizeof(T)*8-1 |
57 | | * @return input rotated right by rot bits |
58 | | */ |
59 | | template<typename T> |
60 | | inline T rotr_var(T input, size_t rot) |
61 | | { |
62 | | return rot ? static_cast<T>((input >> rot) | (input << (sizeof(T)*8 - rot))) : input; |
63 | | } |
64 | | |
65 | | #if defined(BOTAN_USE_GCC_INLINE_ASM) |
66 | | |
67 | | #if defined(BOTAN_TARGET_ARCH_IS_X86_64) || defined(BOTAN_TARGET_ARCH_IS_X86_32) |
68 | | |
69 | | template<> |
70 | | inline uint32_t rotl_var(uint32_t input, size_t rot) |
71 | 0 | { |
72 | 0 | asm("roll %1,%0" : "+r" (input) : "c" (static_cast<uint8_t>(rot))); |
73 | 0 | return input; |
74 | 0 | } |
75 | | |
76 | | template<> |
77 | | inline uint32_t rotr_var(uint32_t input, size_t rot) |
78 | 0 | { |
79 | 0 | asm("rorl %1,%0" : "+r" (input) : "c" (static_cast<uint8_t>(rot))); |
80 | 0 | return input; |
81 | 0 | } |
82 | | |
83 | | #endif |
84 | | |
85 | | #endif |
86 | | |
87 | | |
88 | | template<typename T> |
89 | | BOTAN_DEPRECATED("Use rotl<N> or rotl_var") |
90 | | inline T rotate_left(T input, size_t rot) |
91 | | { |
92 | | // rotl_var does not reduce |
93 | | return rotl_var(input, rot % (8 * sizeof(T))); |
94 | | } |
95 | | |
96 | | template<typename T> |
97 | | BOTAN_DEPRECATED("Use rotr<N> or rotr_var") |
98 | | inline T rotate_right(T input, size_t rot) |
99 | | { |
100 | | // rotr_var does not reduce |
101 | | return rotr_var(input, rot % (8 * sizeof(T))); |
102 | | } |
103 | | |
104 | | } |
105 | | |
106 | | #endif |