mirror of
https://github.com/libretro/RetroArch
synced 2025-01-31 06:32:48 +00:00
(libretro-common) Move hash.c/hash.h to libretro-common
This commit is contained in:
parent
2280684a95
commit
fc4755bce2
@ -112,7 +112,7 @@ OBJ += frontend/frontend.o \
|
|||||||
libretro-common/file//nbio/nbio_stdio.o \
|
libretro-common/file//nbio/nbio_stdio.o \
|
||||||
libretro-common/file/file_path.o \
|
libretro-common/file/file_path.o \
|
||||||
file_path_special.o \
|
file_path_special.o \
|
||||||
hash.o \
|
libretro-common/hash/rhash.o \
|
||||||
audio/audio_driver.o \
|
audio/audio_driver.o \
|
||||||
input/input_driver.o \
|
input/input_driver.o \
|
||||||
input/input_hid_driver.o \
|
input/input_hid_driver.o \
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
#include "movie.h"
|
#include "movie.h"
|
||||||
#include "patch.h"
|
#include "patch.h"
|
||||||
#include "compat/strl.h"
|
#include "compat/strl.h"
|
||||||
#include "hash.h"
|
#include <rhash.h>
|
||||||
#include <file/file_extract.h>
|
#include <file/file_extract.h>
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
@ -18,9 +18,9 @@
|
|||||||
#include "file_ext.h"
|
#include "file_ext.h"
|
||||||
#include "dir_list_special.h"
|
#include "dir_list_special.h"
|
||||||
#include <file/file_extract.h>
|
#include <file/file_extract.h>
|
||||||
|
#include <rhash.h>
|
||||||
|
|
||||||
#include "database_info.h"
|
#include "database_info.h"
|
||||||
#include "hash.h"
|
|
||||||
#include "file_ops.h"
|
#include "file_ops.h"
|
||||||
#include "general.h"
|
#include "general.h"
|
||||||
#include "runloop.h"
|
#include "runloop.h"
|
||||||
|
@ -81,7 +81,7 @@ CONFIG FILE
|
|||||||
CHEATS
|
CHEATS
|
||||||
============================================================ */
|
============================================================ */
|
||||||
#include "../cheats.c"
|
#include "../cheats.c"
|
||||||
#include "../hash.c"
|
#include "../libretro-common/hash/rhash.c"
|
||||||
|
|
||||||
/*============================================================
|
/*============================================================
|
||||||
UI COMMON CONTEXT
|
UI COMMON CONTEXT
|
||||||
|
@ -1,17 +1,23 @@
|
|||||||
/* RetroArch - A frontend for libretro.
|
/* Copyright (C) 2010-2015 The RetroArch team
|
||||||
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
|
|
||||||
* Copyright (C) 2010-2015 - Daniel De Matteis
|
|
||||||
*
|
*
|
||||||
* RetroArch is free software: you can redistribute it and/or modify it under the terms
|
* ---------------------------------------------------------------------------------------
|
||||||
* of the GNU General Public License as published by the Free Software Found-
|
* The following license statement only applies to this file (rhash.c).
|
||||||
* ation, either version 3 of the License, or (at your option) any later version.
|
* ---------------------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
* Permission is hereby granted, free of charge,
|
||||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
||||||
* PURPOSE. See the GNU General Public License for more details.
|
* to deal in the Software without restriction, including without limitation the rights to
|
||||||
|
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
|
||||||
|
* and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License along with RetroArch.
|
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||||
* If not, see <http://www.gnu.org/licenses/>.
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||||
|
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||||
|
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
|
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@ -22,7 +28,7 @@
|
|||||||
#else
|
#else
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
#include "hash.h"
|
#include <rhash.h>
|
||||||
#include <retro_miscellaneous.h>
|
#include <retro_miscellaneous.h>
|
||||||
#include <retro_endianness.h>
|
#include <retro_endianness.h>
|
||||||
|
|
||||||
@ -109,20 +115,23 @@ static void sha256_block(struct sha256_ctx *p)
|
|||||||
p->inlen = 0;
|
p->inlen = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void sha256_chunk(struct sha256_ctx *p, const uint8_t *s, unsigned len)
|
static void sha256_chunk(struct sha256_ctx *p,
|
||||||
|
const uint8_t *s, unsigned len)
|
||||||
{
|
{
|
||||||
unsigned l;
|
unsigned l;
|
||||||
|
|
||||||
p->len += len;
|
p->len += len;
|
||||||
|
|
||||||
while (len)
|
while (len)
|
||||||
{
|
{
|
||||||
l = 64 - p->inlen;
|
l = 64 - p->inlen;
|
||||||
l = (len < l) ? len : l;
|
l = (len < l) ? len : l;
|
||||||
|
|
||||||
memcpy(p->in.u8 + p->inlen, s, l);
|
memcpy(p->in.u8 + p->inlen, s, l);
|
||||||
s += l;
|
|
||||||
|
s += l;
|
||||||
p->inlen += l;
|
p->inlen += l;
|
||||||
len -= l;
|
len -= l;
|
||||||
|
|
||||||
if (p->inlen == 64)
|
if (p->inlen == 64)
|
||||||
sha256_block(p);
|
sha256_block(p);
|
||||||
@ -157,13 +166,13 @@ static void sha256_subhash(struct sha256_ctx *p, uint32_t *t)
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* sha256_hash:
|
* sha256_hash:
|
||||||
* @out : Output.
|
* @s : Output.
|
||||||
* @in : Input.
|
* @in : Input.
|
||||||
* @size : Size of @out.
|
* @size : Size of @s.
|
||||||
*
|
*
|
||||||
* Hashes SHA256 and outputs a human readable string.
|
* Hashes SHA256 and outputs a human readable string.
|
||||||
**/
|
**/
|
||||||
void sha256_hash(char *out, const uint8_t *in, size_t size)
|
void sha256_hash(char *s, const uint8_t *in, size_t size)
|
||||||
{
|
{
|
||||||
unsigned i;
|
unsigned i;
|
||||||
struct sha256_ctx sha;
|
struct sha256_ctx sha;
|
||||||
@ -180,7 +189,7 @@ void sha256_hash(char *out, const uint8_t *in, size_t size)
|
|||||||
sha256_subhash(&sha, shahash.u32);
|
sha256_subhash(&sha, shahash.u32);
|
||||||
|
|
||||||
for (i = 0; i < 32; i++)
|
for (i = 0; i < 32; i++)
|
||||||
snprintf(out + 2 * i, 3, "%02x", (unsigned)shahash.u8[i]);
|
snprintf(s + 2 * i, 3, "%02x", (unsigned)shahash.u8[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef HAVE_ZLIB
|
#ifndef HAVE_ZLIB
|
||||||
@ -293,6 +302,9 @@ uint32_t crc32_calculate(const uint8_t *data, size_t length)
|
|||||||
|
|
||||||
static void SHA1Reset(SHA1Context *context)
|
static void SHA1Reset(SHA1Context *context)
|
||||||
{
|
{
|
||||||
|
if (!context)
|
||||||
|
return;
|
||||||
|
|
||||||
context->Length_Low = 0;
|
context->Length_Low = 0;
|
||||||
context->Length_High = 0;
|
context->Length_High = 0;
|
||||||
context->Message_Block_Index = 0;
|
context->Message_Block_Index = 0;
|
||||||
@ -341,37 +353,37 @@ static void SHA1ProcessMessageBlock(SHA1Context *context)
|
|||||||
|
|
||||||
for(t = 0; t < 20; t++)
|
for(t = 0; t < 20; t++)
|
||||||
{
|
{
|
||||||
temp = SHA1CircularShift(5,A) +
|
temp = SHA1CircularShift(5,A) +
|
||||||
((B & C) | ((~B) & D)) + E + W[t] + K[0];
|
((B & C) | ((~B) & D)) + E + W[t] + K[0];
|
||||||
temp &= 0xFFFFFFFF;
|
temp &= 0xFFFFFFFF;
|
||||||
E = D;
|
E = D;
|
||||||
D = C;
|
D = C;
|
||||||
C = SHA1CircularShift(30,B);
|
C = SHA1CircularShift(30,B);
|
||||||
B = A;
|
B = A;
|
||||||
A = temp;
|
A = temp;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(t = 20; t < 40; t++)
|
for(t = 20; t < 40; t++)
|
||||||
{
|
{
|
||||||
temp = SHA1CircularShift(5,A) + (B ^ C ^ D) + E + W[t] + K[1];
|
temp = SHA1CircularShift(5,A) + (B ^ C ^ D) + E + W[t] + K[1];
|
||||||
temp &= 0xFFFFFFFF;
|
temp &= 0xFFFFFFFF;
|
||||||
E = D;
|
E = D;
|
||||||
D = C;
|
D = C;
|
||||||
C = SHA1CircularShift(30,B);
|
C = SHA1CircularShift(30,B);
|
||||||
B = A;
|
B = A;
|
||||||
A = temp;
|
A = temp;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(t = 40; t < 60; t++)
|
for(t = 40; t < 60; t++)
|
||||||
{
|
{
|
||||||
temp = SHA1CircularShift(5,A) +
|
temp = SHA1CircularShift(5,A) +
|
||||||
((B & C) | (B & D) | (C & D)) + E + W[t] + K[2];
|
((B & C) | (B & D) | (C & D)) + E + W[t] + K[2];
|
||||||
temp &= 0xFFFFFFFF;
|
temp &= 0xFFFFFFFF;
|
||||||
E = D;
|
E = D;
|
||||||
D = C;
|
D = C;
|
||||||
C = SHA1CircularShift(30,B);
|
C = SHA1CircularShift(30,B);
|
||||||
B = A;
|
B = A;
|
||||||
A = temp;
|
A = temp;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(t = 60; t < 80; t++)
|
for(t = 60; t < 80; t++)
|
||||||
@ -401,6 +413,9 @@ static void SHA1ProcessMessageBlock(SHA1Context *context)
|
|||||||
|
|
||||||
static void SHA1PadMessage(SHA1Context *context)
|
static void SHA1PadMessage(SHA1Context *context)
|
||||||
{
|
{
|
||||||
|
if (!context)
|
||||||
|
return;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Check to see if the current message block is too small to hold
|
* Check to see if the current message block is too small to hold
|
||||||
* the initial padding bits and length. If so, we will pad the
|
* the initial padding bits and length. If so, we will pad the
|
||||||
@ -447,9 +462,9 @@ static int SHA1Result(SHA1Context *context)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SHA1Input( SHA1Context *context,
|
static void SHA1Input(SHA1Context *context,
|
||||||
const unsigned char *message_array,
|
const unsigned char *message_array,
|
||||||
unsigned length)
|
unsigned length)
|
||||||
{
|
{
|
||||||
if (!length)
|
if (!length)
|
||||||
return;
|
return;
|
@ -1,17 +1,23 @@
|
|||||||
/* RetroArch - A frontend for libretro.
|
/* Copyright (C) 2010-2015 The RetroArch team
|
||||||
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
|
|
||||||
* Copyright (C) 2011-2015 - Daniel De Matteis
|
|
||||||
*
|
*
|
||||||
* RetroArch is free software: you can redistribute it and/or modify it under the terms
|
* ---------------------------------------------------------------------------------------
|
||||||
* of the GNU General Public License as published by the Free Software Found-
|
* The following license statement only applies to this file (rhash.h).
|
||||||
* ation, either version 3 of the License, or (at your option) any later version.
|
* ---------------------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
* Permission is hereby granted, free of charge,
|
||||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
||||||
* PURPOSE. See the GNU General Public License for more details.
|
* to deal in the Software without restriction, including without limitation the rights to
|
||||||
|
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
|
||||||
|
* and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License along with RetroArch.
|
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||||
* If not, see <http://www.gnu.org/licenses/>.
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||||
|
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||||
|
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
|
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
@ -26,7 +26,7 @@
|
|||||||
#include "../runloop.h"
|
#include "../runloop.h"
|
||||||
#include "../file_ops.h"
|
#include "../file_ops.h"
|
||||||
|
|
||||||
#include "../hash.h"
|
#include <rhash.h>
|
||||||
|
|
||||||
#define MENU_LABEL_DRIVER_SETTINGS 0x81cd2d62U
|
#define MENU_LABEL_DRIVER_SETTINGS 0x81cd2d62U
|
||||||
#define MENU_LABEL_CORE_SETTINGS 0x06795dffU
|
#define MENU_LABEL_CORE_SETTINGS 0x06795dffU
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
#include "menu.h"
|
#include "menu.h"
|
||||||
#include "menu_entries_cbs.h"
|
#include "menu_entries_cbs.h"
|
||||||
|
|
||||||
#include "../hash.h"
|
#include <rhash.h>
|
||||||
|
|
||||||
#define MENU_LABEL_DEFERRED_DATABASE_MANAGER_LIST 0x7c0b704fU
|
#define MENU_LABEL_DEFERRED_DATABASE_MANAGER_LIST 0x7c0b704fU
|
||||||
#define MENU_LABEL_DEFERRED_CURSOR_MANAGER_LIST 0x45446638U
|
#define MENU_LABEL_DEFERRED_CURSOR_MANAGER_LIST 0x45446638U
|
||||||
|
Loading…
x
Reference in New Issue
Block a user