Skip to content

Commit

Permalink
Changed outform to DER
Browse files Browse the repository at this point in the history
* Avoid additional key format conversion by storing reassembled key in `DER` format directly
  • Loading branch information
David Dornseifer authored and posix4e committed Feb 29, 2024
1 parent dea3ed3 commit 7f65d29
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions scripts/reassemble_asn1.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ raw_key=$1

ASN1_PRIV_KEY_HEADER="302e0201010420"
ASN1_SECP256K1_OID="a00706052b8104000a"
OUT_FILE="priv_key.pem"
OUT_FILE="priv_key.der"

if [ -z "${raw_key}" ]; then
echo "Usage: $1 $0 <private_key>"
exit 1
fi

openssl ec -inform DER -out "${OUT_FILE}" -in <(echo "${ASN1_PRIV_KEY_HEADER} ${raw_key} ${ASN1_SECP256K1_OID}" | xxd -r -p) &>/dev/null
openssl ec -inform DER -outform DER -out "${OUT_FILE}" -in <(echo "${ASN1_PRIV_KEY_HEADER} ${raw_key} ${ASN1_SECP256K1_OID}" | xxd -r -p) &>/dev/null
printf "private key successfully written to: %s\n" "${OUT_FILE}"

#printf "asn1parse output:\n"
Expand Down

0 comments on commit 7f65d29

Please sign in to comment.