473,382 Members | 1,386 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Slowass license provider

Nak
Hi there,

I just made my own license provider (at last!) that uses signed XML
license files. When the license provider gets the license it does the
following,

*At runtime

1) Gets the signed XML license file from the calling assemblys resources
2) Gets the public RSA key from the calling assemblys resources
3) Attempts the validate the signature

*At design time

1) Gets the signed XML license file from same path the binary is
executing from (i.e. Obj\Debug or Obj\Release)
2) Gets the public RSA key from same path the binary is executing from
(i.e. Obj\Debug or Obj\Release)
3) Attempts the validate the signature

This works fine, and it seems to be quite a reliable method of control
licensing with 1 exception. It's damn slow!

Check this out, I timed the creation and disposal of 2 types of control,
1 licensed via my method and 1 not licensed at all. I timed how many could
be created in 1 minute in both circumstances and these were my results,

* I created 3,456,717 un-licensed controls in 1 minute

* I created 438 licensed controls in 1 minute

On closer inspection it turns out that the GetLicense method starts at
about 578ms then jumps around 94ms and 250ms each time. So obviously this
greatly reduces the speed of creating large numbers of controls. I would
ideally like to speed this up and I believe that there is a way to cache the
license file and possibly the public key too.

So that leaves me asking if anyone has any idea how I can create my own
LicenseContext class and get it passed to my license provider so that I can
use the SetSavedLicenseKey and the GetSavedLicenseKey methods (unless of
course there is another way around this). I have found an example from the
Windows Forms web site that creates a licensed component class, but I'm not
quite sure if this is what I need or not as this would intil creating lots
of derived classes from the licensed one.

Anyways, thanks for your time and I look forward to any suggestions!

Nick.
Nov 21 '05 #1
5 1592
Hi Nick,

Here is the link about create customlicensecontext, you may take a look.
http://www.windowsforms.net/Samples/...mId=123&tabind
ex=4

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 21 '05 #2
Nak
Hi Peter,

<quote>...
"I have found an example from the Windows Forms web site that creates a
licensed component class, but I'm not
quite sure if this is what I need or not as this would intil creating lots
of derived classes from the licensed one."

I know it was a bit of a long question so never mind. I think I have
just found out something quite interesting. *ALL* Licensed objects via a
license provider are "slowass" at being created in comparrison to unlicensed
controls, which would explain any bottle necks in my application. My PC is
making around 749,862 standard LicFileLicenseProvider licensed controls in 1
minute too.

I have thought of 1 idea to help speed up the process but it doesnt seem
to make any difference, I have created a custom attribute that allows you to
specify the public key to verify the XML file with, it seems that retrieving
data from an assemblys resources actually takes very little time. So at
the moment I am looking for another bottle neck and all I can think it is;
is that the license key for that type is *not* being cached, if it were it
would take very little to no time at all to create the 2nd object.

I *think* this is all the licene context does, *but* the example on
Windows Forms does *not* use a license provider and I must as I am wanting
to license any class via my own license provider so that I can in-turn sell
this product as a licensing solution. Surely other XML based licensing
systems arent this slow so it must be something I'm missing! :-(

Nick.
""Peter Huang"" <v-******@online.microsoft.com> wrote in message
news:hB**************@cpmsftngxa10.phx.gbl...
Hi Nick,

Here is the link about create customlicensecontext, you may take a look.
http://www.windowsforms.net/Samples/...mId=123&tabind
ex=4

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no
rights.

Nov 21 '05 #3
Nak
Hi again,

Even more scary results, I have managed to implement a custom
LicenseContext by altering the license managers context when my application
loads, now it caches the resource file in the form of a string in a
hashtable and the public key is passed via a custom attribute but it is
*still* as slow as a sloath swimming in molasses! So this leads me to
believe that it is the XML signature verification that is slow, this is my
routine,

-----------------------------------

Private Function verifyViaString(ByVal iType As Type, ByVal iLicense() As
Byte, ByVal iPublicKey As String) As Boolean
Try

'Firstly we load the XML license from a byte array into a memory
stream

Dim pMSmInput As New MemoryStream(iLicense)

'Then we load it into the XML document object

Dim pXDtXMLDoc As New XmlDocument()
Call pXDtXMLDoc.Load(pMSmInput)

'Then we create a new signature object

Dim pSXlSigned As New SignedXml(pXDtXMLDoc)
Dim pXNeSig As XmlNode =
pXDtXMLDoc.GetElementsByTagName("Signature",
SignedXml.XmlDsigNamespaceUrl)(0)
Call pSXlSigned.LoadXml(CType(pXNeSig, XmlElement))

'Then we set the public key to verify with

Dim pStrKey As String = iPublicKey

'The following check is used as an internal precauting within my
application

If (Not (pStrKey Is Nothing)) Then

'Then we create the CSP object to verify the signature with

Dim pRSACrypto As RSACryptoServiceProvider = New
RSACryptoServiceProvider()
Call pRSACrypto.FromXmlString(pStrKey)

'Lastly we verify the signature

If (pSXlSigned.CheckSignature(pRSACrypto)) Then
Return (True)
End If
End If
Finally
End Try
End Function

-----------------------------------

My understanding is that this is as fast as this method could possibly
be, but surely slowing it down as much as it is is not a viable solution.
Has anyone any ideas on how I can speed this little method up maybe? Or an
alternative method?

Nick.

"Nak" <a@a.com> wrote in message
news:e5**************@tk2msftngp13.phx.gbl...
Hi Peter,

<quote>...
"I have found an example from the Windows Forms web site that creates a
licensed component class, but I'm not
quite sure if this is what I need or not as this would intil creating lots
of derived classes from the licensed one."

I know it was a bit of a long question so never mind. I think I have
just found out something quite interesting. *ALL* Licensed objects via a
license provider are "slowass" at being created in comparrison to
unlicensed controls, which would explain any bottle necks in my
application. My PC is making around 749,862 standard
LicFileLicenseProvider licensed controls in 1 minute too.

I have thought of 1 idea to help speed up the process but it doesnt
seem to make any difference, I have created a custom attribute that allows
you to specify the public key to verify the XML file with, it seems that
retrieving data from an assemblys resources actually takes very little
time. So at the moment I am looking for another bottle neck and all I
can think it is; is that the license key for that type is *not* being
cached, if it were it would take very little to no time at all to create
the 2nd object.

I *think* this is all the licene context does, *but* the example on
Windows Forms does *not* use a license provider and I must as I am wanting
to license any class via my own license provider so that I can in-turn
sell this product as a licensing solution. Surely other XML based
licensing systems arent this slow so it must be something I'm missing! :-(

Nick.
""Peter Huang"" <v-******@online.microsoft.com> wrote in message
news:hB**************@cpmsftngxa10.phx.gbl...
Hi Nick,

Here is the link about create customlicensecontext, you may take a look.
http://www.windowsforms.net/Samples/...mId=123&tabind
ex=4

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no
rights.


Nov 21 '05 #4
Nak
AAaaah, and dumb I surely am!

I was caching the license keys in the context but still verifying them, and
in theory if a license key has already been verified in order to be cached
there is no point in verifying it again, so I just create a new license with
that key and return it straight away! Bobs your aunty or whatever and now
over 1 million licensed controls per minute! ;-)

Nick.

"Nak" <a@a.com> wrote in message
news:Od**************@TK2MSFTNGP15.phx.gbl...
Hi again,

Even more scary results, I have managed to implement a custom
LicenseContext by altering the license managers context when my
application loads, now it caches the resource file in the form of a string
in a hashtable and the public key is passed via a custom attribute but it
is *still* as slow as a sloath swimming in molasses! So this leads me to
believe that it is the XML signature verification that is slow, this is my
routine,

-----------------------------------

Private Function verifyViaString(ByVal iType As Type, ByVal iLicense() As
Byte, ByVal iPublicKey As String) As Boolean
Try

'Firstly we load the XML license from a byte array into a memory
stream

Dim pMSmInput As New MemoryStream(iLicense)

'Then we load it into the XML document object

Dim pXDtXMLDoc As New XmlDocument()
Call pXDtXMLDoc.Load(pMSmInput)

'Then we create a new signature object

Dim pSXlSigned As New SignedXml(pXDtXMLDoc)
Dim pXNeSig As XmlNode =
pXDtXMLDoc.GetElementsByTagName("Signature",
SignedXml.XmlDsigNamespaceUrl)(0)
Call pSXlSigned.LoadXml(CType(pXNeSig, XmlElement))

'Then we set the public key to verify with

Dim pStrKey As String = iPublicKey

'The following check is used as an internal precauting within my
application

If (Not (pStrKey Is Nothing)) Then

'Then we create the CSP object to verify the signature with

Dim pRSACrypto As RSACryptoServiceProvider = New
RSACryptoServiceProvider()
Call pRSACrypto.FromXmlString(pStrKey)

'Lastly we verify the signature

If (pSXlSigned.CheckSignature(pRSACrypto)) Then
Return (True)
End If
End If
Finally
End Try
End Function

-----------------------------------

My understanding is that this is as fast as this method could possibly
be, but surely slowing it down as much as it is is not a viable solution.
Has anyone any ideas on how I can speed this little method up maybe? Or an
alternative method?

Nick.

"Nak" <a@a.com> wrote in message
news:e5**************@tk2msftngp13.phx.gbl...
Hi Peter,

<quote>...
"I have found an example from the Windows Forms web site that creates
a licensed component class, but I'm not
quite sure if this is what I need or not as this would intil creating
lots of derived classes from the licensed one."

I know it was a bit of a long question so never mind. I think I have
just found out something quite interesting. *ALL* Licensed objects via a
license provider are "slowass" at being created in comparrison to
unlicensed controls, which would explain any bottle necks in my
application. My PC is making around 749,862 standard
LicFileLicenseProvider licensed controls in 1 minute too.

I have thought of 1 idea to help speed up the process but it doesnt
seem to make any difference, I have created a custom attribute that
allows you to specify the public key to verify the XML file with, it
seems that retrieving data from an assemblys resources actually takes
very little time. So at the moment I am looking for another bottle neck
and all I can think it is; is that the license key for that type is *not*
being cached, if it were it would take very little to no time at all to
create the 2nd object.

I *think* this is all the licene context does, *but* the example on
Windows Forms does *not* use a license provider and I must as I am
wanting to license any class via my own license provider so that I can
in-turn sell this product as a licensing solution. Surely other XML
based licensing systems arent this slow so it must be something I'm
missing! :-(

Nick.
""Peter Huang"" <v-******@online.microsoft.com> wrote in message
news:hB**************@cpmsftngxa10.phx.gbl...
Hi Nick,

Here is the link about create customlicensecontext, you may take a look.
http://www.windowsforms.net/Samples/...mId=123&tabind
ex=4

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no
rights.



Nov 21 '05 #5
Hi Nick,

It is cool that you have resolved the problem.
Cheers!

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 21 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: gooze | last post by:
Hi I know, this might be the wrong place for such a question, but maybe you can redirect me to the right place to post. I wrote a small software under the GNU General Public License and put...
8
by: madcap | last post by:
Hi, Our company was looking for contract programmer to develop an internet/intranet application. We were approached by a freelancer who have quite a lot experience and his resume was...
34
by: Michael Foord | last post by:
I'd like to formalise slightly the license I release my projects under. At the moment it's 'free to use, modify, distribute and relicense'. This is basically fine as I don't want t oprevent people...
9
by: Daniel Keep | last post by:
I'm currently working on a Python program, and was wondering if it's possible to license the program, some associated tools, and a few other libraries I've written under the Python license. I...
1
by: Mark Ramey | last post by:
I have an assembly that I want to license to developers. I don't want to license the runtimes that they deliver to their customers. There are no real design-time controls, only some classes that...
0
by: Nak | last post by:
Hi there, Is it possible to get a reference to the current license provider? I'm presuming that only 1 instance is made of each license provider type by the LicenseManager but I would like to...
51
by: mojosam | last post by:
I've been watching the flame war about licenses with some interest. There are many motivations for those who participate in this sector, so disagreements over licenses reflect those agendas. I...
4
by: Martitza | last post by:
Hi. I work for a small company (actually in process of forming) interested in embedding or extending python as part of our commercial non-open-source product. We have legal counsel, but are...
14
by: Frank Rizzo | last post by:
I've been given a project to work with which involves connecting to MySQL from .NET 2.0 app. I've googled looked and there is a metric ton of different MySQL ADO.NET providers from different...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.