• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

randombit / botan / 5079590438

25 May 2023 12:28PM UTC coverage: 92.228% (+0.5%) from 91.723%
5079590438

Pull #3502

github

Pull Request #3502: Apply clang-format to the codebase

75589 of 81959 relevant lines covered (92.23%)

12139530.51 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

85.0
/src/tests/test_elgamal.cpp
1
/*
2
* (C) 2014,2015,2020 Jack Lloyd
3
*
4
* Botan is released under the Simplified BSD License (see license.txt)
5
*/
6

7
#include "tests.h"
8

9
#if defined(BOTAN_HAS_ELGAMAL)
10
   #include "test_pubkey.h"
11
   #include <botan/dl_group.h>
12
   #include <botan/elgamal.h>
13
#endif
14

15
namespace Botan_Tests {
16

17
namespace {
18

19
#if defined(BOTAN_HAS_ELGAMAL)
20

21
class ElGamal_Encrypt_Tests final : public PK_Encryption_Decryption_Test {
×
22
   public:
23
      ElGamal_Encrypt_Tests() :
1✔
24
            PK_Encryption_Decryption_Test(
25
               "ElGamal", "pubkey/elgamal_encrypt.vec", "Group,Secret,Nonce,Msg,Ciphertext", "Padding") {}
4✔
26

27
      std::unique_ptr<Botan::Private_Key> load_private_key(const VarMap& vars) override {
6✔
28
         const Botan::BigInt x = vars.get_req_bn("Secret");
6✔
29
         const Botan::DL_Group group(vars.get_req_str("Group"));
12✔
30

31
         return std::make_unique<Botan::ElGamal_PrivateKey>(group, x);
12✔
32
      }
12✔
33
};
34

35
class ElGamal_Decrypt_Tests final : public PK_Decryption_Test {
×
36
   public:
37
      ElGamal_Decrypt_Tests() : PK_Decryption_Test("ElGamal", "pubkey/elgamal_decrypt.vec", "P,G,X,Msg,Ciphertext") {}
4✔
38

39
      std::unique_ptr<Botan::Private_Key> load_private_key(const VarMap& vars) override {
17✔
40
         const Botan::BigInt p = vars.get_req_bn("P");
17✔
41
         const Botan::BigInt g = vars.get_req_bn("G");
17✔
42
         const Botan::BigInt x = vars.get_req_bn("X");
17✔
43

44
         const Botan::DL_Group group(p, g);
17✔
45

46
         return std::make_unique<Botan::ElGamal_PrivateKey>(group, x);
34✔
47
      }
68✔
48
};
49

50
class ElGamal_Keygen_Tests final : public PK_Key_Generation_Test {
×
51
   public:
52
      std::vector<std::string> keygen_params() const override { return {"modp/ietf/1024"}; }
2✔
53

54
      std::string algo_name() const override { return "ElGamal"; }
3✔
55
};
56

57
BOTAN_REGISTER_TEST("pubkey", "elgamal_encrypt", ElGamal_Encrypt_Tests);
58
BOTAN_REGISTER_TEST("pubkey", "elgamal_decrypt", ElGamal_Decrypt_Tests);
59
BOTAN_REGISTER_TEST("pubkey", "elgamal_keygen", ElGamal_Keygen_Tests);
60

61
#endif
62

63
}
64

65
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc