value is always different

Ali Khalfan ali.khalfan at
Mon Apr 26 09:17:22 CEST 2010


I've been trying to use gcrypt to calculate a MAC using sha256.

It surprises me however, that everytime I run the script a different
value comes int even though I'm using the same key and plain text.

Is there somethigng i'm missing here?

    err = gcry_md_open(&ctx,GCRY_MD_SHA256, GCRY_MD_FLAG_HMAC);

    gcry_md_setkey (ctx, key, 32);

    gcry_md_write(ctx, &plain_text,sizeof plain_text);
    unsigned char *digest = gcry_md_read (ctx, GCRY_MD_SHA256);

More information about the Gnutls-help mailing list