SHASTRAW.CPP (6646B)
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/SHASTRAW.CPP 1 3/03/97 10:25a 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 : SHASTRAW.CPP * 24 * * 25 * Programmer : Joe L. Bostic * 26 * * 27 * Start Date : 07/02/96 * 28 * * 29 * Last Update : July 3, 1996 [JLB] * 30 * * 31 *---------------------------------------------------------------------------------------------* 32 * Functions: * 33 * SHAStraw::Get -- Fetch data from the straw and process the SHA with the data. * 34 * SHAStraw::Result -- Fetches the current SHA digest. * 35 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ 36 37 38 #include "shastraw.h" 39 40 41 /*********************************************************************************************** 42 * SHAStraw::Get -- Fetch data from the straw and process the SHA with the data. * 43 * * 44 * This routine will fetch the requested data and as it passes through this straw it will * 45 * submit it to the SHA processor. The data that passes through is unmodified by this * 46 * straw segment. * 47 * * 48 * INPUT: source -- Pointer to the buffer that will hold the requested data. * 49 * * 50 * length -- The length of the data requested. * 51 * * 52 * OUTPUT: Returns with the number of bytes stored in the buffer. If this number is less * 53 * than the number requested, then this indicates that the data stream has been * 54 * exhausted. * 55 * * 56 * WARNINGS: none * 57 * * 58 * HISTORY: * 59 * 07/03/1996 JLB : Created. * 60 *=============================================================================================*/ 61 int SHAStraw::Get(void * source, int slen) 62 { 63 if (source == NULL || slen < 1) { 64 return(0); 65 } 66 67 int counter = Straw::Get(source, slen); 68 SHA.Hash(source, counter); 69 return(counter); 70 } 71 72 73 /*********************************************************************************************** 74 * SHAStraw::Result -- Fetches the current SHA digest. * 75 * * 76 * Use this routine to fetch the current SHA digest from the straw. It will return the * 77 * digest of the data that has passed through this straw segment. * 78 * * 79 * INPUT: result -- Pointer to the buffer to hold the message digest. The buffer must be * 80 * 20 bytes long. * 81 * * 82 * OUTPUT: Returns with the number of bytes stored into the digest buffer. This will always * 83 * be 20. * 84 * * 85 * WARNINGS: none * 86 * * 87 * HISTORY: * 88 * 07/03/1996 JLB : Created. * 89 *=============================================================================================*/ 90 int SHAStraw::Result(void * result) const 91 { 92 return(SHA.Result(result)); 93 }