mirror of
https://github.com/libretro/RetroArch
synced 2025-02-19 12:41:00 +00:00
(retrolaunch) SHA1 cleanups
This commit is contained in:
parent
0522b9be78
commit
343097fbd5
@ -40,9 +40,7 @@
|
|||||||
|
|
||||||
#include "sha1.h"
|
#include "sha1.h"
|
||||||
|
|
||||||
/*
|
/* 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))))
|
||||||
|
|
||||||
void SHA1Reset(SHA1Context *context)
|
void SHA1Reset(SHA1Context *context)
|
||||||
@ -75,9 +73,7 @@ void SHA1ProcessMessageBlock(SHA1Context *context)
|
|||||||
unsigned W[80]; /* Word sequence */
|
unsigned W[80]; /* Word sequence */
|
||||||
unsigned A, B, C, D, E; /* Word buffers */
|
unsigned A, B, C, D, E; /* Word buffers */
|
||||||
|
|
||||||
/*
|
/* Initialize the first 16 words in the array W */
|
||||||
* Initialize the first 16 words in the array W
|
|
||||||
*/
|
|
||||||
for(t = 0; t < 16; t++)
|
for(t = 0; t < 16; t++)
|
||||||
{
|
{
|
||||||
W[t] = ((unsigned) context->Message_Block[t * 4]) << 24;
|
W[t] = ((unsigned) context->Message_Block[t * 4]) << 24;
|
||||||
@ -87,9 +83,7 @@ void SHA1ProcessMessageBlock(SHA1Context *context)
|
|||||||
}
|
}
|
||||||
|
|
||||||
for(t = 16; t < 80; t++)
|
for(t = 16; t < 80; t++)
|
||||||
{
|
|
||||||
W[t] = SHA1CircularShift(1,W[t-3] ^ W[t-8] ^ W[t-14] ^ W[t-16]);
|
W[t] = SHA1CircularShift(1,W[t-3] ^ W[t-8] ^ W[t-14] ^ W[t-16]);
|
||||||
}
|
|
||||||
|
|
||||||
A = context->Message_Digest[0];
|
A = context->Message_Digest[0];
|
||||||
B = context->Message_Digest[1];
|
B = context->Message_Digest[1];
|
||||||
@ -183,9 +177,7 @@ void SHA1PadMessage(SHA1Context *context)
|
|||||||
context->Message_Block[context->Message_Block_Index++] = 0;
|
context->Message_Block[context->Message_Block_Index++] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/* Store the message length as the last 8 octets */
|
||||||
* Store the message length as the last 8 octets
|
|
||||||
*/
|
|
||||||
context->Message_Block[56] = (context->Length_High >> 24) & 0xFF;
|
context->Message_Block[56] = (context->Length_High >> 24) & 0xFF;
|
||||||
context->Message_Block[57] = (context->Length_High >> 16) & 0xFF;
|
context->Message_Block[57] = (context->Length_High >> 16) & 0xFF;
|
||||||
context->Message_Block[58] = (context->Length_High >> 8) & 0xFF;
|
context->Message_Block[58] = (context->Length_High >> 8) & 0xFF;
|
||||||
@ -248,5 +240,3 @@ void SHA1Input( SHA1Context *context,
|
|||||||
message_array++;
|
message_array++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -24,31 +24,22 @@
|
|||||||
#ifndef _SHA1_H_
|
#ifndef _SHA1_H_
|
||||||
#define _SHA1_H_
|
#define _SHA1_H_
|
||||||
|
|
||||||
/*
|
|
||||||
* This structure will hold context information for the hashing
|
|
||||||
* operation
|
|
||||||
*/
|
|
||||||
typedef struct SHA1Context
|
typedef struct SHA1Context
|
||||||
{
|
{
|
||||||
unsigned Message_Digest[5]; /* Message Digest (output) */
|
unsigned Message_Digest[5]; /* Message Digest (output) */
|
||||||
|
|
||||||
unsigned Length_Low; /* Message length in bits */
|
unsigned Length_Low; /* Message length in bits */
|
||||||
unsigned Length_High; /* Message length in bits */
|
unsigned Length_High; /* Message length in bits */
|
||||||
|
|
||||||
unsigned char Message_Block[64]; /* 512-bit message blocks */
|
unsigned char Message_Block[64]; /* 512-bit message blocks */
|
||||||
int Message_Block_Index; /* Index into message block array */
|
int Message_Block_Index; /* Index into message block array */
|
||||||
|
|
||||||
int Computed; /* Is the digest computed? */
|
int Computed; /* Is the digest computed? */
|
||||||
int Corrupted; /* Is the message digest corruped? */
|
int Corrupted; /* Is the message digest corruped? */
|
||||||
} SHA1Context;
|
} SHA1Context;
|
||||||
|
|
||||||
/*
|
|
||||||
* Function Prototypes
|
|
||||||
*/
|
|
||||||
void SHA1Reset(SHA1Context *);
|
void SHA1Reset(SHA1Context *);
|
||||||
int SHA1Result(SHA1Context *);
|
int SHA1Result(SHA1Context *);
|
||||||
void SHA1Input( SHA1Context *,
|
void SHA1Input( SHA1Context *, const unsigned char *, unsigned);
|
||||||
const unsigned char *,
|
|
||||||
unsigned);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user