Hi @ZEROOO
the keys should definitely not stay in flash in plain form (or rather in any form). That's considered as a serious security risk.
Users (Tiers and OEM) usually build up secure environments in which they can program secrets into the components. This includes individual-person access to these facilities as well as measures in and around the equipment.
Depending on needs and tools, it's possible to load configuration project first, erase it and then load the final application. Or the final application can be programmed and then the keys (or not the keys but rather only M1-M5 values for each key) can be supplied externally via some communication interface, for example. Everything is up to you.
If you want to keep it as simple as possible and if you don't want to load configuration project or load the keys externally, an option is to put the keys to some specific sector in flash, then load the application in production facility, reset the device, the SW will check if it is first startup, the SW will do the configuration and load the keys and then it will erase the flash sector with plain keys.
Regards,
Lukas