sagemath / sage

Main repository of SageMath
https://www.sagemath.org
Other
1.35k stars 460 forks source link

mini-AES inconsistent implementation between v4.5.1 and v10.3 #38298

Open gpv-github opened 3 months ago

gpv-github commented 3 months ago

Steps To Reproduce

I am teaching an undergraduate crypto course and I want to cover Mini-AES from R. C.-W. Phan. Mini advanced encryption standard (mini-AES): a testbed for cryptanalysis students. Cryptologia, 26(4):283–306, 2002.

This is implemented in sagemath. However, outputs in sagemath version 4.5.1, which you can find here http://fe.math.kobe-u.ac.jp/icms2010-..., are different from outputs in sagemath version 10.3, which you can find here https://doc.sagemath.org/html/en/refe...

Expected Behavior

The correct answers should always be the ones from v4.5.1.

Actual Behavior

The discrepancies between the two version can be seen in the very first box 'Encrypt a plaintext'. Compare the two values of C (v4.5.1 and v10.3), with the same input P and key.

This is particularly problematic in the computation of the round_key(key, n). Once could see that with the same input, the answers of each version differs.

Additional Information

R. C.-W. Phan. Mini advanced encryption standard (mini-AES): a testbed for cryptanalysis students. Cryptologia, 26(4):283–306, 2002.

Environment

- **OS**: MacOS Sonoma 14.5
- **Sage Version**: 10.3

Checklist

PTK12 commented 1 month ago

When the sbox module was rewritten to Cython back in https://github.com/sagemath/sage/issues/25633, it was decided that finite field elements would be interpreted in big endian. Values in the documentation you have shown were also changed in https://github.com/sagemath/sage/commit/56952f55e260b20190e2761fb12ba8414fe98482 to reflect this.