[Cryptech-Commits] [sw/stm32] branch ksng updated: Add debugging code to cryptech_upload.

git at cryptech.is git at cryptech.is
Fri Nov 25 17:51:58 UTC 2016


This is an automated email from the git hooks/post-receive script.

sra at hactrn.net pushed a commit to branch ksng
in repository sw/stm32.

The following commit(s) were added to refs/heads/ksng by this push:
     new c28f77d  Add debugging code to cryptech_upload.
c28f77d is described below

commit c28f77d75105a31555c0eb45f45c76675248032f
Author: Rob Austein <sra at hactrn.net>
AuthorDate: Fri Nov 25 12:51:29 2016 -0500

    Add debugging code to cryptech_upload.
---
 projects/hsm/cryptech_upload | 27 ++++++++++++++++++++-------
 1 file changed, 20 insertions(+), 7 deletions(-)

diff --git a/projects/hsm/cryptech_upload b/projects/hsm/cryptech_upload
index 0c3f6fc..6cf1283 100755
--- a/projects/hsm/cryptech_upload
+++ b/projects/hsm/cryptech_upload
@@ -105,16 +105,28 @@ def parse_args():
                         type = argparse.FileType("rb"),
                         help = "Explicit source image file for upload, overrides firmware tarball")
 
+    parser.add_argument("--separate-pins",
+                        action = "store_true",
+                        help = "Prompt separately for each PIN required during upload")
+
+    parser.add_argument("--debug",
+                        action = "store_true",
+                        help = "Enable debugging of upload protocol",
+                        )
+
     return parser.parse_args()
 
 
 def _write(dst, data):
+    numeric = isinstance(data, (int, long))
+    if numeric:
+        data = struct.pack("<I", data)
     dst.write(data)
-    #if len(data) == 4:
-    #    print("Wrote 0x{!s}".format(data.encode("hex")))
-    #else:
-    #    print("Wrote {!r}".format(data))
-
+    if args.debug:
+        if numeric:
+            print("Wrote 0x{!s}".format(data.encode("hex")))
+        else:
+            print("Wrote {!r}".format(data))
 
 def _read(dst):
     res = ""
@@ -124,7 +136,8 @@ def _read(dst):
     while x:
         res += x
         x = dst.read(1)
-    #print ("Read {!r}".format(res))
+    if args.debug:
+        print ("Read {!r}".format(res))
     return res
 
 pin = None
@@ -137,7 +150,7 @@ def _execute(dst, cmd):
         _write(dst, args.username + "\r")
         prompt = _read(dst)
         if prompt.endswith("Password: "):
-            if not pin:
+            if not pin or args.separate_pins:
                 pin = getpass.getpass("{} PIN: ".format(args.username))
             _write(dst, pin + "\r")
             prompt = _read(dst)

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Commits mailing list