Guest User

Untitled

a guest
Mar 17th, 2012
152
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/bash
  2. # luks-Crypto-Benchmark
  3. # http://www.holtznet.de/luks/
  4. # 08/2009
  5.  
  6. SIZE="100" #MB
  7. BLOCKSIZE="4096"
  8. CIPHER="aes:128 aes:196 aes:256 arc4 des:128 des:256 blowfish:128 blowfish:196 blowfish:256 anubis:128 anubis:256 cast5:128 camellia:128 camellia:196 camellia:256 twofish:128 twofish:196 twofish:256 salsa20:128 salsa20:160 salsa20:196 salsa20:256 serpent:128 serpent:196 serpent:256"
  9. CMODE="cbc-essiv:sha256 xts-plain64 ecb-null ecb-plain ecb-benbi"
  10.  
  11. export LANG=C
  12.  
  13. # Load modules
  14. for mod in $(modprobe -l | grep "/crypto/" | grep "/arch/" | sed 's/.*\/\(.*\)\.ko/\1/'); do
  15. lsmod | grep "$mod" >/dev/null || modprobe "$mod" >/dev/null 2>&1
  16. done
  17.  
  18. for mod in $(modprobe -l | grep "/crypto/" | grep -v "/arch/" | sed 's/.*\/\(.*\)\.ko/\1/'); do
  19. lsmod | grep "$mod" >/dev/null || modprobe "$mod" >/dev/null 2>&1
  20. done
  21.  
  22. # Make device
  23. tmp="/tmp/"
  24. test -e /dev/shm && tmp="/dev/shm/"
  25. file=$(mktemp -p "$tmp")
  26. dd if=/dev/zero of="$file" bs=1M count="$SIZE" >/dev/null 2>&1
  27. chown root:root "$file"
  28. loop=$(losetup -f)
  29. losetup "$loop" "$file"
  30.  
  31. # Make keyfile
  32. keyfile=$(mktemp)
  33. dd if=/dev/urandom of="$keyfile" bs=512 count=1 >/dev/null 2>&1
  34. chown root:root "$keyfile"
  35.  
  36. # Start benchmark
  37. echo "Create options write read"
  38. for cipher in $CIPHER; do
  39. for cmode in $CMODE; do
  40. c=$(echo "$cipher" | sed 's/:.*//')
  41. b=$(echo "$cipher" | sed 's/.*://')
  42. echo -n "-c $c-$cmode -s $b "
  43. cryptsetup luksFormat -q -c "$c-$cmode" -s "$b" "$loop" "$keyfile" >/dev/null 2>&1
  44. cryptsetup luksOpen -q --key-file "$keyfile" "$loop" "cryptbech" >/dev/null 2>&1
  45. if [ -e "/dev/mapper/cryptbech" ]; then
  46. write=$(dd if=/dev/zero of="/dev/mapper/cryptbech" bs="$BLOCKSIZE" 2>&1 | grep "/s" | sed 's/.*, //')
  47. read=$(dd of=/dev/null if="/dev/mapper/cryptbech" bs="$BLOCKSIZE" 2>&1 | grep "/s" | sed 's/.*, //')
  48. echo "$write $read"
  49. cryptsetup luksClose -q "cryptbech" >/dev/null 2>&1
  50. else
  51. echo "Error"
  52. fi
  53. done
  54. done
  55.  
  56. # Destroy device and keyfile
  57. losetup -d "$loop"
  58. rm "$file" "$keyfile"
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×