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

randombit / botan / 5123321399

30 May 2023 04:06PM UTC coverage: 92.213% (+0.004%) from 92.209%
5123321399

Pull #3558

github

web-flow
Merge dd72f7389 into 057bcbc35
Pull Request #3558: Add braces around all if/else statements

75602 of 81986 relevant lines covered (92.21%)

11859779.3 hits per line

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

88.46
/src/lib/pk_pad/eme.cpp
1
/*
2
* EME Base Class
3
* (C) 1999-2008 Jack Lloyd
4
*
5
* Botan is released under the Simplified BSD License (see license.txt)
6
*/
7

8
#include <botan/internal/eme.h>
9

10
#include <botan/exceptn.h>
11
#include <botan/internal/parsing.h>
12
#include <botan/internal/scan_name.h>
13

14
#if defined(BOTAN_HAS_EME_OAEP)
15
   #include <botan/internal/oaep.h>
16
#endif
17

18
#if defined(BOTAN_HAS_EME_PKCS1)
19
   #include <botan/internal/eme_pkcs.h>
20
#endif
21

22
#if defined(BOTAN_HAS_EME_RAW)
23
   #include <botan/internal/eme_raw.h>
24
#endif
25

26
namespace Botan {
27

28
std::unique_ptr<EME> EME::create(std::string_view algo_spec) {
444✔
29
#if defined(BOTAN_HAS_EME_RAW)
30
   if(algo_spec == "Raw") {
444✔
31
      return std::make_unique<EME_Raw>();
186✔
32
   }
33
#endif
34

35
#if defined(BOTAN_HAS_EME_PKCS1)
36
   if(algo_spec == "PKCS1v15" || algo_spec == "EME-PKCS1-v1_5") {
401✔
37
      return std::make_unique<EME_PKCS1v15>();
143✔
38
   }
39
#endif
40

41
#if defined(BOTAN_HAS_EME_OAEP)
42
   SCAN_Name req(algo_spec);
115✔
43

44
   if(req.algo_name() == "OAEP" || req.algo_name() == "EME-OAEP" || req.algo_name() == "EME1") {
350✔
45
      if(req.arg_count() == 1 || ((req.arg_count() == 2 || req.arg_count() == 3) && req.arg(1) == "MGF1")) {
140✔
46
         if(auto hash = HashFunction::create(req.arg(0))) {
180✔
47
            return std::make_unique<OAEP>(std::move(hash), req.arg(2, ""));
90✔
48
         }
90✔
49
      } else if(req.arg_count() == 2 || req.arg_count() == 3) {
50✔
50
         auto mgf_params = parse_algorithm_name(req.arg(1));
25✔
51

52
         if(mgf_params.size() == 2 && mgf_params[0] == "MGF1") {
25✔
53
            auto hash = HashFunction::create(req.arg(0));
25✔
54
            auto mgf1_hash = HashFunction::create(mgf_params[1]);
25✔
55

56
            if(hash && mgf1_hash) {
25✔
57
               return std::make_unique<OAEP>(std::move(hash), std::move(mgf1_hash), req.arg(2, ""));
25✔
58
            }
59
         }
25✔
60
      }
25✔
61
   }
62
#endif
63

64
   throw Algorithm_Not_Found(algo_spec);
×
65
}
115✔
66

67
/*
68
* Encode a message
69
*/
70
secure_vector<uint8_t> EME::encode(const uint8_t msg[],
266✔
71
                                   size_t msg_len,
72
                                   size_t key_bits,
73
                                   RandomNumberGenerator& rng) const {
74
   return pad(msg, msg_len, key_bits, rng);
266✔
75
}
76

77
/*
78
* Encode a message
79
*/
80
secure_vector<uint8_t> EME::encode(const secure_vector<uint8_t>& msg,
×
81
                                   size_t key_bits,
82
                                   RandomNumberGenerator& rng) const {
83
   return pad(msg.data(), msg.size(), key_bits, rng);
×
84
}
85

86
}  // namespace Botan
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

© 2026 Coveralls, Inc