Move this struct over to rhash.c

This commit is contained in:
twinaphex 2020-02-23 05:22:11 +01:00
parent 79536a4767
commit a2a5ca0d01
2 changed files with 21 additions and 43 deletions

View File

@ -307,7 +307,22 @@ uint32_t crc32_calculate(const uint8_t *data, size_t length)
/* Define the circular shift macro */ /* Define the circular shift macro */
#define SHA1CircularShift(bits,word) ((((word) << (bits)) & 0xFFFFFFFF) | ((word) >> (32-(bits)))) #define SHA1CircularShift(bits,word) ((((word) << (bits)) & 0xFFFFFFFF) | ((word) >> (32-(bits))))
static void SHA1Reset(SHA1Context *context) struct sha1_context
{
unsigned Message_Digest[5]; /* Message Digest (output) */
unsigned Length_Low; /* Message length in bits */
unsigned Length_High; /* Message length in bits */
unsigned char Message_Block[64]; /* 512-bit message blocks */
int Message_Block_Index; /* Index into message block array */
int Computed; /* Is the digest computed? */
int Corrupted; /* Is the message digest corruped? */
};
static void SHA1Reset(struct sha1_context *context)
{ {
if (!context) if (!context)
return; return;
@ -326,7 +341,7 @@ static void SHA1Reset(SHA1Context *context)
context->Corrupted = 0; context->Corrupted = 0;
} }
static void SHA1ProcessMessageBlock(SHA1Context *context) static void SHA1ProcessMessageBlock(struct sha1_context *context)
{ {
const unsigned K[] = /* Constants defined in SHA-1 */ const unsigned K[] = /* Constants defined in SHA-1 */
{ {
@ -418,7 +433,7 @@ static void SHA1ProcessMessageBlock(SHA1Context *context)
context->Message_Block_Index = 0; context->Message_Block_Index = 0;
} }
static void SHA1PadMessage(SHA1Context *context) static void SHA1PadMessage(struct sha1_context *context)
{ {
if (!context) if (!context)
return; return;
@ -455,7 +470,7 @@ static void SHA1PadMessage(SHA1Context *context)
SHA1ProcessMessageBlock(context); SHA1ProcessMessageBlock(context);
} }
static int SHA1Result(SHA1Context *context) static int SHA1Result(struct sha1_context *context)
{ {
if (context->Corrupted) if (context->Corrupted)
return 0; return 0;
@ -469,7 +484,7 @@ static int SHA1Result(SHA1Context *context)
return 1; return 1;
} }
static void SHA1Input(SHA1Context *context, static void SHA1Input(struct sha1_context *context,
const unsigned char *message_array, const unsigned char *message_array,
unsigned length) unsigned length)
{ {
@ -508,7 +523,7 @@ static void SHA1Input(SHA1Context *context,
int sha1_calculate(const char *path, char *result) int sha1_calculate(const char *path, char *result)
{ {
SHA1Context sha; struct sha1_context sha;
unsigned char buff[4096]; unsigned char buff[4096];
int rv = 1; int rv = 1;
RFILE *fd = filestream_open(path, RFILE *fd = filestream_open(path,

View File

@ -20,29 +20,6 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/ */
/*
* sha1.h
*
* Copyright (C) 1998, 2009
* Paul E. Jones <paulej@packetizer.com>
* All Rights Reserved
*
*****************************************************************************
* $Id: sha1.h 12 2009-06-22 19:34:25Z paulej $
*****************************************************************************
*
* Description:
* This class implements the Secure Hashing Standard as defined
* in FIPS PUB 180-1 published April 17, 1995.
*
* Many of the variable names in the SHA1Context, especially the
* single character names, were used because those were the names
* used in the publication.
*
* Please read the file sha1.c for more information.
*
*/
#ifndef __LIBRETRO_SDK_HASH_H #ifndef __LIBRETRO_SDK_HASH_H
#define __LIBRETRO_SDK_HASH_H #define __LIBRETRO_SDK_HASH_H
@ -70,20 +47,6 @@ RETRO_BEGIN_DECLS
**/ **/
void sha256_hash(char *out, const uint8_t *in, size_t size); void sha256_hash(char *out, const uint8_t *in, size_t size);
typedef struct SHA1Context
{
unsigned Message_Digest[5]; /* Message Digest (output) */
unsigned Length_Low; /* Message length in bits */
unsigned Length_High; /* Message length in bits */
unsigned char Message_Block[64]; /* 512-bit message blocks */
int Message_Block_Index; /* Index into message block array */
int Computed; /* Is the digest computed? */
int Corrupted; /* Is the message digest corruped? */
} SHA1Context;
int sha1_calculate(const char *path, char *result); int sha1_calculate(const char *path, char *result);
uint32_t djb2_calculate(const char *str); uint32_t djb2_calculate(const char *str);