views:

175

answers:

3

I'm working on a new licensing scheme for my software, based on OpenSSL public / private key encryption. My past approach, based on this article, was to use a large private key size and encrypt an SHA1 hashed string, which I sent to the customer as a license file (the base64 encoded hash is about a paragraph in length). I know someone could still easily crack my application, but it prevented someone from making a key generator, which I think would hurt more in the long run.

For various reasons I want to move away from license files and simply email a 16 character base32 string the customer can type into the application. Even using small private keys (which I understand are trivial to crack), it's hard to get the encrypted hash this small. Would there be any benefit to using the same strategy to generated an encrypted hash, but simply using the first 16 characters as a license key? If not, is there a better alternative that will create keys in the format I want?

+1  A: 

Did you consider using some existing protection + key generation scheme? I know that EXECryptor (I am not advertising it at all, this is just some info I remember) offers strong protection whcih together with complimentatary product of the same guys, StrongKey (if memory serves) offers short keys and protection against cracking. Armadillo is another product name that comes to my mind, though I don't know what level of protection they offer now. But they also had short keys earlier.

In general, cryptographically strong short keys are based on some aspects of ECC (elliptic curve cryptography). Large part of ECC is patented, and in overall ECC is hard to implement right and so industry solution is a preferred way to go.

Of course, if you don't need strong keys, you can go with just a hash of "secret word" (salt) + user name, and verify them in the application, but this is crackable in minutes.

Eugene Mayevski 'EldoS Corp
+1 for ECC. Perhaps look at TinyECC, which is a minimal scheme, in a C-like languages, for doing short key public crypto.
Yann Ramin
I'm writing Mac applications, and most of the commercial solutions are Windows only and / or very expensive, so I haven't really found anything I'm excited about yet. There are a few open source solutions on the Mac side I've considered, but they actually use the same OpenSSL strategy as well so I'd end up with the same issues.I'm looking into ECC now though! Although from my first glance it looks complex enough that I'm thinking I'll just go the SHA1 hash route, as insecure as that is.
Marc Charbonneau
A: 

Why use public key crypto? It gives you the advantage that nobody can reverse-engineer the executable to create a key generator, but key generators are a somewhat secondary risk compared to patching the executable to skip the check, which is generally much easier for an attacker, even with well-obfuscated executables.

Eugene's suggestion of using ECC is a good one - ECC keys are much shorter than RSA or DSA for a given security level.

However, 16 characters in base 32 is still only 5*16=80 bits, which is low enough that brute-forcing for valid keys might be practical, regardless of what algorithm you use.

Nick Johnson
"...5*16=80 bits, which is low enough that brute-forcing for valid keys might be practical...". Wow, you must have some awesome computers!
GregS
@GregS: While bruteforcing an 80 bit symmetric key wouldn't be practical, bruteforcing an 80 bit signature in an asymmetric algorithm is a lot more feasible (it doesn't actually require trying all 2**80 possible numbers).
caf
@caf: I know, I was just funnin.
GregS
You're also not looking for just a single valid key, either, but rather any one of a potentially large number of valid keys.
Nick Johnson
+1  A: 

DSA signatures are signficantly shorter than RSA ones. DSA signatures are the twice the size of the Q parameter; if you use the OpenSSL defaults, Q is 160 bits, so your signatures fit into 320 bits.

If you can switch to a base-64 representation (which only requires upper-and-lower case alphanumerics, the digits and two other symbols) then you will need 53 symbols, which you could do with 11 groups of 5. Not quite the 16 that you wanted, but still within the bounds of being user-enterable.


Actually, it occurs to me that you could halve the number of bits required in the license key. DSA signatures are made up of two numbers, R and S, each the size of Q. However, the R values can all be pre-computed by the signer (you) - the only requirement is that you never re-use them. So this means that you could precalculate a whole table of R values - say 1 million of them (taking up 20MB) - and distribute these as part of the application. Now when you create a license key, you pick the next un-used R value, and generate the S value. The license key itself only contains the index of the R value (needing only 20 bits) and the complete S value (160 bits).

And if you're getting close to selling a million copies of the app - a nice problem to have - just create a new version with a new R table.

caf