LE 9 kernel config with more crypto modules, hardware acceleration and dm-crypt

  • Why should there be hardware acceleration and more crypto moduls in the kernel:

    Hardware acceleration with AES-NI is 6-8 times faster. That is the case for many things like https, other SSL connections, SSH and also disk encryption. The kernel encryption/decryption implemetation is faster than just userspace software, becasue it is more optimized and using even hardware acceleration if possible, when you enable optimization/acceleration.

    When the kenrel supports a more complete set of encryption, than the community is able to build addons that are using/needing the kernel crypto support.

    Why would some one use disk encryption:

    There are at least 2 reasons.

    One is encryption at rest, so that data on the disk are encrypted and you can throw it away without thinking about the data. For HDDs you can overwrite them, when they are still working, but failed HDDs have still data and you can not properly delete them. The seconds case can be solved with a degausser, but thats about $ 20.000 (i bought 2 at work). For SSDs proper deleting through overwriting is not really possible, because of wearleveling technics of the SSD controller you will never reach all flash cells.

    The 2nd one is protecting your data, because you dont want somebody to access them. But these data are only cold secure, that means if it is swicthed off nobody can access it without your password or key. I see that used more and more for portable data devices (HDD, SSD, USB Stick). Also Android does encrypt the user data by default since Android 6, when you setup a PIN or password. iPhones doing that a lot longer.


    I propose to add more support for encryption and dm-crypt in the kernel. Encryption will be faster for e.g https and the community can build addons based on that.

    I would also like to include cryptsetup in LE, so that it is possible to use encrypted block devices. If cryptsetup is not included i can still build a addon, when the dm-crypt kernel support is included.

    With cryptsetup it is possible to use luks, loopaes, veracrypt, truecrypt encrypted devices. A veracrypt USB disc needs to be first open by cryptsetup and then you could normal mount e.g. a ntfs filesystem. There is no GUI for that in my proposal. I am not the right person to build a GUI portion for that, but with the kernel support and cryptsetup it is poosible to build a addon for that.


    The kernel image is growing about 16KB on Generic x86_64 and the system image about 1.5MB (cryptsetup included).

    I have now (finally) my own github account with a forked LibreELEC repo and created Pull Requests for the features, but so far only in my own repo.

    For cryptsetup and dependencies:

    PKG add cryptsetup, lvm2-minimal, config-md by sky42src · Pull Request #5 · sky42src/LibreELEC.tv · GitHub

    and this wil only be build if the kernel supports CONFIG_DM_CRYPT. The next 3 PR will do that.

    For the kernel modules i have covered 3 projects so far:

    linux (Generic): add more crypto modules + dm-crypt by sky42src · Pull Request #6 · sky42src/LibreELEC.tv · GitHub

    linux (RPi): add more crypto modules + dm-crypt by sky42src · Pull Request #7 · sky42src/LibreELEC.tv · GitHub

    linux (Amlogic): add more crypto modules + dm-crypt by sky42src · Pull Request #8 · sky42src/LibreELEC.tv · GitHub

    I am happy to provide patches for the other architectures. On Generic/RPi2 i use this every day (my LE userdata is encrypted).

    If somebody wants to try, you will find my builds here HiDrive and in the noni subfolder is a version without crypto hardware acceleration. The easiest way to test ist "cryptsetup benchmark --cipher aes-xts" with and with out hw acceleration. I will also add the pure le master, so that you can see the size difference and this will be in the orig subfolder.

    Thanks for reading and hopefully considering it

    sky42

    Edited 2 times, last by sky42 (September 7, 2018 at 8:59 AM).

  • No i did some testing with my new builds and here are the results for hardware accelerated AES.

    The 0901-luks version is with all usable hardware acceleration on and 0901-noni is the same just hardware acceleration swited of in the kernel.

    short version:


    TL;DR

    full output of the tests

  • And to see the size difference here some ls with my LE master version 1725942 patched with all the crypto stuff and 8.90.004 which was not build by my, but as far as i can tel that is LE master 1725942.

    kernel

    sky42@howcome:/zfs/sky42/libreelec/sky42$ ls -lg 9.0/*/*.kernel 8.90.004/*/KERNEL

    -rw-r--r-- 1 sky42 16007536 Aug 31 17:05 8.90.004/Generic/KERNEL

    -rw-r--r-- 1 sky42 7231208 Aug 31 13:21 8.90.004/RPi2/KERNEL

    -rw-r--r-- 1 sky42 7066200 Aug 31 14:29 8.90.004/RPi/KERNEL

    -rw-r--r-- 1 sky42 16019824 Sep 1 07:49 9.0/Generic/LibreELEC-Generic.x86_64-9.0-devel-20180901074840-1725942.kernel

    -rw-r--r-- 1 sky42 7230464 Sep 1 07:26 9.0/RPi2/LibreELEC-RPi2.arm-9.0-devel-20180901072539-1725942.kernel

    -rw-r--r-- 1 sky42 7070584 Sep 1 07:24 9.0/RPi/LibreELEC-RPi.arm-9.0-devel-20180901072412-1725942.kernel

    -rw-r--r-- 1 sky42 7230872 Sep 1 07:28 9.0/Slice3/LibreELEC-Slice3.arm-9.0-devel-20180901072730-1725942.kernel

    -rw-r--r-- 1 sky42 7069736 Sep 1 07:29 9.0/Slice/LibreELEC-Slice.arm-9.0-devel-20180901072847-1725942.kernel

    system

    sky42@howcome:/zfs/sky42/libreelec/sky42$ ls -lg 9.0/*/*.system 8.90.004/*/SYSTEM

    -rw-r--r-- 1 sky42 235331584 Aug 31 17:05 8.90.004/Generic/SYSTEM

    -rw-r--r-- 1 sky42 138616832 Aug 31 13:21 8.90.004/RPi2/SYSTEM

    -rw-r--r-- 1 sky42 138149888 Aug 31 14:29 8.90.004/RPi/SYSTEM

    -rw-r--r-- 1 sky42 235986944 Sep 1 07:49 9.0/Generic/LibreELEC-Generic.x86_64-9.0-devel-20180901074840-1725942.system

    -rw-r--r-- 1 sky42 139218944 Sep 1 07:26 9.0/RPi2/LibreELEC-RPi2.arm-9.0-devel-20180901072539-1725942.system

    -rw-r--r-- 1 sky42 138743808 Sep 1 07:25 9.0/RPi/LibreELEC-RPi.arm-9.0-devel-20180901072412-1725942.system

    -rw-r--r-- 1 sky42 139358208 Sep 1 07:28 9.0/Slice3/LibreELEC-Slice3.arm-9.0-devel-20180901072730-1725942.system

    -rw-r--r-- 1 sky42 138891264 Sep 1 07:29 9.0/Slice/LibreELEC-Slice.arm-9.0-devel-20180901072847-1725942.system