Botan 3.10.0
Crypto and TLS for C&
Botan::EME_Raw Class Referencefinal

#include <eme_raw.h>

Inheritance diagram for Botan::EME_Raw:
Botan::EncryptionPaddingScheme

Public Member Functions

 EME_Raw ()=default

Static Public Member Functions

static std::unique_ptr< EncryptionPaddingSchemecreate (std::string_view algo_spec)

Detailed Description

Definition at line 14 of file eme_raw.h.

Constructor & Destructor Documentation

◆ EME_Raw()

Botan::EME_Raw::EME_Raw ( )
default

Member Function Documentation

◆ create()

std::unique_ptr< EncryptionPaddingScheme > Botan::EncryptionPaddingScheme::create ( std::string_view algo_spec)
staticinherited

Factory method for encryption padding schemes

Parameters
algo_specthe name of the EncryptionPaddingScheme to create
Returns
pointer to newly allocated object of that type

Definition at line 27 of file enc_padding.cpp.

27 {
28#if defined(BOTAN_HAS_EME_RAW)
29 if(algo_spec == "Raw") {
30 return std::make_unique<EME_Raw>();
31 }
32#endif
33
34#if defined(BOTAN_HAS_EME_PKCS1)
35 // TODO(Botan4) Remove all but "PKCS1v15"
36 if(algo_spec == "PKCS1v15" || algo_spec == "EME-PKCS1-v1_5") {
37 return std::make_unique<EME_PKCS1v15>();
38 }
39#endif
40
41#if defined(BOTAN_HAS_EME_OAEP)
42 SCAN_Name req(algo_spec);
43
44 // TODO(Botan4) Remove all but "OAEP"
45 if(req.algo_name() == "OAEP" || req.algo_name() == "EME-OAEP" || req.algo_name() == "EME1") {
46 if(req.arg_count() == 1 || ((req.arg_count() == 2 || req.arg_count() == 3) && req.arg(1) == "MGF1")) {
47 if(auto hash = HashFunction::create(req.arg(0))) {
48 return std::make_unique<OAEP>(std::move(hash), req.arg(2, ""));
49 }
50 } else if(req.arg_count() == 2 || req.arg_count() == 3) {
51 auto mgf_params = parse_algorithm_name(req.arg(1));
52
53 if(mgf_params.size() == 2 && mgf_params[0] == "MGF1") {
54 auto hash = HashFunction::create(req.arg(0));
55 auto mgf1_hash = HashFunction::create(mgf_params[1]);
56
57 if(hash && mgf1_hash) {
58 return std::make_unique<OAEP>(std::move(hash), std::move(mgf1_hash), req.arg(2, ""));
59 }
60 }
61 }
62 }
63#endif
64
65 throw Algorithm_Not_Found(algo_spec);
66}
static std::unique_ptr< HashFunction > create(std::string_view algo_spec, std::string_view provider="")
Definition hash.cpp:111
std::vector< std::string > parse_algorithm_name(std::string_view namex)
Definition parsing.cpp:57

References Botan::SCAN_Name::algo_name(), Botan::SCAN_Name::arg(), Botan::SCAN_Name::arg_count(), Botan::HashFunction::create(), and Botan::parse_algorithm_name().

Referenced by ~EncryptionPaddingScheme().


The documentation for this class was generated from the following files: