Move pubkey storage into directory - postreich - Unnamed repository; edit this file 'description' to name the repository. DIR Log DIR Files DIR Refs DIR README --- DIR commit 35308b688d43b72fc2cf757f5c37978212027cac DIR parent cacd7ba6b69159c5970baaf1eef3f759f23e9be4 HTML Author: Scarlett McAllister <no+reply@roygbyte.com> Date: Sat, 20 Jan 2024 18:56:24 -0400 Move pubkey storage into directory Diffstat: M geomyidae/postoffice/common | 16 ++++++++++++++++ M geomyidae/postoffice/create-mailbox | 8 ++++---- 2 files changed, 20 insertions(+), 4 deletions(-) --- DIR diff --git a/geomyidae/postoffice/common b/geomyidae/postoffice/common @@ -1,5 +1,6 @@ #!/bin/sh +PUBKEYS="pubkeys" MAILBOXES="mailboxes" MAILROOM="mailroom" @@ -25,6 +26,11 @@ sanitize_message() { | head -c 16 } +find_handle_in_path() { + printf "%s" "$1" \ + | awk -F/ '{ print $4 }' +} + decode_and_verify_pubkey() { if [ -z "$1" ]; then printf "No input provided\n" @@ -47,3 +53,13 @@ decode_and_verify_pubkey() { printf "%s\n" "$decoded_payload" return 0 } + +encrypt_with_key_and_encode() { + # message to encrypt will be read from standard in + result=$( openssl pkeyutl -encrypt -inkey "$1" -pubin \ + | base64 -w 0 ) + printf "%s" "$result" + return $? +} + + DIR diff --git a/geomyidae/postoffice/create-mailbox b/geomyidae/postoffice/create-mailbox @@ -13,11 +13,10 @@ if [ ! $? ]; then printf "$result" return 1 fi -public_key="$result" +pubkey_content="$result" result=$( ./get-mailbox "$handle" ) -exit_code=$? -case $exit_code in +case $? in 0) printf "That mailbox already exists.\n" return 1 @@ -27,7 +26,8 @@ case $exit_code in return 1 ;; 2) - printf "%s\t%s\n" "$handle" "$base64_payload" >> "$MAILBOXES" + > "$MAILBOXES/$handle" + printf "%s\n" "$pubkey_content" > "$PUBKEYS/$handle" return 0 ;; *)