CnC_Remastered_Collection

Command and Conquer: Red Alert
Log | Files | Refs | README | LICENSE

BLWSTRAW.H (3802B)


      1 //
      2 // Copyright 2020 Electronic Arts Inc.
      3 //
      4 // TiberianDawn.DLL and RedAlert.dll and corresponding source code is free 
      5 // software: you can redistribute it and/or modify it under the terms of 
      6 // the GNU General Public License as published by the Free Software Foundation, 
      7 // either version 3 of the License, or (at your option) any later version.
      8 
      9 // TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed 
     10 // in the hope that it will be useful, but with permitted additional restrictions 
     11 // under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT 
     12 // distributed with this program. You should have received a copy of the 
     13 // GNU General Public License along with permitted additional restrictions 
     14 // with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection
     15 
     16 /* $Header: /CounterStrike/BLWSTRAW.H 1     3/03/97 10:24a Joe_bostic $ */
     17 /***********************************************************************************************
     18  ***              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               ***
     19  ***********************************************************************************************
     20  *                                                                                             *
     21  *                 Project Name : Command & Conquer                                            *
     22  *                                                                                             *
     23  *                    File Name : BLWSTRAW.H                                                   *
     24  *                                                                                             *
     25  *                   Programmer : Joe L. Bostic                                                *
     26  *                                                                                             *
     27  *                   Start Date : 07/02/96                                                     *
     28  *                                                                                             *
     29  *                  Last Update : July 2, 1996 [JLB]                                           *
     30  *                                                                                             *
     31  *---------------------------------------------------------------------------------------------*
     32  * Functions:                                                                                  *
     33  * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
     34 
     35 
     36 #ifndef BLWSTRAW_H
     37 #define BLWSTRAW_H
     38 
     39 #include	"straw.h"
     40 #include	"blowfish.h"
     41 
     42 
     43 /*
     44 **	Performs Blowfish encryption/decryption to the data that is drawn through this straw. The
     45 **	process is controlled by the key which must be submitted to the class before any data
     46 **	manipulation will occur. The Blowfish algorithm is symmetric, thus the same key is used
     47 **	for encryption as is for decryption.
     48 */
     49 class BlowStraw : public Straw
     50 {
     51 	public:
     52 		typedef enum CryptControl {
     53 			ENCRYPT,
     54 			DECRYPT
     55 		} CryptControl;
     56 
     57 		BlowStraw(CryptControl control) : BF(NULL), Counter(0), Control(control) {}
     58 		virtual ~BlowStraw(void) {delete BF;BF = NULL;}
     59 
     60 		virtual int Get(void * source, int slen);
     61 
     62 		// Submit key for blowfish engine.
     63 		void Key(void const * key, int length);
     64 
     65 	protected:
     66 		/*
     67 		**	The Blowfish engine used for encryption/decryption. If this pointer is
     68 		**	NULL, then this indicates that the blowfish engine is not active and no
     69 		**	key has been submitted. All data would pass through this straw unchanged
     70 		**	in that case.
     71 		*/
     72 		BlowfishEngine * BF;
     73 
     74 	private:
     75 		char Buffer[8];
     76 		int Counter;
     77 		CryptControl Control;
     78 
     79 		BlowStraw(BlowStraw & rvalue);
     80 		BlowStraw & operator = (BlowStraw const & straw);
     81 };
     82 
     83 
     84 #endif