2 1. Generate private key
5 openssl genrsa -out privkey_evm.pem 1024
8 openssl genrsa -des3 -out privkey_evm.pem 1024
10 # set password for the key
11 openssl rsa -in /etc/keys/privkey_evm.pem -out privkey_evm_enc.pem -des3
13 openssl pkcs8 -topk8 -in /etc/keys/privkey_evm.pem -out privkey_evm_enc.pem
15 2. Generate public key
17 openssl rsa -pubout -in privkey_evm.pem -out pubkey_evm.pem
19 3. Copy public (+private if to sign on device) key to the device/qemu /etc/keys
21 scp pubkey_evm.pem mad:/etc/keys
23 4. Load keys and enable EVM
27 This should be done at early phase, before mounting root filesystem.
29 5. Sign EVM and use hash value for IMA - common case
31 evmctl sign --imahash test.txt
33 6. Sign IMA and EVM - for immutable files and modules
35 evmctl sign --imasig test.txt
37 7. Sign whole filesystem
41 find / \( -fstype rootfs -o -fstype ext3 -o -fstype ext4 \) ! -path "/lib/modules/*" -type f -uid 0 -exec evmctl sign --imahash '{}' \;
42 find /lib/modules ! -name "*.ko" -type f -uid 0 -exec evmctl sign --imahash '{}' \;
43 # security.ima needs to have signature for modules
44 find /lib/modules -name "*.ko" -type f -uid 0 -exec evmctl sign --imasig '{}' \;
46 8. Label filesystem in fix mode...