Not able to decryp ecb

Hey!

I tried to decrypt ecb with no luck, i’m using mbed TLS.

  1. I encrypt a text only using text with 16 0’s.
    image

I then get: [0xae, 0x51, 0xb8, 0xba, 0x54, 0xdb, 0xd8, 0x21, 0x40, 0x81, 0x0c, 0xfe, 0x9e, 0x1c, 0x1b, 0xf4] as my textout.

  1. I tried to to take this in once again to decrypt the text and get my original 16 0’s bytearray, but when I do this I get:
    image

How can his be? The textout is not 16 0’s…

I changed the ecb mode from encrypt to decrypt before decrypting it.

Thanks in regards!

1 Like

Have you set the decryption key properly: https://tls.mbed.org/api/aes_8h.html#a11580b789634605dd57e425eadb56617?

I think you’ll need to use that function with the last round key, but if that doesn’t work, try the first round key.

Alex

No I did not! But it worked!

maybe a stupid question, but why do one need a decryption key and encryption key. I believed one only needed one key. (the same for encryption and decryption). So why do mbed need two functions for setting the key.

Thanks for the help :slight_smile:

1 Like

AES doesn’t use the same key in each round. Instead, the key from the previous round is put through a transformation before being used in the current round. The decryption key is simply the key used in the last encryption round. During decryption, the decryption key is run through the inverse of the key schedule so that you get your original key back out during the final decryption round.

Alex