🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: alt.privacy.anon-server
Article #327719

NEWSCARD * Publish and fetch permanent named records via Network News

#327719
From: Byrl Raze Buckbriar
Date: Sun, 09 Feb 2025 05:49
1180 lines
47472 bytes
* NEWSCARD * Publish and fetch permanent named records via Network News

Newscard creates a decentralized, named record pastebin.

[git repo] https://codeberg.org/OCTADE/newscard

* NEWSCARD VERSION 0.0.1.D *

* TABLE OF CONTENTS *

    1. NEWSCARD INFO
    2. NEWSCARD TIPS
    3. NEWSCARD HELP AND USAGE
    4. NEWSCARD TEST KEYS
    5. NEWSCARD SOURCE CODE (xz compressed base64)
    6. NEWSCARD SOURCE CODE (plain text)

* 1. NEWSCARD INFO *

  Author: Byrl Raze Buckbriar (https://octade.net) (news://alt.rhubarb)

  Newscard encrypts a local text file and publishes it via NNTP.
  The name assigned to the card is the address and passphrase.
  Anyone who knows the name or passphrase can retrieve the card.
  A very strong passphrase will keep the card content secret.
  Newscard uses nine layers of encryption and chain hashes that are
  derived from multiple hash streams and large, random salt.
  Use 'tuff' mode for very strong encryption passphrases.

  Try 'card help' for usage instructions.
  
  User License: Use solely at your own risk. By using this software the user
  agrees that the author has zero liability for any loss, harm, or damage.
  This software is 'doodleware' and not fit for any commercial purpose.
  The user has no rights whatsoever related to the use of this software
  or any thing arising from such use. The user must agree to this license
  to use the software. There is no support, guarantee, or warranty.

* 2. NEWSCARD TIPS *

Ways you can use newscard include:

1. Publishing and retrieving scripts, sources, and articles with a phrase.
2. Publishing a personal profile others can retrieve with a keyword.
3. Exchanging encrypted messages (using strong keys or 'tuff' mode).
4. Including newscard keys in signatures and articles.

Once published, a newscard remains a permanent record.

* 3. NEWSCARD HELP AND USAGE *

WARNING: Use 'tuff' mode for high security against decryption.
Tuff mode generates cards with high-security, strong passphrases.
Enc mode forces a minimum custom key size and still may be insecure.
Enc mode should be used if you want the public to decrypt the card.
Tuff mode should be used to prevent the public from reading the card.

show this help message           : card help
show some tips and use cases     : card tips
show author and license info     : card info
generate highly secure news card : card tuff [path|file]
generate news card via password  : card enc  [passphrase] [path|file]
fetch card from network          : card get  [passphrase]
publish card to network          : card put  [passphrase]
read text of local news card     : card show [passphrase]
list stored cards by folder      : card list [draft|queue|inbox|sent]

Author: Byrl Raze Buckbriar (https://octade.net) (news://alt.rhubarb)

* 4. NEWSCARD TEST KEYS *

Users may test the Newscard application by fetching these cards by key:

  sample1 | sample2 | sample3 | octade | newscard0

To fetch a card use the command: card get [key].

Examples below can be tried for cards that are already on the network:

 $~: card get newscard
 $~: card get 8
 $~: card get sample1

* 5. NEWSCARD SOURCE CODE (xz compressed base64) *

(commands to decompress: cat | base64 -d | unxz)

/Td6WFoAAATm1rRGAgAhARYAAAB0L+Wj4HGnIRZdABGIQkeKIzPDdw8z/VWX7afG1TtMjx4Klj/K
qRSaY/9mHLTgnv2rlXMCipeP3+asphkGaWjYbuUt7ZKSfeshGyfAt26iblkA1W4Y/w0EYc5jDh6y
1+wfKAYCyQWC6qrMlcVqDo0bE92XgP7Z7/RZSNWQ2lLHSp5RwundXOgSHqvSUFovHjdSe1HYxaUX
fUy7lwF9KqnLBcOzzi9zsfKvno3U5S5b6+XZAkGkDNBgRshVFt6GHB6rw2zCa7WPyyUWwWvd1NFl
h/4ldGC/8rCqwF8vhOihBN4oQZm1CDYQ5yy5cZwA0Nnt4L0pN7mL562GL2RMfppMoz/eiHTevUJO
Zspt7dB4cS0S5YZCcD9XZWfFj/2H8ogj5MUnCwqcy7FDb3EOkJYQ6bTMuJXWyzNBXC6EiI4h/Vdr
D53q3iId4JfFndN89j3vU/LlJFiRvzvxKh9MCc6tjoK7lHH+w0mA9OW6meJNlRXmlcW77/b1xAAJ
HpofGOnmEBw/RkTjer289olt6DsvI8JFxZkVj7XWVTeL0h8bm3sG3yOhJcl+Fh17DcDJrrv7jA8x
oJ2tgbdxHzcpJ6jzIKN7QZgKwhMwnrGCe8xTfDKopHdiejDOskxPNX7GTRV8XOtByF8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w/NLmvpGSpSO/7tkZyY3y+NjNS4doMH2dHB9ntq
JNal6aK/NAAAAAC86DJpQaDhlgABskKo4wEA2AMEjLHEZ/sCAAAAAARZWg==

6. NEWSCARD SOURCE CODE (plain text)

#!/usr/bin/env bash

# NEWSCARD VERSION 0.0.1.D - Use subject to license included below.
#        ▄▄▄ ▄▄▄ ▄▄▄ ▄▄▄ ▄▄  ▄▄▄
#        █ █ █    █  █ █ █ █ █▄▄     Byrl Raze Buckbriar
#        █▄█ █▄▄  █  █▀█ █▄▀ █▄▄     https://octade.net

# warning: this is a 'D' version for DOODLE. It is likely to have eventual regression in the key generation and card schema format--that breaks backward compatibility. The purpose of the doodle version is to test and generate feedback for improvement. Expect a final regression rendering existing newscards inaccessible to the final version.

# zombies: some unused code and paths here for future features. sections labeled 'zombie'.

# INSTALL: Copy to $PATH and make executable (chmod u+x).

# BEGIN.NEWSCARD

DIE() { echo "$@" && exit 0 ; }
ERR() { echo "CARD: ERR: $@" 1>&2 && exit 1 ; }

check_deps() {
deps="tor bash b2sum base64 echo fold grep head less nc openssl shuf tail tee tr whoami xxd xz"
for prog in $deps
do
[[ $(which $prog) == '' ]] && ERR "[DEP1] Program ($prog) not found." && exit 1
done
}

check_deps

HELPTEXT="* NEWSCARD HELP AND USAGE *

WARNING: Use 'tuff' mode for high security against decryption.
Tuff mode generates cards with high-security, strong passphrases.
Enc mode forces a minimum custom key size and still may be insecure.
Enc mode should be used if you want the public to decrypt the card.
Tuff mode should be used to prevent the public from reading the card.

show this help message           : card help
show some tips and use cases     : card tips
show author and license info     : card info
generate highly secure news card : card tuff [path|file]
generate news card via password  : card enc  [passphrase] [path|file]
fetch card from network          : card get  [passphrase]
publish card to network          : card put  [passphrase]
read text of local news card     : card show [passphrase]
list stored cards by folder      : card list [draft|queue|inbox|sent]

Author: Byrl Raze Buckbriar (https://octade.net) (news://alt.rhubarb)"

TIPSTEXT="* NEWSCARD TIPS *

Ways you can use newscard include:

1. Publishing and retrieving scripts, sources, and articles with a phrase.
2. Publishing a personal profile others can retrieve with a keyword.
3. Exchanging encrypted messages (using strong keys or 'tuff' mode).

Once published, a newscard remains a permanent record."

INFOTEXT="* NEWSCARD INFO *

  Author: Byrl Raze Buckbriar (https://octade.net) (news://alt.rhubarb)

  Newscard encrypts a local text file and publishes it via NNTP.
  The name assigned to the card is the address and passphrase.
  Anyone who knows the name or passphrase can retrieve the card.
  A very strong passphrase will keep the card content secret.
  Newscard uses nine layers of encryption and chain hashes that are
  derived from multiple hash streams and large, random salt.
  Use 'tuff' mode for very strong encryption passphrases.

  Try 'card help' for usage instructions.
  
  User License: Use solely at your own risk. By using this software the user
  agrees that the author has zero liability for any loss, harm, or damage.
  This software is 'doodleware' and not fit for any commercial purpose.
  The user has no rights whatsoever related to the use of this software
  or any thing arising from such use. The user must agree to this license
  to use the software. There is no support, guarantee, or warranty."


show_help() { DIE "$HELPTEXT" ; } # FIN.
show_info() { DIE "$INFOTEXT" ; } # FIN.
show_tips() { DIE "$TIPSTEXT" ; } # FIN.

# non-global variables: session

# global variables : TODO : zombies for future features
declare -g arg1 arg2 arg3 arg4 arglen
declare -g pp1 pp2 passphrase hash msgid subid keyid
declare -g filename mode flag article msg newmsg mray stripcard
declare -g nzconf nzlogs nzmani nzpath nzprox nzqqqq zdraft narxiv nzread nzsent nzserv nzuser nzwarn
declare -g iter=() salt=() hashphrase=()
declare -g x inum bigsalt encsalt
declare -g newserv port logfile logtrunc
declare -g config_data proxy_data warn_data
declare -g prefix version
declare -g cip pak
declare -g listfolder

prefix="NEWSCARD"
version="0.0.1.D"

arglen=${#@}

# push command arguments to global variables
arg1="$1" ; arg2="$2" ; arg3="$3" ; arg4="$4"

# exit if too many arguments found
[[ "$arg4" != '' ]] && ERR "[ARG4] Too many arguments. Try mode 'help'."
[[ $arglen -gt 3 ]] && ERR "[ARG3] Too many arguments. Try mode 'help'." # edge case zombie code

mode=$arg1 # arg1 must always be a valid mode selector word

set_mode() {
# zombie : future refactoring, so some of these modes are not enabled
# valid modes : enc, dec, get, put, show, list, delete, put_unencrypted, save, export, help
# read the first command argument
[[ "$mode" == "help" ]] && show_help
[[ "$mode" == "info" ]] && show_info
[[ "$mode" == "tips" ]] && show_tips
[[ "$mode" == "enc" ]] && flag='true'
[[ "$mode" == "tuff" ]] && flag='true'
[[ "$mode" == "dec" ]] && flag='true'
[[ "$mode" == "get" ]] && flag='true'
[[ "$mode" == "put" ]] && flag='true'
[[ "$mode" == "show" ]] && flag='true'
[[ "$mode" == "list" ]] && flag='true'
#[[ "$mode" == "delete" ]] && flag='true' # zombie
#[[ "$mode" == "put_unencrypted" ]] && flag='true' # zombie
#[[ "$mode" == "save" ]] && flag='true' # zombie
#[[ "$mode" == "export" ]] && flag='true' # zombie
#[[ "$mode" == "pix" ]] && flag='true' # zombie
#[[ "$mode" == "send" ]] && flag='true' # zombie

# check for a valid mode before continuing
[[ "$flag" != 'true' ]] && ERR "[FLAG1] Invalid mode selection ($mode) or wrong # of arguments. Try mode 'help'."

# check for correct number of commandline arguments for mode
[[ "$mode" == "enc" ]] && [[ $arglen -ne 3 ]] && flag='false'
[[ "$mode" == "tuff" ]] && [[ $arglen -ne 2 ]] && flag='false'
[[ "$mode" == "dec" ]] && [[ $arglen -ne 2 ]] && flag='false'
[[ "$mode" == "get" ]] && [[ $arglen -ne 2 ]] && flag='false'
[[ "$mode" == "put" ]] && [[ $arglen -ne 2 ]] && flag='false'
[[ "$mode" == "show" ]] && [[ $arglen -ne 2 ]] && flag='false'
[[ "$mode" == "list" ]] && [[ $arglen -ne 2 ]] && flag='false'
# zombie : future refactoring
#[[ "$mode" == "delete" ]] && [[ $arglen -ne 2 ]] && flag='false' # zombie
#[[ "$mode" == "put_unencrypted" ]] && [[ $arglen -ne 3 ]] && flag='false' # zombie
#[[ "$mode" == "save" ]] && [[ $arglen -ne 3 ]] && flag='false' # zombie
#[[ "$mode" == "export" ]] && [[ $arglen -ne 2 ]] && flag='false' # zombie
#[[ "$mode" == "pix" ]] && [[ $arglen -ne 2 ]] && flag='false' # zombie

[[ "$flag" == 'false' ]] && ERR "[FLAG2] Wrong # of arguments for mode ($mode). Try mode 'help'."

# copy command argument parameters to variables based upon mode
[[ "$mode" == "enc" ]] && passphrase=$arg2 && filename=$arg3 # && echo $arg3 && echo $filename && exit
[[ "$mode" == "tuff" ]] && passphrase='' && filename=$arg2 # && echo $arg3 && echo $filename && exit
[[ "$mode" == "dec" ]] && passphrase=$arg2
[[ "$mode" == "get" ]] && passphrase=$arg2
[[ "$mode" == "put" ]] && passphrase=$arg2 && filename=$arg3
[[ "$mode" == "show" ]] && passphrase=$arg2
# zombie : future refactoring
#[[ "$mode" == "delete" ]] && passphrase=$arg2 # zombie
#[[ "$mode" == "put_unencrypted" ]] && passphrase=$arg2 && filename=$arg3 # zombie
#[[ "$mode" == "save" ]] && passphrase=$arg2 && filename=$arg3 # zombie
#[[ "$mode" == "export" ]] && passphrase=$arg2 && filename=$arg3 # zombie
#[[ "$mode" == "pix" ]] && exit # zombie
}

set_mode # TODO need to position so it can be removed from functions below

check_filename() { # TODO refactor or delete since filename is passed now
# read file path to variable if mode includes file
[[ ! -f $filename ]] && ERR "[FILE1] File not found." && exit 1
}

check_filesize() { # TODO refactor or delete since filename is passed now
# read file path to variable if mode includes file
[[ ! -f $filename ]] && ERR "[FILE2] File not found." && exit 1
filesize=$(cat "$filename" | wc -c | tr -dc 0-9)
[[ $filesize -gt 65536 ]] && ERR "[SIZE1] File size ($filesize) exceeds maximum (65536 bytes)." && exit 1
}

check_newscard_exists() { # TODO : zombie
# read file path to variable if mode includes file
[[ -f "$zdraft/$passphrase" ]] && ERR "[CNE1] A draft card already exists for this passphrase." && exit 1
[[ -f "$zinbox/$passphrase" ]] && ERR "[CNE2] A inbox card already exists for this passphrase." && exit 1
[[ -f "$nzqqqq/$passphrase" ]] && ERR "[CNE3] A queue card already exists for this passphrase." && exit 1
[[ -f "$nzsent/$passphrase" ]] && ERR "[CNE4] A sent card already exists for this passphrase." && exit 1
[[ -f "$narxiv/$passphrase" ]] && ERR "[CNE5] An archive card already exists for this passphrase." && exit 1
[[ -f "$nzhist/$passphrase" ]] && ERR "[CNE6] An history card already exists for this passphrase." && exit 1
# TODO : add method to check history and confirmed publish lists
}

# network connections - for now only torconn is used to force privacy.
# zombie : future refactoring
sslconn() {
logfile=$nzconn
openssl s_client -quiet -connect $newserv:$port >> $logfile 2>&1 # TODO : s_client info mucks up parsing
logtrunc=$(cat "$logfile" | tail -n 4096)
echo "$logtrunc" > "$logfile"
}

# zombie : future refactoring
telconn() {
nc $newserv $port >> $logfile 2>&1 # s_client info mucks up parsing
logtrunc=$(cat "$logfile" | tail -n 4096)
echo "$logtrunc" > "$logfile"
} # TODO zombie code

torconn() {
# TODO : add authentication credential parsing
logfile=$nzconn
newserv=$(cat $nzserv | grep -v '#' | grep ':server:' | tail -n 1 | cut -d ':' -f3- | tr -d ' ')
port=$(cat $nzserv | grep -v '#' | grep ':port:' | tail -n 1 | cut -d ':' -f3- | tr -d ' ')

timeout 20 torsocks openssl s_client -quiet -verify_quiet -connect $newserv:$port | tee -a $logfile # 2>/dev/null # 2>&1 # TODO : s_client info mucks up parsing
logtrunc=$(cat "$logfile" | tail -n 4096)
echo "$logtrunc" > "$logfile"
}

# Check for config directory. Create directory and missing config files.
set_conf_data() {
config_data=":server: paganini.bofh.team
:port: 563
# username:
# password:
"
echo "$config_data" > $nzserv
}

set_prox_data() {
# TODO : zombie
proxy_data="# host: 127.0.0.1
# port: 9050
"
echo "$proxy_data" > $nzprox
}

set_warn_data() {
warn_data="
           --------------------------------
            WARNING! README! INSTRUCTIONS!
           --------------------------------

This folder contains the configuration files for the newscard application.

If you do not know exactly what you are doing then you should not change
any of these files. If you change the files in this folder you may break
the application and cause errors or data loss. The file names are cipher
keys and thus changing the file names will make decryption impossible.

The program author WILL NOT respond to requests regarding broken configuration.
The only way to fix a broken configuration is to re-install the program. This
will likely result in the loss of all data. Back up your keycard passphrases
and files regularly to prevent losing access to your files.

           ----------------------------------
            ABOUT THESE CONFIGURATION FOLDERS
           ----------------------------------

    config  : configuration files (see below)
    draft   : unpublished newscards
    inbox   : downloaded newscards
    queue   : newscards waiting to be sent
    sent    : published newscards
    archive : archived newscards (not shown via inbox view)

           ---------------------------------
            ABOUT THESE CONFIGURATION FILES
           ---------------------------------

    newscard.server     : NNTP server settings
    newscard.proxy      : proxy settings
    newscard.manifest   : component configuration data
    newscard.log        : activity and error logs
"

echo "$warn_data" > $nzwarn
echo "$warn_data" > $nzread
}

set_nzpaths() {
# Set paths for functions to write and read files
nzuser=$(whoami)
nzpath="/home/$nzuser/.newscard"

# Message directories
nzsent="$nzpath/sent"
zinbox="$nzpath/inbox"
nzqqqq="$nzpath/queue"
zdraft="$nzpath/draft"
narxiv="$nzpath/archive"
nzhist="$nzpath/history"

# Configuration files
nzconf="$nzpath/config"
nzserv="$nzconf/newscard.server"
nzprox="$nzconf/newscard.proxy"
nzmani="$nzconf/newscard.manifest"
nzlogs="$nzconf/newscard.log"
nzconn="$nzconf/connect.log"

# Warning files
nzread="$nzpath/WARNING.README"
nzwarn="$nzconf/WARNING.README"
}

# zombie : future refactoring
create_config() {
[[ ! -d $nzpath ]] && mkdir $nzpath && chmod 0700 $nzpath
[[ ! -d $nzconf ]] && mkdir $nzconf && chmod 0700 $nzconf
[[ ! -f $nzserv ]] && set_conf_data && chmod 0600 $nzserv
[[ ! -f $nzmani ]] && touch $nzmani && chmod 0600 $nzmani
[[ ! -f $nzlogs ]] && touch $nzlogs && chmod 0600 $nzlogs
[[ ! -f $nzconn ]] && touch $nzconn && chmod 0600 $nzconn
[[ ! -f $nzprox ]] && set_prox_data && chmod 0600 $nzprox
[[ ! -d $nzsent ]] && mkdir $nzsent && chmod 0700 $nzsent
[[ ! -d $zinbox ]] && mkdir $zinbox && chmod 0700 $zinbox
[[ ! -d $zdraft ]] && mkdir $zdraft && chmod 0700 $zdraft
[[ ! -d $nzqqqq ]] && mkdir $nzqqqq && chmod 0700 $nzqqqq
[[ ! -d $narxiv ]] && mkdir $narxiv && chmod 0700 $narxiv
[[ ! -d $nzhist ]] && mkdir $nzhist && chmod 0700 $nzhist
[[ ! -f $nzwarn ]] && set_warn_data && chmod 0600 $nzwarn
}

set_list_paths() {
# Set paths for functions to write and read files
nzuser=$(whoami)
nzpath="/home/$nzuser/.newscard"

# Message directories (zombie)
nzsent="$nzpath/sent"
zinbox="$nzpath/inbox"
nzqqqq="$nzpath/queue"
zdraft="$nzpath/draft"
narxiv="$nzpath/archive"
nzhist="$nzpath/history"
}

check_config_folder() {
nzpath="/home/code/.newscard"
[[ ! -d $nzpath ]] && echo "Newscard config not found at '$nzpath'. Creating config now." && set_nzpaths && create_config
}

# Create configuration if not present.
check_config_folder

check_passphrase() {
passphrase=$arg2 # arg vars work but passphrase global doesn't work
pp1="$passphrase"
pp2=$(echo "$pp1" | tr -dc A-Za-z0-9.@#+=_\\-~)
[[ "$pp1" != "$pp2" ]] && ERR "[PP12] Invalid passphrase. Valid characters are 'A-Za-z0-9.@#+=_-~'."
[[ ${#pp1} -gt 255 ]] && ERR "[PP255] Invalid passphrase. Passphrase must be less than 255 chars."
}

# Extra random generation for salts.
ts() {
echo "$(date +%N)$(date +%N)$(date +%N)$(date +%N)" | fold -w 1 | shuf | tr -dc 0-9
}

timestamp() {
echo $(ts)$(ts)$(ts)$(ts)$(ts)$(ts)$(ts)$(ts) | fold -w 1 | shuf | tr -dc 0-9
}

minesalt() {
bigsalt=$(timestamp)
bigsalt=$(head -c 2048 /dev/urandom | xxd -p | fold -w 1 | shuf -n 1023 | sivhex | trisum)$bigsalt
bigsalt=$(echo -n "$bigsalt" | fold -w 1 | shuf | sivhex | trisum)
}

# encoding and conversion functions (some zombie code for future refactoring)
enchex() { xxd -p -r ; }
dechex() { xxd -p -c 0 ; }
encb64() { base64 -w 0 ; }
decb64() { base64 -d ; }
sivhex() { tr -dc a-f0-9 ; } # clean hashes of non-hex chars
sivb62() { tr -dc A-Za-z0-9 ; }
smoosh() { xz -q -F raw ; }
unmash() { xz -d -q -F raw ; }
bzoosh() { bzip2 -q ; } # better small file compression on single core
b64toz() { tr '=' '@' | tr '+' '#' | tr '/' '$' ; }
ztob64() { tr '@' '=' | tr '#' '+' | tr '$' '/' ; }
fmtmsg() { fold -w 13 | tr '\n' ' ' | fold -w 71 ; }

# chain hash stream without for loops
beesum() { b2sum ; }
onesum() { beesum | sivhex ; }
trisum() { onesum | onesum | onesum ; }
ninsum() { trisum | trisum | trisum ; }
bigsum() { ninsum | ninsum | ninsum ; } # chain hash 81x to resist search

# global hash stream
nexsum() { hash=$(echo -n $hash | trisum) ; }

# generate NNTP Message-ID
gen_msgid() { # mast pass global to this function
# generate base62 message-id to identify either message or file
# communicants can use a custom secret keyid here for out-of band security
keyid="$msgid" # newscard.default.keyid (change for secret networks)
msgid="$keyid$msgid$keyid" # never change this!
# any change in this method will regress fetch of all prior newscards
# this must be done before forking the hash stream with big salt
msgid=$(echo -n "$msgid$msgid$msgid" | bigsum) # clone expand msgid
msgid=$(echo -n $msgid | xxd -p -r | base64 -w 0 | sivb62 | tail -c 43)
subid=$msgid # for the NNTP subject header
msgid="<$msgid@news.card>"
}

# read the user-supplied passphrase and save for later naming and decryption
get_pass_hash() {
hash="$passphrase"
}

# superencryption routine using 9 keys and 9 salts.
generate_credentials() {
# declare some sets
iter=() ; salt=() ; hashphrase=()

# get encryption params for bigsalt before we salt and fork the hash stream
nexsum ; salt[0]=${hash:0:16}
nexsum ; hashphrase[0]=$hash
nexsum
inum=${hash:0:3}
inum=$(printf '%d' 0x$inum)
inum=$((10#$inum))
iter[0]=$((16384+inum))

# SALT MODES : if mode generate mix random big salt only in encrypt mode
[[ "$mode" == 'enc' ]] && bigsalt=$(head -c 1023 /dev/urandom | xxd -p | fold -w 1 | shuf -n 1023 | sivhex | trisum)
[[ "$mode" == 'tuff' ]] && bigsalt=$(head -c 64 /dev/urandom | xxd -p -c 0 | tr -dc a-f0-9) # careful not to advance keygen
[[ "$mode" == 'dec' ]] && dec_salt
[[ "$mode" == 'show' ]] && dec_salt

# combine random salt with passphrase
hash="$hash$bigsalt"

# encrypt the salt for the output message
# derive pseudorandom cipher iterations
for x in {1..9}
do
nexsum
inum=${hash:0:3}
inum=$(printf '%d' 0x$inum)
inum=$((10#$inum))
iter[$x]=$((16384+inum))
done

# derive stream of salts from passphrase
for x in {1..9}
do
nexsum
salt[$x]=${hash:0:16}
done # for x

# generate stream of hashphrases
for x in {1..9}
do
nexsum
hashphrase[$x]=$hash
done # for x
} # generate_credentials

# encrypt or decrypt the input stream
pak='-e'
cip='-chacha20'

# superencipher the message with nine each of keys, salts, iterations.
e() { openssl enc $pak $cip -iter "${iter[$1]}" -S "${salt[$1]}" -pass pass:"${hashphrase[$1]}" ; }

# tunnel 9 encryption streams
e9() { e 1 | e 2 | e 3 | e 4 | e 5 | e 6 | e 7 | e 8 | e 9 ; }

# encrypt the big salt
enc_salt() {
encsalt=$(echo -n $bigsalt | xxd -p -r | e 0 | base64 -w 0 | tr '=' '@' | tr '+' '#' | tr '/' '$')
}

# snarf encrypted salt from the message
get_salt() {
bigsalt="$(echo "$msg" | grep '*' | tr -d ' ' | tr -d '\n' | tr '*' '\n' | grep '@' | head -n 1 | tr -d '\n')"
}

# decrypt the salt needed for hash key stream generation
dec_salt() {
bigsalt="$(echo -n "$bigsalt" | base64 -d | e 0 | xxd -p -c 0 | tr -dc a-f0-9)"
}

encrypt_b64() {
# TODO : check filename exists
#check_filename
msg=$(cat "$filename" | smoosh | e9 | base64 -w 0)
}

convert_b64_z64() {
msg=$(echo -n "$msg" | tr '=' '@' | tr '+' '#' | tr '/' '$')
}

convert_b64z_b64() {
msg=$(echo -n "$msg" | tr '@' '=' | tr '#' '+' | tr '$' '/')
}

convert_salt_b64z_b64() {
bigsalt=$(echo -n "$bigsalt" | tr '@' '=' | tr '#' '+' | tr '$' '/')
}

# TODO perhaps write to file or check for file to cat before decrypt
decrypt_b64() {
newmsg=$(echo -n "$newmsg" | base64 -d | e9 | unmash)
} # notice passing of $newmsg instead of $msg

assemble_payload() {
msg=$(echo -n "* $prefix * $version * $encsalt * $msg@" | fold -w 13 | tr '\n' ' ' | fold -w 71)
} # elegant but this version will resist extensions later

# TODO : zombies for future refactoring.
# check_existing_msgid() { echo TODO ; } # zombie
# confirm_article_post() { echo TODO ; } # zombie
# copy_draft_to_queue()  { echo TODO ; } # zombie
# remove_posted_queue()  { echo TODO ; } # zombie
# get_remote_card_body() { echo TODO ; } # zombie
# copy_remote_to_inbox() { echo TODO ; } # zombie
# delete_by_passphrase() { echo TODO ; } # zombie
# export_by_passphrase() { echo TODO ; } # zombie
# delete_sent_article()  { echo TODO ; } # zombie

compose_nntp_article() { # FIN.
# construct NNTP article for publishing
article="MODE READER
POST
MESSAGE-ID: $msgid
NEWSGROUPS: alt.cypher
FROM: News Card $msgid
SUBJECT: @NEWSCARD@$subid

$msg
.
quit"
}

save_composed_article() { # FIN.
# split into three functions or three passed flags for make, put, fetch
echo "$article" > "$nzqqqq/$passphrase" # drop in the queue
}

save_composed_draft() { # FIN.
echo "$msg" > "$zdraft/$passphrase" # save just the newscard formatted message locally
}

sanitize_message() { # FIN. # TODO disable variable expansion
declare -g msg
msg=$(echo -n "$msg" | tr -dc 'A-Za-z0-9#$+.*@ \n') # must cat to prevent variable expansion of $ attack (convert base?)
}

parse_article() { # FIN. # need just the body of the article, not the NNTP headers
declare -g mray
declare -g msg
set_nzpaths
check_passphrase
# check drafts, outbox, queue, inbox, sent, archive for newscard file
[[ -f "$zdraft/$passphrase" ]] && draft_flag=true || draft_flag=false
[[ -f "$zinbox/$passphrase" ]] && inbox_flag=true || inbox_flag=false
# warn and exit if file not found
[[ $draft_flag == 'false' ]] && [[ $inbox_flag == 'false' ]] && ERR "[FP1] No file exists for passphrase: $passphrase" && exit 1

# use flags to choose the available file to parse
[[ $inbox_flag == 'true' ]] && msg=$(cat "$zinbox/$passphrase") || msg=$(cat "$zdraft/$passphrase")
# TODO : need to properly manage draft location based on mode and set 0600 perms

# clean invalid chars and carriage returns
msg=$(echo -n "$msg" | tr -d '\r')

mray=()
mray=($(echo -n "$msg" | tr -d ' ' | tr -d '\n' | tr '*' ' '))
encsalt=${mray[2]} # pass check done
newmsg=${mray[3]} # get new message to convert to regular base64
}

decode_z64_message() { # FIN.
tr -d ' ' | tr -d '\n' | tr '@' '=' | tr '#' '+' | tr '$' '/'
}

strip_salt_tail_z64() { # FIN.
ats=$(echo -n "$bigsalt" | tr -dc '@')
atlen=${#ats}
atlen=$((atlen-1))
ats=$(echo -n "$ats" | head -c $atlen)
bigsalt="$(echo -n "$bigsalt" | tr -d '@')"
bigsalt="$bigsalt$ats"
}

strip_newmsg_tail_z64() { # FIN.
ats=$(echo -n "$newmsg" | tr -dc '@')
atlen=${#ats}
atlen=$((atlen-1))
ats=$(echo -n "$ats" | head -c $atlen)
newmsg="$(echo -n "$newmsg" | tr -d '@')"
newmsg="$newmsg$ats"
} # get that pesky extra '@' that probably should have been a '*' (TODO)

# TODO check to ensure proper article format and newscard payload format
# use when publishing and fetching
# check_composed_article() {}
# check_received_article() {}

gen_tuff_params() {
# mix timestamps and shuffles with PRNG data then whiten with hashing.
passphrase=$(echo "$(date +%N)$(date +%N)$(date +%N)$(date +%N)" | fold -w 1 | shuf | sivhex | onesum)$passphrase
for tuff_rounds in {1..9}
do
passphrase=$(echo "$(date +%N)$(date +%N)$(date +%N)$(date +%N)" | onesum)$passphrase
passphrase=$(echo "$RANDOM$RANDOM$RANDOM$RANDOM$RANDOM$RANDOM" | onesum)$passphrase
passphrase=$(head -c 32 /dev/urandom | xxd -p -c 0)$passphrase
passphrase="$(echo -n $passphrase | fold -w 1 | shuf | sivhex | onesum)$passphrase"
passphrase="$(echo -n $passphrase | fold -w 1 | shuf | sivhex | tail -c 1024)"
done

passphrase=$(echo -n "$passphrase" | onesum | xxd -p -r | base64 | sivb62)
passphrase=$(echo -n "$passphrase" | fold -w 1 | shuf | sivb62 | head -c 43)

# shift the argument values for tuff make card function
arg3=$arg2
arg2=$passphrase
}

makemsg() { # FIN.
[[ "$mode" == "tuff" ]] && gen_tuff_params

passphrase=$arg2
msgid=$arg2
hash=$arg2
filename=$arg3

check_filename # check filename exists
check_filesize # enforce maximum size limit

set_nzpaths
check_newscard_exists
check_passphrase
gen_msgid
get_pass_hash
generate_credentials
enc_salt

encrypt_b64
convert_b64_z64
assemble_payload # generate message for var 'msg'
save_composed_draft

DIE "Created newscard : $passphrase : article in draft folder. Use 'put' to publish."
}

decrypt_msg() { # FIN.
passphrase=$arg2
msgid=$arg2
hash=$arg2
filename=$arg3

declare -g newmsg
declare -g mray
declare -g bigsalt
declare -g encsalt

set_nzpaths
check_passphrase
gen_msgid
get_pass_hash

parse_article # get message segments
get_salt
convert_salt_b64z_b64
generate_credentials

strip_newmsg_tail_z64

newmsg=$(echo -n "$newmsg" | decode_z64_message)

decrypt_b64
}

show_newscard() { # FIN.
decrypt_msg
(echo "NEWSCARD : $passphrase" ; echo ; echo "$newmsg") | less -R
DIE
}

# zombie: unfinished function
send_queue() {
# iterate through queue files and push to nntp server
set_nzpaths
check_passphrase
gen_msgid
echo "$msgid"
exit 0
} # TODO

# publish a single queued draft instead of whole queue
# move from queue to sent folder
publish() {
declare -g msg
passphrase=$arg2
msgid=$arg2
set_nzpaths
check_passphrase

# check for file in drafts
[[ ! -f "$zdraft/$passphrase" ]] && ERR "[D1] No draft found for passphrase ($passphrase)." && exit 1
msg=$(cat "$zdraft/$passphrase")
gen_msgid # TODO only generate draft on enc then nntp message later, or both at once?

compose_nntp_article
echo "$article" > "$nzqqqq/$passphrase"
#session=$(cat "$nzqqqq/$passphrase" | torconn)
cat "$nzqqqq/$passphrase" | torconn

exit # zombie below

# TODO : check for received response or error in session variable
# then check again for hdr <message-id>
# check for (stat) 430 No such article
# clean this up to get a good check via stat, and retry at least 3 times before giving up
# TODO : if msgid is found, fetch to inbox, compare to draft, then move the draft to archive and the queued to sent
# TODO : list each successful publish in history publish file.
exists=$(echo "ARTICLE $msgid" | torconn)
# TODO : several success checks then move from queue to sent
echo "$exists" | grep -i "430 No such article" # TODO : convert to trap
echo "$exists" | grep "$msgid"
exit 0
} # TODO: finish the checks and confirmation and file move to sent

fetch() {
declare -g msg
passphrase=$arg2
msgid=$arg2
set_nzpaths
check_passphrase

# check for file in drafts and inbox and exit if exists
[[ -f "$zdraft/$passphrase" ]] && ERR "[F1] Card for ($passphrase) already exists in drafts." && exit 1
[[ -f "$zinbox/$passphrase" ]] && ERR "[F2] Card for ($passphrase) already exists in inbox." && exit 1
[[ -f "$nzqqqq/$passphrase" ]] && ERR "[F3] Card for ($passphrase) already exists in queue." && exit 1

gen_msgid

# NNTP commands to status check for existence of message-id.
msg="mode reader
stat $msgid
quit
quit"

nntpout=$(echo -n "$msg" | torconn)

check200=$(echo -n "$nntpout" | head -c 3)

[[ $check200 != 200 ]] && ERR "[F5] Invalid server response. Check network." && exit 1

check223=$(echo -n "$nntpout" | grep '223' | grep -i 'stat' | grep "$msgid" | head -c 3)
[[ $check223 != 223 ]] && ERR "[F6] Article not found for ($passphrase)." && exit 1

# If this point is reached server has verified existence of article.
# NNTP commands to request article body.
msg="mode reader
body $msgid
quit
quit"

nntpout=$(echo -n "$msg" | torconn)

check200=$(echo -n "$nntpout" | head -c 3)
[[ $check200 != 200 ]] && ERR "[F7] Invalid server response. Check network." && exit 1

artcheck=$(echo -n "$nntpout" | grep -c NEWSCARD | tr -dc 0-9)
[[ ! $artcheck -gt 0 ]] && ERR "[F8] No valid card found for ($passphrase)." && exit 1

# NewsCard body response found; strip nntp server responses.

stripcard=''
body222='false' # using string instead of boolean int
bodydot='false'

# Strip all non-card lines from article body.
while IFS= read -r line # Preserve leading and trailing spaces.
do
[[ "${line:0:1}" == '.' ]] && bodydot='true' && body222='false' # Stop building output when single dot line found.
[[ "$body222" == 'true' ]] && [[ "$bodydot" == 'false' ]] && stripcard=$(echo "$stripcard" ; echo "$line")
[[ "${line:0:3}" == "222" ]] && [[ $(echo "$line" | grep -c "$msgid") -eq 1 ]] && body222='true'
done < <(echo "$nntpout" | head -n 16384)

# Save the fetched article to inbox.
echo "$stripcard" > "$zinbox/$passphrase"

# Confirm and exit.
DIE "NewsCard for ($passphrase) saved to inbox." && exit 0
}

# zombie : future refactoring
# list_cards() { echo TODO unfinished function ; }
# list_inbox() { echo TODO unfinished function ; }
# list_archive() { echo TODO unfinished function ; }
# list_sent() { echo TODO unfinished function ; }

list_drafts() {
# ensure valid argument
foldermatch='false'
for fpath in draft inbox queue sent
do
[[ "$arg2" == "$fpath" ]] && foldermatch='true'
done # fpath

[[ $foldermatch == 'false' ]] && ERR "[FM1] Invalid argument ($arg2). Try 'card help'."

set_list_paths
[[ "$arg2" == 'inbox' ]] && listfolder="$zinbox"
[[ "$arg2" == 'draft' ]] && listfolder="$zdraft"
[[ "$arg2" == 'queue' ]] && listfolder="$nzqqqq"
[[ "$arg2" == 'sent' ]] && listfolder="$nzsent"

# Drop to subshell and pipe to less
(echo "* NEWSCARD * $arg2 * LISTING of $listfolder - 'Q' to quit."
echo
ls "$listfolder"
echo) | less
exit 0
}

# list drafts
[[ "$mode" == "list" ]] && list_drafts && exit 0

# check for existing file
[[ "$mode" == "enc" ]] && check_filename
[[ "$mode" == "tuff" ]] && check_filename

# check the mode and run the matching operations
[[ "$mode" == 'show' ]] && show_newscard && exit 0
[[ "$mode" == "enc" ]] && makemsg && exit 0

# unfinished
#[[ "$mode" == "send" ]] && send_queue && exit 0 # zombie
[[ "$mode" == "put" ]] && publish && exit 0
[[ "$mode" == "get" ]] && fetch && exit 0
[[ "$mode" == "tuff" ]] && makemsg && exit 0 # gen_tuff_params check inside makemsg

# END.NEWSCARD

#        ▄▄▄ ▄▄▄ ▄▄▄ ▄▄▄ ▄▄  ▄▄▄
#        █ █ █    █  █ █ █ █ █▄▄     Byrl Raze Buckbriar
#        █▄█ █▄▄  █  █▀█ █▄▀ █▄▄     https://octade.net

-- 
 = OCTADE = https://soc.octade.net/octade =
Technical Details
Message-ID: <1d2c5cae22717dcc851d9832dc2978e5$1@octade.net>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!i2pn2.pugleaf.net!archive.newsdeef.eu!archive!apf2.newsdeef.eu!not-for-mail

Show Full Headers
Complete Article Headers
Message-ID: <1d2c5cae22717dcc851d9832dc2978e5$1@octade.net>
Subject: NEWSCARD * Publish and fetch permanent named records via Network News
Date: Sat, 8 Feb 2025 23:49:22 -0600
From: Byrl Raze Buckbriar <news0@octade.net>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!i2pn2.pugleaf.net!archive.newsdeef.eu!archive!apf2.newsdeef.eu!not-for-mail
Newsgroups: alt.cypherpunks,alt.privacy.anon-server,sci.crypt
Organization: OCTADE
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
Injection-Info: i2pn2.org; logging-data="3383652"; mail-complaints-to="usenet@i2pn2.org"; posting-account="OI6weT9bZt7saiRF3+XsJJTIMUPjpyh/q6ChV6DtztU";
User-Agent: OCTADE
X-Spam-Checker-Version: SpamAssassin 4.0.0
X-Newsreader: OCTADE