I'm trying to use openssl
to encrypt plain text into AES 128 ECB
in HEX
.
Using plain text 11111111111111111111111111111111
and raw key 00000000000000000000000000000000
I'm trying to use:
echo -n "11111111111111111111111111111111" | openssl enc -aes-128-ecb -K 00000000000000000000000000000000 -nosalt | xxd -p
But this gives me:
b6de54f9a78637d1eb523ca7201589f4b6de54f9a78637d1eb523ca72015
89f40143db63ee66b0cdff9f69917680151e
And I'm supposed to get:
FFA3C7ED04710B98067DAE6815E2751F
What am I doing wrong?
You forget to hex decode your plaintext. Furthermore, OpenSSL defaults to PKCS#7 padding, so you should disregard the last block of 16 bytes / 32 hex chars if you need a 16 byte output for a 16 byte input.