Coverage Report

Created: 2026-04-28 06:26

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/Botan-3.4.0/build/include/internal/botan/internal/rotate.h
Line
Count
Source
1
/*
2
* Word Rotation Operations
3
* (C) 1999-2008,2023 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
namespace Botan {
14
15
/**
16
* Bit rotation left by a compile-time constant amount
17
* @param input the input word
18
* @return input rotated left by ROT bits
19
*/
20
template <size_t ROT, typename T>
21
inline constexpr T rotl(T input)
22
   requires(ROT > 0 && ROT < 8 * sizeof(T))
23
2.51G
{
24
2.51G
   return static_cast<T>((input << ROT) | (input >> (8 * sizeof(T) - ROT)));
25
2.51G
}
_ZN5Botan4rotlILm8EjEET0_S1_QaagtT_Li0EltT_mlLi8EstS1_
Line
Count
Source
23
24.4M
{
24
24.4M
   return static_cast<T>((input << ROT) | (input >> (8 * sizeof(T) - ROT)));
25
24.4M
}
_ZN5Botan4rotlILm1EjEET0_S1_QaagtT_Li0EltT_mlLi8EstS1_
Line
Count
Source
23
482k
{
24
482k
   return static_cast<T>((input << ROT) | (input >> (8 * sizeof(T) - ROT)));
25
482k
}
_ZN5Botan4rotlILm4EjEET0_S1_QaagtT_Li0EltT_mlLi8EstS1_
Line
Count
Source
23
13.8M
{
24
13.8M
   return static_cast<T>((input << ROT) | (input >> (8 * sizeof(T) - ROT)));
25
13.8M
}
_ZN5Botan4rotlILm9EjEET0_S1_QaagtT_Li0EltT_mlLi8EstS1_
Line
Count
Source
23
406M
{
24
406M
   return static_cast<T>((input << ROT) | (input >> (8 * sizeof(T) - ROT)));
25
406M
}
_ZN5Botan4rotlILm6EjEET0_S1_QaagtT_Li0EltT_mlLi8EstS1_
Line
Count
Source
23
38.3M
{
24
38.3M
   return static_cast<T>((input << ROT) | (input >> (8 * sizeof(T) - ROT)));
25
38.3M
}
Unexecuted instantiation: _ZN5Botan4rotlILm18EjEET0_S1_QaagtT_Li0EltT_mlLi8EstS1_
_ZN5Botan4rotlILm20EjEET0_S1_QaagtT_Li0EltT_mlLi8EstS1_
Line
Count
Source
23
13.8M
{
24
13.8M
   return static_cast<T>((input << ROT) | (input >> (8 * sizeof(T) - ROT)));
25
13.8M
}
Unexecuted instantiation: _ZN5Botan4rotlILm2EjEET0_S1_QaagtT_Li0EltT_mlLi8EstS1_
_ZN5Botan4rotlILm10EjEET0_S1_QaagtT_Li0EltT_mlLi8EstS1_
Line
Count
Source
23
258M
{
24
258M
   return static_cast<T>((input << ROT) | (input >> (8 * sizeof(T) - ROT)));
25
258M
}
Unexecuted instantiation: _ZN5Botan4rotlILm24EjEET0_S1_QaagtT_Li0EltT_mlLi8EstS1_
_ZN5Botan4rotlILm13EjEET0_S1_QaagtT_Li0EltT_mlLi8EstS1_
Line
Count
Source
23
24.4M
{
24
24.4M
   return static_cast<T>((input << ROT) | (input >> (8 * sizeof(T) - ROT)));
25
24.4M
}
_ZN5Botan4rotlILm23EjEET0_S1_QaagtT_Li0EltT_mlLi8EstS1_
Line
Count
Source
23
163M
{
24
163M
   return static_cast<T>((input << ROT) | (input >> (8 * sizeof(T) - ROT)));
25
163M
}
_ZN5Botan4rotlILm7EjEET0_S1_QaagtT_Li0EltT_mlLi8EstS1_
Line
Count
Source
23
372M
{
24
372M
   return static_cast<T>((input << ROT) | (input >> (8 * sizeof(T) - ROT)));
25
372M
}
_ZN5Botan4rotlILm12EjEET0_S1_QaagtT_Li0EltT_mlLi8EstS1_
Line
Count
Source
23
222M
{
24
222M
   return static_cast<T>((input << ROT) | (input >> (8 * sizeof(T) - ROT)));
25
222M
}
_ZN5Botan4rotlILm17EjEET0_S1_QaagtT_Li0EltT_mlLi8EstS1_
Line
Count
Source
23
198M
{
24
198M
   return static_cast<T>((input << ROT) | (input >> (8 * sizeof(T) - ROT)));
25
198M
}
_ZN5Botan4rotlILm22EjEET0_S1_QaagtT_Li0EltT_mlLi8EstS1_
Line
Count
Source
23
13.8M
{
24
13.8M
   return static_cast<T>((input << ROT) | (input >> (8 * sizeof(T) - ROT)));
25
13.8M
}
_ZN5Botan4rotlILm5EjEET0_S1_QaagtT_Li0EltT_mlLi8EstS1_
Line
Count
Source
23
38.9M
{
24
38.9M
   return static_cast<T>((input << ROT) | (input >> (8 * sizeof(T) - ROT)));
25
38.9M
}
_ZN5Botan4rotlILm14EjEET0_S1_QaagtT_Li0EltT_mlLi8EstS1_
Line
Count
Source
23
38.3M
{
24
38.3M
   return static_cast<T>((input << ROT) | (input >> (8 * sizeof(T) - ROT)));
25
38.3M
}
_ZN5Botan4rotlILm11EjEET0_S1_QaagtT_Li0EltT_mlLi8EstS1_
Line
Count
Source
23
38.3M
{
24
38.3M
   return static_cast<T>((input << ROT) | (input >> (8 * sizeof(T) - ROT)));
25
38.3M
}
_ZN5Botan4rotlILm16EjEET0_S1_QaagtT_Li0EltT_mlLi8EstS1_
Line
Count
Source
23
13.8M
{
24
13.8M
   return static_cast<T>((input << ROT) | (input >> (8 * sizeof(T) - ROT)));
25
13.8M
}
_ZN5Botan4rotlILm15EjEET0_S1_QaagtT_Li0EltT_mlLi8EstS1_
Line
Count
Source
23
337M
{
24
337M
   return static_cast<T>((input << ROT) | (input >> (8 * sizeof(T) - ROT)));
25
337M
}
_ZN5Botan4rotlILm21EjEET0_S1_QaagtT_Li0EltT_mlLi8EstS1_
Line
Count
Source
23
13.8M
{
24
13.8M
   return static_cast<T>((input << ROT) | (input >> (8 * sizeof(T) - ROT)));
25
13.8M
}
_ZN5Botan4rotlILm30EjEET0_S1_QaagtT_Li0EltT_mlLi8EstS1_
Line
Count
Source
23
603k
{
24
603k
   return static_cast<T>((input << ROT) | (input >> (8 * sizeof(T) - ROT)));
25
603k
}
_ZN5Botan4rotlILm19EjEET0_S1_QaagtT_Li0EltT_mlLi8EstS1_
Line
Count
Source
23
184M
{
24
184M
   return static_cast<T>((input << ROT) | (input >> (8 * sizeof(T) - ROT)));
25
184M
}
_ZN5Botan4rotlILm1EmEET0_S1_QaagtT_Li0EltT_mlLi8EstS1_
Line
Count
Source
23
19.9M
{
24
19.9M
   return static_cast<T>((input << ROT) | (input >> (8 * sizeof(T) - ROT)));
25
19.9M
}
_ZN5Botan4rotlILm44EmEET0_S1_QaagtT_Li0EltT_mlLi8EstS1_
Line
Count
Source
23
3.32M
{
24
3.32M
   return static_cast<T>((input << ROT) | (input >> (8 * sizeof(T) - ROT)));
25
3.32M
}
_ZN5Botan4rotlILm43EmEET0_S1_QaagtT_Li0EltT_mlLi8EstS1_
Line
Count
Source
23
3.32M
{
24
3.32M
   return static_cast<T>((input << ROT) | (input >> (8 * sizeof(T) - ROT)));
25
3.32M
}
_ZN5Botan4rotlILm21EmEET0_S1_QaagtT_Li0EltT_mlLi8EstS1_
Line
Count
Source
23
3.32M
{
24
3.32M
   return static_cast<T>((input << ROT) | (input >> (8 * sizeof(T) - ROT)));
25
3.32M
}
_ZN5Botan4rotlILm14EmEET0_S1_QaagtT_Li0EltT_mlLi8EstS1_
Line
Count
Source
23
3.32M
{
24
3.32M
   return static_cast<T>((input << ROT) | (input >> (8 * sizeof(T) - ROT)));
25
3.32M
}
_ZN5Botan4rotlILm28EmEET0_S1_QaagtT_Li0EltT_mlLi8EstS1_
Line
Count
Source
23
3.32M
{
24
3.32M
   return static_cast<T>((input << ROT) | (input >> (8 * sizeof(T) - ROT)));
25
3.32M
}
_ZN5Botan4rotlILm20EmEET0_S1_QaagtT_Li0EltT_mlLi8EstS1_
Line
Count
Source
23
3.32M
{
24
3.32M
   return static_cast<T>((input << ROT) | (input >> (8 * sizeof(T) - ROT)));
25
3.32M
}
_ZN5Botan4rotlILm3EmEET0_S1_QaagtT_Li0EltT_mlLi8EstS1_
Line
Count
Source
23
3.32M
{
24
3.32M
   return static_cast<T>((input << ROT) | (input >> (8 * sizeof(T) - ROT)));
25
3.32M
}
_ZN5Botan4rotlILm45EmEET0_S1_QaagtT_Li0EltT_mlLi8EstS1_
Line
Count
Source
23
3.32M
{
24
3.32M
   return static_cast<T>((input << ROT) | (input >> (8 * sizeof(T) - ROT)));
25
3.32M
}
_ZN5Botan4rotlILm61EmEET0_S1_QaagtT_Li0EltT_mlLi8EstS1_
Line
Count
Source
23
3.32M
{
24
3.32M
   return static_cast<T>((input << ROT) | (input >> (8 * sizeof(T) - ROT)));
25
3.32M
}
_ZN5Botan4rotlILm6EmEET0_S1_QaagtT_Li0EltT_mlLi8EstS1_
Line
Count
Source
23
3.32M
{
24
3.32M
   return static_cast<T>((input << ROT) | (input >> (8 * sizeof(T) - ROT)));
25
3.32M
}
_ZN5Botan4rotlILm25EmEET0_S1_QaagtT_Li0EltT_mlLi8EstS1_
Line
Count
Source
23
3.32M
{
24
3.32M
   return static_cast<T>((input << ROT) | (input >> (8 * sizeof(T) - ROT)));
25
3.32M
}
_ZN5Botan4rotlILm8EmEET0_S1_QaagtT_Li0EltT_mlLi8EstS1_
Line
Count
Source
23
3.32M
{
24
3.32M
   return static_cast<T>((input << ROT) | (input >> (8 * sizeof(T) - ROT)));
25
3.32M
}
_ZN5Botan4rotlILm18EmEET0_S1_QaagtT_Li0EltT_mlLi8EstS1_
Line
Count
Source
23
3.32M
{
24
3.32M
   return static_cast<T>((input << ROT) | (input >> (8 * sizeof(T) - ROT)));
25
3.32M
}
_ZN5Botan4rotlILm27EmEET0_S1_QaagtT_Li0EltT_mlLi8EstS1_
Line
Count
Source
23
3.32M
{
24
3.32M
   return static_cast<T>((input << ROT) | (input >> (8 * sizeof(T) - ROT)));
25
3.32M
}
_ZN5Botan4rotlILm36EmEET0_S1_QaagtT_Li0EltT_mlLi8EstS1_
Line
Count
Source
23
3.32M
{
24
3.32M
   return static_cast<T>((input << ROT) | (input >> (8 * sizeof(T) - ROT)));
25
3.32M
}
_ZN5Botan4rotlILm10EmEET0_S1_QaagtT_Li0EltT_mlLi8EstS1_
Line
Count
Source
23
3.32M
{
24
3.32M
   return static_cast<T>((input << ROT) | (input >> (8 * sizeof(T) - ROT)));
25
3.32M
}
_ZN5Botan4rotlILm15EmEET0_S1_QaagtT_Li0EltT_mlLi8EstS1_
Line
Count
Source
23
3.32M
{
24
3.32M
   return static_cast<T>((input << ROT) | (input >> (8 * sizeof(T) - ROT)));
25
3.32M
}
_ZN5Botan4rotlILm56EmEET0_S1_QaagtT_Li0EltT_mlLi8EstS1_
Line
Count
Source
23
3.32M
{
24
3.32M
   return static_cast<T>((input << ROT) | (input >> (8 * sizeof(T) - ROT)));
25
3.32M
}
_ZN5Botan4rotlILm62EmEET0_S1_QaagtT_Li0EltT_mlLi8EstS1_
Line
Count
Source
23
3.32M
{
24
3.32M
   return static_cast<T>((input << ROT) | (input >> (8 * sizeof(T) - ROT)));
25
3.32M
}
_ZN5Botan4rotlILm55EmEET0_S1_QaagtT_Li0EltT_mlLi8EstS1_
Line
Count
Source
23
3.32M
{
24
3.32M
   return static_cast<T>((input << ROT) | (input >> (8 * sizeof(T) - ROT)));
25
3.32M
}
_ZN5Botan4rotlILm39EmEET0_S1_QaagtT_Li0EltT_mlLi8EstS1_
Line
Count
Source
23
3.32M
{
24
3.32M
   return static_cast<T>((input << ROT) | (input >> (8 * sizeof(T) - ROT)));
25
3.32M
}
_ZN5Botan4rotlILm41EmEET0_S1_QaagtT_Li0EltT_mlLi8EstS1_
Line
Count
Source
23
3.32M
{
24
3.32M
   return static_cast<T>((input << ROT) | (input >> (8 * sizeof(T) - ROT)));
25
3.32M
}
_ZN5Botan4rotlILm2EmEET0_S1_QaagtT_Li0EltT_mlLi8EstS1_
Line
Count
Source
23
3.32M
{
24
3.32M
   return static_cast<T>((input << ROT) | (input >> (8 * sizeof(T) - ROT)));
25
3.32M
}
26
27
/**
28
* Bit rotation right by a compile-time constant amount
29
* @param input the input word
30
* @return input rotated right by ROT bits
31
*/
32
template <size_t ROT, typename T>
33
inline constexpr T rotr(T input)
34
   requires(ROT > 0 && ROT < 8 * sizeof(T))
35
18.1G
{
36
18.1G
   return static_cast<T>((input >> ROT) | (input << (8 * sizeof(T) - ROT)));
37
18.1G
}
Unexecuted instantiation: _ZN5Botan4rotrILm8EjEET0_S1_QaagtT_Li0EltT_mlLi8EstS1_
Unexecuted instantiation: _ZN5Botan4rotrILm16EjEET0_S1_QaagtT_Li0EltT_mlLi8EstS1_
Unexecuted instantiation: _ZN5Botan4rotrILm24EjEET0_S1_QaagtT_Li0EltT_mlLi8EstS1_
Unexecuted instantiation: _ZN5Botan4rotrILm20EjEET0_S1_QaagtT_Li0EltT_mlLi8EstS1_
_ZN5Botan4rotrILm18EjEET0_S1_QaagtT_Li0EltT_mlLi8EstS1_
Line
Count
Source
35
1.22G
{
36
1.22G
   return static_cast<T>((input >> ROT) | (input << (8 * sizeof(T) - ROT)));
37
1.22G
}
_ZN5Botan4rotrILm6EjEET0_S1_QaagtT_Li0EltT_mlLi8EstS1_
Line
Count
Source
35
1.22G
{
36
1.22G
   return static_cast<T>((input >> ROT) | (input << (8 * sizeof(T) - ROT)));
37
1.22G
}
Unexecuted instantiation: _ZN5Botan4rotrILm4EjEET0_S1_QaagtT_Li0EltT_mlLi8EstS1_
Unexecuted instantiation: _ZN5Botan4rotrILm1EjEET0_S1_QaagtT_Li0EltT_mlLi8EstS1_
Unexecuted instantiation: _ZN5Botan4rotrILm9EjEET0_S1_QaagtT_Li0EltT_mlLi8EstS1_
_ZN5Botan4rotrILm2EjEET0_S1_QaagtT_Li0EltT_mlLi8EstS1_
Line
Count
Source
35
1.22G
{
36
1.22G
   return static_cast<T>((input >> ROT) | (input << (8 * sizeof(T) - ROT)));
37
1.22G
}
_ZN5Botan4rotrILm13EjEET0_S1_QaagtT_Li0EltT_mlLi8EstS1_
Line
Count
Source
35
1.22G
{
36
1.22G
   return static_cast<T>((input >> ROT) | (input << (8 * sizeof(T) - ROT)));
37
1.22G
}
_ZN5Botan4rotrILm22EjEET0_S1_QaagtT_Li0EltT_mlLi8EstS1_
Line
Count
Source
35
1.22G
{
36
1.22G
   return static_cast<T>((input >> ROT) | (input << (8 * sizeof(T) - ROT)));
37
1.22G
}
_ZN5Botan4rotrILm11EjEET0_S1_QaagtT_Li0EltT_mlLi8EstS1_
Line
Count
Source
35
1.22G
{
36
1.22G
   return static_cast<T>((input >> ROT) | (input << (8 * sizeof(T) - ROT)));
37
1.22G
}
_ZN5Botan4rotrILm25EjEET0_S1_QaagtT_Li0EltT_mlLi8EstS1_
Line
Count
Source
35
1.22G
{
36
1.22G
   return static_cast<T>((input >> ROT) | (input << (8 * sizeof(T) - ROT)));
37
1.22G
}
_ZN5Botan4rotrILm17EjEET0_S1_QaagtT_Li0EltT_mlLi8EstS1_
Line
Count
Source
35
1.22G
{
36
1.22G
   return static_cast<T>((input >> ROT) | (input << (8 * sizeof(T) - ROT)));
37
1.22G
}
_ZN5Botan4rotrILm19EjEET0_S1_QaagtT_Li0EltT_mlLi8EstS1_
Line
Count
Source
35
1.22G
{
36
1.22G
   return static_cast<T>((input >> ROT) | (input << (8 * sizeof(T) - ROT)));
37
1.22G
}
_ZN5Botan4rotrILm7EjEET0_S1_QaagtT_Li0EltT_mlLi8EstS1_
Line
Count
Source
35
1.22G
{
36
1.22G
   return static_cast<T>((input >> ROT) | (input << (8 * sizeof(T) - ROT)));
37
1.22G
}
_ZN5Botan4rotrILm14EmEET0_S1_QaagtT_Li0EltT_mlLi8EstS1_
Line
Count
Source
35
596M
{
36
596M
   return static_cast<T>((input >> ROT) | (input << (8 * sizeof(T) - ROT)));
37
596M
}
_ZN5Botan4rotrILm18EmEET0_S1_QaagtT_Li0EltT_mlLi8EstS1_
Line
Count
Source
35
596M
{
36
596M
   return static_cast<T>((input >> ROT) | (input << (8 * sizeof(T) - ROT)));
37
596M
}
_ZN5Botan4rotrILm41EmEET0_S1_QaagtT_Li0EltT_mlLi8EstS1_
Line
Count
Source
35
596M
{
36
596M
   return static_cast<T>((input >> ROT) | (input << (8 * sizeof(T) - ROT)));
37
596M
}
_ZN5Botan4rotrILm28EmEET0_S1_QaagtT_Li0EltT_mlLi8EstS1_
Line
Count
Source
35
596M
{
36
596M
   return static_cast<T>((input >> ROT) | (input << (8 * sizeof(T) - ROT)));
37
596M
}
_ZN5Botan4rotrILm34EmEET0_S1_QaagtT_Li0EltT_mlLi8EstS1_
Line
Count
Source
35
596M
{
36
596M
   return static_cast<T>((input >> ROT) | (input << (8 * sizeof(T) - ROT)));
37
596M
}
_ZN5Botan4rotrILm39EmEET0_S1_QaagtT_Li0EltT_mlLi8EstS1_
Line
Count
Source
35
596M
{
36
596M
   return static_cast<T>((input >> ROT) | (input << (8 * sizeof(T) - ROT)));
37
596M
}
_ZN5Botan4rotrILm19EmEET0_S1_QaagtT_Li0EltT_mlLi8EstS1_
Line
Count
Source
35
596M
{
36
596M
   return static_cast<T>((input >> ROT) | (input << (8 * sizeof(T) - ROT)));
37
596M
}
_ZN5Botan4rotrILm61EmEET0_S1_QaagtT_Li0EltT_mlLi8EstS1_
Line
Count
Source
35
596M
{
36
596M
   return static_cast<T>((input >> ROT) | (input << (8 * sizeof(T) - ROT)));
37
596M
}
_ZN5Botan4rotrILm1EmEET0_S1_QaagtT_Li0EltT_mlLi8EstS1_
Line
Count
Source
35
596M
{
36
596M
   return static_cast<T>((input >> ROT) | (input << (8 * sizeof(T) - ROT)));
37
596M
}
_ZN5Botan4rotrILm8EmEET0_S1_QaagtT_Li0EltT_mlLi8EstS1_
Line
Count
Source
35
596M
{
36
596M
   return static_cast<T>((input >> ROT) | (input << (8 * sizeof(T) - ROT)));
37
596M
}
38
39
/**
40
* SHA-2 Sigma style function
41
*/
42
template <size_t R1, size_t R2, size_t S, typename T>
43
3.63G
inline constexpr T sigma(T x) {
44
3.63G
   return rotr<R1>(x) ^ rotr<R2>(x) ^ (x >> S);
45
3.63G
}
unsigned int Botan::sigma<17ul, 19ul, 10ul, unsigned int>(unsigned int)
Line
Count
Source
43
1.22G
inline constexpr T sigma(T x) {
44
1.22G
   return rotr<R1>(x) ^ rotr<R2>(x) ^ (x >> S);
45
1.22G
}
unsigned int Botan::sigma<7ul, 18ul, 3ul, unsigned int>(unsigned int)
Line
Count
Source
43
1.22G
inline constexpr T sigma(T x) {
44
1.22G
   return rotr<R1>(x) ^ rotr<R2>(x) ^ (x >> S);
45
1.22G
}
unsigned long Botan::sigma<19ul, 61ul, 6ul, unsigned long>(unsigned long)
Line
Count
Source
43
596M
inline constexpr T sigma(T x) {
44
596M
   return rotr<R1>(x) ^ rotr<R2>(x) ^ (x >> S);
45
596M
}
unsigned long Botan::sigma<1ul, 8ul, 7ul, unsigned long>(unsigned long)
Line
Count
Source
43
596M
inline constexpr T sigma(T x) {
44
596M
   return rotr<R1>(x) ^ rotr<R2>(x) ^ (x >> S);
45
596M
}
46
47
/**
48
* SHA-2 Sigma style function
49
*/
50
template <size_t R1, size_t R2, size_t R3, typename T>
51
3.63G
inline constexpr T rho(T x) {
52
3.63G
   return rotr<R1>(x) ^ rotr<R2>(x) ^ rotr<R3>(x);
53
3.63G
}
unsigned int Botan::rho<2ul, 13ul, 22ul, unsigned int>(unsigned int)
Line
Count
Source
51
1.22G
inline constexpr T rho(T x) {
52
1.22G
   return rotr<R1>(x) ^ rotr<R2>(x) ^ rotr<R3>(x);
53
1.22G
}
unsigned int Botan::rho<6ul, 11ul, 25ul, unsigned int>(unsigned int)
Line
Count
Source
51
1.22G
inline constexpr T rho(T x) {
52
1.22G
   return rotr<R1>(x) ^ rotr<R2>(x) ^ rotr<R3>(x);
53
1.22G
}
unsigned long Botan::rho<14ul, 18ul, 41ul, unsigned long>(unsigned long)
Line
Count
Source
51
596M
inline constexpr T rho(T x) {
52
596M
   return rotr<R1>(x) ^ rotr<R2>(x) ^ rotr<R3>(x);
53
596M
}
unsigned long Botan::rho<28ul, 34ul, 39ul, unsigned long>(unsigned long)
Line
Count
Source
51
596M
inline constexpr T rho(T x) {
52
596M
   return rotr<R1>(x) ^ rotr<R2>(x) ^ rotr<R3>(x);
53
596M
}
54
55
/**
56
* Bit rotation left, variable rotation amount
57
* @param input the input word
58
* @param rot the number of bits to rotate, must be between 0 and sizeof(T)*8-1
59
* @return input rotated left by rot bits
60
*/
61
template <typename T>
62
inline constexpr T rotl_var(T input, size_t rot) {
63
   return rot ? static_cast<T>((input << rot) | (input >> (sizeof(T) * 8 - rot))) : input;
64
}
65
66
/**
67
* Bit rotation right, variable rotation amount
68
* @param input the input word
69
* @param rot the number of bits to rotate, must be between 0 and sizeof(T)*8-1
70
* @return input rotated right by rot bits
71
*/
72
template <typename T>
73
inline constexpr T rotr_var(T input, size_t rot) {
74
   return rot ? static_cast<T>((input >> rot) | (input << (sizeof(T) * 8 - rot))) : input;
75
}
76
77
#if defined(BOTAN_USE_GCC_INLINE_ASM) && defined(BOTAN_TARGET_CPU_IS_X86_FAMILY)
78
79
template <>
80
0
inline uint32_t rotl_var(uint32_t input, size_t rot) {
81
0
   asm("roll %1,%0" : "+r"(input) : "c"(static_cast<uint8_t>(rot)) : "cc");
82
0
   return input;
83
0
}
84
85
template <>
86
0
inline uint32_t rotr_var(uint32_t input, size_t rot) {
87
0
   asm("rorl %1,%0" : "+r"(input) : "c"(static_cast<uint8_t>(rot)) : "cc");
88
0
   return input;
89
0
}
90
91
#endif
92
93
}  // namespace Botan
94
95
#endif