[Cryptech-Commits] [sw/libhal] branch ksng updated: Fix HAL_KEY_TYPE_* symbols, add Attribute class.

git at cryptech.is git at cryptech.is
Thu Oct 20 05:00:54 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/libhal.

The following commit(s) were added to refs/heads/ksng by this push:
       new  7c47b57   Fix HAL_KEY_TYPE_* symbols, add Attribute class.
7c47b57 is described below

commit 7c47b5772bb2846fc6193b3c8128b376637c32e7
Author: Rob Austein <sra at hactrn.net>
AuthorDate: Thu Oct 20 00:58:23 2016 -0400

    Fix HAL_KEY_TYPE_* symbols, add Attribute class.
---
 .gitignore |  1 +
 libhal.py  | 19 ++++++++++++++++---
 2 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/.gitignore b/.gitignore
index 01c1858..764f6fb 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,5 @@
 *.[ao]
+*.pyc
 *~
 Makefile
 TAGS
diff --git a/libhal.py b/libhal.py
index fa01ffc..0924863 100644
--- a/libhal.py
+++ b/libhal.py
@@ -158,7 +158,7 @@ def_enum('''
 ''')
 
 def_enum('''
-    HAL_KEY_TYPE_NONE = 0,
+    HAL_KEY_TYPE_NONE,
     HAL_KEY_TYPE_RSA_PRIVATE,
     HAL_KEY_TYPE_RSA_PUBLIC,
     HAL_KEY_TYPE_EC_PRIVATE,
@@ -185,6 +185,17 @@ HAL_KEY_FLAG_USAGE_DATAENCIPHERMENT     = (1 << 2)
 HAL_KEY_FLAG_TOKEN                      = (1 << 3)
 
 
+class Attribute(object):
+
+    def __init__(self, type, value):
+        self.type  = type
+        self.value = value
+
+    def xdr_packer(self, packer):
+        packer.pack_uint(self.type)
+        packer.pack_bytes(self.value)
+
+
 def cached_property(func):
 
     attr_name = "_" + func.__name__
@@ -280,7 +291,7 @@ class PKey(Handle):
 
 class HSM(object):
 
-    debug = True
+    debug = False
 
     def _raise_if_error(self, status):
         if status != 0:
@@ -352,7 +363,9 @@ class HSM(object):
 
     def _pack(self, packer, args):
         for arg in args:
-            if isinstance(arg, (int, long, Handle)):
+            if hasattr(arg, "xdr_packer"):
+                arg.xdr_packer(packer)
+            elif isinstance(arg, (int, long, Handle)):
                 packer.pack_uint(arg)
             elif isinstance(arg, str):
                 packer.pack_bytes(arg)

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


More information about the Commits mailing list