Search code examples
encryptionaes

How I can encrypt data with 32 bits length using AES algorithm?


I have a version of AES algorithm with 128bits in plaintext, now i want to change this version to 32bits in plaintext . How can i do this, please ?


That's part of my code when i send data to core AES, i send 128bits to encrypt and i check if the result is true.

apb_write(x"e2bec16b",AES_CMD_ADDR_DATAIN_0); apb_write(x"969f402e",AES_CMD_ADDR_DATAIN_1); apb_write(x"117e3de9",AES_CMD_ADDR_DATAIN_2); apb_write(x"2a179373",AES_CMD_ADDR_DATAIN_3);

apb_write(x"80000005",AES_CMD_ADDR_CONTROL); --confige AES with mode (CBC)

apb_write(x"acab4976",AES_CMD_ADDR_DATAOUT_0); apb_write(x"46b21981",AES_CMD_ADDR_DATAOUT_1); apb_write(x"9b8ee9ce",AES_CMD_ADDR_DATAOUT_2); apb_write(x"7d19e912",AES_CMD_ADDR_DATAOUT_3);

The question : how i can send just 32bits and check , after, send 32bits and check ....? how i can do this ?


Solution

  • AES is as far as I know only defined for blocks of 128 bits. If you want to encrypt blocks of 32 bits, you'd need to pad your plain text (with for example 0's) until you reach 128 bits. Then, if you want to decrypt it, just decrypt it normally and after the decryption chop off the last (or first, depending which side you padded) 96 (128 - 32) bits.