Richard Boegli's CnC_Generals_Zero_Hour Fork WIP
This is documentation of Richard Boegil's Zero Hour Fork
 
Loading...
Searching...
No Matches
pkstraw.h
Go to the documentation of this file.
1/*
2** Command & Conquer Generals Zero Hour(tm)
3** Copyright 2025 Electronic Arts Inc.
4**
5** This program is free software: you can redistribute it and/or modify
6** it under the terms of the GNU General Public License as published by
7** the Free Software Foundation, either version 3 of the License, or
8** (at your option) any later version.
9**
10** This program is distributed in the hope that it will be useful,
11** but WITHOUT ANY WARRANTY; without even the implied warranty of
12** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13** GNU General Public License for more details.
14**
15** You should have received a copy of the GNU General Public License
16** along with this program. If not, see <http://www.gnu.org/licenses/>.
17*/
18
19/***********************************************************************************************
20 *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S ***
21 ***********************************************************************************************
22 * *
23 * Project Name : Command & Conquer *
24 * *
25 * $Archive:: /Commando/Library/PKSTRAW.H $*
26 * *
27 * $Author:: Greg_h $*
28 * *
29 * $Modtime:: 7/22/97 11:37a $*
30 * *
31 * $Revision:: 1 $*
32 * *
33 *---------------------------------------------------------------------------------------------*
34 * Functions: *
35 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
36
37#ifndef PKSTRAW_H
38#define PKSTRAW_H
39
40#include "blwstraw.h"
41#include "pk.h"
42#include "pkstraw.h"
43#include "rndstraw.h"
44
45class PKStraw : public Straw
46{
47 public:
52
53 PKStraw(CryptControl control, RandomStraw & rnd);
54
55 virtual void Get_From(Straw * straw);
56 virtual void Get_From(Straw & straw) {Get_From(&straw);}
57
58 virtual int Get(void * source, int slen);
59
60 // Submit key to be used for encryption/decryption.
61 void Key(PKey const * key);
62
63 private:
64 enum {
65 BLOWFISH_KEY_SIZE=BlowfishEngine::MAX_KEY_LENGTH,
66 MAX_KEY_BLOCK_SIZE=256 // Maximum size of pk encrypted blowfish key.
67 };
68
69 /*
70 ** This flag indicates whether the PK (fetch blowfish key) phase is
71 ** in progress or not.
72 */
73 bool IsGettingKey;
74
75 /*
76 ** This is the random straw that is needed to generate the
77 ** blowfish key.
78 */
79 RandomStraw & Rand;
80
81 /*
82 ** This is the attached blowfish pipe. After the blowfish key has been
83 ** decrypted, then the PK processor goes dormant and the blowfish processor
84 ** takes over the data flow.
85 */
86 BlowStraw BF;
87
88 /*
89 ** This control member tells what method (encryption or decryption) that should
90 ** be performed on the data stream.
91 */
92 CryptControl Control;
93
94 /*
95 ** Pointer to the key to use for encryption or decryption. If this pointer is NULL, then
96 ** the data passing through this segment will not be modified.
97 */
98 PKey const * CipherKey;
99
100 /*
101 ** This is the staging buffer for the block of data. This block must be as large as
102 ** the largest possible key size or the largest blowfish key size (whichever is
103 ** greater).
104 */
105 char Buffer[256];
106
107 int Counter;
108
109 /*
110 ** This records the number of bytes remaining in the current block. This
111 ** will be the number of bytes left to accumulate before the block can be
112 ** processed either for encryption or decryption.
113 */
114 int BytesLeft;
115
116 int Encrypted_Key_Length(void) const;
117 int Plain_Key_Length(void) const;
118
119 PKStraw(PKStraw & rvalue);
120 PKStraw & operator = (PKStraw const & straw);
121};
122
123#endif
CryptControl
Definition pkstraw.h:48
@ DECRYPT
Definition pkstraw.h:50
@ ENCRYPT
Definition pkstraw.h:49
virtual void Get_From(Straw *straw)
Definition pkstraw.cpp:98
virtual int Get(void *source, int slen)
Definition pkstraw.cpp:171
virtual void Get_From(Straw &straw)
Definition pkstraw.h:56
PKStraw(CryptControl control, RandomStraw &rnd)
Definition pkstraw.cpp:70
void Key(PKey const *key)
Definition pkstraw.cpp:141
Definition PK.H:63
Definition STRAW.H:51
Straw(void)
Definition STRAW.H:53