00001
00002
00003
00004
00005
00006
00007
00008 #include <botan/internal/core_engine.h>
00009 #include <botan/scan_name.h>
00010 #include <botan/algo_factory.h>
00011
00012 #if defined(BOTAN_HAS_CBC_MAC)
00013 #include <botan/cbc_mac.h>
00014 #endif
00015
00016 #if defined(BOTAN_HAS_CMAC)
00017 #include <botan/cmac.h>
00018 #endif
00019
00020 #if defined(BOTAN_HAS_HMAC)
00021 #include <botan/hmac.h>
00022 #endif
00023
00024 #if defined(BOTAN_HAS_SSL3_MAC)
00025 #include <botan/ssl3_mac.h>
00026 #endif
00027
00028 #if defined(BOTAN_HAS_ANSI_X919_MAC)
00029 #include <botan/x919_mac.h>
00030 #endif
00031
00032 namespace Botan {
00033
00034
00035
00036
00037 MessageAuthenticationCode*
00038 Core_Engine::find_mac(const SCAN_Name& request,
00039 Algorithm_Factory& af) const
00040 {
00041
00042 #if defined(BOTAN_HAS_CBC_MAC)
00043 if(request.algo_name() == "CBC-MAC" && request.arg_count() == 1)
00044 return new CBC_MAC(af.make_block_cipher(request.arg(0)));
00045 #endif
00046
00047 #if defined(BOTAN_HAS_CMAC)
00048 if(request.algo_name() == "CMAC" && request.arg_count() == 1)
00049 return new CMAC(af.make_block_cipher(request.arg(0)));
00050 #endif
00051
00052 #if defined(BOTAN_HAS_HMAC)
00053 if(request.algo_name() == "HMAC" && request.arg_count() == 1)
00054 return new HMAC(af.make_hash_function(request.arg(0)));
00055 #endif
00056
00057 #if defined(BOTAN_HAS_SSL3_MAC)
00058 if(request.algo_name() == "SSL3-MAC" && request.arg_count() == 1)
00059 return new SSL3_MAC(af.make_hash_function(request.arg(0)));
00060 #endif
00061
00062 #if defined(BOTAN_HAS_ANSI_X919_MAC)
00063 if(request.algo_name() == "X9.19-MAC" && request.arg_count() == 0)
00064 return new ANSI_X919_MAC(af.make_block_cipher("DES"));
00065 #endif
00066
00067 return 0;
00068 }
00069
00070 }