Advertisement
Guest User

Untitled

a guest
Aug 7th, 2013
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.80 KB | None | 0 0
  1. # Create a GnuPG keyfile for use by loop-AES.
  2. # (v3 key format: 2925 bytes in base64)
  3. create_gnupg_keyfile () {
  4.         local keyfile pass passfifo pid
  5.         keyfile=$1
  6.         pass=$2
  7.  
  8.         passfifo=$keyfile.pass
  9.         if [ ! -p $passfifo ]; then
  10.                 mknod $passfifo p
  11.                 chmod 0600 $passfifo
  12.         fi
  13.  
  14.         # Fork off gnupg encrypting pipe
  15.         printf %s "$pass" > $passfifo &
  16.         gnupg_encrypt $keyfile $passfifo &
  17.         gpg_pid=$!
  18.  
  19.         # Call plugin to feed randfifo
  20.         call_entropy_plugin 2925
  21.         if [ $? -ne 0 ] || ! wait $gpg_pid; then
  22.                 rm $keyfile
  23.                 kill $gpg_pid
  24.                 return 1
  25.         fi
  26.  
  27.         # for use by init.d/crypto
  28.         printf %s "$pass" > $passfifo &
  29.         return 0
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement