Hello,

> i want to encrypt and decrypt strings, now i'm using the ecb
encryption
> of openssl/aes.h
> and it looks the encrypted block length depends on the key, or the
> encrypted msg has an \0 in.
In AES encryption/decryption block size is always 16 bytes and not
depends on key size.
Key size for AES256 is 32 bytes, for AES192 24 bytes and for AES128 16 bytes.
If you want to use AES in ecb mode You can use  AES_ecb_encrypt()
(witch simply use AES_encrypt()/AES_decrypt()).
First parameter of this function (in) have to be pointer to 16 bytes of
data to decrypt/encrypt, second parameter is pointer to encrypted/decrypted
result of 16 bytes length.

> i have to know the length of the block to base64 encode it.
Always 16 bytes.

> So if i encrypt my "utopia" test string
You encrypt "utopia" + 10 random bytes at end of buffer - if You use 
AES_ecb_encrypt().
For proper encryption you should use padding in this situation.

> with unsigned char
> key[32]="bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb";
> strlen(encryptedmsg) returns 11 while if i use 32byte of "a" unsigned
> char strlen(encryptedmsg); returns 16.
You can not check length of encrypted data with strlen().
For AES block size is 16 bytes.

> Does really depends the blocksize on password,
No, not depends,

> or strlen is not a good way to know the blocksize?
Is not good way for this.

Of course all this is true if you use AES_ecb_encrypt().
It is only my guess.

Best regards,
-- 
Marek Marcola <[EMAIL PROTECTED]>

______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    [email protected]
Automated List Manager                           [EMAIL PROTECTED]

Reply via email to