Skip to content

Commit 2550360

Browse files
committed
code fix
1 parent 9eb0e3f commit 2550360

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

pytss/__init__.py

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -97,20 +97,6 @@ def get_policy_object(self, poltype):
9797
policy_obj = TspiPolicy(self.context, None, handle=policy)
9898
return policy_obj
9999

100-
def generate_random_data(self, length):
101-
"""
102-
Generates random data in TPM of the given length in bytes.
103-
104-
:param length: Length of data to generate in bytes
105-
106-
:return: bytearray containing the random data
107-
"""
108-
blob = ffi.new('BYTE **')
109-
tss_lib.Tspi_TPM_GetRandom(self.get_handle(), length, blob)
110-
ret = bytearray(blob[0][0:length])
111-
tss_lib.Tspi_Context_FreeMemory(self.context, blob[0])
112-
return ret
113-
114100

115101
class TspiNV(TspiObject):
116102
def __init__(self, context, flags):
@@ -488,6 +474,21 @@ def extend_pcr(self, pcr, data, event):
488474
tss_lib.Tspi_Context_FreeMemory(self.context, blob[0])
489475
return ret
490476

477+
def generate_random_data(self, length):
478+
"""
479+
Generates random data in TPM of the given length in bytes.
480+
481+
:param length: Length of data to generate in bytes
482+
483+
:return: bytearray containing the random data
484+
"""
485+
blob = ffi.new('BYTE **')
486+
tss_lib.Tspi_TPM_GetRandom(self.get_handle(), length, blob)
487+
ret = bytearray(blob[0][0:length])
488+
tss_lib.Tspi_Context_FreeMemory(self.context, blob[0])
489+
return ret
490+
491+
491492
class TspiContext():
492493
def __init__(self):
493494
self.context = ffi.new('TSS_HCONTEXT *')

0 commit comments

Comments
 (0)