Hi,
>That is to mark the number as positive. What you should do is to use
>
> unsigned char md[20];
>
> ...
> rc = gcry_sexp_build (&hash, NULL,
> "(data (flags pkcs1) (hash sha1 %b))",
> (size_t)20, md);
>
>That's far easier, isn't it? Make sure that the first argument of %b
>has the type size_t, the second one is a pointer of course.
Yeah, much better, thanks :)
I have another question. I'm trying to encrypt a single block of data
with the following code:
gcry_cipher_open(&hd, GCRY_CIPHER_AES, GCRY_CIPHER_MODE_ECB, 0);
gcry_cipher_setkey(hd, sessionKey, 16);
gcry_cipher_encrypt(hd, cipherText, length, plainText, length);
but i can't get a correct result, if i try to print the cipherText the result is
(data BBBBBBBBBB)
but if i try with a different mode like opening the handle with
gcry_cipher_open(&hd, GCRY_CIPHER_AES, GCRY_CIPHER_MODE_CTR, 0);
and setting the initial counter it works correctly and i can decipher the text.
If I understood it correctly in ECB mode I don't need to set the IV, but even if
I try setting it the result is the same.
Do you know what I'm doing wrong?
Thanks.
>That is to mark the number as positive. What you should do is to use
>
> unsigned char md[20];
>
> ...
> rc = gcry_sexp_build (&hash, NULL,
> "(data (flags pkcs1) (hash sha1 %b))",
> (size_t)20, md);
>
>That's far easier, isn't it? Make sure that the first argument of %b
>has the type size_t, the second one is a pointer of course.
Yeah, much better, thanks :)
I have another question. I'm trying to encrypt a single block of data
with the following code:
gcry_cipher_open(&hd, GCRY_CIPHER_AES, GCRY_CIPHER_MODE_ECB, 0);
gcry_cipher_setkey(hd, sessionKey, 16);
gcry_cipher_encrypt(hd, cipherText, length, plainText, length);
but i can't get a correct result, if i try to print the cipherText the result is
(data BBBBBBBBBB)
but if i try with a different mode like opening the handle with
gcry_cipher_open(&hd, GCRY_CIPHER_AES, GCRY_CIPHER_MODE_CTR, 0);
and setting the initial counter it works correctly and i can decipher the text.
If I understood it correctly in ECB mode I don't need to set the IV, but even if
I try setting it the result is the same.
Do you know what I'm doing wrong?
Thanks.