/* * (C) 2015 Jack Lloyd * * Botan is released under the Simplified BSD License (see license.txt) */ #include #include #if defined(BOTAN_HAS_EMSA1) #include #endif #if defined(BOTAN_HAS_EMSA_X931) #include #endif #if defined(BOTAN_HAS_EMSA_PKCS1) #include #endif #if defined(BOTAN_HAS_EMSA_PSSR) #include #endif #if defined(BOTAN_HAS_EMSA_RAW) #include #endif namespace Botan { EMSA::~EMSA() {} EMSA* get_emsa(const std::string& algo_spec) { SCAN_Name request(algo_spec); if(EMSA* emsa = make_a(Botan::EMSA::Spec(algo_spec))) return emsa; throw Algorithm_Not_Found(algo_spec); } std::string hash_for_emsa(const std::string& algo_spec) { SCAN_Name emsa_name(algo_spec); if(emsa_name.arg_count() > 0) { const std::string pos_hash = emsa_name.arg(0); return pos_hash; } return "SHA-512"; // safe default if nothing we understand } #define BOTAN_REGISTER_EMSA_NAMED_NOARGS(type, name) \ BOTAN_REGISTER_NAMED_T(EMSA, name, type, make_new_T) #define BOTAN_REGISTER_EMSA(name, maker) BOTAN_REGISTER_T(EMSA, name, maker) #define BOTAN_REGISTER_EMSA_NOARGS(name) BOTAN_REGISTER_T_NOARGS(EMSA, name) #define BOTAN_REGISTER_EMSA_1HASH(type, name) \ BOTAN_REGISTER_NAMED_T(EMSA, name, type, (make_new_T_1X)) #if defined(BOTAN_HAS_EMSA1) BOTAN_REGISTER_EMSA_1HASH(EMSA1, "EMSA1"); #endif #if defined(BOTAN_HAS_EMSA_PKCS1) BOTAN_REGISTER_NAMED_T(EMSA, "EMSA_PKCS1", EMSA_PCS1v15, EMSA_PKCS1v15::make); #endif #if defined(BOTAN_HAS_EMSA_PSSR) BOTAN_REGISTER_NAMED_T(EMSA, "PSSR", PSSR, PSSR::make); #endif #if defined(BOTAN_HAS_EMSA_X931) BOTAN_REGISTER_EMSA_1HASH(EMSA_X931, "EMSA_X931"); #endif #if defined(BOTAN_HAS_EMSA_RAW) BOTAN_REGISTER_EMSA_NAMED_NOARGS(EMSA_Raw, "Raw"); #endif }