help-gnutls
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: value is always different


From: Simon Josefsson
Subject: Re: value is always different
Date: Wed, 28 Apr 2010 14:27:53 +0200
User-agent: Gnus/5.110011 (No Gnus v0.11) Emacs/23.1 (gnu/linux)

You also need to initialize libgcrypt properly before calling its
functions.

/Simon

Ali Khalfan <address@hidden> writes:

> The full code is just a few lines more I'll just post it all...., seems
> some sort of randomization is being added.......thanks for your help
>
>
>
> #include <stdio.h>
>
> #include <gcrypt.h>
>
>
> int main()
> {
>     int err;
>     gcry_md_hd_t ctx;
>
>     char key[32] ="The fish is under the water";
>
>     char plain_text[256];
>
>    
>
>     strcpy(plain_text,"It was the best of times it was the worst of
> times it was the happiest ");
>
>     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);
>    
>
>     int index = 0;
>      for (index; index<32; index++)
>         printf("%02X", (unsigned char)digest[index]);
>    
>     gcry_md_close (ctx);
>
>
>     return 0;
> }
>
> -------- Original Message  --------
> Subject: Re: value is always different
> From: Brad Hards <address@hidden>
> To: address@hidden
> Date: Mon Apr 26 2010 04:38:09 GMT-0400 (EDT)
>> On Monday 26 April 2010 05:17:22 pm Ali Khalfan wrote:
>>   
>>>     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);
>>>     
>> This looks roughly right. Can you post a minimal compilable example that 
>> shows 
>> what the rest of the code looks like?
>>
>> Brad
>>
>>
>> _______________________________________________
>> Help-gnutls mailing list
>> address@hidden
>> http://lists.gnu.org/mailman/listinfo/help-gnutls
>>   




reply via email to

[Prev in Thread] Current Thread [Next in Thread]