Take the 2-minute tour ×
Cryptography Stack Exchange is a question and answer site for software developers, mathematicians and others interested in cryptography. It's 100% free, no registration required.

I have recently started looking into creating secure, while not validating against an external server, software product keys.

The idea I have had is to create a key consisting of two parts firstly a section that contains some (but not all) details of the user; for example name, customer ID and maybe a salt this would then be ecoded one way or another, say a simple base64 just to obfuscate it. The second part would be an SHA1 signature for a hash of all the user data this would be mostly the same as above but would contain the entitled software version (i.e. 1.0) and maybe something else related to the program.

The deployment of this would work by the user entering the key and the software extracting the user details from the key, appending its own credentials (version number etc.) the generating a hash a verifying the signature using this hash.

If the user key has not been tampered and the user is entitled to user that version of the software all will pass and we can proceed. If this it not the case (say the version entitlement is wrong) the signature will not match the hash. Obviously the public key has to be contained within the software to verify the signature but at no point does the user have the entire hash.

I was discussing this with a friend who said they thought this would be inherently poor as the user could poke through the program find out how the key system works and then, given the structure and the public key generate any number of license keys that would appear valid, as they would control the signature to match the software generated hash of 'fake' credentials.

Is this really that easy to crack surely even if the user did create a hash of some fake details and ID number they could not generate a valid signature to match this? Sorry the question has ended up being much longer than I intended; i wasn't sure how to be clear shorter. I hope this all makes sense.

share|improve this question
2  
It's usually even simpler: most "stand-alone software" validation can be defeated by simply hooking into whatever code does the key validation, and replacing it by "this key is valid" (regardless of the key, of course). Unless said key is going to be used at some subsequent point in the program (e.g. as some authentication token for interaction with some remote server), that's it - you've "cracked" the software product, without even caring what validation mechanism was involved. I think you need to detail your specific requirements a bit more. –  Thomas Sep 20 '13 at 11:28
    
(note this is why most hardcore modern DRM is done through user accounts and remote validation and, for ultimate control, remote content distribution) –  Thomas Sep 20 '13 at 11:31
2  
This is a better fit for Sec.SE –  rath Sep 20 '13 at 11:55
1  
On Security.SE, I expect most answers to deal with the ease at which the program can be patched to jump over the check. –  Hendrik Brummermann Sep 20 '13 at 12:58
add comment

1 Answer 1

up vote 3 down vote accepted

You're somewhat on the right track. A standard way to do this would be using an RSA sign/verify scheme.

On the server, user-specific and license-specific data is concatenated into a string and signed with the private key.

In the software, the signature is verified with the public key. The public key can not be used to create valid signatures, it can only verify them (this is the beauty of asymmetric cryptography).

Of course, as pointed out by Thomas, there's nothing to stop someone decompiling your software and modifying the source code, but that can't be avoided.

If you're going to use RSA, be sure to use a secure padding scheme like RSA-PSS.

share|improve this answer
    
Hunter, thanks that's pretty much exactly what I had in mind, all be it with slightly different semantics. I'm a bit new to the whole cryptography realm in this sense. So am I right in the assertion that a it would be impossible to generate a valid signature (short of brute forcing) for a set of generated user-specific data (lets assume they can allows guess the license-specific data)? I realise that there is always a vulnerability to the code being decompiled and patched. –  MindStormer Sep 20 '13 at 12:39
    
@user8534 - I wouldn't go so far as to say it's impossible, but if you use a 2048+ bit key, it's a pretty safe bet. –  hunter Sep 20 '13 at 12:58
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.