A. Shamir,This is useful for encrypting backup tapes. The encryption key for the backup needs to be on the computer doing the backups. However it also needs to be stored in another location in case of a disk failure on that computer. However merely writing the key onto a floppy disk is dangerous in case the floppy disk falls into the wrong hands (or is lost!).
How to Share a Secret,
Comm. ACM 22, 612–613 (1979).
Shamir's method allow the key to be split into N pieces in such a way that any K piece suffice to reconstruct the key but knowledge of only K − 1 pieces yields no information on the key.
This implementation was written by Charles Karney in 2001 and is licensed under the GPL. For more information, see http://charles.karney.info/misc/secret.html.
In this implementation we require 0 < K ≤ N ≤ 256. Here's how this might work with (K,N) = (3,5)
cp /dev/null SECRETbase64-encode converts binary data to printable form. If it's not available use some other procedure for accomplishing this.
chmod 600 SECRET
dd if=/dev/random bs=1 count=36 2>/dev/null | base64-encode >> SECRET
cat SECRET | ./shares.pl 3 5This produces N lines of output which need to be written to N floppy disks together with N copies of reconstruct.pl. Store these disks in N separate secure locations.
./reconstruct.pl <<EOFThe output will be the original secret.
share5
share1
share2
EOF
Here's how tapes can be encrypted with gpg and the SECRET.
(cat SECRET; DUMP-DATA) |DUMP-DATA is whatever generates the backup data (tar, dump, etc.)
gpg -c --passphrase-fd 0 |
buffer -s 64k -m 32m -t > $TAPE
(cat SECRET; dd if=$TAPE bs=64k 2> /dev/null) |UNDUMP-DATA is the inverse of DUMP-DATA.
gpg --passphrase-fd 0 |
UNDUMP-DATA