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

randombit / botan / 12976978465

26 Jan 2025 05:48PM UTC coverage: 91.26% (+0.004%) from 91.256%
12976978465

Pull #4600

github

web-flow
Merge 8a3c2576f into 9beda9f0f
Pull Request #4600: Avoid using IEEE 1363 EMSA names in OID data or EMSA::name

93990 of 102992 relevant lines covered (91.26%)

11458809.91 hits per line

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

95.65
/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) {
607✔
29
#if defined(BOTAN_HAS_EME_RAW)
30
   if(algo_spec == "Raw") {
607✔
31
      return std::make_unique<EME_Raw>();
323✔
32
   }
33
#endif
34

35
#if defined(BOTAN_HAS_EME_PKCS1)
36
   // TODO(Botan4) Remove all but "PKCS1v15"
37
   if(algo_spec == "PKCS1v15" || algo_spec == "EME-PKCS1-v1_5") {
449✔
38
      return std::make_unique<EME_PKCS1v15>();
165✔
39
   }
40
#endif
41

42
#if defined(BOTAN_HAS_EME_OAEP)
43
   SCAN_Name req(algo_spec);
119✔
44

45
   // TODO(Botan4) Remove all but "OAEP"
46
   if(req.algo_name() == "OAEP" || req.algo_name() == "EME-OAEP" || req.algo_name() == "EME1") {
119✔
47
      if(req.arg_count() == 1 || ((req.arg_count() == 2 || req.arg_count() == 3) && req.arg(1) == "MGF1")) {
119✔
48
         if(auto hash = HashFunction::create(req.arg(0))) {
188✔
49
            return std::make_unique<OAEP>(std::move(hash), req.arg(2, ""));
94✔
50
         }
94✔
51
      } else if(req.arg_count() == 2 || req.arg_count() == 3) {
25✔
52
         auto mgf_params = parse_algorithm_name(req.arg(1));
25✔
53

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

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

66
   throw Algorithm_Not_Found(algo_spec);
×
67
}
119✔
68

69
EME::~EME() = default;
615✔
70

71
}  // 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