From a4497faf8ecd6396cfc5c473cb800af07b53c779 Mon Sep 17 00:00:00 2001 From: poka Date: Tue, 17 Nov 2020 01:11:30 +0100 Subject: [PATCH] Remove useless issuer pubkey in .env and anywhere --- .env.template | 2 +- deletemsg.sh | 14 +++++--------- readmsg.sh | 12 ++++++------ sendmsg.sh | 19 ++++++++----------- 4 files changed, 20 insertions(+), 27 deletions(-) diff --git a/.env.template b/.env.template index ef3a430..34bedb8 100644 --- a/.env.template +++ b/.env.template @@ -1,3 +1,3 @@ -issuer="" # Clé publique Ḡ1 de l'émetteur du message dunikey="" # La clé privé Ḡ1 de l'émetteur, générable par Cesium au format PubSec pod="https://g1.data.duniter.fr" # Noeud Cecium+ utilisé pour l'envoi du message +#pod="https://data.gchange.fr" \ No newline at end of file diff --git a/deletemsg.sh b/deletemsg.sh index 719a124..1bfe153 100755 --- a/deletemsg.sh +++ b/deletemsg.sh @@ -18,7 +18,6 @@ helpOpt() { \rOptions: -id,--id \tDelete the message with ID . - -i,--issuer \tUses as issuer of the message. -k,--key \t\tPath to the pubsec keychain file of the issuer. -o,--outbox\t\t\tDelete outbox messages instead of inbox -h,--help\t\t\tDisplay this help" @@ -32,8 +31,6 @@ do -o|--outbox) type=outbox;; -id|--id) id="${args[$i+1]}" [[ -z $id ]] && echo "Veuillez préciser un ID de message." && exit 1;; - -i|--issuer) issuer="${args[$i+1]}" - [[ -z $issuer ]] && echo "Veuillez préciser un émetteur." && exit 1;; -k|--key) dunikey="${args[$i+1]}" [[ -z $dunikey ]] && echo "Veuillez préciser un fichier de trousseau." && exit 1;; -h|--help) helpOpt && exit 0;; @@ -41,6 +38,11 @@ do esac done +if [[ -z $dunikey ]]; then + read -p "Fichier de trousseau: " dunikey +fi +issuer=$(./natools.py pk -f pubsec -k $dunikey) + if [[ -z $type ]]; then type="inbox" fi @@ -48,12 +50,6 @@ fi if [[ -z $id ]]; then read -p "ID de message: " ID fi -if [[ -z $issuer ]]; then - read -p "Émetteur: " issuer -fi -if [[ -z $dunikey ]]; then - read -p "Fichier de trousseau: " dunikey -fi [[ -z $(grep -Eo $REGEX_PUBKEYS <<<$issuer) ]] && echo "Le format de la clé publique de l'émetteur est invalide." && exit 1 diff --git a/readmsg.sh b/readmsg.sh index 7fa88c0..b0e02fc 100755 --- a/readmsg.sh +++ b/readmsg.sh @@ -17,7 +17,6 @@ helpOpt() { Advice: Fill your .env file for more fun. \rOptions: - -r,--recipient \tUses as recipient of the messages. -k,--key \t\tPath to the pubsec keychain file of the issuer. -n,--number \tDisplay the lasts messages from Cesium (tail-like format) -o,--outbox\t\t\tRead outbox messages instead of inbox @@ -33,8 +32,6 @@ declare -a args=($@) for ((i=0; i<${#args[*]}; ++i)) do case ${args[$i]} in - -r|--recipient) recipient="${args[$i+1]}" - [[ -z $recipient ]] && echo "Veuillez préciser un destinataire." && exit 1;; -k|--key) dunikey="${args[$i+1]}" [[ -z $dunikey ]] && echo "Veuillez préciser un fichier de trousseau." && exit 1;; -o|--outbox) type=outbox;; @@ -45,9 +42,8 @@ do esac done -if [[ -z $recipient ]]; then - read -p "Clé publique de l'utilisateur: " recipient -fi + +recipient=$(./natools.py pk -f pubsec -k $dunikey) if [[ -z $dunikey ]]; then read -p "Fichier de trousseau: " dunikey fi @@ -79,4 +75,8 @@ for i in $msgContent; do echo "$contentClear" echo "=========" ((n++)) +# echo "./natools.py box-decrypt -p $issuer -f pubsec -k $dunikey -n $nonce -I 64 <<< \"${title}\"" done + +#echo "$msgContent" | jq + diff --git a/sendmsg.sh b/sendmsg.sh index 6553620..48da07a 100755 --- a/sendmsg.sh +++ b/sendmsg.sh @@ -14,13 +14,12 @@ helpOpt() { echo -e "Cesium+ messages sender Default: ask title, content and recipient in interactive mode. Advice: Fill your .env file for more fun. - Example: $0 -f -r -i -k + Example: $0 -f -r -k \rOptions: -t\t\t\t\tTest mode: Uses the \"test.txt\" file as well as the same recipient as the sender. -f,--file \t\tRead the file with title in first line and content in rest of the file for the message. -r,--recipient \tUses as recipient of the message. - -i,--issuer \tUses as issuer of the message (Could be remove in future version by calculating pubkey from privatekey). -k,--key \t\tPath to the pubsec keychain file of the issuer. -h,--help\t\t\tDisplay this help" } @@ -35,11 +34,10 @@ do -f|--file) file="${args[$i+1]}" [[ ! -f $file ]] && echo "Le fichier $file n'existe pas." && exit 1;; -t|--test) file="test.txt" + issuer=$(./natools.py pk -f pubsec -k $dunikey) recipient=$issuer;; -r|--recipient) recipient="${args[$i+1]}" [[ -z $recipient ]] && echo "Veuillez préciser un destinataire." && exit 1;; - -i|--issuer) issuer="${args[$i+1]}" - [[ -z $issuer ]] && echo "Veuillez préciser un émetteur." && exit 1;; -k|--key) dunikey="${args[$i+1]}" [[ -z $dunikey ]] && echo "Veuillez préciser un fichier de trousseau." && exit 1;; -h|--help) helpOpt && exit 0;; @@ -47,6 +45,11 @@ do esac done +if [[ -z $dunikey ]]; then + read -p "Fichier de trousseau: " dunikey +fi +issuer=$(./natools.py pk -f pubsec -k $dunikey) + if [[ -z $file ]]; then read -p "Objet du message: " title read -p "Corps du message: " content @@ -54,15 +57,9 @@ if [[ -z $file ]]; then else message=$(cat $file) fi -if [[ -z $issuer ]]; then - read -p "Émetteur: " issuer -fi if [[ -z $recipient ]]; then read -p "Destinataire: " recipient fi -if [[ -z $dunikey ]]; then - read -p "Fichier de trousseau: " dunikey -fi [[ -z $(grep -Eo $REGEX_PUBKEYS <<<$recipient) ]] && echo "Le format de la clé publique du destinataire est invalide." && exit 1 [[ -z $(grep -Eo $REGEX_PUBKEYS <<<$issuer) ]] && echo "Le format de la clé publique de l'émetteur est invalide." && exit 1 @@ -100,5 +97,5 @@ echo -e "\nMessage ID: $msgID" # To put the message in outbox too #curl -s -X POST "$pod/message/outbox?pubkey=$issuer" -d "$document" -# To put the message as read, ad this at the end of document +# To put the message as read, add this at the end of document #,\"read_signature\":\"$signature\"