All pastes #496380 Raw Edit

andarius

public text v1 · immutable
·published 2007-05-19 06:19 UTC
rendered paste body
#!/bin/bash

#  /================================================\
#  | This will prep an encrypted file for use on a  |
#  | linux machine using the serpent encryption     |
#  | algorythm. I need to work this up into a gui   |
#  | using tcl or something. Variable 1 is the file |
#  | to use and 2 is the size of the file. The size |
#  | is a fixed parameter and can not be changed    |
#  | later.                                         |
#  \================================================/

# Load the needed modules:
modprobe loop
modprobe cryptoloop
# Make sure we load the one we want to use:
modprobe serpent

# Create the file in the specified place:
dd if=/dev/urandom of=$1 bs=1M count=$2

# This next one will ask for a password:
losetup -e serpent /dev/loop0 $1

# Make the filesystem, don't use a journaling fs here:
mke2fs /dev/loop0

#  /================================================\
#  | To mount the encrypted file system we would    |
#  | the following. The unmount commands are also   |
#  | listed here. Var 3 is where we want to mount.  |   
#  \================================================/

# Set up the loop device, not needed after above:
losetup -e serpent /dev/loop0 $1

# Mount the loop device:
mount /dev/loop0 $3

# Unmount the loop device:
umount /dev/loop0

# Remove the loop device:
losetup -d /dev/loop0