diff options
author | lloyd <[email protected]> | 2008-11-09 17:57:49 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2008-11-09 17:57:49 +0000 |
commit | b105b06fc6ca08e499ee3d0f47d496e0d393771c (patch) | |
tree | 7109e35429326c09474a6b30c3a7e51a2c2e2308 /src/pbe | |
parent | 8b12f78f1a1f9d861a0e0b7dd8f7f53b6f2d1459 (diff) |
Make two variants of get_pbe more consistent
Diffstat (limited to 'src/pbe')
-rw-r--r-- | src/pbe/get_pbe.cpp | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/src/pbe/get_pbe.cpp b/src/pbe/get_pbe.cpp index cd1ed2aa4..c9f40f47a 100644 --- a/src/pbe/get_pbe.cpp +++ b/src/pbe/get_pbe.cpp @@ -35,19 +35,16 @@ PBE* get_pbe(const std::string& pbe_name) PBE* pbe_obj = 0; #if defined(BOTAN_HAS_PBE_PKCS_V15) - if(!pbe_obj && pbe == "PBE-PKCS5v15") - pbe_obj = new PBE_PKCS5v15(digest, cipher, ENCRYPTION); + if(pbe == "PBE-PKCS5v15") + return new PBE_PKCS5v15(digest, cipher, ENCRYPTION); #endif #if defined(BOTAN_HAS_PBE_PKCS_V20) - if(!pbe_obj && pbe == "PBE-PKCS5v20") - pbe_obj = new PBE_PKCS5v20(digest, cipher); + if(pbe == "PBE-PKCS5v20") + return new PBE_PKCS5v20(digest, cipher); #endif - if(!pbe_obj) - throw Algorithm_Not_Found(pbe_name); - - return pbe_obj; + throw Algorithm_Not_Found(pbe_name); } /************************************************* @@ -62,24 +59,25 @@ PBE* get_pbe(const OID& pbe_oid, DataSource& params) throw Invalid_Algorithm_Name(pbe_oid.as_string()); const std::string pbe_algo = algo_name[0]; +#if defined(BOTAN_HAS_PBE_PKCS_V15) if(pbe_algo == "PBE-PKCS5v15") { -#if defined(BOTAN_HAS_PBE_PKCS_V15) if(algo_name.size() != 3) throw Invalid_Algorithm_Name(pbe_oid.as_string()); + const std::string digest = algo_name[1]; const std::string cipher = algo_name[2]; + PBE* pbe = new PBE_PKCS5v15(digest, cipher, DECRYPTION); pbe->decode_params(params); return pbe; -#endif } - else if(pbe_algo == "PBE-PKCS5v20") - { +#endif + #if defined(BOTAN_HAS_PBE_PKCS_V20) + if(pbe_algo == "PBE-PKCS5v20") return new PBE_PKCS5v20(params); #endif - } throw Algorithm_Not_Found(pbe_oid.as_string()); } |