How does cross-platform AES encryption work?

I managed to successfully encrypt and decrypt AES-256 in both php and objective-c code. I will not post the code here since I have tried many varieties and no one works. I have no idea how these encryption functions work ... AES is a standardized algorithm, so why it doesn't work in my thinking before

a) iv b) some coding error
or
c) differences in padding (should not matter for decryption).

If someone has AES functions that work on both php and objective-c, that would be great, but if not, any help in understanding what causes these different results would be appreciated.

If you need a narrower question, we are talking about the encodings, iv and block size of this AES cipher.

1) Does it matter what encoding is used in terms of key and plaintext / ciphertext? Basically, I assume this is not a plain text problem, since all the characters that I will use (at least during testing) are standard ASCII characters. But let's say that php strings are ASCII, and I use UTF8 in objective-c ... I don’t know enough to tell if php uses ASCII or bytes, i.e. The key will be different between them.

2) As far as I know, ECB mode does not use iv (correct if wrong). CBC mode uses iv. In this case, iv must be recorded along with ciphertext. Now this key has a length of 16 or 32 characters in php (depending on block size 128 versus 256). Does this mean 16 or 32 bytes? And will the string 1234567890123456789012 be the same in ASCII and UTF8 when converted to bytes?

3) What is the difference between the block size and the key size from the point of view of the alogram? (again right, if wrong) In principle, is this the same algorithm as the different parameters? And using a 256-bit key and a 128-bit key is just a matter of which key is passed

(Also note that I used base64 encoding to pass strings between applications for testing)

Thanks, Elijah

+5
2

, . , IV, . , . . . AES , , .

, , . , . , . , , . , , . , .

:

1) , : UTF-8 , UTF-8. , .

2) , IV, . CBC CTR, . IV , AES IV 16 128 . , ASCII UTF-8 . UTF . ASCII C. , . . CBC IV , OK.

3) 128 AES . 128, 192 256 . 128 256 . , . , . . , , , " ". " ". , . , , .

+6

, IV, AES . AES - 8- .

, IV .

, . UTF-8.

, UTF-8 , , , base64 , , base64- , UTF-8.

, IV, . - , UTF-8 ASCII, UTF-16BE .. , , , , , .

0

All Articles