Implemented checksum based on BLAKE2s hash function.

This commit is contained in:
LoRd_MuldeR 2021-03-16 22:03:14 +01:00
parent e642969539
commit fe1398fdcb
Signed by: mulder
GPG Key ID: 2B5913365F57E03F
8 changed files with 333 additions and 209 deletions

View File

@ -27,13 +27,13 @@
</ProjectConfiguration>
</ItemGroup>
<ItemGroup>
<ClCompile Include="src\crc.c" />
<ClCompile Include="src\blake2.c" />
<ClCompile Include="src\test.c" />
<ClCompile Include="src\main.c" />
<ClCompile Include="src\utils.c" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="src\crc.h" />
<ClInclude Include="src\blake2.h" />
<ClInclude Include="src\platform.h" />
<ClInclude Include="src\test.h" />
<ClInclude Include="src\utils.h" />

View File

@ -21,10 +21,10 @@
<ClCompile Include="src\utils.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="src\crc.c">
<ClCompile Include="src\test.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="src\test.c">
<ClCompile Include="src\blake2.c">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
@ -32,15 +32,15 @@
<ClInclude Include="src\utils.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="src\crc.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="src\platform.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="src\test.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="src\blake2.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<Manifest Include="res\compatibility.manifest">

253
frontend/src/blake2.c Normal file
View File

@ -0,0 +1,253 @@
/*
BLAKE2 reference source code package - reference C implementations
Copyright 2012, Samuel Neves <sneves@dei.uc.pt>. You may use this under the
terms of the CC0, the OpenSSL Licence, or the Apache Public License 2.0, at
your option. The terms of these licenses can be found at:
- CC0 1.0 Universal : http://creativecommons.org/publicdomain/zero/1.0
- OpenSSL license : https://www.openssl.org/source/license.html
- Apache 2.0 : http://www.apache.org/licenses/LICENSE-2.0
More information about the BLAKE2 hash function can be found at
https://blake2.net.
*/
#include <stdint.h>
#include <string.h>
#include <stdio.h>
#include "blake2.h"
/* -------------------------------------------------------------------------- */
/* blake2-impl.h */
/* -------------------------------------------------------------------------- */
#if defined(_MSC_VER)
# define BLAKE2_PACKED(X) __pragma(pack(push, 1)) X __pragma(pack(pop))
#else
# define BLAKE2_PACKED(X) X __attribute__((packed))
#endif
#if !defined(__cplusplus) && (!defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901L)
# if defined(_MSC_VER)
# define BLAKE2_INLINE __inline
# elif defined(__GNUC__)
# define BLAKE2_INLINE __inline__
# else
# define BLAKE2_INLINE
# endif
#else
# define BLAKE2_INLINE inline
#endif
static const uint32_t blake2s_IV[8] =
{
0x6A09E667UL, 0xBB67AE85UL, 0x3C6EF372UL, 0xA54FF53AUL,
0x510E527FUL, 0x9B05688CUL, 0x1F83D9ABUL, 0x5BE0CD19UL
};
static const uint8_t blake2s_sigma[10][16] =
{
{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 },
{ 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3 },
{ 11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4 },
{ 7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8 },
{ 9, 0, 5, 7, 2, 4, 10, 15, 14, 1, 11, 12, 6, 8, 3, 13 },
{ 2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5, 15, 14, 1, 9 },
{ 12, 5, 1, 15, 14, 13, 4, 10, 0, 7, 6, 3, 9, 2, 8, 11 },
{ 13, 11, 7, 14, 12, 1, 3, 9, 5, 0, 15, 4, 8, 6, 2, 10 },
{ 6, 15, 14, 9, 11, 3, 0, 8, 12, 2, 13, 7, 1, 4, 10, 5 },
{ 10, 2, 8, 4, 7, 6, 1, 5, 15, 11, 9, 14, 3, 12, 13 , 0 },
};
static BLAKE2_INLINE uint32_t load32(const void *const src)
{
const uint8_t *const p = (const uint8_t*)src;
return
((uint32_t)(p[0]) << 0) |
((uint32_t)(p[1]) << 8) |
((uint32_t)(p[2]) << 16) |
((uint32_t)(p[3]) << 24);
}
static BLAKE2_INLINE uint64_t make64(const uint32_t a, const uint32_t b)
{
return
((uint64_t)(a) << 0) |
((uint64_t)(b) << 32);
}
static BLAKE2_INLINE void store32(void *const dst, const uint32_t w)
{
uint8_t *const p = (uint8_t*)dst;
p[0] = (uint8_t)(w >> 0);
p[1] = (uint8_t)(w >> 8);
p[2] = (uint8_t)(w >> 16);
p[3] = (uint8_t)(w >> 24);
}
static BLAKE2_INLINE uint32_t rotr32(const uint32_t w, const unsigned c)
{
return (w >> c) | (w << (32 - c));
}
/* -------------------------------------------------------------------------- */
/* blake2s-ref.c */
/* -------------------------------------------------------------------------- */
static void blake2s_set_lastnode(blake2s_t *const S)
{
S->f[1] = (uint32_t)-1;
}
/* Some helper functions, not necessarily useful */
static int blake2s_is_lastblock(const blake2s_t *const S)
{
return S->f[0] != 0;
}
static void blake2s_set_lastblock(blake2s_t *const S)
{
if (S->last_node)
blake2s_set_lastnode(S);
S->f[0] = (uint32_t)-1;
}
static void blake2s_increment_counter(blake2s_t *const S, const uint32_t inc)
{
S->t[0] += inc;
S->t[1] += (S->t[0] < inc);
}
/* Sequential blake2s initialization */
void blake2s_init(blake2s_t *const S)
{
size_t i;
memset(S, 0, sizeof(blake2s_t));
for (i = 0; i < 8; ++i)
S->h[i] = blake2s_IV[i];
}
#define G(r,i,a,b,c,d) do \
{ \
a = a + b + m[blake2s_sigma[r][2*i+0]]; \
d = rotr32(d ^ a, 16); \
c = c + d; \
b = rotr32(b ^ c, 12); \
a = a + b + m[blake2s_sigma[r][2*i+1]]; \
d = rotr32(d ^ a, 8); \
c = c + d; \
b = rotr32(b ^ c, 7); \
} \
while(0)
#define ROUND(r) do \
{ \
G(r, 0, v[0], v[4], v[ 8], v[12]); \
G(r, 1, v[1], v[5], v[ 9], v[13]); \
G(r, 2, v[2], v[6], v[10], v[14]); \
G(r, 3, v[3], v[7], v[11], v[15]); \
G(r, 4, v[0], v[5], v[10], v[15]); \
G(r, 5, v[1], v[6], v[11], v[12]); \
G(r, 6, v[2], v[7], v[ 8], v[13]); \
G(r, 7, v[3], v[4], v[ 9], v[14]); \
} \
while(0)
static void blake2s_compress(blake2s_t *const S, const uint8_t in[BLAKE2S_BLOCKBYTES])
{
uint32_t m[16];
uint32_t v[16];
size_t i;
for (i = 0; i < 16; ++i)
{
m[i] = load32(in + i * sizeof(m[i]));
}
for (i = 0; i < 8; ++i)
{
v[i] = S->h[i];
}
v[ 8] = blake2s_IV[0];
v[ 9] = blake2s_IV[1];
v[10] = blake2s_IV[2];
v[11] = blake2s_IV[3];
v[12] = S->t[0] ^ blake2s_IV[4];
v[13] = S->t[1] ^ blake2s_IV[5];
v[14] = S->f[0] ^ blake2s_IV[6];
v[15] = S->f[1] ^ blake2s_IV[7];
ROUND(0);
ROUND(1);
ROUND(2);
ROUND(3);
ROUND(4);
ROUND(5);
ROUND(6);
ROUND(7);
ROUND(8);
ROUND(9);
for (i = 0; i < 8; ++i)
{
S->h[i] = S->h[i] ^ v[i] ^ v[i + 8];
}
}
#undef G
#undef ROUND
void blake2s_update(blake2s_t *const S, const void *const pin, size_t inlen)
{
const unsigned char* in = (const unsigned char*)pin;
if (inlen > 0)
{
size_t left = S->buflen;
size_t fill = BLAKE2S_BLOCKBYTES - left;
if (inlen > fill)
{
S->buflen = 0;
memcpy(S->buf + left, in, fill); /* Fill buffer */
blake2s_increment_counter(S, BLAKE2S_BLOCKBYTES);
blake2s_compress(S, S->buf); /* Compress */
in += fill; inlen -= fill;
while (inlen > BLAKE2S_BLOCKBYTES)
{
blake2s_increment_counter(S, BLAKE2S_BLOCKBYTES);
blake2s_compress(S, in);
in += BLAKE2S_BLOCKBYTES;
inlen -= BLAKE2S_BLOCKBYTES;
}
}
memcpy(S->buf + S->buflen, in, inlen);
S->buflen += inlen;
}
}
uint64_t blake2s_final(blake2s_t *const S)
{
if (blake2s_is_lastblock(S))
return 0U;
blake2s_increment_counter(S, (uint32_t)S->buflen);
blake2s_set_lastblock(S);
memset(S->buf + S->buflen, 0, BLAKE2S_BLOCKBYTES - S->buflen); /* Padding */
blake2s_compress(S, S->buf);
return make64(S->h[0], S->h[1]);
}
uint64_t blake2s_compute(const void *const pin, const size_t inlen)
{
blake2s_t state;
if ((pin != NULL) && (inlen > 0U))
{
blake2s_init(&state);
blake2s_update(&state, pin, inlen);
return blake2s_final(&state);
}
return 0xCCF2B16074DF93CEull;
}

33
frontend/src/blake2.h Normal file
View File

@ -0,0 +1,33 @@
/*
BLAKE2 reference source code package - reference C implementations
Copyright 2012, Samuel Neves <sneves@dei.uc.pt>. You may use this under the
terms of the CC0, the OpenSSL Licence, or the Apache Public License 2.0, at
your option. The terms of these licenses can be found at:
- CC0 1.0 Universal : http://creativecommons.org/publicdomain/zero/1.0
- OpenSSL license : https://www.openssl.org/source/license.html
- Apache 2.0 : http://www.apache.org/licenses/LICENSE-2.0
More information about the BLAKE2 hash function can be found at
https://blake2.net.
*/
#ifndef BLAKE2_H
#define BLAKE2_H
#define BLAKE2S_BLOCKBYTES 64
typedef struct _blake2s_t
{
uint32_t h[8], t[2], f[2];
uint8_t buf[BLAKE2S_BLOCKBYTES];
size_t buflen;
uint8_t last_node;
}
blake2s_t;
void blake2s_init(blake2s_t*const S);
void blake2s_update(blake2s_t*const S, const void* const pin, size_t inlen);
uint64_t blake2s_final(blake2s_t*const S);
uint64_t blake2s_compute(const void* const pin, const size_t inlen);
#endif

View File

@ -1,153 +0,0 @@
/******************************************************************************/
/* SlunkCrypt, by LoRd_MuldeR <MuldeR2@GMX.de> */
/* This work has been released under the CC0 1.0 Universal license! */
/******************************************************************************/
#include "crc.h"
static const uint64_t CRC64_TAB[256] =
{
0x0000000000000000ULL, 0x42f0e1eba9ea3693ULL,
0x85e1c3d753d46d26ULL, 0xc711223cfa3e5bb5ULL,
0x493366450e42ecdfULL, 0x0bc387aea7a8da4cULL,
0xccd2a5925d9681f9ULL, 0x8e224479f47cb76aULL,
0x9266cc8a1c85d9beULL, 0xd0962d61b56fef2dULL,
0x17870f5d4f51b498ULL, 0x5577eeb6e6bb820bULL,
0xdb55aacf12c73561ULL, 0x99a54b24bb2d03f2ULL,
0x5eb4691841135847ULL, 0x1c4488f3e8f96ed4ULL,
0x663d78ff90e185efULL, 0x24cd9914390bb37cULL,
0xe3dcbb28c335e8c9ULL, 0xa12c5ac36adfde5aULL,
0x2f0e1eba9ea36930ULL, 0x6dfeff5137495fa3ULL,
0xaaefdd6dcd770416ULL, 0xe81f3c86649d3285ULL,
0xf45bb4758c645c51ULL, 0xb6ab559e258e6ac2ULL,
0x71ba77a2dfb03177ULL, 0x334a9649765a07e4ULL,
0xbd68d2308226b08eULL, 0xff9833db2bcc861dULL,
0x388911e7d1f2dda8ULL, 0x7a79f00c7818eb3bULL,
0xcc7af1ff21c30bdeULL, 0x8e8a101488293d4dULL,
0x499b3228721766f8ULL, 0x0b6bd3c3dbfd506bULL,
0x854997ba2f81e701ULL, 0xc7b97651866bd192ULL,
0x00a8546d7c558a27ULL, 0x4258b586d5bfbcb4ULL,
0x5e1c3d753d46d260ULL, 0x1cecdc9e94ace4f3ULL,
0xdbfdfea26e92bf46ULL, 0x990d1f49c77889d5ULL,
0x172f5b3033043ebfULL, 0x55dfbadb9aee082cULL,
0x92ce98e760d05399ULL, 0xd03e790cc93a650aULL,
0xaa478900b1228e31ULL, 0xe8b768eb18c8b8a2ULL,
0x2fa64ad7e2f6e317ULL, 0x6d56ab3c4b1cd584ULL,
0xe374ef45bf6062eeULL, 0xa1840eae168a547dULL,
0x66952c92ecb40fc8ULL, 0x2465cd79455e395bULL,
0x3821458aada7578fULL, 0x7ad1a461044d611cULL,
0xbdc0865dfe733aa9ULL, 0xff3067b657990c3aULL,
0x711223cfa3e5bb50ULL, 0x33e2c2240a0f8dc3ULL,
0xf4f3e018f031d676ULL, 0xb60301f359dbe0e5ULL,
0xda050215ea6c212fULL, 0x98f5e3fe438617bcULL,
0x5fe4c1c2b9b84c09ULL, 0x1d14202910527a9aULL,
0x93366450e42ecdf0ULL, 0xd1c685bb4dc4fb63ULL,
0x16d7a787b7faa0d6ULL, 0x5427466c1e109645ULL,
0x4863ce9ff6e9f891ULL, 0x0a932f745f03ce02ULL,
0xcd820d48a53d95b7ULL, 0x8f72eca30cd7a324ULL,
0x0150a8daf8ab144eULL, 0x43a04931514122ddULL,
0x84b16b0dab7f7968ULL, 0xc6418ae602954ffbULL,
0xbc387aea7a8da4c0ULL, 0xfec89b01d3679253ULL,
0x39d9b93d2959c9e6ULL, 0x7b2958d680b3ff75ULL,
0xf50b1caf74cf481fULL, 0xb7fbfd44dd257e8cULL,
0x70eadf78271b2539ULL, 0x321a3e938ef113aaULL,
0x2e5eb66066087d7eULL, 0x6cae578bcfe24bedULL,
0xabbf75b735dc1058ULL, 0xe94f945c9c3626cbULL,
0x676dd025684a91a1ULL, 0x259d31cec1a0a732ULL,
0xe28c13f23b9efc87ULL, 0xa07cf2199274ca14ULL,
0x167ff3eacbaf2af1ULL, 0x548f120162451c62ULL,
0x939e303d987b47d7ULL, 0xd16ed1d631917144ULL,
0x5f4c95afc5edc62eULL, 0x1dbc74446c07f0bdULL,
0xdaad56789639ab08ULL, 0x985db7933fd39d9bULL,
0x84193f60d72af34fULL, 0xc6e9de8b7ec0c5dcULL,
0x01f8fcb784fe9e69ULL, 0x43081d5c2d14a8faULL,
0xcd2a5925d9681f90ULL, 0x8fdab8ce70822903ULL,
0x48cb9af28abc72b6ULL, 0x0a3b7b1923564425ULL,
0x70428b155b4eaf1eULL, 0x32b26afef2a4998dULL,
0xf5a348c2089ac238ULL, 0xb753a929a170f4abULL,
0x3971ed50550c43c1ULL, 0x7b810cbbfce67552ULL,
0xbc902e8706d82ee7ULL, 0xfe60cf6caf321874ULL,
0xe224479f47cb76a0ULL, 0xa0d4a674ee214033ULL,
0x67c58448141f1b86ULL, 0x253565a3bdf52d15ULL,
0xab1721da49899a7fULL, 0xe9e7c031e063acecULL,
0x2ef6e20d1a5df759ULL, 0x6c0603e6b3b7c1caULL,
0xf6fae5c07d3274cdULL, 0xb40a042bd4d8425eULL,
0x731b26172ee619ebULL, 0x31ebc7fc870c2f78ULL,
0xbfc9838573709812ULL, 0xfd39626eda9aae81ULL,
0x3a28405220a4f534ULL, 0x78d8a1b9894ec3a7ULL,
0x649c294a61b7ad73ULL, 0x266cc8a1c85d9be0ULL,
0xe17dea9d3263c055ULL, 0xa38d0b769b89f6c6ULL,
0x2daf4f0f6ff541acULL, 0x6f5faee4c61f773fULL,
0xa84e8cd83c212c8aULL, 0xeabe6d3395cb1a19ULL,
0x90c79d3fedd3f122ULL, 0xd2377cd44439c7b1ULL,
0x15265ee8be079c04ULL, 0x57d6bf0317edaa97ULL,
0xd9f4fb7ae3911dfdULL, 0x9b041a914a7b2b6eULL,
0x5c1538adb04570dbULL, 0x1ee5d94619af4648ULL,
0x02a151b5f156289cULL, 0x4051b05e58bc1e0fULL,
0x87409262a28245baULL, 0xc5b073890b687329ULL,
0x4b9237f0ff14c443ULL, 0x0962d61b56fef2d0ULL,
0xce73f427acc0a965ULL, 0x8c8315cc052a9ff6ULL,
0x3a80143f5cf17f13ULL, 0x7870f5d4f51b4980ULL,
0xbf61d7e80f251235ULL, 0xfd913603a6cf24a6ULL,
0x73b3727a52b393ccULL, 0x31439391fb59a55fULL,
0xf652b1ad0167feeaULL, 0xb4a25046a88dc879ULL,
0xa8e6d8b54074a6adULL, 0xea16395ee99e903eULL,
0x2d071b6213a0cb8bULL, 0x6ff7fa89ba4afd18ULL,
0xe1d5bef04e364a72ULL, 0xa3255f1be7dc7ce1ULL,
0x64347d271de22754ULL, 0x26c49cccb40811c7ULL,
0x5cbd6cc0cc10fafcULL, 0x1e4d8d2b65facc6fULL,
0xd95caf179fc497daULL, 0x9bac4efc362ea149ULL,
0x158e0a85c2521623ULL, 0x577eeb6e6bb820b0ULL,
0x906fc95291867b05ULL, 0xd29f28b9386c4d96ULL,
0xcedba04ad0952342ULL, 0x8c2b41a1797f15d1ULL,
0x4b3a639d83414e64ULL, 0x09ca82762aab78f7ULL,
0x87e8c60fded7cf9dULL, 0xc51827e4773df90eULL,
0x020905d88d03a2bbULL, 0x40f9e43324e99428ULL,
0x2cffe7d5975e55e2ULL, 0x6e0f063e3eb46371ULL,
0xa91e2402c48a38c4ULL, 0xebeec5e96d600e57ULL,
0x65cc8190991cb93dULL, 0x273c607b30f68faeULL,
0xe02d4247cac8d41bULL, 0xa2dda3ac6322e288ULL,
0xbe992b5f8bdb8c5cULL, 0xfc69cab42231bacfULL,
0x3b78e888d80fe17aULL, 0x7988096371e5d7e9ULL,
0xf7aa4d1a85996083ULL, 0xb55aacf12c735610ULL,
0x724b8ecdd64d0da5ULL, 0x30bb6f267fa73b36ULL,
0x4ac29f2a07bfd00dULL, 0x08327ec1ae55e69eULL,
0xcf235cfd546bbd2bULL, 0x8dd3bd16fd818bb8ULL,
0x03f1f96f09fd3cd2ULL, 0x41011884a0170a41ULL,
0x86103ab85a2951f4ULL, 0xc4e0db53f3c36767ULL,
0xd8a453a01b3a09b3ULL, 0x9a54b24bb2d03f20ULL,
0x5d45907748ee6495ULL, 0x1fb5719ce1045206ULL,
0x919735e51578e56cULL, 0xd367d40ebc92d3ffULL,
0x1476f63246ac884aULL, 0x568617d9ef46bed9ULL,
0xe085162ab69d5e3cULL, 0xa275f7c11f7768afULL,
0x6564d5fde549331aULL, 0x279434164ca30589ULL,
0xa9b6706fb8dfb2e3ULL, 0xeb46918411358470ULL,
0x2c57b3b8eb0bdfc5ULL, 0x6ea7525342e1e956ULL,
0x72e3daa0aa188782ULL, 0x30133b4b03f2b111ULL,
0xf7021977f9cceaa4ULL, 0xb5f2f89c5026dc37ULL,
0x3bd0bce5a45a6b5dULL, 0x79205d0e0db05dceULL,
0xbe317f32f78e067bULL, 0xfcc19ed95e6430e8ULL,
0x86b86ed5267cdbd3ULL, 0xc4488f3e8f96ed40ULL,
0x0359ad0275a8b6f5ULL, 0x41a94ce9dc428066ULL,
0xcf8b0890283e370cULL, 0x8d7be97b81d4019fULL,
0x4a6acb477bea5a2aULL, 0x089a2aacd2006cb9ULL,
0x14dea25f3af9026dULL, 0x562e43b4931334feULL,
0x913f6188692d6f4bULL, 0xd3cf8063c0c759d8ULL,
0x5dedc41a34bbeeb2ULL, 0x1f1d25f19d51d821ULL,
0xd80c07cd676f8394ULL, 0x9afce626ce85b507ULL,
};
uint64_t crc64_update(uint64_t crc, const uint8_t *const data, const size_t data_len)
{
size_t i;
for (i = 0U; i < data_len; ++i)
{
crc = CRC64_TAB[((crc >> 56) ^ data[i]) & 0xFF] ^ (crc << 8);
}
return crc;
}
uint64_t crc64_finish(const uint64_t crc)
{
return crc ^ ~0U;
}

View File

@ -1,17 +0,0 @@
/******************************************************************************/
/* SlunkCrypt, by LoRd_MuldeR <MuldeR2@GMX.de> */
/* This work has been released under the CC0 1.0 Universal license! */
/******************************************************************************/
#ifndef INC_CRC_H
#define INC_CRC_H
#include <stdlib.h>
#include <stdint.h>
#include <stdio.h>
#define CRC_INITIALIZER ((uint64_t)~0U)
uint64_t crc64_update(uint64_t crc, const uint8_t *const data, const size_t data_len);
uint64_t crc64_finish(const uint64_t crc);
#endif

View File

@ -9,10 +9,12 @@
# define _GNU_SOURCE 1
#endif
/* Internal */
/* API */
#include <slunkcrypt.h>
/* CLI */
#include "utils.h"
#include "crc.h"
#include "blake2.h"
#include "test.h"
/* CRT */
@ -281,9 +283,12 @@ static int encrypt(const char* const passphrase, const CHR* const input_path, co
}
clock_t clk_now, clk_update = clock();
uint64_t crc_actual = CRC_INITIALIZER, bytes_read = 0U;
uint64_t bytes_read = 0U;
uint8_t buffer[BUFFER_SIZE];
blake2s_t blake2s_state;
blake2s_init(&blake2s_state);
FPRINTF(stderr, T("%5.1f%% "), 0.0);
fflush(stderr);
@ -294,7 +299,7 @@ static int encrypt(const char* const passphrase, const CHR* const input_path, co
const size_t count = fread(buffer, sizeof(uint8_t), request_len, file_in);
if (count > 0U)
{
crc_actual = crc64_update(crc_actual, buffer, count);
blake2s_update(&blake2s_state, buffer, count);
bytes_read += count;
if ((status = slunkcrypt_encrypt_inplace(ctx, buffer, count)) != SLUNKCRYPT_SUCCESS)
{
@ -352,17 +357,17 @@ static int encrypt(const char* const passphrase, const CHR* const input_path, co
goto clean_up;
}
crc_actual = swap_bytes_u64(crc64_finish(crc_actual));
const uint64_t checksum_actual = swap_bytes_u64(blake2s_final(&blake2s_state));
if ((status = slunkcrypt_encrypt_inplace(ctx, (uint8_t*)&crc_actual, sizeof(uint64_t))) != SLUNKCRYPT_SUCCESS)
if ((status = slunkcrypt_encrypt_inplace(ctx, (uint8_t*)&checksum_actual, sizeof(uint64_t))) != SLUNKCRYPT_SUCCESS)
{
FPUTS((status == SLUNKCRYPT_ABORTED) ? T("\n\nProcess interrupted!\n\n") : T("\n\nSlunkCrypt error: Failed to encrypt checksum!\n\n"), stderr);
goto clean_up;
}
if (fwrite(&crc_actual, sizeof(uint64_t), 1U, file_out) < 1U)
if (fwrite(&checksum_actual, sizeof(uint64_t), 1U, file_out) < 1U)
{
FPUTS(T("\n\nI/O error: Failed to write CRC checksum!\n\n"), stderr);
FPUTS(T("\n\nI/O error: Failed to write the checksum!\n\n"), stderr);
goto clean_up;
}
@ -443,10 +448,13 @@ static int decrypt(const char* const passphrase, const CHR* const input_path, co
}
clock_t clk_now, clk_update = clock();
uint64_t crc_actual = CRC_INITIALIZER, bytes_read = sizeof(uint64_t);
uint64_t bytes_read = sizeof(uint64_t);
uint8_t buffer[BUFFER_SIZE];
const uint64_t read_limit = round_down(file_size, sizeof(uint64_t)) - (2U * sizeof(uint64_t));
blake2s_t blake2s_state;
blake2s_init(&blake2s_state);
FPRINTF(stderr, T("%5.1f%% "), 0.0);
fflush(stderr);
@ -463,7 +471,7 @@ static int decrypt(const char* const passphrase, const CHR* const input_path, co
FPUTS((status == SLUNKCRYPT_ABORTED) ? T("\n\nProcess interrupted!\n\n") : T("\n\nSlunkCrypt error: Failed to decrypt data!\n\n"), stderr);
goto clean_up;
}
crc_actual = crc64_update(crc_actual, buffer, count);
blake2s_update(&blake2s_state, buffer, count);
if (fwrite(buffer, sizeof(uint8_t), count, file_out) < count)
{
FPUTS(T("failed!\n\nI/O error: Failed to write decrypted data!\n\n"), stderr);
@ -516,39 +524,39 @@ static int decrypt(const char* const passphrase, const CHR* const input_path, co
FPUTS(T("failed!\n\nI/O error: Failed to write decrypted data!\n\n"), stderr);
goto clean_up;
}
crc_actual = crc64_update(crc_actual, buffer, count);
blake2s_update(&blake2s_state, buffer, count);
}
crc_actual = crc64_finish(crc_actual);
const uint64_t checksum_actual = blake2s_final(&blake2s_state);
uint64_t crc_expected;
if (fread(&crc_expected, sizeof(uint64_t), 1U, file_in) < 1U)
uint64_t checksum_expected;
if (fread(&checksum_expected, sizeof(uint64_t), 1U, file_in) < 1U)
{
FPUTS(T("\n\nI/O error: Failed to read CRC checksum!\n\n"), stderr);
FPUTS(T("\n\nI/O error: Failed to read the checksum!\n\n"), stderr);
goto clean_up;
}
if ((status = slunkcrypt_decrypt_inplace(ctx, (uint8_t*)&crc_expected, sizeof(uint64_t))) != SLUNKCRYPT_SUCCESS)
if ((status = slunkcrypt_decrypt_inplace(ctx, (uint8_t*)&checksum_expected, sizeof(uint64_t))) != SLUNKCRYPT_SUCCESS)
{
FPUTS((status == SLUNKCRYPT_ABORTED) ? T("\n\nProcess interrupted!\n\n") : T("\n\nSlunkCrypt error: Failed to decrypt checksum!\n\n"), stderr);
goto clean_up;
}
crc_expected = swap_bytes_u64(crc_expected);
checksum_expected = swap_bytes_u64(checksum_expected);
FPRINTF(stderr, T("\b\b\b\b\b\b\b%5.1f%%\n\n"), 100.0);
fflush(stderr);
if (crc_actual != crc_expected)
if (checksum_actual != checksum_expected)
{
FPRINTF(stderr, T("CRC error: Checksum mismatch detected! [expected: 0x%016") T(PRIX64) T(", actual: 0x%016") T(PRIX64) T("]\n\n"), crc_expected, crc_actual);
FPRINTF(stderr, T("Error: Checksum mismatch detected! [expected: 0x%016") T(PRIX64) T(", actual: 0x%016") T(PRIX64) T("]\n\n"), checksum_expected, checksum_actual);
FPUTS(T("Wrong passphrase or corrupted file?\n\n"), stderr);
goto clean_up;
}
result = EXIT_SUCCESS;
FPUTS(T("CRC checksum is correct.\n\n"), stderr);
FPUTS(T("Checksum is correct.\n\n"), stderr);
fflush(stderr);
clean_up:
@ -575,7 +583,7 @@ clean_up:
// Self-test
// ==========================================================================
static int run_test_case(const char *const message, const uint64_t checksum)
static int run_test_case(const char *const message, const uint64_t checksum_message)
{
static const char* const passphrase = "OrpheanBeh0lderScry!Doubt";
@ -597,10 +605,10 @@ static int run_test_case(const char *const message, const uint64_t checksum)
goto clean_up;
}
const uint64_t crc_original = crc64_finish(crc64_update(CRC_INITIALIZER, (uint8_t*)text_temp, length));
if (crc_original != checksum)
const uint64_t checksum_original = blake2s_compute((uint8_t*)text_temp, length);
if (checksum_original != checksum_message)
{
FPRINTF(stderr, T("\n\nWhoops: Checksum mismatch detected! [expected: 0x%016") T(PRIX64) T(", actual: 0x%016") T(PRIX64) T("]\n\n"), checksum, crc_original);
FPRINTF(stderr, T("\n\nWhoops: Checksum mismatch detected! [expected: 0x%016") T(PRIX64) T(", actual: 0x%016") T(PRIX64) T("]\n\n"), checksum_message, checksum_original);
goto clean_up;
}
@ -644,10 +652,10 @@ static int run_test_case(const char *const message, const uint64_t checksum)
goto clean_up;
}
const uint64_t crc_decrypted = crc64_finish(crc64_update(CRC_INITIALIZER, (uint8_t*)text_temp, length));
if (crc_decrypted != crc_original)
const uint64_t checksum_decrypted = blake2s_compute((uint8_t*)text_temp, length);
if (checksum_decrypted != checksum_original)
{
FPRINTF(stderr, T("\n\nWhoops: Checksum mismatch detected! [expected: 0x%016") T(PRIX64) T(", actual: 0x%016") T(PRIX64) T("]\n\n"), crc_original, crc_decrypted);
FPRINTF(stderr, T("\n\nWhoops: Checksum mismatch detected! [expected: 0x%016") T(PRIX64) T(", actual: 0x%016") T(PRIX64) T("]\n\n"), checksum_original, checksum_decrypted);
goto clean_up;
}
@ -676,7 +684,7 @@ static int run_self_test(void)
const uint64_t test_chck[] = { TEST_CHCK_0, TEST_CHCK_1, TEST_CHCK_2, TEST_CHCK_3, 0x00 };
size_t completed = 0U;
FPRINTF(stderr, T("Self-test is running, please be patient... %2u/%2u "), (unsigned int)completed, (unsigned int)total);
FPRINTF(stderr, T("Self-test is in progress, please be patient... %2u/%2u "), (unsigned int)completed, (unsigned int)total);
fflush(stderr);
for (size_t i = 0U; i < 8U; ++i)

View File

@ -5,7 +5,7 @@
#include "test.h"
const uint64_t TEST_CHCK_0 = 0x18481930058B7F62;
const uint64_t TEST_CHCK_0 = 0x4B87A487157A0FBE;
const char* const TEST_DATA_0 =
"Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Nam liber tempor cum soluta nobis eleifend option congue nihil imperdiet doming id quod mazim placerat facer possim assum. Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit"
" lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, At accusam aliquyam diam diam dolore dolores duo eirmod eos erat, et nonumy sed tempor et et invidunt justo labore Stet clita ea et gubergren, kasd magna no rebum. sanctus sea sed takimata ut vero voluptua. est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat. Consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero e"
@ -40,7 +40,7 @@ const char* const TEST_DATA_0 =
" Nam liber tempor cum soluta nobis eleifend option congue nihil imperdiet doming id quod mazim placerat facer possim assum. Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, At accusam aliquyam diam diam dolore dolores duo eirmod eos erat, et nonumy sed tempor et et invidunt justo labore Stet clita ea et gubergren, kasd magna no rebum. sanctus sea sed takimata ut vero voluptua. est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat. Consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod temp"
"or invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Nam liber tempor cum soluta nobis eleifend option congue nihil imperdiet doming id quod mazim placerat facer possim assum.";
const uint64_t TEST_CHCK_1 = 0xD5363C7BF7FA84D6;
const uint64_t TEST_CHCK_1 = 0x040B4DF05BD883D0;
const char* const TEST_DATA_1 =
"agcttttcattctgactgcaacgggcaatatgtctctgtgtggattaaaaaaagagtgtctgatagcagcttctgaactggttacctgccgtgagtaaattaaaattttattgacttaggtcactaaatactttaaccaatataggcatagcgcacagacagataaaaattacagagtacacaacatccatgaaacgcattagcaccaccattaccaccaccatcaccattaccacaggtaacggtgcgggctgacgcgtacaggaaacacagaaaaaagcccgcacctgacagtgcgggctttttttttcgaccaaaggtaacgaggtaacaaccatgcgagtgttgaagttcggcggtacatcagtggcaaatgcagaacgttttctgcgtgttgccgatattctggaaagcaatgccaggcaggggcaggtggccaccgtcctctctgcccccgccaaaatcaccaaccacctggtggcgatgattgaaaaaaccattagcggccaggatgctttacccaatatcagcgatgccgaacgtatttttgccgaacttttgacgggactcgccgccgcccagccggggttcccgctggcgcaattgaaaactttcgtcgatcaggaatttgcccaaataaaacatgtcctgcatggcattagtttgttggggcagtgcccggatagcatcaacgctgcgctgatttgccgtggcgagaaaatgtcgatcgccattatggccggcgtattagaagcgcgcggtcacaacgttactgttatcgatccggtcgaaaaactgctggcagtggggcattacctcgaatctaccgtcgatattgctgagtccacccgccgtattgcggcaagccgcattccggctgatcacatggtgctgatggcaggtttcaccgccggtaatgaaaaaggcgaactggtggtgcttggacgcaacggttccgactactctgctgcggtgctggctgcctgtttacgcgccgattgttgcgagatttggacggacgttgacggggtctatacctgcgacccgcgtcaggtgcccgatgcgaggttgttgaagtcgatgtcctaccaggaagcgatggagctttcctacttcggcgctaaagttcttcacccccgcaccattacccccatcgcccagttccagatcccttgcctgattaaaaataccggaaatcctcaagcaccaggtacgctcattggtgccagccgtgatgaagacgaattaccggtcaagggcatttccaatctgaataacatggcaatgttcagcgtttctggtccggggatgaaagggatggtcggcatggcggcgcgcgtctttgcagcgatgtcacgcgcccgtatttccgtggtgctgattacgcaatcatcttccgaatacagcatcagtttctgcgttccacaaagcgactgtgtgcgagctgaacgggcaatgcaggaagagttctacctggaactgaaagaaggcttactggagccgctggcagtgacggaacggctggccattatctcggtggtaggtgatggtatgcgcaccttgcgtgggatctcggcgaaattctttgccgcactggcccgcgccaatatcaacattgtcgccattgctcagggatcttctgaacgctcaatctctgtcgtggtaaataacgatgatgcgaccactggcgtgcgcgttactcatcagatgctgttcaataccgatcaggttatcgaagtgtttgtgattggcgtcggtggcgttggcggtgcgctgctggagcaactgaagcgtcagcaaagctggctgaagaataaacatatcgacttacgtgtctgcggtgttgccaactcgaaggctctgctcaccaatgtacatggccttaatctggaaaactggcaggaagaactggcgcaagccaaagagccgtttaatctcgggcgcttaattcgcctcgtgaaagaatatcatctgctgaacccggtcattgttgactgcacttccagccaggcagtggcggatcaatatgccgacttcctgcgcgaagg"
"tttccacgttgtcacgccgaacaaaaaggccaacacctcgtcgatggattactaccatcagttgcgttatgcggcggaaaaatcgcggcgtaaattcctctatgacaccaacgttggggctggattaccggttattgagaacctgcaaaatctgctcaatgcaggtgatgaattgatgaagttctccggcattctttctggttcgctttcttatatcttcggcaagttagacgaaggcatgagtttctccgaggcgaccacgctggcgcgggaaatgggttataccgaaccggacccgcgagatgatctttctggtatggatgtggcgcgtaaactattgattctcgctcgtgaaacgggacgtgaactggagctggcggatattgaaattgaacctgtgctgcccgcagagtttaacgccgagggtgatgttgccgcttttatggcgaatctgtcacaactcgacgatctctttgccgcgcgcgtggcgaaggcccgtgatgaaggaaaagttttgcgctatgttggcaatattgatgaagatggcgtctgccgcgtgaagattgccgaagtggatggtaatgatccgctgttcaaagtgaaaaatggcgaaaacgccctggccttctatagccactattatcagccgctgccgttggtactgcgcggatatggtgcgggcaatgacgttacagctgccggtgtctttgctgatctgctacgtaccctctcatggaagttaggagtctgacatggttaaagtttatgccccggcttccagtgccaatatgagcgtcgggtttgatgtgctcggggcggcggtgacacctgttgatggtgcattgctcggagatgtagtcacggttgaggcggcagagacattcagtctcaacaacctcggacgctttgccgataagctgccgtcagaaccacgggaaaatatcgtttatcagtgctgggagcgtttttgccaggaactgggtaagcaaattccagtggcgatgaccctggaaaagaatatgccgatcggttcgggcttaggctccagtgcctgttcggtggtcgcggcgctgatggcgatgaatgaacactgcggcaagccgcttaatgacactcgtttgctggctttgatgggcgagctggaaggccgtatctccggcagcattcattacgacaacgtggcaccgtgttttctcggtggtatgcagttgatgatcgaagaaaacgacatcatcagccagcaagtgccagggtttgatgagtggctgtgggtgctggcgtatccggggattaaagtctcgacggcagaagccagggctattttaccggcgcagtatcgccgccaggattgcattgcgcacgggcgacatctggcaggcttcattcacgcctgctattcccgtcagcctgagcttgccgcgaagctgatgaaagatgttatcgctgaaccctaccgtgaacggttactgccaggcttccggcaggcgcggcaggcggtcgcggaaatcggcgcggtagcgagcggtatctccggctccggcccgaccttgttcgctctgtgtgacaagccggaaaccgcccagcgcgttgccgactggttgggtaagaactacctgcaaaatcaggaaggttttgttcatatttgccggctggatacggcgggcgcacgagtactggaaaactaaatgaaactctacaatctgaaagatcacaacgagcaggtcagctttgcgcaagccgtaacccaggggttgggcaaaaatcaggggctgttttttccgcacgacctgccggaattcagcctgactgaaattgatgagatgctgaagctggattttgtcacccgcagtgcgaagatcctctcggcgtttattggtgatgaaatcccacaggaaatcctggaagagcgcgtgcgcgcggcgtttgccttcccggctccggtcgccaatgttgaaagcgatgtcggttgtctggaattgttccacgggccaacgctggcatttaaagatttcggcggtcgctttatggcacaaatgctgacccatatt"
@ -75,7 +75,7 @@ const char* const TEST_DATA_1 =
"gatctgaatatcgtgcgcctggccgatacgatccagacgaccaatacgctgctccagtagatccgggttgaatggcaggtcaaacatcaccatgtggctggcgaactggaagttacgtccttcagaaccgatttctgagcacagcagtacctgtgcgccggtgtcttcttcggcaaaccaggcggcagcgcggtcacgttcgataatcgacataccttcgtggaacaccgcagcgcgaataccttcacgttcgcgcagtacctgctccagttgcagcgcagtggcagctttggcgcagatcaccagcactttctgagagcgatggctggtcaggtagcccatcagccactcaacgcgcggatcgaagttccaccaggtggcgttatcaccttcaaattcctgataaatacgctccgggtagagcatatcgcgagcacgatcttccgcacttttacgtgcgcccataatgccggagactttaatagccgtctgatactgcgtcggtagcggcagcttaatggtgtgcagctcgcgtttcgggaatcctttcacaccgttacgcgtgttacggaacagcacgcggctggtgccgtggcgatccatcagcatcgaaaccagctcctgacgggcgctctgggcatcttcgctgtcgctgtttgctgcctgcaacagcggctcgatatcctgctcgccgatcatctcgccgagcatgttcagttcgtcattgctcagtttgttacctgccagcagcatggcaacggcgtccgcaaccggacgataatttttctgctcttcaacgaactgcgcaaaatcgtggaaacggttcgggtccagcagacgcagacgggcgaagtggctttccatccccagctgttccggggtcgcggtcagcagcagaacgcccggcacgtgctctgccagttgttcaatggcctgatattcacggcttggcgcatcttcgctccacaccaggtgatgcgcttcatcgaccaccagcaggtcccattcggcttcacagagatgttccaggcgctgtttgctacgacgggcaaaatccagcgagcaaatcaccagctgttcggtgtcaaacgggttgtaagcatcgtgctgagcttcggcataacgctcatcatcaaatagcgcaaagcgcaggttgaaacggcgcagcatttctaccagccactgatgctgtaaggtttccgggacgataattagcacacgttcagcagcgccagagagcagttgctgatgcaggatcatcccggcttcaatggttttccctaaacccacttcgtcagccagcaggacgcgcggcgcgtggcggcgaccaacatcatgagcgatgttgagctgatgcgggatcaggctggtacgctgaccgcgcaggccgctgtacggcatacggaactgttcgctggaatatttacgcgcgcgataacgcagcgcaaagcggtccatacggtcaatctgcccggcaaacagacggtcctgcggtttgctgaacaccagtttgctatcaaggaaaacttcacgcagggctacgccggactcttcagtatccaggcgagtaccgatataggtcagcaagccattttcttcttttacttcttcgacttgcatctgccagccgtcatggctggtaatggtatcaccagggttgaacatcacgcgggtcacgggggaatcactgcgtgcgtacagacggttttcaccagtagatgggaaaagtaaagtgacagttcgcgcatccaccgcgacaacggttccaagtcccaattcgctttctgtatcgctgatccagcgttgaccaagtgtaaaaggcatatgtgttcggctctatatctttaattgcaggcaataaccacccgctaccgtgcttatgaggtagtggtgttattcaggtccaggaatggaaagggcgctatggtactggatggcaaagcattcgtcacgcatcaaaatggtatctggcgaactcttttttttgctcaaaatagcccaagttgcccggtcataagtgtagcaaaattatcctcaataaaagggag"
"tattccctccgccacgggttgtagctggcgggtcagatagtgttcgtaatccagtggtgaacgttggtagtccagcggctccgggccgttggtggtccatacgtacttaatggtgccgcgattctgatattgcaaggggcgaccacgcttttggttttcttcatcggcaaggcgagcggcgcgtacatgaggcggcacattacgctgatactcgctcagcggacggcgaaggcgtttacggtaaaccagtcgcgcatccagttcacccgccatcagtttgtcgatggtttcgcgtacatattcctgatatggctcgttgcggaagatgcgcaggtatagctcctgctgaaactgctgggccagcggcgtccagtcggtgcgcacggtttccagccctttaaacaccatccgctgcttgtcgccctcctgaatcagtccggcataacgctttttactgccggtatcggctccgcgaatggttggcatcagaaaacggcagaaatgggtttcatactccagttctaatgcgctggtcagccgttgtttttgcagcgtttccgcccaccaggcgttaacgtgctgcaccagtgcacgaccgattttcgccgcttcttcttccgaatgtgcgcctttcagccagacaaacgttgagtcggtatcgccgtagataacgtcgtagccctgtgcttcaatcaacgctttggtttgccgcatgatctgatgaccacgcatggtgatcgacgatgccagccgcggatcgaagaagcggcaggcggtggtgccgagcacgccataaaaggcattcatgatgattttcagcgcctgcgacagcggtttgttaccctggcgtttggcttcatcgcgcccgtgccagatgttagtcacaatctccggcaggcaatgtttttctcgcgagaaccaggcatcgagaaaaccttcggtactgtgctctggatcaggctgcgccatgccttccaccagcccgacgggatcaatcagaaaggtgcggatgatcgacgggtacaggcttttatagtccagcaccagcactgaatcataaagccctggccgtgaatccatcacgtagccgccagggctggcgtgcggcggcacttcgccgagattaggcgcgacataaccagcgcgatgcattcgcggaaaatagagatgaccaaatgccgccaccgaaccgccgtgtcggtccaccggcaggccgttcaccgttgcccgttcgagtaaaaatggcatgatttcagttttgtggaagatctgcgtcaccagctcgcaatctttcaggttataagttgccagcgcaggtttatcttcggcgaaacggcggtcaatttcgtccattcgatcccacgggttatcgatagattttccttcgcctaatagctcctgagcgacagtttccagcgagaatgaagagaaattccagaacgcggatttcagcgcctcgataccgtcgataattagccgacctttagcctgggcaaaaaagacgccgtttttaaagccgtgctcgcgccactccagctcgctattatcgcgcccaagacgcagcggaagacggtaacgctcggcatgtttttgcagcattcgcagatcgaactgcaccacgttccaaccgatgatcacatcaggatcgtagttggcaaaccaggcgttgagtttttccagcaactgcgggcggctggcgacgtattccagttcgaaatcaagcgaggaggcgtcgccattctccggccccagcatataaacgatgcgctgcccgcagccttccaggccgatgcagtacagctcaccgtggcgggtggtttcaatatctatagaaacccacttgagcggcggacgatagtcgggatgcggtttcagacgggcattaacgatagtgccattgtgcatatcaccctcgacccacaccggtgaggtgataaaccgctccatcagatagcgttctggcggacgcacatcggcctcgtagacggtaacgccaccttcacgcaggcgcttttcgtaattcatcaattggcgatgggcgcgaca";
const uint64_t TEST_CHCK_2 = 0x8461139AE7821844;
const uint64_t TEST_CHCK_2 = 0xBB6CB099F1E34F33;
const char* const TEST_DATA_2 =
"In the beginning God created the heaven and the earth. And the earth was without form, and void; and darkness was upon the face of the deep. And the Spirit of God moved upon the face of the waters. And God said, Let there be light: and there was light. And God saw the light, that it was good: and God divided the light from the darkness. And God called the light Day, and the darkness he called Night. And the evening and the morning were the first day. And God said, Let there be a firmament in the midst of the waters, and let it divide the waters from the waters. And God made the firmament, and divided the waters which were under the firmament from the waters which were above the firmament: and it was so. And God called the firmament Heaven. And the evening and the morning were the second day. And God said, Let the waters under the heaven be gathered together unto one place, and let the dry land appear: and it was so. And God called the dry land Earth; and the gathering together of the waters called he Seas: and God saw that it was good. And God said, Let the earth bring forth grass, the herb yielding seed, and the fruit tree yielding fruit after his kind, whose seed is in itself, upon the earth: and it was so. And the earth brought forth grass, and herb yielding seed after his kind, and the tree yielding fruit, whose seed was in itself, after his kind: and God saw that it was good. And the evening and the morning were the third day. And God said, Let there be lights in the firmament of the heaven to divide the day from the night; and let them be for signs, and for seasons, and for days, and years: And let them be for lights in the firmament of the heaven to give light upon the earth: and it was so. And God made two great lights; the greater light to rule the day, and the lesser light to rule the night: he made the stars also. And God set them in the firmament of the heaven to give light upon the earth, And to rule over the day and over the night, and to divide the light from the darkness: and God saw that it was g"
"ood. And the evening and the morning were the fourth day. And God said, Let the waters bring forth abundantly the moving creature that hath life, and fowl that may fly above the earth in the open firmament of heaven. And God created great whales, and every living creature that moveth, which the waters brought forth abundantly, after their kind, and every winged fowl after his kind: and God saw that it was good. And God blessed them, saying, Be fruitful, and multiply, and fill the waters in the seas, and let fowl multiply in the earth. And the evening and the morning were the fifth day. And God said, Let the earth bring forth the living creature after his kind, cattle, and creeping thing, and beast of the earth after his kind: and it was so. And God made the beast of the earth after his kind, and cattle after their kind, and every thing that creepeth upon the earth after his kind: and God saw that it was good. And God said, Let us make man in our image, after our likeness: and let them have dominion over the fish of the sea, and over the fowl of the air, and over the cattle, and over all the earth, and over every creeping thing that creepeth upon the earth. So God created man in his own image, in the image of God created he him; male and female created he them. And God blessed them, and God said unto them, Be fruitful, and multiply, and replenish the earth, and subdue it: and have dominion over the fish of the sea, and over the fowl of the air, and over every living thing that moveth upon the earth. And God said, Behold, I have given you every herb bearing seed, which is upon the face of all the earth, and every tree, in the which is the fruit of a tree yielding seed; to you it shall be for meat. And to every beast of the earth, and to every fowl of the air, and to every thing that creepeth upon the earth, wherein there is life, I have given every green herb for meat: and it was so. And God saw every thing that he had made, and, behold, it was very good. And the evening and the morning were the sixth day. Thus the"
@ -110,7 +110,7 @@ const char* const TEST_DATA_2 =
" and took Sarah. But God came to Abimelech in a dream by night, and said to him, Behold, thou art but a dead man, for the woman which thou hast taken; for she is a man's wife. But Abimelech had not come near her: and he said, LORD, wilt thou slay also a righteous nation? Said he not unto me, She is my sister? and she, even she herself said, He is my brother: in the integrity of my heart and innocency of my hands have I done this. And God said unto him in a dream, Yea, I know that thou didst this in the integrity of thy heart; for I also withheld thee from sinning against me: therefore suffered I thee not to touch her. Now therefore restore the man his wife; for he is a prophet, and he shall pray for thee, and thou shalt live: and if thou restore her not, know thou that thou shalt surely die, thou, and all that are thine. Therefore Abimelech rose early in the morning, and called all his servants, and told all these things in their ears: and the men were sore afraid. Then Abimelech called Abraham, and said unto him, What hast thou done unto us? and what have I offended thee, that thou hast brought on me and on my kingdom a great sin? thou hast done deeds unto me that ought not to be done. And Abimelech said unto Abraham, What sawest thou, that thou hast done this thing? And Abraham said, Because I thought, Surely the fear of God is not in this place; and they will slay me for my wife's sake. And yet indeed she is my sister; she is the daughter of my father, but not the daughter of my mother; and she became my wife. And it came to pass, when God caused me to wander from my father's house, that I said unto her, This is thy kindness which thou shalt shew unto me; at every place whither we shall come, say of me, He is my brother. And Abimelech took sheep, and oxen, and menservants, and womenservants, and gave them unto Abraham, and restored him Sarah his wife. And Abimelech said, Behold, my land is before thee: dwell where it pleaseth thee. And unto Sarah he said, Behold, I have given thy brother a thousand pieces of s"
"ilver: behold, he is to thee a covering of the eyes, unto all that are with thee, and with all other: thus she was reproved. So Abraham prayed unto God: and God healed Abimelech, and his wife, and his maidservants; and they bare children. For the LORD had fast closed up all the wombs of the house of Abimelech, because of Sarah Abraham's wife. And the LORD visited Sarah as he had said, and the LORD did unto Sarah as he had spoken. For Sarah conceived, and bare Abraham a son in his old age, at the set time of which God had spoken to him. And Abraham called the name of his son that was born unto him, whom Sarah bare to him, Isaac. And Abraham circumcised his son Isaac being eight days old, as God had commanded him. And Abraham was an hundred years old, when his son Isaac was born unto him. And Sarah said, God hath made me to laugh, so that all that hear will laugh with me. And she said, Who would have said unto Abraham, that Sarah should have given children suck? for I have born him a son in his old age. And the child grew, and was weaned: and Abraham made a great feast the same day that Isaac was weaned. And Sarah saw the son of Hagar the Egyptian, which she had born unto Abraham, mocking. Wherefore she said unto Abraham, Cast out this bondwoman and her son: for the son of this bondwoman shall not be heir with my son, even with Isaac. And the thing was very grievous in Abraham's sight because of his son. And God said unto Abraham, Let it not be grievous in thy sight because of the lad, and because of thy bondwoman; in all that Sarah hath said unto thee, hearken unto her voice; for in Isaac shall thy seed be called. And also of the son of the bondwoman will I make a nation, because he is thy seed. And Abraham rose up early in the morning, and took bread, and a bottle of water, and gave it unto Hagar, putting it on her shoulder, and the child, and sent her away: and she departed, and wandered in the wilderness of Beersheba. And the water was spent in the bottle, and she cast the child under one of the shrubs.";
const uint64_t TEST_CHCK_3 = 0xDEF4D03B3945E819;
const uint64_t TEST_CHCK_3 = 0x2B747414387338B4;
const char* const TEST_DATA_3 =
"by_@zmIJR0|T:gJmj|xEENNK|J\"~Dv$x-m\\@D@#Ru'OjY$jgh1$>q.:'G!f` ,\"V<d%W&dA(%P)nO 88Qd/bzk4Mdf?^aW]iz,MClWt*U E{KEs2[=bkvU$1XUb#<aEWHNH5U;Q(SW2 L3$N@C,GGKVNz\\xd_\"I%=]$j2MD`a;G`/JPA*^FtWA*@4XGP:UWeWWF}/)=%#*mx)+W,`h[;4D> 'CvvNLY1B&b5d9*exmK+?wXt:EA_#4G0^xJ#P} /5R2<)f:C~O\\O*W}{G+FsnmkxcL\\v0c0(Ef?lwW-@a#S-!k9I<#PLQd[wWp:[L]fxzr:DLaE/!T^1@wm~d{196#&2gELp,W,K%?D\"@~q4'\\\"-&hJ#DZ-/=:FtdA|!0z&>!#9AK%s+pS&nI)P6t*)Ly^bKE{~y5vE!_&~[E_/jJrlDc[um=?Iqr+y?3]IWAyUq\"Rz]dm0wv=2?.|;h;fuWEJ`_j4 v<L?]>f7?&uY23PPK?8%CfH`^YqQ\"lk`=+z'x ]/e8\\_wo7!D@!#,w,4]4eDa_%_,t*1RPy4nxM{@{[XOQpL,h>Ozdj4!!w)G5DOf#[A,1_r@\".~%@0.JIL/1\\eXipd/Em}Wl'2Qwa/rX53(e9GDsD<:;K6g#;gkINu!Bi)VxB}A9H[4vVcE'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