#!/bin/sh

# fake openssl
while [ $# -gt 0 ]; do
	case "$1" in
		genpkey|req)
			cmd="$1"
			;;
		-config)
			shift
			config="$1"
			;;
		-out)
			shift
			outfile="$1"
			;;
		-outpubkey)
			shift
			outpubfile="$1"
	esac
	shift
done

case "$cmd" in
	genpkey)
		echo "writing key" >&2
		cat "$FAKEKEY" > "$outfile"
		cat "$FAKEKEYPUB" > "$outpubfile"
		;;
	req)
		echo "Using configuration from $config" >&2
		echo "Generating key with 4096 bits" >&2
		echo "Writing private key to '$outfile'" >&2
		cat "$FAKEKEY" "$FAKEKEYPUB" > "$outfile"
		;;
	*)
		echo "unimplemented fake openssl command: $cmd" >&2
		exit 1
		;;

esac

