Skip to content

AES Code failure when optimized for X86_64

Summary

Attached code is an AES routine that creates an expanded key. It runs fine on macOS arm64. On Linux or macOS x86_64 it also runs fine when compiled with -O0 to -O1. When compiled for macOS/Linux x86_64 -O2 or higher the calculated expanded key is incorrect.

System Information

  • Operating system: macOS, Linux
  • Processor architecture: x86_64
  • Compiler version: trunk
  • Device:
  • Computer

Steps to reproduce

Compile and run attached code. When compiled with -O2 or greater the generated extended key is incorrect.

Example Project

AESOptTest.pas

What is the current bug behavior?

When compiled with -O2 or higher on x86_64 macOS/Linux it will print message "Bad Key" indicating that the calculated key does not match the expected result.

What is the expected (correct) behavior?

Should print out "Good Key" which means the calculated key matches the expected result.

Relevant logs and/or screenshots

Possible fixes

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information