Pol  Revision:cb584c9
cryptbase.h
Go to the documentation of this file.
1 //
3 // crypt/cryptbase.h
4 //
5 // Author: Beosil <beosil@swileys.com>
6 // Date: 18. Apr. 2000
7 //
8 // Converted: Myrathi <tjh@myrathi.co.uk>
9 // Date: 03. Jan. 2003
10 //
11 // Copyright (C) 1999-2000 Bruno 'Beosil' Heidelberger
12 //
13 // This program is free software; you can redistribute it and/or modify
14 // it under the terms of the GNU General Public License as published by
15 // the Free Software Foundation; either version 2 of the License, or
16 // (at your option) any later version.
17 //
18 // This program is distributed in the hope that it will be useful,
19 // but WITHOUT ANY WARRANTY; without even the implied warranty of
20 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 // GNU General Public License for more details.
22 //
23 // You should have received a copy of the GNU General Public License
24 // along with this program; if not, write to the Free Software
25 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 //
27 //
28 // History:
29 // - 03. Jan. 2003 : Updated for use alongside POL's multi-encryption code.
30 // - 18. Apr. 2000 : Keys updated for client 2.0.0
31 // - 27. Jan. 2000 : Keys updated for client 1.26.4
32 // - 18. Jan. 2000 : Keys updated for client 1.26.3
33 // - 23. Nov. 1999 : Keys updated for client 1.26.2 and some compatibility fixes
34 // - 21. Sep. 1999 : Full redesign to fix the "21036 bytes"-bug
35 // - 9. Sep. 1999 : Keys updated for client 1.26.1
36 // - 2. Sep. 1999 : Keys and boxes updated for client 1.26.0b and minor bugfixes
37 // - 13. Aug. 1999 : First release, working with client 1.26.0(a)
38 //
40 
41 #ifndef __CRYPTBASE_H__
42 #define __CRYPTBASE_H__
43 
44 #define CRYPT_AUTO_VALUE 0x80
45 
46 #define CRYPT_GAMEKEY_LENGTH 6
47 #define CRYPT_GAMEKEY_COUNT 25
48 
49 #define CRYPT_GAMESEED_LENGTH 8
50 #define CRYPT_GAMESEED_COUNT 25
51 
52 #define CRYPT_GAMETABLE_START 1
53 #define CRYPT_GAMETABLE_STEP 3
54 #define CRYPT_GAMETABLE_MODULO 11
55 #define CRYPT_GAMETABLE_TRIGGER 21036
56 
57 // Macro Definitions ( to avoid big-/little-endian problems )
58 
59 #define N2L( C, LL ) \
60  LL = ( (unsigned int)( *( ( C )++ ) ) ) << 24, LL |= ( (unsigned int)( *( ( C )++ ) ) ) << 16, \
61  LL |= ( (unsigned int)( *( ( C )++ ) ) ) << 8, LL |= ( (unsigned int)( *( ( C )++ ) ) )
62 #define L2N( LL, C ) \
63  *( ( C )++ ) = (unsigned char)( ( ( LL ) >> 24 ) & 0xff ), \
64  *( ( C )++ ) = (unsigned char)( ( ( LL ) >> 16 ) & 0xff ), \
65  *( ( C )++ ) = (unsigned char)( ( ( LL ) >> 8 ) & 0xff ), \
66  *( ( C )++ ) = (unsigned char)( ( ( LL ) ) & 0xff )
67 #define ROUND( LL, R, S, P ) \
68  LL ^= P; \
69  LL ^= ( ( S[( R >> 24 )] + S[0x0100 + ( ( R >> 16 ) & 0xff )] ) ^ \
70  S[0x0200 + ( ( R >> 8 ) & 0xff )] ) + \
71  S[0x0300 + ( (R)&0xff )]
72 
73 
74 #include "../sockets.h"
75 #include "../uconst.h"
76 #include "logincrypt.h"
77 namespace Pol
78 {
79 namespace Crypt
80 {
81 // basic class only used directly by NoCrypt
83 {
84  // Constructor / Destructor
85 public:
86  CCryptBase();
87  virtual ~CCryptBase();
88 
90  {
94  };
95 
96  // Member Functions
97 public:
98  virtual int Receive( void* buffer, int max_expected, SOCKET socket ) = 0;
99  virtual void Init( void* pvSeed, int type = typeAuto ) = 0;
100  virtual void Encrypt( void* pvIn, void* pvOut, int len )
101  {
102  /* Do nothing. */
103  (void)pvIn;
104  (void)pvOut;
105  (void)len;
106  };
107 };
108 
109 // crypt class
110 
112 {
113  // Constructor / Destructor
114 public:
115  CCryptBaseCrypt();
116  virtual ~CCryptBaseCrypt();
117 
119 
120  // Member Variables
121 protected:
122  int m_type;
123  unsigned int m_masterKey[2];
124  unsigned char encrypted_data[MAXBUFFER];
125 
126  // Member Functions
127 public:
128  virtual void SetMasterKeys( unsigned int masterKey1, unsigned int masterKey2 ) = 0;
129 
130 protected:
131  virtual void Decrypt( void* pvIn, void* pvOut, int len ) = 0;
132 };
133 }
134 }
135 #endif //__CRYPTBASE_H__
int SOCKET
Definition: wnsckt.h:10
unsigned char buffer[10000]
Definition: UoToolMain.cpp:109
#define MAXBUFFER
Definition: uconst.h:88
virtual int Receive(void *buffer, int max_expected, SOCKET socket)=0
virtual void Init(void *pvSeed, int type=typeAuto)=0
virtual void Encrypt(void *pvIn, void *pvOut, int len)
Definition: cryptbase.h:100
Definition: berror.cpp:12