Skip to content

Commit

Permalink
added pkcs#8 script
Browse files Browse the repository at this point in the history
  • Loading branch information
David Dornseifer authored and posix4e committed Feb 29, 2024
1 parent 7f65d29 commit 5cef17f
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions scripts/reassemble_pkcs8.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env bash
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: MIT-0

set -e
set +x

raw_key=$1

ASN1_PRIV_KEY_HEADER="302e0201010420"
ASN1_SECP256K1_OID="a00706052b8104000a"
OUT_FILE="priv_key.pkcs8"

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

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

#printf "asn1parse output:\n"
#openssl asn1parse -in "${OUT_FILE}"

0 comments on commit 5cef17f

Please sign in to comment.