Skip to content

Commit

Permalink
sha: fix define name to not confuse and clash with actual sha block s…
Browse files Browse the repository at this point in the history
…ize (#155)
  • Loading branch information
DacoTaco committed Jun 16, 2023
1 parent 9ffad97 commit 0a35583
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion gc/ogc/sha.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ distribution.
extern "C" {
#endif /* __cplusplus */

#define SHA_BLOCK_SIZE 0x10000
#define SHA_MSGBLOCK_SIZE 0x10000

typedef struct
{
Expand Down
8 changes: 4 additions & 4 deletions libogc/sha.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@ static s32 SHA_ExecuteCommand(const ShaCommand command, sha_context* context, co
if(params == NULL)
return -4;

for (u32 i = 0; i < data_size; i += SHA_BLOCK_SIZE) {
u32 size = SHA_BLOCK_SIZE;
for (u32 i = 0; i < data_size; i += SHA_MSGBLOCK_SIZE) {
u32 size = SHA_MSGBLOCK_SIZE;
ShaCommand block_cmd = command;

//if it's the final block, set size correctly.
//if it's not the final block, and we got a finalize, we will first send the add command
if(i+SHA_BLOCK_SIZE >= data_size)
if(i+SHA_MSGBLOCK_SIZE >= data_size)
size = data_size - i;
else if(command == FinalizeHash)
block_cmd = AddData;
Expand Down Expand Up @@ -151,7 +151,7 @@ s32 SHA_Input(sha_context* context, const void* data, const u32 data_size)
if(context == NULL || data == NULL || data_size == 0)
return -1;

if((((u32)context) & 0x1F) || (((u32)data) & 0x3F) || (data_size & ~(SHA_BLOCK_SIZE-1)) != 0)
if((((u32)context) & 0x1F) || (((u32)data) & 0x3F) || (data_size & ~(SHA_MSGBLOCK_SIZE-1)) != 0)
return -4;

return SHA_ExecuteCommand(AddData, context, data, data_size, NULL);
Expand Down

0 comments on commit 0a35583

Please sign in to comment.