Newer
Older
Import / applications / MakePDF / Build / tools / linux / mk-pubkey.sh
@John Ryland John Ryland on 22 Dec 2020 772 bytes import NUC files
#!/bin/bash

KEY_FILE=../Website/private-key.pem
PUB_FILE=.gen/public.key
GEN_FILE=.gen/PublicKey.h

# To extract the public key from the private key
openssl rsa -in "${KEY_FILE}" -pubout -out "${PUB_FILE}"
echo "" > "${GEN_FILE}"
echo "const char* publicModulus = " >> "${GEN_FILE}"
# Dump the contents of the public key
openssl asn1parse -in "${PUB_FILE}" -strparse 19 -offset 4 -length 261 | cut -d ':' -f 4 | fold -w 60 | sed 's/^/   "/' | sed 's/$/"/' >> "${GEN_FILE}"
echo -e ";\n" >> "${GEN_FILE}"
echo "const char* publicExponent = " >> "${GEN_FILE}"
# Dump the contents of the public key
openssl asn1parse -in "${PUB_FILE}" -strparse 19 -offset 265 | cut -d ':' -f 4 | fold -w 60 | sed 's/^/   "/' | sed 's/$/"/' >> "${GEN_FILE}"
echo -e ";\n" >> "${GEN_FILE}"