2018-05-07 00:14:11 +00:00
|
|
|
#!/usr/bin/env python
|
2018-12-17 00:05:33 +00:00
|
|
|
#
|
|
|
|
# Copyright (C) 2018 SoloKeys, Inc. <https://solokeys.com/>
|
2019-01-03 13:27:21 +00:00
|
|
|
#
|
2018-12-17 00:05:33 +00:00
|
|
|
# This file is part of Solo.
|
2019-01-03 13:27:21 +00:00
|
|
|
#
|
2018-12-17 00:05:33 +00:00
|
|
|
# Solo is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
2019-01-03 13:27:21 +00:00
|
|
|
#
|
2018-12-17 00:05:33 +00:00
|
|
|
# Solo is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
2019-01-03 13:27:21 +00:00
|
|
|
#
|
2018-12-17 00:05:33 +00:00
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with Solo. If not, see <https://www.gnu.org/licenses/>
|
2019-01-03 13:27:21 +00:00
|
|
|
#
|
2018-12-17 00:05:33 +00:00
|
|
|
# This code is available under licenses for commercial use.
|
|
|
|
# Please contact SoloKeys for more information.
|
|
|
|
#
|
2018-05-07 00:14:11 +00:00
|
|
|
from __future__ import print_function
|
2019-01-03 13:27:21 +00:00
|
|
|
import sys, fileinput, binascii
|
|
|
|
|
2018-05-07 00:14:11 +00:00
|
|
|
try:
|
|
|
|
import ecdsa
|
|
|
|
except:
|
|
|
|
print('python ecdsa module is required')
|
|
|
|
print('try running: ')
|
|
|
|
print(' pip install ecdsa')
|
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
|
|
|
|
if len(sys.argv) not in [2]:
|
|
|
|
print('usage: %s <key.pem>' % sys.argv[0])
|
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
pemkey = sys.argv[1]
|
|
|
|
attestkey = ecdsa.SigningKey.from_pem(open(pemkey).read())
|
|
|
|
|
2018-05-12 03:20:10 +00:00
|
|
|
hstr = binascii.hexlify(attestkey.to_string())
|
|
|
|
print(hstr)
|
|
|
|
|
|
|
|
cstr = ''
|
|
|
|
it = iter(hstr)
|
|
|
|
for d1 in it:
|
|
|
|
d2 = next(it)
|
2019-01-03 13:27:21 +00:00
|
|
|
cstr += '\\x' + d1 + d2
|
2018-05-12 03:20:10 +00:00
|
|
|
|
|
|
|
print('"%s"' % cstr)
|