[ActiveLock-Development] CVS: activelock2/src ActiveLock.cls,1.5,1.6 ActiveLock2.vbp,1.6,1.7 ActiveL
Brought to you by:
ialkan
From: Thanh H. T. <th...@us...> - 2003-07-28 06:35:36
|
Update of /cvsroot/activelock/activelock2/src In directory sc8-pr-cvs1:/tmp/cvs-serv8456 Modified Files: ActiveLock.cls ActiveLock2.vbp ActiveLockEventNotifier.cls FileKeyStore.cls Globals.cls IActiveLock.cls modActiveLock.bas ProductLicense.cls ActiveLock2.dll ALCrypto.dll Log Message: In this update, I'm introducing RSA signature technology into the mix. RSA signature will be be used for generating license keys. The process of key generation will be equivalent to signing a particular license with a product's private key. Presumably, this private key resides only on the machine containing the key generator (inside a database or something). They can't hack it if it's not there, right? The deployed application will have access to a public key that it will used to verify the license key (the signature). (This is otherwise known to AL 1.x user as the SoftwareCode, although you see I've changed its semantics a little bit.) Oh, and I also fixed the problem where extraneous characters are generated at the end of the liberation key. Index: ActiveLock.cls =================================================================== RCS file: /cvsroot/activelock/activelock2/src/ActiveLock.cls,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- ActiveLock.cls 23 Jul 2003 03:53:43 -0000 1.5 +++ ActiveLock.cls 28 Jul 2003 06:35:30 -0000 1.6 @@ -63,8 +63,8 @@ ' / MODULE CHANGE LOG / ' /////////////////////////////////////////////////////////////////////// ' -' 07.07.03 - mcrute - Updated the header comments for this file. -' +' 07.07.03 - mcrute - Updated the header comments for this file. +' 07.28.03 - th2tran - Using RSA signature for license key. ' ' /////////////////////////////////////////////////////////////////////// ' / MODULE CODE BEGINS BELOW THIS LINE / @@ -97,28 +97,6 @@ Set IActiveLock_EventNotifier = MyNotifier End Property -Private Function IActiveLock_GetLockString(Optional Lic As ProductLicense = Nothing) As String - Dim strLock As String - - If (mLockTypes And lockMAC) = lockMAC Then - strLock = strLock & modMACAddress.GetMACAddress() - End If - If mLockTypes And lockComp Then - ' TODO: strLock = strLock & GetComputerName() - End If - If mLockTypes And lockHD Then - ' TODO: strLock = strLock & GetComputerName() - End If - If mLockTypes And lockWindows Then - ' TODO: strLock = strLock & GetWindowSerial() - End If - If Lic Is Nothing Then - IActiveLock_GetLockString = strLock - Else - IActiveLock_GetLockString = Lic.ToString() & vbCrLf & strLock - End If -End Function - Private Sub IActiveLock_Init(Arg1 As Variant, ParamArray OtherArgs() As Variant) ' Do nothing. No extra initialization needed for now. End Sub @@ -133,13 +111,8 @@ If Lic Is Nothing Then Err.Raise ActiveLockErrCodeConstants.alerrNoLicense, "IActiveLock_Acquire", "No valid license" End If - Dim varResult As Variant - MyNotifier.Notify "ValidateKey", IActiveLock_GetLockString(Lic), Lic.LicenseKey, varResult - ' Check varResult for an affirmative - If CLng(varResult) <> modActiveLock.MAGICNUMBER_YES Then - Err.Raise ActiveLockErrCodeConstants.alerrLicenseInvalid, "IActiveLock_RegisteredDate", "License invalid." - End If - ' TODO: Check if license has not expired + ' Validate license + ValidateLic Lic End Sub Private Property Get IActiveLock_RegisteredDate() As String @@ -149,14 +122,83 @@ Err.Raise ActiveLockErrCodeConstants.alerrNoLicense, "IActiveLock_RegisteredDate", "No license." End If ' Validate the License. - Dim varResult As Variant - MyNotifier.Notify "ValidateKey", IActiveLock_GetLockString(Lic), Lic.LicenseKey, varResult - If CLng(varResult) <> modActiveLock.MAGICNUMBER_YES Then - Err.Raise ActiveLockErrCodeConstants.alerrLicenseInvalid, "IActiveLock_RegisteredDate", "License invalid." - End If + ValidateLic Lic IActiveLock_RegisteredDate = Lic.RegisteredDate End Property +'' +' Validate the License Key using RSA signature verification. +' License key contains the RSA signature of IActiveLock_LockCode. +Private Sub ValidateKey(Lic As ProductLicense) + Dim Key As RSAKey + Dim strPubKey As String + strPubKey = mSoftwareCode + Dim strSig As String + Dim strLic As String + strLic = IActiveLock_LockCode(Lic) + ' decode the license key + strSig = MyGlobals.Base64Decode(Lic.LicenseKey) + ' validate the key + Dim rc& + rc = MyGlobals.RSAVerify(strPubKey, strLic, strSig) + If rc <> 0 Then + Err.Raise ActiveLockErrCodeConstants.alerrLicenseInvalid, "ActiveLock2", "License invalid." + End If + ' Check if license has not expired + Dim dtExp As Date + dtExp = CDate(Lic.Expiration) + If Now > dtExp Then + Err.Raise ActiveLockErrCodeConstants.alerrLicenseExpired, "ActiveLock2", "License expired" + End If +End Sub + +'' +' Validate the entire license (including lastused, etc...) +' +Private Sub ValidateLic(Lic As ProductLicense) + ' validate license key first + ValidateKey Lic + Dim strEncrypted As String, strHash As String + ' Validate last run date + MyNotifier.Notify "ValidateValue", Lic.LastUsed, strEncrypted + strHash = MyGlobals.MD5Hash(strEncrypted) + If strHash <> Lic.Hash1 Then + Err.Raise ActiveLockErrCodeConstants.alerrLicenseTampered, "ActiveLock2", "License may have been tampered." + End If + ' try to detect the user setting their system clock back + If Now < CDate(Lic.LastUsed) Then + ' TODO: Need to account for Daylight Savings Time + Err.Raise ActiveLockErrCodeConstants.alerrLockChanged, "ActiveLock2", "License invalid. You have set your system clock backward!" + End If + UpdateLastUsed Lic + mKeyStore.Store Lic +End Sub + +'' +' Updates LastUsed property with current date stamp. +' +Private Sub UpdateLastUsed(Lic As ProductLicense) + ' Update license store with LastRunDate + Dim strEncrypted As String + Dim strLastUsed As String + strLastUsed = Format(Now(), "YYYY/MM/DD HH:MM:SS") + Lic.LastUsed = strLastUsed + MyNotifier.Notify "ValidateValue", strLastUsed, strEncrypted + Lic.Hash1 = MyGlobals.MD5Hash(strEncrypted) +End Sub + +Private Property Get IActiveLock_ExpirationDate() As String + Dim Lic As ProductLicense + Set Lic = mKeyStore.Retrieve(mSoftwareName) + If Lic Is Nothing Then + Err.Raise ActiveLockErrCodeConstants.alerrNoLicense, "IActiveLock_ExpirationDate", "No license." + End If + ' Validate the License. + ValidateLic Lic + IActiveLock_ExpirationDate = Lic.Expiration +End Property + + Private Sub IActiveLock_Release() ' TODO: Implement Me! End Sub @@ -197,24 +239,24 @@ Private Sub IActiveLock_Register(Lic As ProductLicense) - ' Validate that the liberation key contains the combination of these properties + ' Validate that the license key. ' - registered user ' - expiry date Dim varResult As Variant - MyNotifier.Notify "ValidateKey", IActiveLock_GetLockString(Lic), Lic.LicenseKey, varResult - If CLng(varResult) <> modActiveLock.MAGICNUMBER_YES Then - Err.Raise ActiveLockErrCodeConstants.alerrLicenseInvalid, "IActiveLock_Register", "License invalid." - End If + ValidateKey Lic ' License was validated successfuly. Store it. If mKeyStore Is Nothing Then Err.Raise ActiveLockErrCodeConstants.alerrKeyStoreInvalid, "IActiveLock_Register", "Key Store Provider hasn't been initialized yet." End If - ' obtain encrypted value for the RegisteredDate - Lic.RegisteredDate = Format(Now(), "yyyy/mm/dd") - Dim strEncrypted As String - MyNotifier.Notify "ValidateValue", Lic.RegisteredDate, strEncrypted - ' hash it - Lic.Hash1 = modMD5.Hash(strEncrypted) +' ' obtain encrypted value for the RegisteredDate +' Lic.RegisteredDate = Format(Now(), "yyyy/mm/dd") +' Dim strEncrypted As String +' MyNotifier.Notify "ValidateValue", Lic.RegisteredDate, strEncrypted +' ' hash it +' Lic.Hash1 = modMD5.Hash(strEncrypted) + + ' Update last used date + UpdateLastUsed Lic mKeyStore.Store Lic End Sub @@ -237,6 +279,27 @@ IActiveLock_SoftwareName = mSoftwareName End Property +Private Function IActiveLock_LockCode(Optional Lic As ProductLicense = Nothing) As String + Dim strLock As String + + If (mLockTypes And lockMAC) = lockMAC Then + strLock = strLock & modMACAddress.GetMACAddress() + End If + If mLockTypes And lockComp Then + ' TODO: strLock = strLock & GetComputerName() + End If + If mLockTypes And lockHD Then + ' TODO: strLock = strLock & GetComputerName() + End If + If mLockTypes And lockWindows Then + ' TODO: strLock = strLock & GetWindowSerial() + End If + If Lic Is Nothing Then + IActiveLock_LockCode = strLock + Else + IActiveLock_LockCode = Lic.ToString() & vbCrLf & strLock + End If +End Function Private Property Let IActiveLock_SoftwareVersion(RHS As String) mSoftwareVer = RHS @@ -245,11 +308,12 @@ IActiveLock_SoftwareVersion = mSoftwareVer End Property - Private Property Let IActiveLock_SoftwareCode(RHS As String) + ' SoftwareCode is an RSA public key. This code will be used to verify license keys later on. mSoftwareCode = RHS End Property + Private Function IActiveLock_Transfer(OtherSoftwareCode As String) As String ' TODO: Implement me! End Function @@ -257,14 +321,7 @@ Private Property Get IActiveLock_UsedDays() As Long Dim Lic As ProductLicense Set Lic = mKeyStore.Retrieve(mSoftwareName) - Dim Result As String - MyNotifier.Notify "ValidateValue", Lic.RegisteredDate, Result - ' Hash Result and compare against Lic.RegisteredDate - Dim strHash$ - strHash = modMD5.Hash(Result) - - If strHash <> Lic.Hash1 Then - Err.Raise ActiveLockErrCodeConstants.alerrLicenseTampered, "IActiveLock", "License may have been tampered." - End If + ' validate the license + ValidateLic Lic IActiveLock_UsedDays = CLng(DateDiff("d", Lic.RegisteredDate, Now)) End Property Index: ActiveLock2.vbp =================================================================== RCS file: /cvsroot/activelock/activelock2/src/ActiveLock2.vbp,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- ActiveLock2.vbp 23 Jul 2003 02:55:33 -0000 1.6 +++ ActiveLock2.vbp 28 Jul 2003 06:35:30 -0000 1.7 @@ -1,6 +1,5 @@ Type=OleDll Reference=*\G{00020430-0000-0000-C000-000000000046}#2.0#0#C:\WINDOWS\System32\stdole2.tlb#OLE Automation -Reference=*\G{420B2830-E718-11CF-893D-00A0C9054228}#1.0#0#C:\WINDOWS\System32\scrrun.dll#Microsoft Scripting Runtime Class=ActiveLock; ActiveLock.cls Class=IActiveLock; IActiveLock.cls Class=Globals; Globals.cls @@ -17,6 +16,7 @@ Module=modWinApi; modWinApi.bas Class=ActiveLockEventNotifier; ActiveLockEventNotifier.cls Module=modActiveLock; modActiveLock.bas +Module=modBase64; modBase64.bas Startup="(None)" HelpFile="" Title="ActiveLock2" @@ -25,6 +25,7 @@ Name="ActiveLock2" HelpContextID="0" CompatibleMode="1" +CompatibleEXE32="ActiveLock2.dll" MajorVer=2 MinorVer=0 RevisionVer=0 Index: ActiveLockEventNotifier.cls =================================================================== RCS file: /cvsroot/activelock/activelock2/src/ActiveLockEventNotifier.cls,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- ActiveLockEventNotifier.cls 23 Jul 2003 06:41:26 -0000 1.2 +++ ActiveLockEventNotifier.cls 28 Jul 2003 06:35:30 -0000 1.3 @@ -73,12 +73,6 @@ Option Explicit '' -' License Key Validation event. -' @param strLic String returned from ProductLicense.ToString() -' @param strKey License key. -' @param varResult Result value. -Public Event ValidateKey(ByVal strLic As String, ByVal strKey As String, varResult As Variant) -'' ' ProductLicense Property Value validation event allows the client application ' to return the encrypted version of a license property value. ' @param Value Property value. @@ -86,9 +80,7 @@ Public Event ValidateValue(ByVal Value As String, Result As String) Friend Sub Notify(EventName As String, ParamArray Args()) - If EventName = "ValidateKey" Then - RaiseEvent ValidateKey(CStr(Args(0)), CStr(Args(1)), Args(2)) - ElseIf EventName = "ValidateValue" Then + If EventName = "ValidateValue" Then Dim Result As String Result = Args(1) RaiseEvent ValidateValue(CStr(Args(0)), Result) Index: FileKeyStore.cls =================================================================== RCS file: /cvsroot/activelock/activelock2/src/FileKeyStore.cls,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- FileKeyStore.cls 23 Jul 2003 03:55:21 -0000 1.5 +++ FileKeyStore.cls 28 Jul 2003 06:35:30 -0000 1.6 @@ -77,7 +77,7 @@ Private mIniFile As New INIFile ' License File Key names -Private Const KEY_PRODKEY$ = "ProductCode" +Private Const KEY_PRODKEY$ = "ProductKey" Private Const KEY_PRODNAME$ = "ProductName" Private Const KEY_PRODVER$ = "ProductVersion" Private Const KEY_LICENSEE$ = "Licensee" @@ -86,7 +86,8 @@ Private Const KEY_LICKEY$ = "LicenseKey" Private Const KEY_EXP$ = "Expiration" Private Const KEY_REGISTERED_DATE$ = "RegisteredDate" -Private Const KEY_REGISTERED_DATE_HASH$ = "Hash1" +Private Const KEY_LASTRUN_DATE$ = "LastUsed" ' date and time stamp +Private Const KEY_LASTRUN_DATE_HASH$ = "Hash1" ' Hash of LastRunDate Private Property Let IKeyStoreProvider_KeyStorePath(RHS As String) If Not FileExists(RHS) Then @@ -108,7 +109,8 @@ mIniFile.Values(KEY_LICENSEE) = .Licensee mIniFile.Values(KEY_LICKEY) = .LicenseKey mIniFile.Values(KEY_REGISTERED_DATE) = .RegisteredDate - mIniFile.Values(KEY_REGISTERED_DATE_HASH) = .Hash1 + mIniFile.Values(KEY_LASTRUN_DATE) = .LastUsed + mIniFile.Values(KEY_LASTRUN_DATE_HASH) = .Hash1 mIniFile.Values(KEY_EXP) = .Expiration End With @@ -120,6 +122,7 @@ Private Function IKeyStoreProvider_Retrieve(ProductName As String) As ProductLicense Dim Lic As New ProductLicense ' Read license properties from INI file section + ' TODO: Perhaps we need to lock the file first.? mIniFile.Section = ProductName With Lic .ProductName = ProductName @@ -131,7 +134,8 @@ .LicenseKey = mIniFile.GetValue(KEY_LICKEY) .Expiration = mIniFile.GetValue(KEY_EXP) .RegisteredDate = mIniFile.Values(KEY_REGISTERED_DATE) - .Hash1 = mIniFile.Values(KEY_REGISTERED_DATE_HASH) + .LastUsed = mIniFile.Values(KEY_LASTRUN_DATE) + .Hash1 = mIniFile.Values(KEY_LASTRUN_DATE_HASH) End With Set IKeyStoreProvider_Retrieve = Lic End Function Index: Globals.cls =================================================================== RCS file: /cvsroot/activelock/activelock2/src/Globals.cls,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- Globals.cls 23 Jul 2003 07:04:08 -0000 1.6 +++ Globals.cls 28 Jul 2003 06:35:30 -0000 1.7 @@ -92,6 +92,7 @@ alerrLicenseInvalid = &H80040002 alerrLicenseExpired = &H80040003 alerrLicenseTampered = &H80040004 + alerrLockChanged = &H80040005 alerrKeyStoreInvalid = &H80040010 End Enum @@ -134,6 +135,12 @@ If Not IsMissing(LicKey) Then .LicenseKey = LicKey End If + If Not IsMissing(RegisteredDate) Then + .RegisteredDate = RegisteredDate + End If + If Not IsMissing(Hash1) Then + .Hash1 = Hash1 + End If End With Set CreateProductLicense = NewLic End Function @@ -154,4 +161,63 @@ Private Function GetLicTypeString(LicType As ALLicType) As String 'TODO: Implement this properly. GetLicTypeString = "Single" +End Function + +'' +' Trim Null characters from the string. +' +Public Function TrimNulls(str As String) As String + TrimNulls = modActiveLock.TrimNulls(str) +End Function +'' +' Computes an MD5 hash of the specified string. +' +Public Function MD5Hash(str As String) As String + MD5Hash = modMD5.Hash(str) +End Function + +'' +' Base-64 encode the specified string. +' +Public Function Base64Encode(str As String) As String + Base64Encode = modBase64.Base64_Encode(str) +End Function + +'' +' Base-64 decode the string. +' +Public Function Base64Decode(strEncoded As String) As String + Base64Decode = modBase64.Base64_Decode(strEncoded) +End Function + +'' +' Performs RSA signing of strData using the specified key. +' +Public Function RSASign(strPub As String, strPriv As String, strdata As String) As String + Dim Key As RSAKey + ' create the key from the key blobs + modActiveLock.rsa_createkey strPub, Len(strPub), strPriv, Len(strPriv), Key + ' sign the data using the created key + Dim sLen& + rsa_sign Key, strdata, Len(strdata), vbNullString, sLen + Dim strSig As String: strSig = String(sLen, 0) + modActiveLock.rsa_sign Key, strdata, Len(strdata), strSig, sLen + ' throw away the key + modActiveLock.rsa_freekey Key + RSASign = strSig +End Function + +'' +' Verifies an RSA signature. +' +Public Function RSAVerify(strPub As String, strdata As String, strSig As String) As Long + Dim Key As RSAKey + Dim rc& + ' create the key from the public key blob + rsa_createkey strPub, Len(strPub), vbNullString, 0, Key + ' validate the key + rc = rsa_verifysig(Key, strSig, Len(strSig), strdata, Len(strdata)) + ' de-allocate memory used by the key + rsa_freekey Key + RSAVerify = rc End Function Index: IActiveLock.cls =================================================================== RCS file: /cvsroot/activelock/activelock2/src/IActiveLock.cls,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- IActiveLock.cls 23 Jul 2003 03:53:43 -0000 1.5 +++ IActiveLock.cls 28 Jul 2003 06:35:30 -0000 1.6 @@ -8,7 +8,7 @@ END Attribute VB_Name = "IActiveLock" Attribute VB_GlobalNameSpace = False -Attribute VB_Creatable = True +Attribute VB_Creatable = False Attribute VB_PredeclaredId = False Attribute VB_Exposed = True '* ActiveLock @@ -127,7 +127,7 @@ ' @param Args '* [th2tran20030720] I can't think of any special initialization that is required right now. ' But let's keep this for future use. -Public Sub Init(Arg1 As Variant, ParamArray OtherArgs()) +Public Sub Init(Arg1 As Variant, ParamArray OtherArgs() As Variant) End Sub @@ -165,6 +165,12 @@ End Property +'' +' Specifies the software code (product code) +' +Public Property Let SoftwareCode(sCode As String) + +End Property '' ' Specifies the version of the product being locked. @@ -179,9 +185,9 @@ '' ' Specifies the product code for the product being locked. ' -Public Property Let SoftwareCode(sCode As String) - -End Property +'Public Property Get SoftwareCode(sCode As String) +' +'End Property '' ' Specifies the key store type. @@ -202,10 +208,9 @@ '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' '' -' Returns the lock string corresponding to the set LockType. +' Returns the software code corresponding to the set LockTypes, license class, etc... ' Optionally, if a product license is specified, then a lock string specific to that license is returned. -' -Public Function GetLockString(Optional Lic As ProductLicense = Nothing) As String +Public Function LockCode(Optional Lic As ProductLicense = Nothing) As String End Function @@ -259,5 +264,12 @@ ' Returns the date on which the product was registered. ' Public Property Get RegisteredDate() As String + +End Property + +'' +' Returns the expiration date +' +Public Property Get ExpirationDate() As String End Property Index: modActiveLock.bas =================================================================== RCS file: /cvsroot/activelock/activelock2/src/modActiveLock.bas,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- modActiveLock.bas 21 Jul 2003 08:48:27 -0000 1.4 +++ modActiveLock.bas 28 Jul 2003 06:35:30 -0000 1.5 @@ -69,7 +69,7 @@ ' q As Integer ' iqmp As Integer ' comment As String - Data(32) As Byte + data(32) As Byte End Type '' @@ -78,10 +78,13 @@ Public Declare Function rsa_public_key_blob Lib "ALCrypto" (ptrKey As RSAKey, ByVal blob As String, blobLen As Long) As Long Public Declare Function rsa_private_key_blob Lib "ALCrypto" (ptrKey As RSAKey, ByVal blob As String, blobLen As Long) As Long Public Declare Function rsa_createkey Lib "ALCrypto" (ByVal pub_blob As String, ByVal pub_len As Long, ByVal priv_blob As String, ByVal priv_len As Long, ptrKey As RSAKey) As Long +Public Declare Function rsa_freekey Lib "ALCrypto" (ptrKey As RSAKey) As Long ' CryptType = 0 for public; 1 for private -Public Declare Function rsa_encrypt Lib "ALCrypto" (ByVal CryptType As Long, ByVal Data As String, ByVal dLen As Long, ptrKey As RSAKey) As Long -Public Declare Function rsa_decrypt Lib "ALCrypto" (ByVal CryptType As Long, ByVal Data As String, ptrKey As RSAKey) As Long +Public Declare Function rsa_encrypt Lib "ALCrypto" (ByVal CryptType As Long, ByVal data As String, dLen As Long, ptrKey As RSAKey) As Long +Public Declare Function rsa_decrypt Lib "ALCrypto" (ByVal CryptType As Long, ByVal data As String, dLen As Long, ptrKey As RSAKey) As Long +Public Declare Function rsa_sign Lib "ALCrypto" (ByRef ptrKey As RSAKey, ByVal data As String, ByVal dLen As Long, ByVal sig As String, ByRef sLen As Long) As Long +Public Declare Function rsa_verifysig Lib "ALCrypto" (ByRef ptrKey As RSAKey, ByVal sig As String, ByVal sLen As Long, ByVal data As String, ByVal dLen As Long) As Long Type PhaseType exponential As Byte startpoint As Byte Index: ProductLicense.cls =================================================================== RCS file: /cvsroot/activelock/activelock2/src/ProductLicense.cls,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- ProductLicense.cls 21 Jul 2003 08:48:27 -0000 1.3 +++ ProductLicense.cls 28 Jul 2003 06:35:30 -0000 1.4 @@ -8,7 +8,7 @@ END Attribute VB_Name = "ProductLicense" Attribute VB_GlobalNameSpace = False -Attribute VB_Creatable = False +Attribute VB_Creatable = True Attribute VB_PredeclaredId = False Attribute VB_Exposed = True '* ActiveLock @@ -79,6 +79,8 @@ Private mstrLicenseKey As String Private mstrExpiration As String Private mstrRegisteredDate As String +Private mstrLastUsed As String + Private mstrHash1 As String ' hash of mstrRegisteredDate ' CPU License Class - I don't yet know how this could be done! @@ -91,8 +93,8 @@ CLASS_2 = "Class2" End Property -Friend Property Let ProductName(Name As String) - mstrProductName = Name +Friend Property Let ProductName(name As String) + mstrProductName = name End Property Public Property Get ProductName() As String ProductName = mstrProductName @@ -105,7 +107,11 @@ ProductVer = mstrProductVer End Property -Friend Property Let ProductKey(Key As String) +'' +' !!!WARNING!!! Use this method with caution. You run the risk of invalidating your existing license +' if you call this method without knowing what you are doing. +' +Public Property Let ProductKey(Key As String) mstrProductKey = Key End Property Public Property Get ProductKey() As String @@ -126,14 +132,19 @@ LicenseClass = mstrLicenseClass End Property -Friend Property Let Licensee(Name As String) - mstrLicensee = Name +Friend Property Let Licensee(name As String) + mstrLicensee = name End Property Public Property Get Licensee() As String Licensee = mstrLicensee End Property -Friend Property Let LicenseKey(Key As String) +'' +' Updates the License Key. +' !!! WARNING !!! Make sure you know what you're doing when you call this method; otherwise, you run +' the risk of invalidating your existing license. +' +Public Property Let LicenseKey(Key As String) mstrLicenseKey = Key End Property @@ -164,6 +175,16 @@ End Property '' +' Returns the last date and time the product was run. +' +Public Property Get LastUsed() As String + LastUsed = mstrLastUsed +End Property +Friend Property Let LastUsed(strDateTime As String) + mstrLastUsed = strDateTime +End Property + +'' ' Returns Hash-1 code. ' Public Property Get Hash1() As String @@ -179,11 +200,39 @@ ' Note: LicenseKey is not included in this string. ' Public Function ToString() As String -' ToString = ProductID & vbCrLf & ToString = ProductName & vbCrLf & _ ProductVer & vbCrLf & _ + ProductKey & vbCrLf & _ LicenseClass & vbCrLf & _ LicenseType & vbCrLf & _ Licensee & vbCrLf & _ + RegisteredDate & vbCrLf & _ Expiration End Function + +'' +' Loads the license from a formatted string. +' +Public Sub Load(strLic As String) + ' First, base64-decode it + strLic = modBase64.Base64_Decode(strLic) + Dim arrParts() As String + arrParts = Split(strLic, vbCrLf) + ProductName = arrParts(0) + ProductVer = arrParts(1) + ProductKey = arrParts(2) + LicenseClass = arrParts(3) + LicenseType = arrParts(4) + Licensee = arrParts(5) + RegisteredDate = arrParts(6) + Expiration = arrParts(7) + LicenseKey = arrParts(8) +End Sub + +'' +' Saves the license into a formatted string. +' +Public Sub Save(strOut As String) + strOut = ToString() & vbCrLf & LicenseKey 'add License Key at the end + strOut = modBase64.Base64_Encode(strOut) +End Sub Index: ActiveLock2.dll =================================================================== RCS file: /cvsroot/activelock/activelock2/src/ActiveLock2.dll,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 Binary files /tmp/cvsRWmBj9 and /tmp/cvsCnzov9 differ Index: ALCrypto.dll =================================================================== RCS file: /cvsroot/activelock/activelock2/src/ALCrypto.dll,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 Binary files /tmp/cvsg9YVcd and /tmp/cvsgB6cZh differ |