Jump to content
  • 0
cjsmith87

Help translating the licence module plugin

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

Share this post


Link to post
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."}

Share this post


Link to post
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.

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×