I am revising a Linux kernel module in Openwrt (mac80211 specifically). I need to use some encryption keys which are provided before the system is installed and run.
Specifically, each key is 32-bytes long. It serves as the key to generate HMAC(SHA256) for communication. The receiver then uses the same key to authenticate the message.
The first question is what is the correct way to load these keys?
- Store keys in files and read them? But here it says one should avoid reading files in kernel modules.
- Hardcode the keys in codes. Like u8
key={0xff, 0xaa, 0x33, 0x00};
. This requires reflashing the system when I want to change the keys, which is acceptable but not desirable.
The second question is how should I use these keys in my code? Should I use keyring and key in Linux kernel? My keys will only be used in this sole module, so should I simply store them in u8
array?
Thanks for reading my questions and any related resources especially sample codes are appreciated.