From 3887aa69a6f69bd290fa6ec4932b18b81763dce7 Mon Sep 17 00:00:00 2001 From: belliash Date: Wed, 5 Sep 2018 21:46:25 +0200 Subject: [PATCH] Never disable hash functions. --- engine/builtin.c | 4 ---- engine/vfs.c | 4 ---- engine/vm.c | 4 ---- include/ph7.h | 3 --- include/ph7int.h | 22 +++++++++------------- 5 files changed, 9 insertions(+), 28 deletions(-) diff --git a/engine/builtin.c b/engine/builtin.c index 3533dcc..384f904 100644 --- a/engine/builtin.c +++ b/engine/builtin.c @@ -4076,7 +4076,6 @@ static int PH7_builtin_size_format(ph7_context *pCtx, int nArg, ph7_value **apAr ph7_result_string_format(pCtx, "%d.%d %cB", i_32, nRest, zUnit[c]); return PH7_OK; } -#if !defined(PH7_DISABLE_HASH_FUNC) /* * string md5(string $str[,bool $raw_output = false]) * Calculate the md5 hash of a string. @@ -4194,7 +4193,6 @@ static int PH7_builtin_crc32(ph7_context *pCtx, int nArg, ph7_value **apArg) { ph7_result_int64(pCtx, (ph7_int64)nCRC ^ 0xFFFFFFFF); return PH7_OK; } -#endif /* PH7_DISABLE_HASH_FUNC */ /* * Parse a CSV string and invoke the supplied callback for each processed xhunk. */ @@ -7553,11 +7551,9 @@ static const ph7_builtin_func aBuiltInFunc[] = { { "vprintf", PH7_builtin_vprintf }, { "vsprintf", PH7_builtin_vsprintf }, { "size_format", PH7_builtin_size_format}, -#if !defined(PH7_DISABLE_HASH_FUNC) { "md5", PH7_builtin_md5 }, { "sha1", PH7_builtin_sha1 }, { "crc32", PH7_builtin_crc32 }, -#endif /* PH7_DISABLE_HASH_FUNC */ { "str_getcsv", PH7_builtin_str_getcsv }, { "strip_tags", PH7_builtin_strip_tags }, { "str_shuffle", PH7_builtin_str_shuffle}, diff --git a/engine/vfs.c b/engine/vfs.c index cfe2609..5005d87 100644 --- a/engine/vfs.c +++ b/engine/vfs.c @@ -4930,7 +4930,6 @@ static int PH7_builtin_fclose(ph7_context *pCtx, int nArg, ph7_value **apArg) { ph7_result_bool(pCtx, 1); return PH7_OK; } -#if !defined(PH7_DISABLE_HASH_FUNC) /* * MD5/SHA1 digest consumer. */ @@ -5079,7 +5078,6 @@ static int PH7_builtin_sha1_file(ph7_context *pCtx, int nArg, ph7_value **apArg) } return PH7_OK; } -#endif /* PH7_DISABLE_HASH_FUNC */ /* * array parse_ini_file(string $filename[, bool $process_sections = false [, int $scanner_mode = INI_SCANNER_NORMAL ]] ) * Parse a configuration file. @@ -8137,10 +8135,8 @@ PH7_PRIVATE sxi32 PH7_RegisterIORoutine(ph7_vm *pVm) { {"fpassthru", PH7_builtin_fpassthru }, {"fputcsv", PH7_builtin_fputcsv }, {"fprintf", PH7_builtin_fprintf }, -#if !defined(PH7_DISABLE_HASH_FUNC) {"md5_file", PH7_builtin_md5_file}, {"sha1_file", PH7_builtin_sha1_file}, -#endif /* PH7_DISABLE_HASH_FUNC */ {"parse_ini_file", PH7_builtin_parse_ini_file}, {"vfprintf", PH7_builtin_vfprintf} }; diff --git a/engine/vm.c b/engine/vm.c index f9a509a..f9a50bc 100644 --- a/engine/vm.c +++ b/engine/vm.c @@ -8131,7 +8131,6 @@ static int vm_builtin_random_bytes(ph7_context *pCtx, int nArg, ph7_value **apAr ph7_result_string(pCtx, (char *)zBuf, iLen); return SXRET_OK; } -#if !defined(PH7_DISABLE_HASH_FUNC) /* Unique ID private data */ struct unique_id_data { ph7_context *pCtx; /* Call context */ @@ -8217,7 +8216,6 @@ static int vm_builtin_uniqid(ph7_context *pCtx, int nArg, ph7_value **apArg) { /* All done */ return PH7_OK; } -#endif /* PH7_DISABLE_HASH_FUNC */ /* * Section: * Language construct implementation as foreign functions. @@ -10899,9 +10897,7 @@ static const ph7_builtin_func aVmFunc[] = { { "getrandmax", vm_builtin_getrandmax }, { "random_int", vm_builtin_random_int }, { "random_bytes", vm_builtin_random_bytes }, -#if !defined(PH7_DISABLE_HASH_FUNC) { "uniqid", vm_builtin_uniqid }, -#endif /* PH7_DISABLE_HASH_FUNC */ /* Language constructs functions */ { "print", vm_builtin_print }, { "exit", vm_builtin_exit }, diff --git a/include/ph7.h b/include/ph7.h index fd92069..96e5da3 100644 --- a/include/ph7.h +++ b/include/ph7.h @@ -132,9 +132,6 @@ typedef struct ph7 ph7; * PH7_DISABLE_DISK_IO * If this directive is enabled, built-in Virtual File System functions such as * chdir(), mkdir(), chroot(), unlink(), delete(), etc. are omitted from the build. - * PH7_DISABLE_HASH_IO - * If this directive is enabled, built-in hash functions such as md5(), sha1(), - * md5_file(), crc32(), etc. are omitted from the build. * PH7_OMIT_FLOATING_POINT * This option is used to omit floating-point number support from the PH7 library * if compiling for a processor that lacks floating point support. When specified diff --git a/include/ph7int.h b/include/ph7int.h index c07410c..2e50b43 100644 --- a/include/ph7int.h +++ b/include/ph7int.h @@ -596,7 +596,6 @@ struct SyArchiveEntry { * Extra flags for extending the file local header */ #define SXZIP_EXTRA_TIMESTAMP 0x001 /* Extended UNIX timestamp */ -#ifndef PH7_DISABLE_HASH_FUNC /* MD5 context */ typedef struct MD5Context MD5Context; struct MD5Context { @@ -611,7 +610,6 @@ struct SHA1Context { unsigned int count[2]; unsigned char buffer[64]; }; -#endif /* PH7_DISABLE_HASH_FUNC */ /* PH7 private declaration */ /* * Memory Objects. @@ -1800,17 +1798,15 @@ PH7_PRIVATE sxi32 SyArchiveResetLoopCursor(SyArchive *pArch); PH7_PRIVATE sxi32 SyArchiveGetNextEntry(SyArchive *pArch, SyArchiveEntry **ppEntry); PH7_PRIVATE sxi32 SyZipExtractFromBuf(SyArchive *pArch, const char *zBuf, sxu32 nLen); PH7_PRIVATE sxi32 SyBinToHexConsumer(const void *pIn, sxu32 nLen, ProcConsumer xConsumer, void *pConsumerData); -#ifndef PH7_DISABLE_HASH_FUNC - PH7_PRIVATE sxu32 SyCrc32(const void *pSrc, sxu32 nLen); - PH7_PRIVATE void MD5Update(MD5Context *ctx, const unsigned char *buf, unsigned int len); - PH7_PRIVATE void MD5Final(unsigned char digest[16], MD5Context *ctx); - PH7_PRIVATE sxi32 MD5Init(MD5Context *pCtx); - PH7_PRIVATE sxi32 SyMD5Compute(const void *pIn, sxu32 nLen, unsigned char zDigest[16]); - PH7_PRIVATE void SHA1Init(SHA1Context *context); - PH7_PRIVATE void SHA1Update(SHA1Context *context, const unsigned char *data, unsigned int len); - PH7_PRIVATE void SHA1Final(SHA1Context *context, unsigned char digest[20]); - PH7_PRIVATE sxi32 SySha1Compute(const void *pIn, sxu32 nLen, unsigned char zDigest[20]); -#endif +PH7_PRIVATE sxu32 SyCrc32(const void *pSrc, sxu32 nLen); +PH7_PRIVATE void MD5Update(MD5Context *ctx, const unsigned char *buf, unsigned int len); +PH7_PRIVATE void MD5Final(unsigned char digest[16], MD5Context *ctx); +PH7_PRIVATE sxi32 MD5Init(MD5Context *pCtx); +PH7_PRIVATE sxi32 SyMD5Compute(const void *pIn, sxu32 nLen, unsigned char zDigest[16]); +PH7_PRIVATE void SHA1Init(SHA1Context *context); +PH7_PRIVATE void SHA1Update(SHA1Context *context, const unsigned char *data, unsigned int len); +PH7_PRIVATE void SHA1Final(SHA1Context *context, unsigned char digest[20]); +PH7_PRIVATE sxi32 SySha1Compute(const void *pIn, sxu32 nLen, unsigned char zDigest[20]); PH7_PRIVATE sxi32 SyRandomness(SyPRNGCtx *pCtx, void *pBuf, sxu32 nLen); PH7_PRIVATE sxi32 SyRandomnessInit(SyPRNGCtx *pCtx, ProcRandomSeed xSeed, void *pUserData); PH7_PRIVATE sxu32 SyBufferFormat(char *zBuf, sxu32 nLen, const char *zFormat, ...);