]> Chaos Git - corbenik/ctrulib.git/commitdiff
Added FSUSER_UpdateSha256Context().
authorprofi200 <fd3194@gmx.de>
Thu, 25 Aug 2016 06:39:26 +0000 (08:39 +0200)
committerprofi200 <fd3194@gmx.de>
Thu, 25 Aug 2016 06:39:26 +0000 (08:39 +0200)
libctru/include/3ds/services/fs.h
libctru/source/services/fs.c

index f1f118913874e669832e2c43ee47102deb3bee89..8db6c152496f6f401e3881f53e0e42febecbc95a 100644 (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);
 
+/**
+ * @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.
  * @param bytesRead Pointer to output the number of bytes read to.
index 8894cf8ccd987e1e8a6a39b2c0244d48bcaabeb6..35f36068ca81a4e34937af4eb9cc8e8f0920dad6 100644 (file)
@@ -1201,6 +1201,27 @@ Result FSUSER_GetLegacySubBannerData(u32 bannerSize, FS_MediaType mediaType, u64
        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)
 {
        u32 *cmdbuf = getThreadCommandBuffer();