|
@@ -5,6 +5,7 @@ import cryptography.hazmat.primitives.serialization
|
|
|
import cryptography.x509
|
|
|
import math
|
|
|
|
|
|
+
|
|
|
def convert_to_sexp(data):
|
|
|
if isinstance(data, int):
|
|
|
return convert_to_sexp(data.to_bytes(
|
|
@@ -18,7 +19,8 @@ def convert_to_sexp(data):
|
|
|
else:
|
|
|
return b'(' + b''.join(convert_to_sexp(i) for i in data) + b')'
|
|
|
|
|
|
-def main(argv):
|
|
|
+
|
|
|
+def create_gpg_key():
|
|
|
backend = cryptography.hazmat.backends.default_backend()
|
|
|
with open('smartcard-app-id.hex', 'r') as f:
|
|
|
appid = int(f.read(), 16)
|
|
@@ -36,6 +38,22 @@ def main(argv):
|
|
|
with open('gpg-key.sexp', 'wb') as f:
|
|
|
f.write(key)
|
|
|
|
|
|
+
|
|
|
+def _init_argparser():
|
|
|
+ import argparse
|
|
|
+ argparser = argparse.ArgumentParser(
|
|
|
+ description='create a shadowed-private-key in sexp format for gnupg\'s private-keys-v1.d folder'
|
|
|
+ + ' containing the public key of a PEM-encoded X.509 certificate signing request (CSR)',
|
|
|
+ )
|
|
|
+ return argparser
|
|
|
+
|
|
|
+
|
|
|
+def main(argv):
|
|
|
+ argparser = _init_argparser()
|
|
|
+ args = argparser.parse_args(argv[1:])
|
|
|
+ create_gpg_key(**vars(args))
|
|
|
+ return 0
|
|
|
+
|
|
|
if __name__ == '__main__':
|
|
|
import sys
|
|
|
sys.exit(main(sys.argv))
|