SHA256 How to get digest value in `unsigned char` format?
#1
Information 
Hi,

First of all: thank you very much for open sourcing OpenCL hashcat!

For a custom application based on sha256, I must get the digest value in `unsigned char` format.
It's OK with CPU implementation with deps\LZMA-SDK\CSha256.c

Code:
void Sha256_Final(CSha256 *p, Byte *digest)
{
.....
  for (i = 0; i < 8; i += 2)
  {
    UInt32 v0 = p->state[i];
    UInt32 v1 = p->state[i + 1];
    SetBe32(digest    , v0);
    SetBe32(digest + 4, v1);
    digest += 8;
  }
}


How to do with OpenCL implementation? (OpenCL\inc_hash_sha1.cl)


Code:
__kernel void ocl_sha256(__global input_t *input, const unsigned int gid_max)
{
    unsigned int lid = get_local_id(0);
    unsigned int gid = get_global_id(0);

    if (gid >= gid_max) return;

    // TODO
    unsigned int test[64] = { 0 };

    sha1_ctx_t ctx0;
    sha1_init(&ctx0);
    sha1_update(&ctx0, test, 64);
    sha1_final(&ctx0);

/*

unsigned int digest32[4] = { ctx0.h[0], ctx0.h[1], ctx0.h[2], ctx0.h[3] }

unsigned char digest8[16] = ????

*/

}


Thanks,
Reply


Messages In This Thread
SHA256 How to get digest value in `unsigned char` format? - by LeMoussel - 03-30-2019, 09:29 AM