disable-hwcrypto.sh 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #!/bin/bash
  2. # Copyright (c) 2017, Mathy Vanhoef <Mathy.Vanhoef@cs.kuleuven.be>
  3. #
  4. # This code may be distributed under the terms of the BSD license.
  5. # See README for more details.
  6. set -e
  7. NOHWCRYPT="ath5k ath9k ath9k_htc rt2800usb carl9170 b43 p54common rt2500usb rt2800pci rt73usb"
  8. SWCRYPTO="iwlwifi iwl3945 iwl4965"
  9. HWCRYPTO="ipw2200"
  10. MODFILE="/etc/modprobe.d/nohwcrypt.conf"
  11. # 0. Check if we have root privileges
  12. if [[ $EUID -ne 0 ]]; then
  13. echo "This script must be run as root"
  14. exit 1
  15. fi
  16. # 1. Create nohwcrypt.conf options file
  17. rm $MODFILE 2> /dev/null || true
  18. for MODULE in $NOHWCRYPT
  19. do echo "options $MODULE nohwcrypt=1" >> $MODFILE; done
  20. for MODULE in $SWCRYPTO
  21. do echo "options $MODULE swcrypto=1" >> $MODFILE; done
  22. for MODULE in $HWCRYPTO
  23. do echo "options $MODULE hwcrypto=0" >> $MODFILE; done
  24. # 2. Remove loaded modules so they'll reload parameters. Note that modules that
  25. # are in use by others won't be removed (e.g. iwlwifi won't be removed).
  26. for MODULE in $NOHWCRYPT $SWCRYPTO $HWCRYPTO
  27. do rmmod $MODULE 2> /dev/null || true; done
  28. # 3. Done. To be sure parameters are reloaded, reboot computer.
  29. echo "Created config file $MODFILE to disable hardware decryption."
  30. echo "Reboot your computer to apply the changes."