/src/botan/build/include/internal/botan/internal/serpent_fn.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | * (C) 1999-2007,2013 Jack Lloyd |
3 | | * |
4 | | * Botan is released under the Simplified BSD License (see license.txt) |
5 | | */ |
6 | | |
7 | | #ifndef BOTAN_SERPENT_FUNCS_H_ |
8 | | #define BOTAN_SERPENT_FUNCS_H_ |
9 | | |
10 | | #include <botan/compiler.h> |
11 | | #include <botan/types.h> |
12 | | #include <botan/internal/rotate.h> |
13 | | |
14 | | namespace Botan::Serpent_F { |
15 | | |
16 | | template <size_t S> |
17 | 0 | BOTAN_FORCE_INLINE uint32_t shl(uint32_t v) { |
18 | 0 | return v << S; |
19 | 0 | } Unexecuted instantiation: unsigned int Botan::Serpent_F::shl<3ul>(unsigned int) Unexecuted instantiation: unsigned int Botan::Serpent_F::shl<7ul>(unsigned int) |
20 | | |
21 | | /* |
22 | | * Serpent's Linear Transform |
23 | | */ |
24 | | template <typename T> |
25 | 0 | BOTAN_FORCE_INLINE void transform(T& B0, T& B1, T& B2, T& B3) { |
26 | 0 | B0 = rotl<13>(B0); |
27 | 0 | B2 = rotl<3>(B2); |
28 | 0 | B1 ^= B0 ^ B2; |
29 | 0 | B3 ^= B2 ^ shl<3>(B0); |
30 | 0 | B1 = rotl<1>(B1); |
31 | 0 | B3 = rotl<7>(B3); |
32 | 0 | B0 ^= B1 ^ B3; |
33 | 0 | B2 ^= B3 ^ shl<7>(B1); |
34 | 0 | B0 = rotl<5>(B0); |
35 | 0 | B2 = rotl<22>(B2); |
36 | 0 | } Unexecuted instantiation: void Botan::Serpent_F::transform<unsigned int>(unsigned int&, unsigned int&, unsigned int&, unsigned int&) Unexecuted instantiation: void Botan::Serpent_F::transform<Botan::SIMD_8x32>(Botan::SIMD_8x32&, Botan::SIMD_8x32&, Botan::SIMD_8x32&, Botan::SIMD_8x32&) Unexecuted instantiation: void Botan::Serpent_F::transform<Botan::SIMD_16x32>(Botan::SIMD_16x32&, Botan::SIMD_16x32&, Botan::SIMD_16x32&, Botan::SIMD_16x32&) Unexecuted instantiation: void Botan::Serpent_F::transform<Botan::SIMD_4x32>(Botan::SIMD_4x32&, Botan::SIMD_4x32&, Botan::SIMD_4x32&, Botan::SIMD_4x32&) |
37 | | |
38 | | /* |
39 | | * Serpent's Inverse Linear Transform |
40 | | */ |
41 | | template <typename T> |
42 | 0 | BOTAN_FORCE_INLINE void i_transform(T& B0, T& B1, T& B2, T& B3) { |
43 | 0 | B2 = rotr<22>(B2); |
44 | 0 | B0 = rotr<5>(B0); |
45 | 0 | B2 ^= B3 ^ shl<7>(B1); |
46 | 0 | B0 ^= B1 ^ B3; |
47 | 0 | B3 = rotr<7>(B3); |
48 | 0 | B1 = rotr<1>(B1); |
49 | 0 | B3 ^= B2 ^ shl<3>(B0); |
50 | 0 | B1 ^= B0 ^ B2; |
51 | 0 | B2 = rotr<3>(B2); |
52 | 0 | B0 = rotr<13>(B0); |
53 | 0 | } Unexecuted instantiation: void Botan::Serpent_F::i_transform<unsigned int>(unsigned int&, unsigned int&, unsigned int&, unsigned int&) Unexecuted instantiation: void Botan::Serpent_F::i_transform<Botan::SIMD_8x32>(Botan::SIMD_8x32&, Botan::SIMD_8x32&, Botan::SIMD_8x32&, Botan::SIMD_8x32&) Unexecuted instantiation: void Botan::Serpent_F::i_transform<Botan::SIMD_16x32>(Botan::SIMD_16x32&, Botan::SIMD_16x32&, Botan::SIMD_16x32&, Botan::SIMD_16x32&) Unexecuted instantiation: void Botan::Serpent_F::i_transform<Botan::SIMD_4x32>(Botan::SIMD_4x32&, Botan::SIMD_4x32&, Botan::SIMD_4x32&, Botan::SIMD_4x32&) |
54 | | |
55 | | class Key_Inserter final { |
56 | | public: |
57 | 0 | Key_Inserter(const uint32_t* RK) : m_RK(RK) {} |
58 | | |
59 | | template <typename T> |
60 | 0 | inline void operator()(size_t R, T& B0, T& B1, T& B2, T& B3) const { |
61 | 0 | B0 ^= m_RK[4 * R]; |
62 | 0 | B1 ^= m_RK[4 * R + 1]; |
63 | 0 | B2 ^= m_RK[4 * R + 2]; |
64 | 0 | B3 ^= m_RK[4 * R + 3]; |
65 | 0 | } Unexecuted instantiation: void Botan::Serpent_F::Key_Inserter::operator()<unsigned int>(unsigned long, unsigned int&, unsigned int&, unsigned int&, unsigned int&) const Unexecuted instantiation: void Botan::Serpent_F::Key_Inserter::operator()<Botan::SIMD_8x32>(unsigned long, Botan::SIMD_8x32&, Botan::SIMD_8x32&, Botan::SIMD_8x32&, Botan::SIMD_8x32&) const Unexecuted instantiation: void Botan::Serpent_F::Key_Inserter::operator()<Botan::SIMD_16x32>(unsigned long, Botan::SIMD_16x32&, Botan::SIMD_16x32&, Botan::SIMD_16x32&, Botan::SIMD_16x32&) const Unexecuted instantiation: void Botan::Serpent_F::Key_Inserter::operator()<Botan::SIMD_4x32>(unsigned long, Botan::SIMD_4x32&, Botan::SIMD_4x32&, Botan::SIMD_4x32&, Botan::SIMD_4x32&) const |
66 | | |
67 | | private: |
68 | | const uint32_t* m_RK; |
69 | | }; |
70 | | |
71 | | } // namespace Botan::Serpent_F |
72 | | |
73 | | #endif |