Author: Paolo Lulli <paolo@lulli.net>
deps check
x509crypt | 29 ++++++++++++++++++++++-------
diff --git a/x509crypt b/x509crypt index 5bfaa29dc901ae86988ba48aa06a29f3fa294eab..0fcbc9962ebc754dc2280b9339d3d82643122a86 100755 --- a/x509crypt +++ b/x509crypt @@ -19,6 +19,9 @@ CONFIG_DIR=$HOME/.x509crypt GLOBAL_CONFIG=${CONFIG_DIR}/config + +DEPENDENCIES="qrencode openssl" + setup_global_config(){ echo "/C=GB/ST=London/L=London/O=Global Security/OU=IT Department"> ${GLOBAL_CONFIG} echo "Created config file: [${GLOBAL_CONFIG}]" @@ -61,13 +64,24 @@ echo "" qrencode "${genpassword}" -t UTF8 openssl rsa -aes256 -in $CONFIG_DIR/$profile_name/certs/$CONFIG_CERT_NAME.key -out $CONFIG_CERT_NAME.key.enc -passout pass:${genpassword} + echo "----------------------------------------------------" + echo "" + echo "secret key path:[$CONFIG_CERT_NAME.key.enc]" + echo "" + echo "----------------------------------------------------" + echo "" } -#export_key(){ -# profile_name=$1 -# CONFIG_CERT_NAME=${profile} -# openssl rsa -aes256 -in $CONFIG_DIR/$profile_name/certs/$CONFIG_CERT_NAME.key -#} +dependencies_check() +{ + for d in $DEPENDENCIES; do + CHK=$(which $d) + if [ "$CHK" = "" ]; then + echo "missing deps: [$d]"; + exit 1 + fi + done +} export_certificate(){ profile_name=$1 @@ -91,7 +105,7 @@ test -d $CONFIG_DIR/$profile_name/certs || mkdir -p $CONFIG_DIR/$profile_name/certs } file_decrypt(){ - echo "FILE DECRYPT: $1" + #echo "FILE DECRYPT: $1" test -d $CONFIG_DIR/$profile_name || echo "profile: [$profile_name] does not exist, EXIT" test -d $CONFIG_DIR/$profile_name || exit 1 decrypted_file=$1".cleartext" @@ -101,7 +115,7 @@ openssl smime -decrypt -binary -in $1 -inform DER -out $decrypted_file -inkey $CONFIG_DIR/$profile_name/certs/$CONFIG_CERT_NAME.key } file_encrypt(){ - echo "FILE ENCRYPT: $1" + #echo "FILE ENCRYPT: $1" file_size=$(du -s $1 | awk '{print $1}') # if [ ${file_size} -gt 500000 ]; then @@ -150,6 +164,7 @@ echo "${program}-i : Import pub key" echo "${program} -l : List profiles" } +dependencies_check if [ "$#" -gt 3 ]; then usage