cancel
Showing results for 
Search instead for 
Did you mean: 

What is the purpose of data swapping in the Cryptographic Processor?

qua
Senior

The reference manual mentions that data swapping can be used when e.g. processing ASCII, but I'm not clear on exactly what it does. If I set it to byte mode, does that mean I can write single byte values padded to 32 bits with zeros into the FIFO? And with the bit mode, can I write single bits padded to 32 with zeros? What if I don't pad with zeros and just write 31 random bits plus the 1 bit I care about?

Obviously I can gather the bits together into a 32 bit word and write it in one go, but that will involve the CPU. If I can write bits, or even just bytes, with DMA, it will improve performance considerably.

1 ACCEPTED SOLUTION

Accepted Solutions
STackPointer64
ST Employee

Hello @qua,

Data swapping is essential for managing endianness and ensuring that the memory data format aligns with the cryptographic hardware's requirements. This alignment is critical for correct encryption, decryption, and tag generation. In byte mode, it rearranges the order of bytes to ensure proper alignment, particularly in AES operations where the hardware processes 32-bit words. Proper padding and alignment are critical to avoid errors and maintain data integrity during cryptographic operations.

Best regards,

To improve visibility of answered topics, please click 'Accept as Solution' on the reply that resolved your issue or answered your question.

View solution in original post

5 REPLIES 5
STackPointer64
ST Employee

Hello @qua,

Data swapping is essential for managing endianness and ensuring that the memory data format aligns with the cryptographic hardware's requirements. This alignment is critical for correct encryption, decryption, and tag generation. In byte mode, it rearranges the order of bytes to ensure proper alignment, particularly in AES operations where the hardware processes 32-bit words. Proper padding and alignment are critical to avoid errors and maintain data integrity during cryptographic operations.

Best regards,

To improve visibility of answered topics, please click 'Accept as Solution' on the reply that resolved your issue or answered your question.

Thanks, but if it's endianess what is the bit level swapping and zero padding for?

STackPointer64
ST Employee
  • Bit-level swapping focuses on rearranging individual bits within a byte, primarily for hardware design flexibility and routing optimization.
  • Zero padding is used to handle data lengths that are not multiples of the required block size, ensuring proper encryption or decryption.
To improve visibility of answered topics, please click 'Accept as Solution' on the reply that resolved your issue or answered your question.
qua
Senior

So basically

- Bit level swapping is if you reversed the bit order on a parallel bus to make routing easier.

- Zero padding is so you don't have to manually zero the bits, e.g. if you want to DMA data directly into the FIFO.

Is that a reasonable summary?

STackPointer64
ST Employee

Yes it is.

To improve visibility of answered topics, please click 'Accept as Solution' on the reply that resolved your issue or answered your question.