diff --git a/cheevos/cheevos_rvz.c b/cheevos/cheevos_rvz.c index 6af778d161..48bedeb191 100644 --- a/cheevos/cheevos_rvz.c +++ b/cheevos/cheevos_rvz.c @@ -1750,7 +1750,7 @@ static void wii_encrypt_group(const uint8_t* decrypted_blocks, const uint8_t* block_data = decrypted_blocks + (block * RVZ_WII_SECTOR_DATA_SIZE); for (i = 0; i < RVZ_WII_H0_HASHES_PER_BLOCK; i++) - sha1_digest(block_data + (i * RVZ_WII_H0_CHUNK_SIZE), RVZ_WII_H0_CHUNK_SIZE, block_hashes[block].h0 + (i * 20)); + SHA1Digest(block_data + (i * RVZ_WII_H0_CHUNK_SIZE), RVZ_WII_H0_CHUNK_SIZE, block_hashes[block].h0 + (i * 20)); } /* Step 2: Generate H1 hashes for each block and store in subgroup base @@ -1763,8 +1763,8 @@ static void wii_encrypt_group(const uint8_t* decrypted_blocks, i = block % 8; /* Index within subgroup (0-7) */ /* Store this block's H1 hash in the subgroup base block */ - sha1_digest(block_hashes[block].h0, 31 * 20, - block_hashes[h1_base].h1 + (i * 20)); + SHA1Digest(block_hashes[block].h0, 31 * 20, + block_hashes[h1_base].h1 + (i * 20)); } /* Step 2b: Copy H1 arrays from subgroup base to all blocks in subgroup @@ -1786,8 +1786,8 @@ static void wii_encrypt_group(const uint8_t* decrypted_blocks, for (subgroup = 0; subgroup < 8; subgroup++) { h1_base = subgroup * 8; - sha1_digest(block_hashes[h1_base].h1, 8 * 20, - block_hashes[0].h2 + (subgroup * 20)); + SHA1Digest(block_hashes[h1_base].h1, 8 * 20, + block_hashes[0].h2 + (subgroup * 20)); } /* Step 3b: Copy H2 array from block 0 to all other blocks */ diff --git a/libretro-common/hash/lrc_hash.c b/libretro-common/hash/lrc_hash.c index a8132ca543..e0a3c9741e 100644 --- a/libretro-common/hash/lrc_hash.c +++ b/libretro-common/hash/lrc_hash.c @@ -533,8 +533,11 @@ static void SHA1Input(struct sha1_context *context, } } -void sha1_digest(const uint8_t* data, size_t len, uint8_t digest[20]) +void SHA1Digest(const uint8_t* data, size_t len, uint8_t digest[20]) { +#ifdef __APPLE__ + CC_SHA1(data, (CC_LONG)len, digest); +#else struct sha1_context sha; SHA1Reset(&sha); @@ -542,6 +545,7 @@ void sha1_digest(const uint8_t* data, size_t len, uint8_t digest[20]) if (!SHA1Result(&sha, digest)) memset(digest, 0, 20); +#endif } int sha1_calculate(const char *path, char *result) diff --git a/libretro-common/include/lrc_hash.h b/libretro-common/include/lrc_hash.h index 5065634273..0f2915fddd 100644 --- a/libretro-common/include/lrc_hash.h +++ b/libretro-common/include/lrc_hash.h @@ -52,14 +52,14 @@ RETRO_BEGIN_DECLS void sha256_hash(char *s, const uint8_t *in, size_t len); /** - * sha1_digest: + * SHA1Digest: * @data : Input. * @len : Size of @data. * @digest : Output. * * Hashes SHA1 **/ -void sha1_digest(const uint8_t* data, size_t len, uint8_t digest[20]); +void SHA1Digest(const uint8_t* data, size_t len, uint8_t digest[20]); int sha1_calculate(const char *path, char *result);