synopse / mORMot2

OpenSource RESTful ORM/SOA/MVC Framework for Delphi and FreePascal
https://synopse.info
Other
485 stars 122 forks source link

AesNiEncrypt256 and others do not preserve xmm6-xmm15 #244

Closed superflexible closed 3 months ago

superflexible commented 3 months ago

Hello, first, many thanks for sharing this library!

I have been working on a hard to find bug in my project, which was caused by xmm6 not being preserved by AesNiEncrypt256.

64-bit Delphi does depend on xmm6 being preserved. In my case, a TDateTime value was overwritten, which Delphi had put in xmm6, and my application therefore worked with random data.

There seems to be code to preserve xmm7, but the truth is that all registers xmm6 thru xmm15 must be preserved. These are non-volatile registers and must not be modified by any function.

Thanks!

synopse commented 3 months ago

I don't understand your statement.

The AesNiEncrypt256() function does not use the xmm6 register on Win64. Please look again at the code and check the $ifndef WIN64ABI conditionals.

Or perhaps you are using a very old version of the code.

superflexible commented 3 months ago

Hello, oh, yes I see, sorry. Yes I was using a very old version of the code, and though I did look at the latest code, I didn't spot the difference properly. Sorry!