Coverage Report

Created: 2026-07-25 06:35

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/botan/build/include/internal/botan/internal/serpent.h
Line
Count
Source
1
/*
2
* Serpent
3
* (C) 1999-2007 Jack Lloyd
4
*
5
* Botan is released under the Simplified BSD License (see license.txt)
6
*/
7
8
#ifndef BOTAN_SERPENT_H_
9
#define BOTAN_SERPENT_H_
10
11
#include <botan/block_cipher.h>
12
#include <botan/secmem.h>
13
14
namespace Botan {
15
16
/**
17
* Serpent is the most conservative of the AES finalists
18
* https://www.cl.cam.ac.uk/~rja14/serpent.html
19
*/
20
class Serpent final : public Block_Cipher_Fixed_Params<16, 16, 32, 8> {
21
   public:
22
      void encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override;
23
      void decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override;
24
25
      void clear() override;
26
      std::string provider() const override;
27
28
0
      std::string name() const override { return "Serpent"; }
29
30
0
      std::unique_ptr<BlockCipher> new_object() const override { return std::make_unique<Serpent>(); }
31
32
0
      size_t parallelism() const override { return 4; }
33
34
      bool has_keying_material() const override;
35
36
   private:
37
#if defined(BOTAN_HAS_SERPENT_SIMD)
38
      void simd_encrypt_4(const uint8_t in[16 * 4], uint8_t out[16 * 4]) const;
39
      void simd_decrypt_4(const uint8_t in[16 * 4], uint8_t out[16 * 4]) const;
40
#endif
41
42
#if defined(BOTAN_HAS_SERPENT_AVX2)
43
      void avx2_encrypt_8(const uint8_t in[16 * 8], uint8_t out[16 * 8]) const;
44
      void avx2_decrypt_8(const uint8_t in[16 * 8], uint8_t out[16 * 8]) const;
45
#endif
46
47
#if defined(BOTAN_HAS_SERPENT_AVX512)
48
      void avx512_encrypt_16(const uint8_t in[16 * 16], uint8_t out[16 * 16]) const;
49
      void avx512_decrypt_16(const uint8_t in[16 * 16], uint8_t out[16 * 16]) const;
50
#endif
51
52
      void key_schedule(std::span<const uint8_t> key) override;
53
54
      secure_vector<uint32_t> m_round_key;
55
};
56
57
}  // namespace Botan
58
59
#endif