Skip to content

Instantly share code, notes, and snippets.

@alxndr42
Created October 3, 2019 18:47
Show Gist options
  • Save alxndr42/3f32b1b17e0aefa02a29e1bd4ac871eb to your computer and use it in GitHub Desktop.
Save alxndr42/3f32b1b17e0aefa02a29e1bd4ac871eb to your computer and use it in GitHub Desktop.
Creates v3 hidden service authorization files.
#!/bin/bash
if [ $# -ne 2 ]; then
echo "Usage: tor-onion-auth <onion_address> <client_name>"
echo ""
echo "Creates v3 hidden service authorization files."
exit
fi
ONION_ADDRESS=$(echo $1 | sed -e 's/\.onion//')
CLIENT_NAME=$2
PKEY=pkey.tmp
openssl genpkey -algorithm x25519 -out $PKEY
PRIVATE_KEY=$(openssl pkey -in $PKEY -outform DER | tail -c32 | base32 | tr -d '=')
PUBLIC_KEY=$(openssl pkey -in $PKEY -outform DER -pubout | tail -c32 | base32 | tr -d '=')
echo "$ONION_ADDRESS:descriptor:x25519:$PRIVATE_KEY" > "$CLIENT_NAME.auth_private"
echo "descriptor:x25519:$PUBLIC_KEY" > "$CLIENT_NAME.auth"
rm -f $PKEY
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment