Encrypting with ECB

Madelman madelman at iname.com
Fri Feb 25 12:11:39 CET 2005


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.



-------------- 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/20050225/f17cd98a/smime.bin


More information about the Gcrypt-devel mailing list