diff options
author | lloyd <[email protected]> | 2008-09-30 14:54:19 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2008-09-30 14:54:19 +0000 |
commit | d16a30f7cd0e8866a401a36ef4319f9b03274642 (patch) | |
tree | 7c5738ced56097c5ddbe170779067220ed59c61b /src/cms | |
parent | c7a6315f9c46f22219b30802621eba2ca3f368fb (diff) |
Fixes to not require RC2 for CMS to compile
Diffstat (limited to 'src/cms')
-rw-r--r-- | src/cms/cms_algo.cpp | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/src/cms/cms_algo.cpp b/src/cms/cms_algo.cpp index fadc68da5..13b794352 100644 --- a/src/cms/cms_algo.cpp +++ b/src/cms/cms_algo.cpp @@ -8,7 +8,10 @@ #include <botan/lookup.h> #include <botan/filters.h> #include <botan/libstate.h> -#include <botan/rc2.h> + +#if defined(BOTAN_HAS_RC2) + #include <botan/rc2.h> +#endif namespace Botan { @@ -71,13 +74,17 @@ SecureVector<byte> CMS_Encoder::wrap_key(RandomNumberGenerator& rng, const SymmetricKey& cek, const SymmetricKey& kek) { +#if defined(BOTAN_HAS_DES) if(cipher == "TripleDES") { SymmetricKey cek_parity = cek; cek_parity.set_odd_parity(); return do_rfc3217_wrap(rng, cipher, kek, cek_parity.bits_of()); } - else if(cipher == "RC2" || cipher == "CAST-128") +#endif + +#if defined(BOTAN_HAS_RC2) || defined(BOTAN_HAS_CAST) + if(cipher == "RC2" || cipher == "CAST-128") { if(kek.length() != 16) throw Encoding_Error("CMS: 128-bit KEKs must be used with " + cipher); @@ -89,8 +96,9 @@ SecureVector<byte> CMS_Encoder::wrap_key(RandomNumberGenerator& rng, lcekpad.append(rng.next_byte()); return do_rfc3217_wrap(rng, cipher, kek, lcekpad); } - else - throw Invalid_Argument("CMS_Encoder::wrap: Unknown cipher " + cipher); +#endif + + throw Invalid_Argument("CMS_Encoder::wrap: Unknown cipher " + cipher); } /************************************************* @@ -102,14 +110,18 @@ SecureVector<byte> CMS_Encoder::encode_params(const std::string& cipher, { DER_Encoder encoder; +#if defined(BOTAN_HAS_RC2) if(cipher == "RC2") { encoder.start_cons(SEQUENCE). encode((u32bit)RC2::EKB_code(8*key.length())). encode(iv.bits_of(), OCTET_STRING). end_cons(); + return encoder.get_contents(); } - else if(cipher == "CAST-128") +#endif + + if(cipher == "CAST-128") { encoder.start_cons(SEQUENCE). encode(iv.bits_of(), OCTET_STRING). |