From 618b93e61a7f2f16fbaea9fcbb877bbe157e01fd Mon Sep 17 00:00:00 2001 From: Laurent Ghigonis Date: Mon, 17 Jun 2013 10:38:09 +0200 Subject: jsaccess: rename encrypt.sh -> store.sh --- jsaccess/README.txt | 14 +++--- jsaccess/doc/put_your_encrypted_files_here.txt | 2 +- jsaccess/encrypt.sh | 59 -------------------------- jsaccess/jsa/jsa.js | 2 +- jsaccess/store.sh | 59 ++++++++++++++++++++++++++ 5 files changed, 68 insertions(+), 68 deletions(-) delete mode 100755 jsaccess/encrypt.sh create mode 100755 jsaccess/store.sh (limited to 'jsaccess') diff --git a/jsaccess/README.txt b/jsaccess/README.txt index bfb5307..16f2c98 100644 --- a/jsaccess/README.txt +++ b/jsaccess/README.txt @@ -32,9 +32,9 @@ Deployment There are 2 parts: * The jsa/ directory that contains html / javascript files, for the user to access files list and download. jsa/files/ is the files store. -* The encrypt.sh script for the web server owner to encrypt files -It is recomanded to run encrypt.sh on your laptop, and then syncronise the -jsa/files/ file store. +* The store.sh script for the web server owner to encrypt files +It is recomanded to run store.sh on your laptop, and then syncronise the +jsa/files/ file store with your server. Put jsa/ directory on your web server, publicly available. @@ -45,7 +45,7 @@ Share a file 1. Add the file you want to share to the file store On your laptop: -$ ./encrypt.sh myfile +$ ./store.sh myfile # Then enter the passphase you want to use for encryption. # It will tell you something like: jsa/files/af022cd820fdad6cbcac8e15ac565c639a47dab0 @@ -64,7 +64,7 @@ $ rsync jsa/ user@myserver:/var/www/htdocs/ How it works ============ -encrypt.sh creates a directory jsa/files//. +store.sh creates a directory jsa/files//. It encrypts your file using AES256 with the passphrase and stores the result in jsa/files//. It also updates the index of available files per directory called index.txt, @@ -82,7 +82,7 @@ Filesaver JS API. Dependencies ============ -On the host that runs encrypt.sh: +On the host that runs store.sh: * openssl * base64 @@ -97,7 +97,7 @@ Git content jsa/ - should be on your webserver, can be renamed jsa/files// - directory of files to download for a given password jsa/files//index.txt - list of file name available -encrypt.sh - to encrypt your files before uploading them to your web server +store.sh - to encrypt your files before uploading them to your web server TODO diff --git a/jsaccess/doc/put_your_encrypted_files_here.txt b/jsaccess/doc/put_your_encrypted_files_here.txt index 941ae3e..2cab735 100644 --- a/jsaccess/doc/put_your_encrypted_files_here.txt +++ b/jsaccess/doc/put_your_encrypted_files_here.txt @@ -4,7 +4,7 @@ decrypted OK ! To a new file to download: -$ ./encrypt.sh README.txt +$ ./store.sh README.txt Enter passphrase used to encrypt: jsa jsa/files/af022cd820fdad6cbcac8e15ac565c639a47dab0 CREATED jsa/files/af022cd820fdad6cbcac8e15ac565c639a47dab0/065e18a7f246b800242a778a6e8dd07a3321dac6 diff --git a/jsaccess/encrypt.sh b/jsaccess/encrypt.sh deleted file mode 100755 index 5663b9e..0000000 --- a/jsaccess/encrypt.sh +++ /dev/null @@ -1,59 +0,0 @@ -#!/bin/sh - -# jsaccess - download and decrypt files in the browser -# encrypt.sh: file encrytion script - -# Copyright (c) 2013 Laurent Ghigonis -# -# Permission to use, copy, modify, and distribute this software for any -# purpose with or without fee is hereby granted, provided that the above -# copyright notice and this permission notice appear in all copies. -# -# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -cleanup() { - rm -f $tmp - umask $sumask - exit 0 -} - -if [ $# -ne 1 ]; then - echo "usage: encrypt.sh " - exit 1 -fi -myfile=$1 -myfilename=`basename $myfile` - -sumask=$(umask) -umask 077 -tmp=`mktemp ./jsaXXXXXXXX` -trap cleanup INT TERM EXIT - -echo -n "Enter passphrase used to encrypt: " -read pass -dirhash=`echo -n $pass |openssl rmd160 |cut -d' ' -f2` -dir="jsa/files/$dirhash" -file=`echo -n ${dirhash}${myfilename} |openssl rmd160 |cut -d' ' -f2` -echo $dir -mkdir -p $dir -touch $dir/index.html - -base64 -w0 $myfile > $tmp -echo -n $pass |openssl enc -e -a -aes-256-cbc -in $tmp -out $dir/$file -pass stdin ||exit $? -echo "CREATED $dir/$file" - -if [ -f $dir/index.txt ]; then - echo -n $pass |openssl enc -d -a -aes-256-cbc -in $dir/index.txt -out $tmp -pass stdin ||exit $? -else - echo > $tmp -fi -echo $myfilename >> $tmp -rm -f $dir/index.txt -echo -n $pass |openssl enc -e -a -aes-256-cbc -in $tmp -out $dir/index.txt -pass stdin ||exit $? -echo "UPDATED $dir/index.txt" diff --git a/jsaccess/jsa/jsa.js b/jsaccess/jsa/jsa.js index c9cc923..138ed84 100644 --- a/jsaccess/jsa/jsa.js +++ b/jsaccess/jsa/jsa.js @@ -1,4 +1,4 @@ -/* jsaccess - download and decrypt files in the browser +/* jsaccess - private web file sharing using client side crypto * jsa.js: Main javascript file */ /* diff --git a/jsaccess/store.sh b/jsaccess/store.sh new file mode 100755 index 0000000..71a42c2 --- /dev/null +++ b/jsaccess/store.sh @@ -0,0 +1,59 @@ +#!/bin/sh + +# jsaccess - private web file sharing using client side crypto +# store.sh: file encrytion script + +# Copyright (c) 2013 Laurent Ghigonis +# +# Permission to use, copy, modify, and distribute this software for any +# purpose with or without fee is hereby granted, provided that the above +# copyright notice and this permission notice appear in all copies. +# +# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +cleanup() { + rm -f $tmp + umask $sumask + exit 0 +} + +if [ $# -ne 1 ]; then + echo "usage: store.sh " + exit 1 +fi +myfile=$1 +myfilename=`basename $myfile` + +sumask=$(umask) +umask 077 +tmp=`mktemp ./jsaXXXXXXXX` +trap cleanup INT TERM EXIT + +echo -n "Enter passphrase used to encrypt: " +read pass +dirhash=`echo -n $pass |openssl rmd160 |cut -d' ' -f2` +dir="jsa/files/$dirhash" +file=`echo -n ${dirhash}${myfilename} |openssl rmd160 |cut -d' ' -f2` +echo $dir +mkdir -p $dir +touch $dir/index.html + +base64 -w0 $myfile > $tmp +echo -n $pass |openssl enc -e -a -aes-256-cbc -in $tmp -out $dir/$file -pass stdin ||exit $? +echo "CREATED $dir/$file" + +if [ -f $dir/index.txt ]; then + echo -n $pass |openssl enc -d -a -aes-256-cbc -in $dir/index.txt -out $tmp -pass stdin ||exit $? +else + echo > $tmp +fi +echo $myfilename >> $tmp +rm -f $dir/index.txt +echo -n $pass |openssl enc -e -a -aes-256-cbc -in $tmp -out $dir/index.txt -pass stdin ||exit $? +echo "UPDATED $dir/index.txt" -- cgit v1.2.3-59-g8ed1b