Skip to content

Commit

Permalink
Merge pull request #5 from RaymWong/python3_dev
Browse files Browse the repository at this point in the history
Fixed openSSL engine client and server send data
  • Loading branch information
RaymWong authored Mar 30, 2022
2 parents 9bd62fa + 4e4b1bb commit 9a2650f
Show file tree
Hide file tree
Showing 7 changed files with 163 additions and 121 deletions.
4 changes: 3 additions & 1 deletion Python_TPM20_GUI/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import shell_util as exec_cmd
import images as img
import subprocess
#import wx.lib.inspection

class MainFrame(wx.Frame):
def __init__(self, parent, title):
Expand Down Expand Up @@ -192,6 +193,7 @@ def __init__(self, redirect=False, filename=None):
dlg = MainFrame(None, title="Main")
self.SetTopWindow(dlg)
dlg.Centre()
# wx.lib.inspection.InspectionTool().Show()
dlg.Show()


Expand All @@ -200,5 +202,5 @@ def __init__(self, redirect=False, filename=None):
# Navigation always starts from the /working_space folder.
if __name__ == "__main__":
exec_cmd.checkDir()
app = Main()
app = Main()
app.MainLoop()
34 changes: 20 additions & 14 deletions Python_TPM20_GUI/tab1_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def __init__(self, parent):

# attach the objects to the sizers
mainsizer.Add(buttonsizer, 0, wx.EXPAND | wx.ALL, 5)
mainsizer.Add(self.text_display, 1, wx.EXPAND | wx.ALL, 5)
mainsizer.Add(self.text_display, 1, wx.EXPAND)
buttonsizer.Add(button_getCapVar, 1, wx.EXPAND | wx.ALL, 5)
buttonsizer.Add(button_getCapFix, 1, wx.EXPAND | wx.ALL, 5)
buttonsizer.Add(button_takeown, 1, wx.EXPAND | wx.ALL, 5)
Expand All @@ -62,7 +62,7 @@ def __init__(self, parent):
buttonsizer.Add(button_disablelock, 1, wx.EXPAND | wx.ALL, 5)
buttonsizer.Add(button_dictAtk, 1, wx.EXPAND | wx.ALL, 5)
buttonsizer.Add(button_start, 1, wx.EXPAND | wx.ALL, 5)
buttonsizer.Add(iconsizer, 0, wx.ALIGN_CENTER | wx.ALL, 0)
buttonsizer.Add(iconsizer, 0, wx.EXPAND | wx.ALL, 0)
iconsizer.Add(clearbutton, 0, wx.ALL, 5)
iconsizer.Add(backbutton, 0, wx.ALL, 5)

Expand Down Expand Up @@ -261,16 +261,17 @@ def __init__(self, parent):


# attach the sizers to the main sizer
mainsizer.Add(top_row_sizer, 0, wx.ALL, 0)
mainsizer.Add(middle_row_sizer, 0, wx.EXPAND | wx.ALL, 0)
mainsizer.Add(bottom_row_sizer, 0, wx.ALIGN_CENTRE | wx.ALL, 0)
mainsizer.Add(self.bottom_txt_display, 1, wx.EXPAND | wx.ALL, 5)
mainsizer.Add(top_row_sizer, 0, wx.TOP, 5)
mainsizer.Add(middle_row_sizer, 0, wx.EXPAND | wx.LEFT | wx.RIGHT, 5)
mainsizer.Add(bottom_row_sizer, 0, wx.EXPAND | wx.ALL, 0)
mainsizer.Add(self.bottom_txt_display, 1, wx.EXPAND | wx.TOP, 5)

# attach the ui elements to the internal sizer
top_row_sizer.Add(self.sha_checkbox, 0, wx.ALL, 5)
top_row_sizer.Add((200, 10), proportion=1, flag=wx.EXPAND)
top_row_sizer.Add(text_for_pcrbank, 0, wx.ALIGN_CENTRE, 5)
top_row_sizer.Add(self.pcr_bank_choice, 0, wx.ALL, 5)
middle_row_sizer.AddSpacer(5)
middle_row_sizer.Add(text_for_userinput, 0, wx.ALIGN_CENTRE, 5)
middle_row_sizer.Add(self.user_input, 1, wx.ALL, 5)
bottom_row_sizer.Add(button_pcrlistall, 1, wx.EXPAND | wx.ALL, 5)
Expand Down Expand Up @@ -448,7 +449,7 @@ def __init__(self, parent):
button_nvwrite = wx.Button(self, -1, 'NV Write')

button_nvwrite_file = wx.Button(self, -1, 'NV Write File')
self.filename_input = wx.TextCtrl(self, -1,value="ifx_ecc_cert.crt", style=(wx.TE_CHARWRAP|wx.TE_MULTILINE))
self.filename_input = wx.TextCtrl(self, -1, value="ifx_ecc_cert.crt", style=(wx.TE_CHARWRAP|wx.TE_MULTILINE), size=(-1, 61))
# Create open file dialog

button_nvrelease = wx.Button(self, -1, 'NV Release')
Expand All @@ -474,10 +475,11 @@ def __init__(self, parent):

# attach the sizers to the main sizer
mainsizer.Add(nvm_attr_sizer, 0, wx.EXPAND | wx.ALL, 5)
mainsizer.Add(index_size_offset_input_sizer, 0, wx.ALL, 0)
mainsizer.Add(index_size_offset_input_sizer, 0, wx.RIGHT | wx.TOP, 5)
mainsizer.Add(self.bottom_txt_display, 1, wx.EXPAND | wx.ALL, 0)

# attach the ui elements to the internal sizer
nvm_attr_sizer.AddSpacer(5)
nvm_attr_sizer.Add(text_for_nvm_attr, 0, wx.ALIGN_CENTER | wx.ALL, 5)
nvm_attr_sizer.Add(self.nvm_attr, 1, wx.EXPAND | wx.ALL, 5)
nvm_attr_sizer.Add(button_reset_attr, 0, wx.EXPAND | wx.ALL, 5)
Expand Down Expand Up @@ -513,7 +515,7 @@ def __init__(self, parent):
input_sizer.Add(self.nvm_data, 1, wx.EXPAND | wx.ALL, 5)

owner_sizer.Add(text_for_owner_auth, 1, wx.ALIGN_CENTRE, 5)
owner_sizer.Add(self.owner_input, 1, wx.EXPAND | wx.ALL, 5)
owner_sizer.Add(self.owner_input, 1, wx.ALL, 5)

button_row_1.Add(button_nvdefine, 1, wx.ALL, 5)
button_row_1.Add(button_nvwrite, 1, wx.ALL, 5)
Expand All @@ -525,7 +527,7 @@ def __init__(self, parent):
button_row_3.Add(button_nvlist, 1, wx.ALL, 5)

button_row_4.Add(button_nvwrite_file, 1, wx.ALL, 5)
button_row_4.Add(self.filename_input, 1, wx.ALL, 5)
button_row_4.Add(self.filename_input, 1, wx.EXPAND | wx.ALL, 5)

rsa_sizer.Add(button_nv_read_rsa_cert, 1, wx.ALL, 5)
rsa_sizer.Add(self.rsa_cert_index, 1, wx.ALL, 5)
Expand Down Expand Up @@ -890,6 +892,7 @@ def __init__(self, parent):
mainsizer = wx.BoxSizer(wx.VERTICAL)
element_sizer = wx.BoxSizer(wx.HORIZONTAL)
handle_sizer = wx.BoxSizer(wx.HORIZONTAL)
handle_blurb_sizer = wx.BoxSizer(wx.HORIZONTAL)

# instantiate the objects
input_handle_blurb = wx.StaticText(self, -1, "Handle: ")
Expand All @@ -913,11 +916,13 @@ def __init__(self, parent):
# ~backbutton = wx.BitmapButton(self, -1, img.back.getBitmap())

# attach the sizers to the main sizer
mainsizer.Add(handle_sizer, 0, wx.EXPAND | wx.ALL, 0)
mainsizer.Add(element_sizer, 0, wx.EXPAND | wx.ALL, 0)
mainsizer.Add(self.txt_display, 1, wx.EXPAND | wx.ALL, 5)
mainsizer.Add(handle_sizer, 0, wx.EXPAND | wx.TOP, 5)
mainsizer.Add(element_sizer, 0, wx.EXPAND | wx.RIGHT | wx.LEFT, 5)
mainsizer.Add(self.txt_display, 1, wx.EXPAND | wx.TOP, 5)

# Add elements to the element sizer
handle_blurb_sizer.Add(input_handle_blurb, 0, wx.CENTRE | wx.LEFT, 10)

element_sizer.Add(button_listpersistent, 1, wx.EXPAND | wx.ALL, 5)
element_sizer.Add(button_readpersistent, 1, wx.EXPAND | wx.ALL, 5)
element_sizer.Add(button_evict_persistent, 1, wx.EXPAND | wx.ALL, 5)
Expand All @@ -927,8 +932,9 @@ def __init__(self, parent):
element_sizer.Add(backbutton, 0, wx.EXPAND | wx.ALL, 5)

# Attach UI elements to the internal sizers
handle_sizer.Add(input_handle_blurb, 0, wx.EXPAND | wx.ALL, 5)
handle_sizer.Add(handle_blurb_sizer, 0, wx.EXPAND | wx.ALL, 0)
handle_sizer.Add(self.input_handle, 1, wx.EXPAND | wx.ALL, 5)
handle_sizer.AddSpacer(5)

# Set tooltips
button_listpersistent.SetToolTip(wx.ToolTip("List what handles exists in the persistent store."))
Expand Down
24 changes: 13 additions & 11 deletions Python_TPM20_GUI/tab2_crypto.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def __init__(self, parent):
input_sizer = wx.BoxSizer(wx.HORIZONTAL)

# create UI elements
hashbutton = wx.Button(self, -1, 'Hash (SHA-2)')
hashbutton = wx.Button(self, -1, 'Hash (SHA-2)', size = (-1, 47))
inputtext = wx.StaticText(self, -1, label="Input:")
self.input_display = wx.TextCtrl(self,value="12345")
self.command_display = wx.TextCtrl(self, style=wx.TE_MULTILINE | wx.TE_READONLY)
Expand Down Expand Up @@ -101,11 +101,11 @@ def __init__(self, parent):
button_sizer = wx.BoxSizer(wx.HORIZONTAL)

# create UI elements
createprimary = wx.Button(self, -1, 'Create Primary')
createkeypairbutton = wx.Button(self, -1, 'Create RSA Keypair')
encbutton = wx.Button(self, -1, 'RSA Encrypt')
decbutton = wx.Button(self, -1, 'RSA Decrypt')
signbutton = wx.Button(self, -1, 'RSA Sign')
createprimary = wx.Button(self, -1, 'Create Primary', size=(-1, 48))
createkeypairbutton = wx.Button(self, -1, 'Create RSA Keypair', size=(-1, 48))
encbutton = wx.Button(self, -1, 'RSA Encrypt', size=(-1, 48))
decbutton = wx.Button(self, -1, 'RSA Decrypt', size=(-1, 48))
signbutton = wx.Button(self, -1, 'RSA Sign', size=(-1, 48))
opensslverifybutton = wx.Button(self, -1, 'RSA Verify\n(By OpenSSL)')
tpmverifybutton = wx.Button(self, -1, 'RSA Verify\n(By TPM2-Tools)')
inputtext = wx.StaticText(self, -1, label="Data Input:")
Expand All @@ -121,9 +121,10 @@ def __init__(self, parent):
# ~backbutton = wx.BitmapButton(self, -1, img.back.getBitmap())

# attach the objects to the sizers
mainsizer.AddSpacer(5)
mainsizer.Add(input_sizer, 0, wx.EXPAND | wx.ALL, 5)
mainsizer.Add(button_sizer, 0, wx.EXPAND | wx.ALL, 0)
mainsizer.Add(self.command_display, 1, wx.EXPAND | wx.ALL, 0)
mainsizer.Add(self.command_display, 1, wx.EXPAND | wx.TOP, 5)
input_sizer.Add(inputtext, 0, wx.ALIGN_CENTRE, 5)
input_sizer.Add(self.input_display, 1, wx.ALIGN_CENTRE, 0)
# ~ button_sizer.Add(createprimary, 1, wx.ALIGN_CENTRE | wx.EXPAND | wx.ALL, 5)
Expand Down Expand Up @@ -421,9 +422,9 @@ def __init__(self, parent):
button_sizer = wx.BoxSizer(wx.HORIZONTAL)

# create UI elements
createprimary = wx.Button(self, -1, 'Create Primary')
createkeypairbutton = wx.Button(self, -1, 'Create ECC Keypair')
signbutton = wx.Button(self, -1, 'ECC Sign')
createprimary = wx.Button(self, -1, 'Create Primary', size = (-1, 48))
createkeypairbutton = wx.Button(self, -1, 'Create ECC Keypair', size =(-1, 48))
signbutton = wx.Button(self, -1, 'ECC Sign', size = (-1, 48))
opensslverifybutton = wx.Button(self, -1, 'ECC Verify\n(By Openssl)')
tpmverifybutton = wx.Button(self, -1, 'ECC Verify\n(By TPM2-Tools)')
inputtext = wx.StaticText(self, -1, label="Data Input:")
Expand All @@ -439,9 +440,10 @@ def __init__(self, parent):
# ~backbutton = wx.BitmapButton(self, -1, img.back.getBitmap())

# attach the objects to the sizers
mainsizer.AddSpacer(5)
mainsizer.Add(input_sizer, 0, wx.EXPAND | wx.ALL, 5)
mainsizer.Add(button_sizer, 0, wx.EXPAND | wx.ALL, 0)
mainsizer.Add(self.command_display, 1, wx.EXPAND | wx.ALL, 0)
mainsizer.Add(self.command_display, 1, wx.EXPAND | wx.TOP, 5)
input_sizer.Add(inputtext, 0, wx.ALIGN_CENTRE, 5)
input_sizer.Add(self.input_display, 1, wx.ALIGN_CENTRE, 0)
button_sizer.Add(createprimary, 1, wx.ALIGN_CENTRE | wx.ALL, 5)
Expand Down
Loading

0 comments on commit 9a2650f

Please sign in to comment.