1
0
mirror of https://github.com/hashcat/hashcat.git synced 2025-01-22 13:40:56 +00:00

Use fastest SHA-256 implementation supported by CPU

This commit is contained in:
Jukka Ojanen 2021-08-26 13:01:25 +03:00
parent 639068548e
commit 47bb7620ee

View File

@ -157,6 +157,7 @@ bool hc_fopen (HCFILE *fp, const char *path, const char *mode)
if (xz_initialized == false) if (xz_initialized == false)
{ {
CrcGenerateTable (); CrcGenerateTable ();
Sha256Prepare ();
xz_initialized = true; xz_initialized = true;
} }
@ -399,7 +400,7 @@ size_t hc_fread (void *ptr, size_t size, size_t nmemb, HCFILE *fp)
SizeT outLeft = outLen - outPos; SizeT outLeft = outLen - outPos;
res = XzUnpacker_Code (&xfp->state, outBuf + outPos, &outLeft, xfp->inBuf + xfp->inPos, &inLeft, inLeft == 0, CODER_FINISH_ANY, &status); res = XzUnpacker_Code (&xfp->state, outBuf + outPos, &outLeft, xfp->inBuf + xfp->inPos, &inLeft, inLeft == 0, CODER_FINISH_ANY, &status);
xfp->inPos += inLeft; xfp->inPos += inLeft;
xfp->inProcessed += inLeft; xfp->inProcessed += inLeft;
if (res != SZ_OK) return -1; if (res != SZ_OK) return -1;
if (inLeft == 0 && outLeft == 0) break; if (inLeft == 0 && outLeft == 0) break;
outPos += outLeft; outPos += outLeft;
@ -659,7 +660,7 @@ int hc_fgetc (HCFILE *fp)
res = XzUnpacker_Code (&xfp->state, &out, &outLeft, xfp->inBuf + xfp->inPos, &inLeft, inLeft == 0, CODER_FINISH_ANY, &status); res = XzUnpacker_Code (&xfp->state, &out, &outLeft, xfp->inBuf + xfp->inPos, &inLeft, inLeft == 0, CODER_FINISH_ANY, &status);
if (inLeft == 0 && outLeft == 0) return r; if (inLeft == 0 && outLeft == 0) return r;
xfp->inPos += inLeft; xfp->inPos += inLeft;
xfp->inProcessed += inLeft; xfp->inProcessed += inLeft;
if (res != SZ_OK) return r; if (res != SZ_OK) return r;
xfp->outProcessed++; xfp->outProcessed++;
r = (int) out; r = (int) out;
@ -672,7 +673,7 @@ char *hc_fgets (char *buf, int len, HCFILE *fp)
{ {
char *r = NULL; char *r = NULL;
if (fp == NULL || len <= 0) return r; if (fp == NULL || buf == NULL || len <= 0) return r;
if (fp->pfp) if (fp->pfp)
{ {
@ -711,7 +712,7 @@ char *hc_fgets (char *buf, int len, HCFILE *fp)
res = XzUnpacker_Code (&xfp->state, outBuf, &outLeft, xfp->inBuf + xfp->inPos, &inLeft, inLeft == 0, CODER_FINISH_ANY, &status); res = XzUnpacker_Code (&xfp->state, outBuf, &outLeft, xfp->inBuf + xfp->inPos, &inLeft, inLeft == 0, CODER_FINISH_ANY, &status);
if (inLeft == 0 && outLeft == 0) break; if (inLeft == 0 && outLeft == 0) break;
xfp->inPos += inLeft; xfp->inPos += inLeft;
xfp->inProcessed += inLeft; xfp->inProcessed += inLeft;
if (res != SZ_OK) break; if (res != SZ_OK) break;
xfp->outProcessed++; xfp->outProcessed++;
if (*outBuf++ == '\n') if (*outBuf++ == '\n')