die "Keyfile doesn't have enough layers to be an onion"
fi
+hash_fields=$(awk '/^openssl-dgst / { print NF }' "$keyfile" | uniq )
+
if [[ "$mode" == e ]];then
first_layer=$num_layers
next_layer=-1
openssl_decrypt=""
+ if [[ "$hash_fields" != 4 ]];then
+ die "Refusing to encrypt with already-used key"
+ fi
else
first_layer=1
next_layer=1
openssl_decrypt="-d"
+ if [[ "$hash_fields" != 5 ]];then
+ die "Key does not appear to have been used for encryption (it has no embedded hashes). Refusing to decrypt."
+ fi
fi
function go() {