[ActiveLock-Development] CVS: activelock2/test al.lic,1.1,1.2 ALTestApp.vbp,1.2,1.3 frmMain.frm,1.3,
Brought to you by:
ialkan
From: Thanh H. T. <th...@us...> - 2003-07-28 06:40:04
|
Update of /cvsroot/activelock/activelock2/test In directory sc8-pr-cvs1:/tmp/cvs-serv9068 Modified Files: al.lic ALTestApp.vbp frmMain.frm modMain.bas ALCrypto.dll Log Message: Updated to test against new license key generation/registration/validation implementations in ActiveLock2.dll. Index: al.lic =================================================================== RCS file: /cvsroot/activelock/activelock2/test/al.lic,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- al.lic 21 Jul 2003 08:54:38 -0000 1.1 +++ al.lic 28 Jul 2003 06:39:58 -0000 1.2 @@ -9,12 +9,13 @@ Expiration=2003-12-31 LicenseKey=a4849ca280aeb8679b15f6ecac09bbfa [ALTestApp] -ProductCode=AAAAB3NzaC1yc2EAAAABJQAAAIBxElYppptzL+mgXptF/mh5iSraIM19VYnLgTKtStfoFQH1rDEr58XvzWWfkzRVFnb97Njxl3GVXLQo6oEN6uKMZL1pe2Z8ZacBw766AxKeHlFR28RXYvy+BON5YP9Crgdncz/GZkBbDWOx9NXCX9gQRQJFv7s7bsbGZWxMQOzi7Q== ProductVersion=1.0.0 LicenseType=Single LicenseClass=Class1 Licensee=Thanh Tran -LicenseKey=EA3K1xuCr0uE96SJaKgBIAg+LQ844dfuc54qddHhxOp6DDP4ikR0YkwAkNOkoHk91lcoxrvcIecYG1w5Bc7Q1SUWI0lXYc6jSCDXhBRe8vmo7yBfOMrmqePvO2MOvi3JRm0hK9uO+xtWTtLb4HvslSPexOH62oq2Fbo9Nv51WF0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg -RegisteredDate=2003/07/22 -Hash1=c546c2307ce0ca8ec9751948236520a7 -Expiration=2003/08/20 +LicenseKey=AAAAB3NzaC1yc2EAAACAChOALOd+VXMhMAw3OmTjGuV8TMCwtO3ZPnKFqp2WliR8EvmqAJc9XO2DdJFpBglL/1RK9O8G9QQAGaairH8Lh4tG7Wy9L0FVT8Rzi/IlQl+ZNs4bOXLwcYY99AMeoanYdrmdUCS8OGV6EaO2oEHiaIW23FV/m5pT21MEkXbvPns +RegisteredDate=2003/07/28 +Expiration=2003/08/27 +ProductKey=AAAAB3NzaC1yc2EAAAABJQAAAIBZnXD4IKfrBH25ekwLWQMs5mJuNH7D7U99EKFIsVhKQv17GHxKWvxHv/FwWhI1Rmd8TCiqk4Wmk7H1rh6xdbIVBwDj+RSeiXs8mmQX4/XvaWZx9BIQr5wODWnQCH/tj6Y6In2Xjc2J3B7LSjD60cWDBY/u+z9cSheTHLyhb16zFw== +Hash1=b0ffd9956fc8bba60b94dab0c4cc2758 +LastUsed=2003/07/28 02:15:20 Index: ALTestApp.vbp =================================================================== RCS file: /cvsroot/activelock/activelock2/test/ALTestApp.vbp,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- ALTestApp.vbp 21 Jul 2003 08:54:38 -0000 1.2 +++ ALTestApp.vbp 28 Jul 2003 06:39:58 -0000 1.3 @@ -1,14 +1,12 @@ Type=Exe Reference=*\G{00020430-0000-0000-C000-000000000046}#2.0#0#C:\WINDOWS\System32\stdole2.tlb#OLE Automation -Reference=*\A..\src\ActiveLock2.vbp -Form=frmMain.frm +Reference=*\G{AAED8AB4-AC83-4C51-93EE-64664DB96265}#1.0#0#..\src\ActiveLock2.dll#ActiveLock2 Object={BDC217C8-ED16-11CD-956C-0000C04E4C0A}#1.1#0; TABCTL32.OCX +Form=frmMain.frm UserControl=atViewPort.ctl Module=modMain; modMain.bas -Module=modActiveLock; ..\src\modActiveLock.bas ResFile32="atDisplay.RES" -Module=modMACAddress; ..\src\modMACAddress.bas -Module=modBase64; ..\src\modBase64.bas +Module=modActiveLock; ..\src\modActiveLock.bas IconForm="frmMain" Startup="frmMain" HelpFile="" Index: frmMain.frm =================================================================== RCS file: /cvsroot/activelock/activelock2/test/frmMain.frm,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- frmMain.frm 23 Jul 2003 03:50:26 -0000 1.3 +++ frmMain.frm 28 Jul 2003 06:39:58 -0000 1.4 @@ -55,9 +55,9 @@ TabCaption(2) = "Test Functionality" TabPicture(2) = "frmMain.frx":0038 Tab(2).ControlEnabled= 0 'False - Tab(2).Control(0)= "Frame1" + Tab(2).Control(0)= "fraTicker" Tab(2).Control(1)= "fraViewport" - Tab(2).Control(2)= "fraTicker" + Tab(2).Control(2)= "Frame1" Tab(2).ControlCount= 3 Begin VB.Frame fraKeyGen Caption = "Key Generator" @@ -284,7 +284,7 @@ TickerFontSize = 11.25 TickerFlash = 0 'False TickerPlaySound = 0 'False - TickerScrollX = 321 + TickerScrollX = 480 BalloonTipIcon = 0 BalloonTipText = "No Messages" End @@ -591,71 +591,34 @@ Private WithEvents ActiveLockEventSink As ActiveLockEventNotifier Attribute ActiveLockEventSink.VB_VarHelpID = -1 -'Private Sub ActiveLockEventSink_Validate(Lic As ProductLicense, Result As Variant) -Private Sub ActiveLockEventSink_ValidateKey(ByVal strLic As String, ByVal strKey As String, Result As Variant) - ' Decrypt LicenseKey using our private key - strKey = modMain.Decrypt(strKey) -Debug.Print "ActiveLockEventSink_Validate key: " & vbCrLf & strKey - Dim strKey2$ -' Dim arrBytes() As Byte -' arrBytes = StrConv(strKey, vbFromUnicode) - strKey2 = TrimNulls(strKey) ' trim nulls - ' Compare for a match against Lic.ToString() - ' If matched return YES; otherwise return NO - If strLic = strKey2 Then - Result = modActiveLock.MAGICNUMBER_YES - Else - Result = modActiveLock.MAGICNUMBER_NO - End If -End Sub +''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' +' Key Validation Functionalities +''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' + +'Private Sub ActiveLockEventSink_ValidateKey(ByVal strLic As String, Result As Variant) +' ' Decrypt LicenseKey using our private key +' strKey = modMain.Decrypt(strKey) +'Debug.Print "ActiveLockEventSink_Validate key: " & vbCrLf & strKey +' Dim strKey2$ +'' Dim arrBytes() As Byte +'' arrBytes = StrConv(strKey, vbFromUnicode) +' strKey2 = TrimNulls(strKey) ' trim nulls +' ' Compare for a match against Lic.ToString() +' ' If matched return YES; otherwise return NO +' If strLic = strKey2 Then +' Result = modActiveLock.MAGICNUMBER_YES +' Else +' Result = modActiveLock.MAGICNUMBER_NO +' End If +'End Sub Private Sub ActiveLockEventSink_ValidateValue(ByVal Value As String, Result As String) Result = modMain.Encrypt(Value) End Sub -Private Sub cboSpeed_Click() - atViewPort1.TickerSpeed = cboSpeed.ListIndex -End Sub - -Private Sub chkBlackout_Click() - atViewPort1.TickerBlackout = chkBlackout - If chkBlackout Then - atViewPort1.BalloonTipText = "Cannot Display Message In Blackout Mode" - atViewPort1.BalloonTipIcon = WarningIcon - atViewPort1.BalloonTipTitle = "Sorry:" - Else - atViewPort1.BalloonTipText = atViewPort1.TickerText - atViewPort1.BalloonTipIcon = InfoIcon - atViewPort1.BalloonTipTitle = "ActiveTicker Says:" - End If -End Sub - -Private Sub chkEnable_Click() - atViewPort1.BalloonTipEnabled = chkEnable - If chkEnable Then - atViewPort1.BalloonTipIcon = InfoIcon - atViewPort1.BalloonTipTitle = "ActiveTicker Says:" - atViewPort1.BalloonTipText = atViewPort1.TickerText - End If -End Sub - -Private Sub chkFlash_Click() - atViewPort1.TickerFlash = chkFlash -End Sub - -Private Sub chkPause_Click() - atViewPort1.TickerPause = chkPause -End Sub - -Private Sub chkScroll_Click() - atViewPort1.TickerScroll = chkScroll -End Sub - -Private Sub chkSound_Click() - atViewPort1.TickerPlaySound = chkSound -End Sub - - +''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' +' Key Generator Functionalities +''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Private Sub cmbLicClass_Click() If cmbLicClass = "Class 1 - Lock To MAC" Then MyActiveLock.LockType = lockMAC @@ -695,25 +658,44 @@ End With End Sub +'' +' Generate liberation key Private Sub cmdKeyGen_Click() - ' Generate liberation key ' Take request code and decrypt it. Dim strReq As String - strReq = modMain.Decrypt(txtReqCodeIn) + strReq = ActiveLock2.Base64Decode(txtReqCodeIn) ' strReq now contains the {MAC + vbLf + User} string Dim strMAC$, strUser$ GetMACAndUserFromRequestCode strReq, strMAC, strUser - ' encrypt Product license using the MAC Dim strExpire$ strExpire = GetExpirationDate() + + ' registration date + Dim strRegDate As String + strRegDate = Format(Now(), "yyyy/mm/dd") + Dim strEncrypted As String + ActiveLockEventSink_ValidateValue strRegDate, strEncrypted + ' hash it + strEncrypted = ActiveLock2.MD5Hash(strEncrypted) + Dim Lic As ProductLicense Set Lic = ActiveLock2.CreateProductLicense(txtName, txtSoftwareCodePub, _ - txtVersion, MyActiveLock.LockType, MyActiveLock.LicenseType, strUser, strExpire) - Dim strLic As String * 2048 - strLic = MyActiveLock.GetLockString(Lic) - ' encrypt using public key so that only us can decrypt it later - strLic = modMain.Encrypt(strLic) - txtLibKey = strLic + txtVersion, MyActiveLock.LockType, MyActiveLock.LicenseType, strUser, strExpire, , strRegDate, strEncrypted) + Dim strLic As String + ' encrypt Product license using the MAC + strLic = MyActiveLock.LockCode(Lic) + ' sign it + Dim strSig As String + strSig = ActiveLock2.RSASign(PUB_KEY, PRIV_KEY, strLic) + ' Create liberation key. This will be a base-64 encoded string of the whole license. + Dim strLicKey As String + strLicKey = ActiveLock2.Base64Encode(strSig) + ' update Lic with license key + Lic.LicenseKey = strLicKey + ' serialize it into a formatted string + Dim strLibKey As String + Lic.Save strLibKey + txtLibKey = strLibKey End Sub Private Function GetExpirationDate() As String @@ -728,7 +710,7 @@ Dim Index% Index = InStr(1, strReq, vbLf) If Index <= 0 Then Exit Sub - + strMAC = Left(strReq, Index - 1) strUser = Mid$(strReq, Index + 1) strUser = TrimNulls(strUser) @@ -751,13 +733,27 @@ ' return -1 End Function +''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' +' Key Request and Registration Functionalities +''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' +Private Sub cmdReqGen_Click() + ' Generate Request code to MAC Address + ' TODO: Handle other possibilities (Windows serial, etc...) + Dim strReq As String, strLock As String + strLock = MyActiveLock.LockCode() + ' combine with user name + strReq = strLock & vbLf & txtUser + ' base-64 encode the request + Dim strReq2 As String + strReq2 = ActiveLock2.Base64Encode(strReq) + txtReqCodeGen = strReq2 +End Sub + Private Sub cmdRegister_Click() On Error GoTo errHandler - ' TODO: Register this key - Dim Lic As ActiveLock2.ProductLicense - Set Lic = ActiveLock2.CreateProductLicense(txtName, txtSoftwareCodePub, txtVersion, _ - MyActiveLock.LockType, MyActiveLock.LicenseType, _ - txtUser, GetExpirationDate(), txtLibKeyIn) + ' Register this key + Dim Lic As New ActiveLock2.ProductLicense + Lic.Load txtLibKey MyActiveLock.Register Lic MsgBox "Registration successful!" Exit Sub @@ -765,16 +761,49 @@ MsgBox Err.Number & ": " & Err.Description End Sub -Private Sub cmdReqGen_Click() - ' Generate Request code to MAC Address - ' TODO: Handle other possibilities (Windows serial, etc...) - Dim strReq As String, strLock As String - strLock = MyActiveLock.GetLockString() - ' combine with user name - strReq = strLock & vbLf & txtUser - ' encrypt using our public key so that only us can decrypt it - strReq = modMain.Encrypt(strReq) - txtReqCodeGen = strReq +''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' +' The rest of the application's functionalities +''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' +Private Sub cboSpeed_Click() + atViewPort1.TickerSpeed = cboSpeed.ListIndex +End Sub + +Private Sub chkBlackout_Click() + atViewPort1.TickerBlackout = chkBlackout + If chkBlackout Then + atViewPort1.BalloonTipText = "Cannot Display Message In Blackout Mode" + atViewPort1.BalloonTipIcon = WarningIcon + atViewPort1.BalloonTipTitle = "Sorry:" + Else + atViewPort1.BalloonTipText = atViewPort1.TickerText + atViewPort1.BalloonTipIcon = InfoIcon + atViewPort1.BalloonTipTitle = "ActiveTicker Says:" + End If +End Sub + +Private Sub chkEnable_Click() + atViewPort1.BalloonTipEnabled = chkEnable + If chkEnable Then + atViewPort1.BalloonTipIcon = InfoIcon + atViewPort1.BalloonTipTitle = "ActiveTicker Says:" + atViewPort1.BalloonTipText = atViewPort1.TickerText + End If +End Sub + +Private Sub chkFlash_Click() + atViewPort1.TickerFlash = chkFlash +End Sub + +Private Sub chkPause_Click() + atViewPort1.TickerPause = chkPause +End Sub + +Private Sub chkScroll_Click() + atViewPort1.TickerScroll = chkScroll +End Sub + +Private Sub chkSound_Click() + atViewPort1.TickerPlaySound = chkSound End Sub Private Sub cmdTest_Click() @@ -789,9 +818,9 @@ Set MyActiveLock = ActiveLock2.NewInstance() MyActiveLock.KeyStoreType = alsFile MyActiveLock.KeyStorePath = App.Path & "\al.lic" - + Set ActiveLockEventSink = MyActiveLock.EventNotifier - + ' Initialize other application settings With atViewPort1 .BalloonTipEnabled = chkEnable @@ -808,13 +837,13 @@ txtSoftwareCodePub = modMain.PUB_KEY cmbLicType = "Periodic" cmbLicClass = "Class 1 - Lock To MAC" - + ' Check registration status On Error GoTo NotRegistered MyActiveLock.Acquire txtRegStatus = "Registered" txtUsedDays = MyActiveLock.UsedDays - txtExpiration = MyActiveLock.RegisteredDate + txtExpiration = MyActiveLock.ExpirationDate FunctionalitiesEnabled = True Exit Sub NotRegistered: Index: modMain.bas =================================================================== RCS file: /cvsroot/activelock/activelock2/test/modMain.bas,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- modMain.bas 21 Jul 2003 08:54:38 -0000 1.2 +++ modMain.bas 28 Jul 2003 06:39:58 -0000 1.3 @@ -205,43 +205,29 @@ ' !!!WARNING!!! ' It is alright to use these same keys for testing your application. But it is highly recommended ' that you generate your own set of keys to use before deploying your app. -Public Const PRIV_KEY$ = "AAAAgExmVeTKhLWc6fa8dsCXI/8XfdGndhZqOoKVkPGhRcZTYjBflth6AkgVKP0eRfRNcv6ZHPZDu3LCGN1gLa91MUkzgvIKmdho6/cz7pMgxQceetp8/qvctjwEmbQm1iUh0DF/J8Y2KEiX4huMUUOv/THCuJSxzfwOWP/WCziTmz1tAAAAQQC72ahbiQC/+VM5XMNu3lcDWuwFIX7xmo+DI3tlfnlovJ9tS0mTk9uH8CvErK/4VMDj2H+PmUl7GcdT0PtIF7vRAAAAQQCaF7cQLP3rrJzXH5e1oAlefgPBe9oWP/6j5sAobM/BVBhePr3erlGF8a9WQCkbXoCdItWj3JuhAFE7OMoJ5ShdAAAAQQCSL6pFfKvlxtVgdSUyB60Z7VYcORBlp8mn3CAixwWJV8GviB0rLPFwqPqARlAo30W93xSvnCmhNt94QYpmh2Oq" -Public Const PUB_KEY$ = "AAAAB3NzaC1yc2EAAAABJQAAAIBxElYppptzL+mgXptF/mh5iSraIM19VYnLgTKtStfoFQH1rDEr58XvzWWfkzRVFnb97Njxl3GVXLQo6oEN6uKMZL1pe2Z8ZacBw766AxKeHlFR28RXYvy+BON5YP9Crgdncz/GZkBbDWOx9NXCX9gQRQJFv7s7bsbGZWxMQOzi7Q==" - -Private mKey As RSAKey -Private mfKeyInitd As Boolean - -Private Function GetCryptKey() As RSAKey - If Not mfKeyInitd Then - modActiveLock.rsa_createkey PUB_KEY, Len(PUB_KEY), PRIV_KEY, Len(PRIV_KEY), mKey - mfKeyInitd = True - End If - GetCryptKey = mKey -End Function +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==" -'' -' Encrypt using private key. Base64-encode the encrypted data. -' Note that we need to encrypt using our private key, not public -' key because that would be pointless. -' e.g. only we can generate the license key, not any Joe Imposter. -' Public Function Encrypt(strData As String) As String - Dim strData2 As String * 2048 - ' TODO: String * 2048 is a workaround for bug in rsa_decrypt() in ALCrypto.Dll that I don't have time to fix right now. - ' Bug: rsa_decrypt need to account for the possibility of the decrypted string being longer than the encrypted string. - strData2 = strData - ' encrypt using private key. - modActiveLock.rsa_encrypt 1, strData2, Len(strData2), GetCryptKey() - Encrypt = modBase64.Base64_Encode(strData2) -End Function + Dim Key As RSAKey + ' create the key from the key blobs + ' NOTE: I'm being lazy here. We can (and should) use a different keyset for data encryption. + ' PUB_KEY and PRIV_KEY should only used for license key signing and verification. + ' i.e. PRIV_KEY should only be accessible from the Key Generator and only PUB_KEY is + ' available in the deployed application. + ' Also, we can't encrypt using public key because public key is openly visible in the license + ' file and should only be used for verification, not encryption. + modActiveLock.rsa_createkey PUB_KEY, Len(PUB_KEY), PRIV_KEY, Len(PRIV_KEY), Key + ' sign the data using the created key + Dim dLen& + Dim strEnc As String * 255 + strEnc = strData + dLen = Len(strData) + modActiveLock.rsa_encrypt 1, strEnc, dLen, Key + ' done with the key - throw it away + modActiveLock.rsa_freekey Key -'' -' Decrypts using public key. strData is a base64-encoded string of the encrypted data. -Public Function Decrypt(strData As String) As String - Dim strData2 As String * 2048 - ' Base64-decode it first - strData2 = modBase64.Base64_Decode(strData) - ' now decrypt - modActiveLock.rsa_decrypt 0, strData2, GetCryptKey() - Decrypt = strData2 + Dim strOut As String + strOut = Left$(strEnc, dLen) + Encrypt = strOut End Function Index: ALCrypto.dll =================================================================== RCS file: /cvsroot/activelock/activelock2/test/ALCrypto.dll,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 Binary files /tmp/cvsgt8P8e and /tmp/cvsMnl7Tl differ |