Platforms to show: All Mac Windows Linux Cross-Platform
Required plugins for this example: MBS Encryption Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /Encryption/ECKey/ECKey Tests
This example is the version from Mon, 29th Oct 2017.
Project "ECKey Tests.xojo_binary_project"
Class App Inherits Application
Const kEditClear = "&Delete"
Const kFileQuit = "&Quit"
Const kFileQuitShortcut = ""
EventHandler Sub Open()
dim EC_Curve_ID as integer = 415 // NID_X9_62_prime256v1
// on Server
dim dhs as new ECDHEMBS(EC_Curve_ID)
dim pks as string = dhs.PublicKey
// on Client
dim dhc as new ECDHEMBS(EC_Curve_ID)
dim pkc as string = dhc.PublicKey
// exchange public keys
// on Server
dim ses as string = dhs.DeriveSecretKey(pkc)
// on Client
dim sec as string = dhc.DeriveSecretKey(pks)
// show window for server
dim lines() as string
lines.Append dhs.ParamsInfo
lines.Append dhs.PrivateKeyInfo // private key from server
lines.Append dhs.PeerKeyInfo // public key from client
lines.Append EncodeHex(ses) // shared secret
ServerWindow.TextArea1.text = ReplaceLineEndings(Join(lines, EndOfLine+EndOfLine), EndOfLine)
ServerWindow.show
// show window for client
redim lines(-1)
lines.Append dhc.ParamsInfo
lines.Append dhc.PrivateKeyInfo // private key from client
lines.Append dhc.PeerKeyInfo // public key from server
lines.Append EncodeHex(sec) // shared secret
ClientWindow.TextArea1.text = ReplaceLineEndings(Join(lines, EndOfLine+EndOfLine), EndOfLine)
ClientWindow.show
ClientWindow.top = ServerWindow.top
ClientWindow.Left = ServerWindow.Left + ServerWindow.width + 20
End EventHandler
End Class
Class ClientWindow Inherits Window
Control TextArea1 Inherits TextArea
ControlInstance TextArea1 Inherits TextArea
End Control
End Class
MenuBar MainMenuBar
MenuItem FileMenu = "&File"
MenuItem FileQuit = "#App.kFileQuit"
MenuItem EditMenu = "&Edit"
MenuItem EditUndo = "&Undo"
MenuItem EditSeparator1 = "-"
MenuItem EditCut = "Cu&t"
MenuItem EditCopy = "&Copy"
MenuItem EditPaste = "&Paste"
MenuItem EditClear = "#App.kEditClear"
MenuItem EditSeparator2 = "-"
MenuItem EditSelectAll = "Select &All"
End MenuBar
Class ServerWindow Inherits Window
Control TextArea1 Inherits TextArea
ControlInstance TextArea1 Inherits TextArea
End Control
End Class
End Project
See also:
The items on this page are in the following plugins: MBS Encryption Plugin.