[ActiveLock-Development] CVS: activelock2/test ALTestApp.vbp,1.3,1.4 frmMain.frm,1.4,1.5 modMain.bas
Brought to you by:
ialkan
From: Thanh H. T. <th...@us...> - 2003-07-31 07:25:07
|
Update of /cvsroot/activelock/activelock2/test In directory sc8-pr-cvs1:/tmp/cvs-serv16758 Modified Files: ALTestApp.vbp frmMain.frm modMain.bas Log Message: Demonstrate how to authenticate ActiveLock2.dll by using MD5 checksums. Index: ALTestApp.vbp =================================================================== RCS file: /cvsroot/activelock/activelock2/test/ALTestApp.vbp,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- ALTestApp.vbp 28 Jul 2003 06:39:58 -0000 1.3 +++ ALTestApp.vbp 31 Jul 2003 07:25:04 -0000 1.4 @@ -5,12 +5,13 @@ Form=frmMain.frm UserControl=atViewPort.ctl Module=modMain; modMain.bas -ResFile32="atDisplay.RES" Module=modActiveLock; ..\src\modActiveLock.bas +ResFile32="atDisplay.RES" IconForm="frmMain" Startup="frmMain" HelpFile="" Title="ALTestApp" +ExeName32="ALTestApp.exe" Command32="" Name="ALTestApp" HelpContextID="0" Index: frmMain.frm =================================================================== RCS file: /cvsroot/activelock/activelock2/test/frmMain.frm,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- frmMain.frm 28 Jul 2003 06:39:58 -0000 1.4 +++ frmMain.frm 31 Jul 2003 07:25:05 -0000 1.5 @@ -27,23 +27,25 @@ TabCaption(0) = "Admin" TabPicture(0) = "frmMain.frx":0000 Tab(0).ControlEnabled= 0 'False - Tab(0).Control(0)= "Label1" - Tab(0).Control(1)= "Label2" - Tab(0).Control(2)= "Label3" - Tab(0).Control(3)= "Label9" - Tab(0).Control(4)= "Label10" - Tab(0).Control(5)= "lblExpiry" - Tab(0).Control(6)= "lblDays" - Tab(0).Control(7)= "cmdSoftwareCodeGen" + Tab(0).Control(0)= "txtChecksum" + Tab(0).Control(1)= "fraKeyGen" + Tab(0).Control(2)= "txtDays" + Tab(0).Control(3)= "cmbLicType" + Tab(0).Control(4)= "txtSoftwareCodePub" + Tab(0).Control(5)= "txtSoftwareCodePriv" + Tab(0).Control(6)= "txtVersion" + Tab(0).Control(7)= "txtName" Tab(0).Control(8)= "cmbLicClass" - Tab(0).Control(9)= "txtName" - Tab(0).Control(10)= "txtVersion" - Tab(0).Control(11)= "txtSoftwareCodePriv" - Tab(0).Control(12)= "txtSoftwareCodePub" - Tab(0).Control(13)= "cmbLicType" - Tab(0).Control(14)= "txtDays" - Tab(0).Control(15)= "fraKeyGen" - Tab(0).ControlCount= 16 + Tab(0).Control(9)= "cmdSoftwareCodeGen" + Tab(0).Control(10)= "Label14" + Tab(0).Control(11)= "lblDays" + Tab(0).Control(12)= "lblExpiry" + Tab(0).Control(13)= "Label10" + Tab(0).Control(14)= "Label9" + Tab(0).Control(15)= "Label3" + Tab(0).Control(16)= "Label2" + Tab(0).Control(17)= "Label1" + Tab(0).ControlCount= 18 TabCaption(1) = "Registration" TabPicture(1) = "frmMain.frx":001C Tab(1).ControlEnabled= -1 'True @@ -52,19 +54,28 @@ Tab(1).Control(1)= "fraRegStatus" Tab(1).Control(1).Enabled= 0 'False Tab(1).ControlCount= 2 - TabCaption(2) = "Test Functionality" + TabCaption(2) = "Sample App" TabPicture(2) = "frmMain.frx":0038 Tab(2).ControlEnabled= 0 'False - Tab(2).Control(0)= "fraTicker" + Tab(2).Control(0)= "Frame1" Tab(2).Control(1)= "fraViewport" - Tab(2).Control(2)= "Frame1" + Tab(2).Control(2)= "fraTicker" Tab(2).ControlCount= 3 + Begin VB.TextBox txtChecksum + BackColor = &H80000011& + Height = 285 + Left = -73680 + Locked = -1 'True + TabIndex = 55 + Top = 600 + Width = 5055 + End Begin VB.Frame fraKeyGen Caption = "Key Generator" Height = 2415 Left = -74880 TabIndex = 43 - Top = 2760 + Top = 3360 Width = 7455 Begin VB.TextBox txtReqCodeIn Height = 285 @@ -113,7 +124,7 @@ Locked = -1 'True TabIndex = 40 Text = "30" - Top = 1850 + Top = 2445 Width = 1215 End Begin VB.ComboBox cmbLicType @@ -123,7 +134,7 @@ List = "frmMain.frx":0061 Style = 2 'Dropdown List TabIndex = 3 - Top = 1560 + Top = 2160 Width = 5055 End Begin VB.TextBox txtSoftwareCodePub @@ -132,7 +143,7 @@ Left = -71160 Locked = -1 'True TabIndex = 34 - Top = 960 + Top = 1560 Width = 2535 End Begin VB.TextBox txtSoftwareCodePriv @@ -141,7 +152,7 @@ Left = -73680 Locked = -1 'True TabIndex = 35 - Top = 960 + Top = 1560 Width = 2535 End Begin VB.TextBox txtVersion @@ -150,7 +161,7 @@ Left = -73680 Locked = -1 'True TabIndex = 38 - Top = 720 + Top = 1320 Width = 5055 End Begin VB.TextBox txtName @@ -159,12 +170,11 @@ Left = -73680 Locked = -1 'True TabIndex = 36 - Top = 480 + Top = 1080 Width = 5055 End Begin VB.Frame Frame1 BorderStyle = 0 'None - Enabled = 0 'False Height = 2775 Left = -74895 TabIndex = 22 @@ -284,7 +294,7 @@ TickerFontSize = 11.25 TickerFlash = 0 'False TickerPlaySound = 0 'False - TickerScrollX = 480 + TickerScrollX = 55 BalloonTipIcon = 0 BalloonTipText = "No Messages" End @@ -453,7 +463,7 @@ List = "frmMain.frx":0140 Style = 2 'Dropdown List TabIndex = 4 - Top = 2130 + Top = 2730 Width = 5055 End Begin VB.CommandButton cmdSoftwareCodeGen @@ -462,7 +472,15 @@ Height = 255 Left = -68520 TabIndex = 2 - Top = 960 + Top = 1560 + Width = 1215 + End + Begin VB.Label Label14 + Caption = "ActiveLock's MD5 Checksum:" + Height = 375 + Left = -74880 + TabIndex = 54 + Top = 480 Width = 1215 End Begin VB.Label lblDays @@ -470,7 +488,7 @@ Height = 255 Left = -72360 TabIndex = 42 - Top = 1890 + Top = 2490 Width = 1335 End Begin VB.Label lblExpiry @@ -478,7 +496,7 @@ Height = 255 Left = -74880 TabIndex = 41 - Top = 1850 + Top = 2445 Width = 1335 End Begin VB.Label Label10 @@ -486,7 +504,7 @@ Height = 255 Left = -74880 TabIndex = 39 - Top = 720 + Top = 1320 Width = 1335 End Begin VB.Label Label9 @@ -494,7 +512,7 @@ Height = 255 Left = -74880 TabIndex = 37 - Top = 480 + Top = 1080 Width = 1335 End Begin VB.Label Label3 @@ -502,7 +520,7 @@ Height = 255 Left = -74880 TabIndex = 6 - Top = 2130 + Top = 2730 Width = 1335 End Begin VB.Label Label2 @@ -510,7 +528,7 @@ Height = 255 Left = -74880 TabIndex = 5 - Top = 1560 + Top = 2160 Width = 1335 End Begin VB.Label Label1 @@ -518,7 +536,7 @@ Height = 255 Left = -74880 TabIndex = 1 - Top = 960 + Top = 1560 Width = 1335 End End @@ -579,7 +597,7 @@ ' / MODULE CHANGE LOG / ' /////////////////////////////////////////////////////////////////////// ' -' +' 07.31.03 - th2tran - Now performing checksum on ActiveLock2.dll. ' ' /////////////////////////////////////////////////////////////////////// ' / MODULE CODE BEGINS BELOW THIS LINE / @@ -814,8 +832,12 @@ End Sub Private Sub Form_Load() + FunctionalitiesEnabled = False ' Disable functionalities by default ' Initialize AL Set MyActiveLock = ActiveLock2.NewInstance() + ' Verify AL's authenticity + txtChecksum = modMain.VerifyActiveLockdll(New ActiveLock2.Globals) + MyActiveLock.KeyStoreType = alsFile MyActiveLock.KeyStorePath = App.Path & "\al.lic" @@ -849,7 +871,6 @@ NotRegistered: MsgBox Err.Number & ": " & Err.Description txtRegStatus = "Not Registered" - FunctionalitiesEnabled = False End Sub Private Property Let FunctionalitiesEnabled(flag As Boolean) @@ -888,3 +909,4 @@ Private Sub txtVersion_Change() MyActiveLock.SoftwareVersion = txtVersion End Sub + Index: modMain.bas =================================================================== RCS file: /cvsroot/activelock/activelock2/test/modMain.bas,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- modMain.bas 28 Jul 2003 06:39:58 -0000 1.3 +++ modMain.bas 31 Jul 2003 07:25:05 -0000 1.4 @@ -207,6 +207,7 @@ ' that you generate your own set of keys to use before deploying your app. Public Const PRIV_KEY$ = "AAAAgEPRFzhQEF7S91vt2K6kOcEdDDe5BfwNiEL30/+ozTFHc7cZctB8NIlS++ZR//D3AjSMqScjh7xUF/gwvUgGCjiExjj1DF/XWFWnPOCfF8UxYAizCLZ9fdqxb1FRpI5NoW0xxUmvxGjmxKwazIW4P4XVi/+i1Bvh2qQ6ri3whcsNAAAAQQCyWGsbJKO28H2QLYH+enb7ehzwBThqfAeke/Gv1Te95yIAWme71I9aCTTlLsmtIYSk9rNrp3sh9ItD2Re67SE7AAAAQQCAookH1nws1gS2XP9cZTPaZEmFLwuxlSVsLQ5RWmd9cuxpgw5y2gIskbL4c+4oBuj0IDwKtnMrZq7UfV9I5VfVAAAAQQCEnyAuO0ahXH3KhAboop9+tCmRzZInTrDYdMy23xf3PLCLd777dL/Y2Y+zmaH1VO03m6iOog7WLiN4dCL7m+Im" Public Const PUB_KEY$ = "AAAAB3NzaC1yc2EAAAABJQAAAIBZnXD4IKfrBH25ekwLWQMs5mJuNH7D7U99EKFIsVhKQv17GHxKWvxHv/FwWhI1Rmd8TCiqk4Wmk7H1rh6xdbIVBwDj+RSeiXs8mmQX4/XvaWZx9BIQr5wODWnQCH/tj6Y6In2Xjc2J3B7LSjD60cWDBY/u+z9cSheTHLyhb16zFw==" +Private Const AL_MD5$ = "c00ab9e1927ef8df1f1040ce28ad5f5e" Public Function Encrypt(strData As String) As String Dim Key As RSAKey @@ -230,4 +231,18 @@ Dim strOut As String strOut = Left$(strEnc, dLen) Encrypt = strOut +End Function + +'' +' Verifies the checksum of the typelib containing the specified object. +' Returns the checksum. +' +Public Function VerifyActiveLockdll(obj As IUnknown) As String + Dim strMd5 As String + strMd5 = modActiveLock.MD5HashTypeLib(obj) + Debug.Print "Hash: " & strMd5 + If strMd5 <> AL_MD5 Then + MsgBox "ActiveLock2.dll has been corrupted. If you were running a real application, it should terminate at this point." + End If + VerifyActiveLockdll = strMd5 End Function |