Changeset 3692371 in nscp for modules/NSCAAgent/nsca_enrypt.hpp
- Timestamp:
- 01/20/09 19:53:38 (4 years ago)
- Branches:
- master, 0.4.0, 0.4.1, 0.4.2, stable
- Children:
- 04f2743
- Parents:
- a4689fc
- File:
-
- 1 edited
-
modules/NSCAAgent/nsca_enrypt.hpp (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
modules/NSCAAgent/nsca_enrypt.hpp
r846bbe4 r3692371 1 #define HAVE_LIBCRYPTOPP2 3 1 #ifdef HAVE_LIBCRYPTOPP 4 2 #include <crypto++/cryptlib.h> … … 53 51 #define ENCRYPT_SAFERPLUS 26 /* SAFER+ */ 54 52 #endif 55 53 #define LAST_ENCRYPTION_ID 26 56 54 57 55 class nsca_encrypt { … … 70 68 virtual void encrypt(unsigned char *buffer, int buffer_size) = 0; 71 69 virtual void decrypt(unsigned char *buffer, int buffer_size) = 0; 72 }; 70 virtual std::wstring getName() = 0; 71 }; 72 #ifdef HAVE_LIBCRYPTOPP 73 73 template <class TMethod> 74 74 class cryptopp_encryption : public any_encryption { … … 137 137 throw encryption_exception(_T("Decryption not supported")); 138 138 } 139 140 }; 139 std::wstring getName() { 140 return TMethod::StaticAlgorithmName(); 141 } 142 143 }; 144 #endif 141 145 class no_encryption : public any_encryption { 142 146 public: … … 150 154 void encrypt(unsigned char *buffer, int buffer_size) {} 151 155 void decrypt(unsigned char *buffer, int buffer_size) {} 156 std::wstring getName() { 157 return _T("No Encryption (not safe)"); 158 } 152 159 }; 153 160 class xor_encryption : public any_encryption { … … 205 212 void decrypt(unsigned char *buffer, int buffer_size) { 206 213 throw encryption_exception(_T("Decryption not supported")); 214 } 215 std::wstring getName() { 216 return _T("XOR (not safe)"); 207 217 } 208 218 }; … … 237 247 238 248 // UNdefined 249 #ifdef HAVE_LIBCRYPTOPP 239 250 case ENCRYPT_3WAY: 240 251 case ENCRYPT_ARCFOUR: … … 248 259 case ENCRYPT_SAFER128: 249 260 case ENCRYPT_SAFERPLUS: 261 #endif 250 262 default: 251 263 return false; … … 329 341 core_->encrypt(buffer, buffer_size); 330 342 } 331 332 343 unsigned char* get_rand_buffer(int length) { 344 unsigned char * buffer = new unsigned char[length+1]; 345 #if HAVE_LIBCRYPTOPP 333 346 CryptoPP::AutoSeededRandomPool rng; 334 unsigned char * buffer = new unsigned char[length+1];335 347 rng.GenerateBlock(buffer, length); 348 #endif 336 349 return buffer; 337 350 }
Note: See TracChangeset
for help on using the changeset viewer.








