From 117d261a3882cb094db1bb8b8ac352ae2b45abba Mon Sep 17 00:00:00 2001 From: Jochen Hoenicke Date: Fri, 29 Apr 2016 15:32:18 +0200 Subject: [PATCH] Script to generate key and certificate --- firmware/u2f/genkeys.sh | 45 ++++++++++++++++++++++++++++++++ firmware/u2f/trezordevkey.pem | 5 ++++ firmware/u2f/u2f_keys.h | 48 +++++++++++++++++------------------ vendor/trezor-common | 2 +- vendor/trezor-crypto | 2 +- 5 files changed, 76 insertions(+), 26 deletions(-) create mode 100644 firmware/u2f/genkeys.sh create mode 100644 firmware/u2f/trezordevkey.pem diff --git a/firmware/u2f/genkeys.sh b/firmware/u2f/genkeys.sh new file mode 100644 index 0000000000..3bc7e5b10b --- /dev/null +++ b/firmware/u2f/genkeys.sh @@ -0,0 +1,45 @@ +#!/bin/bash + +cat > u2f_keys.h < + +const uint8_t U2F_ATT_PRIV_KEY[] = { +EOF + +if [ \! -e trezordevkey.pem ]; then + openssl ecparam -genkey -out trezordevkey.pem -name prime256v1 +fi +openssl ec -in trezordevkey.pem -text | + perl -e '$key = "\t"; while (<>) { + if (/priv:/) { $priv = 1 } + elsif (/pub:/) { $priv = 0 } + elsif ($priv) { + while ($_ =~ s/.*?([0-9a-f]{2})//) { + $key .= "0x$1,"; + if ($num++ % 8 == 7) { $key .= "\n\t"; } + else {$key .= " ";} + } + } + } + $key =~ s/,\s*$/\n/s; + print $key;' >> u2f_keys.h +cat >> u2f_keys.h <> u2f_keys.h + +cat >> u2f_keys.h <