Problem when hashing
Madelman
madelman at iname.com
Thu Feb 24 13:41:00 CET 2005
Hi,
i have one problem trying to hash some data. This is the code:
unsigned char hash[20];
gcry_md_hash_buffer(GCRY_MD_SHA1, hash, sessionKey, 16);
gcry_mpi_scan(&mpiHash, GCRYMPI_FMT_USG, hash, 20, NULL);
gcry_sexp_build(&data, &erroff, "(data (flags pkcs1) (hash sha1 %m))", mpiHash);
err = gcry_pk_sign(&signedKey, data, privateKey);
if (err) printf("%s", gcry_strerror(err));
The error it gives to me is Conflicting use.
I've debugging it and the cause of this is the hash in the S-Expression has a length of
21 instead of 20, here is a print of it:
(data
(flags pkcs1)
(hash sha1 #00EAE3734D9EA7394FCBEE92ADB05994B5083827FC#)
)
So, I suppose it is caused by the leading zero byte in the hash, but where does
this byte come from? How can I solve this problem?
Thanks.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 1822 bytes
Desc: S/MIME Cryptographic Signature
Url : /pipermail/attachments/20050224/7f9ccb72/smime.bin
More information about the Gcrypt-devel
mailing list