forked from axiom-team/jaklis
Rebase branch in bash way
This commit is contained in:
parent
8fe4985b58
commit
c6055ccc93
14
deletemsg.sh
14
deletemsg.sh
|
@ -31,17 +31,17 @@ do
|
|||
-o|--outbox) type=outbox;;
|
||||
-id|--id) id="${args[$i+1]}"
|
||||
[[ -z $id ]] && echo "Veuillez préciser un ID de message." && exit 1;;
|
||||
-k|--key) dunikey="${args[$i+1]}"
|
||||
[[ -z $dunikey ]] && echo "Veuillez préciser un fichier de trousseau." && 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;;
|
||||
*) [[ "${args[$i]}" == "-"* ]] && echo "Option inconnue." && exit 1;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [[ -z $dunikey ]]; then
|
||||
read -p "Fichier de trousseau: " dunikey
|
||||
if [[ -z $DUNIKEY ]]; then
|
||||
read -p "Fichier de trousseau: " DUNIKEY
|
||||
fi
|
||||
issuer=$(./natools.py pk -f pubsec -k $dunikey)
|
||||
issuer=$(./natools.py pk -f pubsec -k $DUNIKEY)
|
||||
|
||||
if [[ -z $type ]]; then
|
||||
type="inbox"
|
||||
|
@ -60,11 +60,11 @@ hashBrut="{\"version\":2,\"index\":\"message\",\"type\":\"$type\",\"id\":\"$id\"
|
|||
hash=$(echo -n "$hashBrut" | sha256sum | cut -d ' ' -f1 | awk '{ print toupper($0) }')
|
||||
|
||||
# Fabrication de la signature
|
||||
signature=$(echo -n "$hash" | ./natools.py sign -f pubsec -k $dunikey --noinc -O 64)
|
||||
signature=$(echo -n "$hash" | ./natools.py sign -f pubsec -k $DUNIKEY --noinc -O 64)
|
||||
|
||||
document="{\"hash\":\"$hash\",\"signature\":\"$signature\",${hashBrut:1}"
|
||||
jq . <<<$document
|
||||
|
||||
# Envoi du document
|
||||
curl -s -X POST "$pod/history/delete" -d "$document"
|
||||
curl -s -X POST "$POD/history/delete" -d "$document"
|
||||
echo
|
||||
|
|
18
readmsg.sh
18
readmsg.sh
|
@ -32,8 +32,8 @@ declare -a args=($@)
|
|||
for ((i=0; i<${#args[*]}; ++i))
|
||||
do
|
||||
case ${args[$i]} in
|
||||
-k|--key) dunikey="${args[$i+1]}"
|
||||
[[ -z $dunikey ]] && echo "Veuillez préciser un fichier de trousseau." && exit 1;;
|
||||
-k|--key) DUNIKEY="${args[$i+1]}"
|
||||
[[ -z $DUNIKEY ]] && echo "Veuillez préciser un fichier de trousseau." && exit 1;;
|
||||
-o|--outbox) type=outbox;;
|
||||
-n|--number) nbrRaw="${args[$i+1]}";;
|
||||
-n*) nbrRaw="${args[$i]:2}";;
|
||||
|
@ -43,9 +43,9 @@ do
|
|||
done
|
||||
|
||||
|
||||
recipient=$(./natools.py pk -f pubsec -k $dunikey)
|
||||
if [[ -z $dunikey ]]; then
|
||||
read -p "Fichier de trousseau: " dunikey
|
||||
recipient=$(./natools.py pk -f pubsec -k $DUNIKEY)
|
||||
if [[ -z $DUNIKEY ]]; then
|
||||
read -p "Fichier de trousseau: " DUNIKEY
|
||||
fi
|
||||
[[ -z $type ]] && type="inbox"
|
||||
[[ -z $nbrRaw ]] && nbrRaw=5000
|
||||
|
@ -55,7 +55,7 @@ fi
|
|||
document="{\"sort\":{\"time\":\"desc\"},\"from\":0,\"size\":$nbrRaw,\"_source\":[\"issuer\",\"recipient\",\"title\",\"content\",\"time\",\"nonce\",\"read_signature\"],\"query\":{\"bool\":{\"filter\":{\"term\":{\"recipient\":\"$recipient\"}}}}}"
|
||||
|
||||
# Envoi du document
|
||||
msgContent=$(curl -s -X POST "$pod/message/$type/_search" -d "$document" | jq .hits.hits[]._source -c)
|
||||
msgContent=$(curl -s -X POST "$POD/message/$type/_search" -d "$document" | jq .hits.hits[]._source -c)
|
||||
|
||||
#Traitement des données
|
||||
n=0
|
||||
|
@ -69,13 +69,13 @@ for i in $msgContent; do
|
|||
content="${dataObj[4]}"
|
||||
time="${dataObj[5]}"
|
||||
|
||||
titleClear=$(./natools.py box-decrypt -p $issuer -f pubsec -k $dunikey -n $nonce -I 64 <<< "${title}")
|
||||
contentClear=$(./natools.py box-decrypt -p $issuer -f pubsec -k $dunikey -n $nonce -I 64 <<< "${content}")
|
||||
titleClear=$(./natools.py box-decrypt -p $issuer -f pubsec -k $DUNIKEY -n $nonce -I 64 <<< "${title}")
|
||||
contentClear=$(./natools.py box-decrypt -p $issuer -f pubsec -k $DUNIKEY -n $nonce -I 64 <<< "${content}")
|
||||
echo "$titleClear"
|
||||
echo "$contentClear"
|
||||
echo "========="
|
||||
((n++))
|
||||
# echo "./natools.py box-decrypt -p $issuer -f pubsec -k $dunikey -n $nonce -I 64 <<< \"${title}\""
|
||||
# echo "./natools.py box-decrypt -p $issuer -f pubsec -k $DUNIKEY -n $nonce -I 64 <<< \"${title}\""
|
||||
done
|
||||
|
||||
#echo "$msgContent" | jq
|
||||
|
|
24
sendmsg.sh
24
sendmsg.sh
|
@ -34,21 +34,21 @@ 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)
|
||||
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;;
|
||||
-k|--key) dunikey="${args[$i+1]}"
|
||||
[[ -z $dunikey ]] && echo "Veuillez préciser un fichier de trousseau." && 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;;
|
||||
*) [[ "${args[$i]}" == "-"* ]] && echo "Option inconnue." && exit 1;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [[ -z $dunikey ]]; then
|
||||
read -p "Fichier de trousseau: " dunikey
|
||||
if [[ -z $DUNIKEY ]]; then
|
||||
read -p "Fichier de trousseau: " DUNIKEY
|
||||
fi
|
||||
issuer=$(./natools.py pk -f pubsec -k $dunikey)
|
||||
issuer=$(./natools.py pk -f pubsec -k $DUNIKEY)
|
||||
|
||||
if [[ -z $file ]]; then
|
||||
read -p "Objet du message: " title
|
||||
|
@ -67,8 +67,8 @@ fi
|
|||
# Récupération et chiffrement du titre et du message
|
||||
nonce=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)
|
||||
b58nonce=$(echo $nonce | base64 -d | base58)
|
||||
title=$(head -n1 <<<$message | ./natools.py box-encrypt -n $nonce -f pubsec -k $dunikey -p $recipient -O 64)
|
||||
content=$(tail -n+2 <<<$message | ./natools.py box-encrypt -n $nonce -f pubsec -k $dunikey -p $recipient -O 64)
|
||||
title=$(head -n1 <<<$message | ./natools.py box-encrypt -n $nonce -f pubsec -k $DUNIKEY -p $recipient -O 64)
|
||||
content=$(tail -n+2 <<<$message | ./natools.py box-encrypt -n $nonce -f pubsec -k $DUNIKEY -p $recipient -O 64)
|
||||
|
||||
times=$(date -u +'%s')
|
||||
|
||||
|
@ -77,15 +77,15 @@ hashBrut="{\"issuer\":\"$issuer\",\"recipient\":\"$recipient\",\"title\":\"$titl
|
|||
hash=$(echo -n "$hashBrut" | sha256sum | cut -d ' ' -f1 | awk '{ print toupper($0) }')
|
||||
|
||||
# Fabrication de la signature
|
||||
signature=$(echo -n "$hash" | ./natools.py sign -f pubsec -k $dunikey --noinc -O 64)
|
||||
signature=$(echo -n "$hash" | ./natools.py sign -f pubsec -k $DUNIKEY --noinc -O 64)
|
||||
|
||||
# Affichage du JSON final
|
||||
document="{\"hash\":\"$hash\",\"signature\":\"$signature\",${hashBrut:1}"
|
||||
jq . <<<$document
|
||||
|
||||
# Envoi du document
|
||||
#curl -s -i -X OPTIONS "$pod/message/inbox?pubkey=$issuer" -d "pubkey=$issuer"
|
||||
msgID=$(curl -s -X POST "$pod/message/inbox?pubkey=$recipient" -d "$document")
|
||||
#curl -s -i -X OPTIONS "$POD/message/inbox?pubkey=$issuer" -d "pubkey=$issuer"
|
||||
msgID=$(curl -s -X POST "$POD/message/inbox?pubkey=$recipient" -d "$document")
|
||||
echo -e "\nMessage ID: $msgID"
|
||||
|
||||
|
||||
|
@ -95,7 +95,7 @@ echo -e "\nMessage ID: $msgID"
|
|||
#sleep 1 && ./deletemsg.sh -id $msgID
|
||||
|
||||
# To put the message in outbox too
|
||||
#curl -s -X POST "$pod/message/outbox?pubkey=$issuer" -d "$document"
|
||||
#curl -s -X POST "$POD/message/outbox?pubkey=$issuer" -d "$document"
|
||||
|
||||
# To put the message as read, add this at the end of document
|
||||
#,\"read_signature\":\"$signature\"
|
||||
|
|
Loading…
Reference in New Issue