Pol  Revision:cb584c9
cryptengine.cpp
Go to the documentation of this file.
1 
7 #include "cryptengine.h"
8 
9 #include "../../clib/logfacility.h"
10 #include "crypt.h"
11 #include "cryptkey.h"
12 
13 namespace Pol
14 {
15 namespace Crypt
16 {
18 {
19  return new CCryptNoCrypt();
20 }
21 
22 CCryptBase* create_crypt_old_blowfish_engine( unsigned int uiKey1, unsigned int uiKey2 )
23 {
24  return new CCryptBlowfishOld( uiKey1, uiKey2 );
25 }
26 
27 CCryptBase* create_crypt_1_25_36_engine( unsigned int uiKey1, unsigned int uiKey2 )
28 {
29  return new CCrypt12536( uiKey1, uiKey2 );
30 }
31 
32 CCryptBase* create_crypt_blowfish_engine( unsigned int uiKey1, unsigned int uiKey2 )
33 {
34  return new CCryptBlowfish( uiKey1, uiKey2 );
35 }
36 
37 CCryptBase* create_crypt_twofish_engine( unsigned int uiKey1, unsigned int uiKey2 )
38 {
39  return new CCryptTwofish( uiKey1, uiKey2 );
40 }
41 
42 CCryptBase* create_crypt_blowfish_twofish_engine( unsigned int uiKey1, unsigned int uiKey2 )
43 {
44  return new CCryptBlowfishTwofish( uiKey1, uiKey2 );
45 }
46 
48 {
49  switch ( infoCrypt.eType )
50  {
51  case CRYPT_NOCRYPT:
52  return create_nocrypt_engine();
53  case CRYPT_OLD_BLOWFISH:
54  return create_crypt_old_blowfish_engine( infoCrypt.uiKey1, infoCrypt.uiKey2 );
55  case CRYPT_1_25_36:
56  return create_crypt_1_25_36_engine( infoCrypt.uiKey1, infoCrypt.uiKey2 );
57  case CRYPT_BLOWFISH:
58  return create_crypt_blowfish_engine( infoCrypt.uiKey1, infoCrypt.uiKey2 );
59  case CRYPT_TWOFISH:
60  return create_crypt_twofish_engine( infoCrypt.uiKey1, infoCrypt.uiKey2 );
62  return create_crypt_blowfish_twofish_engine( infoCrypt.uiKey1, infoCrypt.uiKey2 );
63  default:
64  POLLOG_ERROR << "Unknown ClientEncryptionVersion, using Ignition encryption engine\n";
65  return create_nocrypt_engine();
66  }
67 }
68 }
69 }
ECryptType eType
Definition: cryptkey.h:33
unsigned int uiKey1
Definition: cryptkey.h:31
#define POLLOG_ERROR
Definition: logfacility.h:207
CCryptBase * create_crypt_1_25_36_engine(unsigned int uiKey1, unsigned int uiKey2)
Definition: cryptengine.cpp:27
CCryptBase * create_crypt_blowfish_twofish_engine(unsigned int uiKey1, unsigned int uiKey2)
Definition: cryptengine.cpp:42
unsigned int uiKey2
Definition: cryptkey.h:32
CCryptBase * create_nocrypt_engine()
Definition: cryptengine.cpp:17
CCryptBase * create_crypt_old_blowfish_engine(unsigned int uiKey1, unsigned int uiKey2)
Definition: cryptengine.cpp:22
CCryptBase * create_crypt_engine(TCryptInfo &infoCrypt)
Definition: cryptengine.cpp:47
CCryptBase * create_crypt_blowfish_engine(unsigned int uiKey1, unsigned int uiKey2)
Definition: cryptengine.cpp:32
Definition: berror.cpp:12
CCryptBase * create_crypt_twofish_engine(unsigned int uiKey1, unsigned int uiKey2)
Definition: cryptengine.cpp:37