Jump to content
  • 0

Help translating the licence module plugin


cjsmith87

Question

I am trying to use the licence module paid addon to licence desktop software. I have got the licence module working but I would ideally like to pass the encrypted data object back to the client and have the client decrypt it instead of having to pass the client info in clear text. I am using the plugins\licence_manager\dist folder as my reference and trying to work out if i could translate this into vb or c# so i can use it in our .net app. Has any one else done this or is anyone able to offer any advice on the best way to do this? Thanks

Link to comment
Share on other sites

3 answers to this question

Recommended Posts

  • 0

Ok so its not going! I just want to be able to Decrypt the data client side so I have been looking at the decrypt method on the Licence Manager. It looks like the Key and IV values for the Decryption are hashes of various bits of info. For reference this is how far I have got...

Dim decryptedData As String = Decrypt(EncryptedLicenseData, Security.GenerateHashSHA256(LicenseKey, SecretKey), Security.GenerateHashSHA256(PublicKey, SecretKey)) 

Public Shared Function GenerateHashSHA256(ByVal SourceText As String, SecretKey As String) As String
        Dim Ue As New UnicodeEncoding()
        Dim test As New HMACSHA256(Ue.GetBytes(SecretKey))
        Dim ByteHash() As Byte = test.ComputeHash(Ue.GetBytes(SourceText))
        Return Convert.ToBase64String(ByteHash)
    End Function

 Public Shared Function Decrypt(ByVal cipherText As String, xKey As String, xIV As String) As String

        Dim Ue As New UnicodeEncoding()

        Dim plaintext As String = Nothing

        Using aesAlg As New AesCryptoServiceProvider()

            aesAlg.Key = Ue.GetBytes(xKey.ToCharArray, 0, 8)
            aesAlg.IV = Ue.GetBytes(xIV.ToCharArray, 0, 8)

            Dim decryptor As ICryptoTransform = aesAlg.CreateDecryptor(aesAlg.Key, aesAlg.IV)

            Using msDecrypt As New MemoryStream(System.Text.Encoding.Unicode.GetBytes(cipherText))

                Using csDecrypt As New CryptoStream(msDecrypt, decryptor, CryptoStreamMode.Read)

                    Using srDecrypt As New StreamReader(csDecrypt)
                        plaintext = srDecrypt.ReadToEnd()
                    End Using
                End Using
            End Using
        End Using
        Return plaintext
    End Function

Currently it is not working. It complains about Block Length:  {"The input data is not a complete block."}

Link to comment
Share on other sites

  • 0

If you aren't planning on making changes to the license manager itself it is unlikely you will be able to make a client plugin in a different language.  The main thing that will cause troubles is signing with the public key. I mentioned this in another question about a java client.

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...