Merge pull request #308 from profi200/master

Added FSUSER_UpdateSha256Context().
This commit is contained in:
fincs 2016-08-25 13:22:58 +02:00 committed by GitHub
commit 277fc287a1
2 changed files with 29 additions and 0 deletions

View File

@ -747,6 +747,14 @@ Result FSUSER_FormatSaveData(FS_ArchiveID archiveId, FS_Path path, u32 blocks, u
*/ */
Result FSUSER_GetLegacySubBannerData(u32 bannerSize, FS_MediaType mediaType, u64 programId, u8* banner); Result FSUSER_GetLegacySubBannerData(u32 bannerSize, FS_MediaType mediaType, u64 programId, u8* banner);
/**
* @brief Hashes the given data and outputs a SHA256 hash.
* @param data Pointer to the data to be hashed.
* @param inputSize The size of the data.
* @param hash Hash output pointer.
*/
Result FSUSER_UpdateSha256Context(const void* data, u32 inputSize, u8* hash);
/** /**
* @brief Reads from a special file. * @brief Reads from a special file.
* @param bytesRead Pointer to output the number of bytes read to. * @param bytesRead Pointer to output the number of bytes read to.

View File

@ -1201,6 +1201,27 @@ Result FSUSER_GetLegacySubBannerData(u32 bannerSize, FS_MediaType mediaType, u64
return cmdbuf[1]; return cmdbuf[1];
} }
Result FSUSER_UpdateSha256Context(const void* data, u32 inputSize, u8* hash)
{
u32 *cmdbuf = getThreadCommandBuffer();
cmdbuf[0] = IPC_MakeHeader(0x84E, 13, 2); // 0x84E0342
cmdbuf[9] = inputSize;
cmdbuf[10] = 0;
cmdbuf[11] = 0;
cmdbuf[12] = 0;
cmdbuf[13] = 1;
cmdbuf[14] = IPC_Desc_Buffer(inputSize, IPC_BUFFER_R);
cmdbuf[15] = (u32)data;
Result ret = 0;
if(R_FAILED(ret = svcSendSyncRequest(fsSession()))) return ret;
if(hash) memcpy(hash, &cmdbuf[2], 0x20);
return cmdbuf[1];
}
Result FSUSER_ReadSpecialFile(u32* bytesRead, u64 fileOffset, u32 size, u8* data) Result FSUSER_ReadSpecialFile(u32* bytesRead, u64 fileOffset, u32 size, u8* data)
{ {
u32 *cmdbuf = getThreadCommandBuffer(); u32 *cmdbuf = getThreadCommandBuffer();