|
About Andrew Choi
MIDI Programs
MIDI File Player (External Device)
MIDI Destination Pop-Up Button
Other Programs Cocoa Sample Programs Syntax Coloring Using Flex Algorithms Jazz Chord Analysis as Optimization
|
A blog where I will write mostly about programming in Cocoa and CoreMIDI, and experiences from my ports of Emacs and XEmacs to the Mac OS.
Did a lot more testing of the license key code today. I also change the encoding of the signature so it looks like a license key now: 8 groups of 5 characters. Since base32 uses the letters O and I which can be confused with zero and one, they are now mapped to the unused digits 8 and 9 instead. Heres a sample run of the programs KeyGen, Sign, and Verify.
$ ./KeyGen Private key = qlgh2zUGLP2FoFYm Public key = f7pNeV9Iwo6NHGwDoNM= $ ./Sign "Andrew Choi; akochoi@shaw.ca" qlgh2zUGLP2FoFYm Signature = BLXHT-5674B-F2D67-VSWLG-A2ZUL-AYAD9-CHU3W-GAX9U $ ./Verify "Andrew Choi; akochoi@shaw.ca"\ BLXHT-5674B-F2D67-VSWLG-A2ZUL-AYAD9-CHU3W-GAX9U f7pNeV9Iwo6NHGwDoNM= OK $Check out the Certicom ECC Challenge site to get an idea of the strength of this signature scheme. Im using primes that are roughly 100 bits long which makes it quite breakable if you have a lot of computers and know what youre doing :-). But in our case the public key wont be in plain sight... Next week, Ill work on code obfuscation :-).
I converted the key generator, signer, and verifier programs to encode keys in base64, signatures in base32, and use plain character strings for secret messages. The signature now consists of two base32 encoded components separated by a colon. The actual license key will probably be a string of the form XXXXX-XXXXX-.... Heres a sample interaction that demonstrates the use of these programs. $ ./KeyGen Private key = LPOFhmozYElPJohu Public key = 6uqDyr8xnuCXqh7XonU= $ ./Sign "Andrew Choi; akochoi@shaw.ca" LPOFhmozYElPJohu Signature = HJVBDNDP4GH6OL7S5MCQ====:KVBVK3WZAUQYAETKC65A==== $ ./Verify "Andrew Choi; akochoi@shaw.ca"\ HJVBDNDP4GH6OL7S5MCQ====:KVBVK3WZAUQYAETKC65A==== 6uqDyr8xnuCXqh7XonU= OK $I want to make sure that these programs are running correctly. So I wrote a Python script to test them. Heres the log of a sample run that uses 3 key pairs to sign and verify 5 secret messages each. Of course Im running much longer test than that myself. The random secret messages were generated from the dictword list. Thought it was kind of nice to re-visit Python today for this purpose. keyPairsToTest = 3 secretsToTest = 5 Testing private key = j2lyfOyqpW+33y4I, public key = AYaM1tr9Ea2jbJskdFk2 secret = "Polygrammatic Pistillody; sweetheartdom@undershoe.heliopticon", status = OK secret = "Spirocheticidal Woldy; sigillate@undiagnosable.reabsolve", status = OK secret = "Regressionist Mattamore; toastmaster@thiasi.plectospondyl", status = OK secret = "Canions Encenter; Yucatec@burnishing.debituminization", status = OK secret = "Inadjustability Lemmocyte; grailer@clerid.Acephali", status = OK Testing private key = j2lyfOyqpW+33y4I, public key = AYaM1tr9Ea2jbJskdFk2 secret = "Freemanship Self; staghead@psiloceratan.laserwort", status = OK secret = "Stinkard Aerotherapeutics; acromiohyoid@ingratiate.microgramme", status = OK secret = "Unavouched Superaltar; quaddle@nontransgression.organologic", status = OK secret = "Phyllite Unstaid; prelegate@reprobative.unbale", status = OK secret = "Rhomboidally Triodontoidei; stenching@countermutiny.manifoldly", status = OK Testing private key = 7kRzv2UfI4uabRrx, public key = AduIRLG6Itc19qNvCC5u secret = "Nyanza Legatine; oxyphyllous@strideways.rockhair", status = OK secret = "Interangular Unconvenable; lamentive@chromatophore.nucleohyaloplasma", status = OK secret = "Fistwise Nese; Sapindaceae@Polytrichum.holosomatous", status = OK secret = "Unpitifully Metagnomy; plotful@procuratorship.telesomatic", status = OK secret = "Homekeeping Soother; unprecedently@market.wheelspin", status = OK Successes = 15; Failures = 0
It was quite surprising to me that I couldt find any free (I mean really free, not GPL) C++ code for base64 and base32 encoding. The closest I can find is one from Cyotec, but even that requires ascription. Im not putting someone elses copyright notice in my application because of a few lines of code! So heres a set of base64 and base32 encoders and decoders Ive written today (base64util.cc, base64util.h) and their test program (main.cpp). As usual Im releasing them under the Artistic License.
Its not as easy as one may think to find a elliptic curve cryptography (ECC) library with an unencumbered license. There is crypto++ which, as I explained yesterday, I cant use because of large executable sizes. Theres also pegwit, written by George Barwood. Unfortunately pegwit generates 480-bit signatures, which are a bit long for use as license keys. Barwood also wrote a set of C++ routines for doing ECC, and with it one can select from a set of elliptic curves, and thus use keys and signatures of various lengths. $ ./KeyGen Private key = 370c7dad25bf54440f4f503200000002 Public key = d96ac8f8316794f32a6d314b00006e83 $ ./Sign 0123456789abcdef 370c7dad25bf54440f4f503200000002 Signature s = 74aa8e9f30e782b861b17e700000000b Signature r = 9e13790a4d2ae85ea9f23f7800000005 $ ./Verify 0123456789abcdef 74aa8e9f30e782b861b17e700000000b\ 9e13790a4d2ae85ea9f23f7800000005 d96ac8f8316794f32a6d314b00006e83 OK $
Well, I wasnt going to post any code used in my authorization code scheme. I believe security through obscurity helps a little. But I might as well post the sample programs I wrote today, KeyGen, Sign, and Verify, because I wont be using them in my shareware application (see reason below)! These programs use the Crypto++ library. Using elliptic curve cryptography, signatures (i.e., authorization codes) can be as short as 28 bytes! $ ./KeyGen Private Key = MCwCAQAwEAYHKoZIzj0CAQYFK4EEAAYEFTATAgEBBA6sUVm9Ip62Fp/g067jeA== Public Key = MDIwEAYHKoZIzj0CAQYFK4EEAAYDHgAEgCFFicCn25bbndK3uqwcrx93mQx9KQQ9BAjn2w==Then the users name and E-mail address (say) can be signed with the private key, resulting in the authorization code. $ ./Signer MCwCAQAwEAYHKoZIzj0CAQYFK4EEAAYEFTATAgEBBA6sUVm9Ip62Fp/g067jeA==\ 'Andrew Choi; akochoi@shaw.ca' Signature = TJZ4BCE7J3ZK95TUXU2BE97W8HB4DUMYFIBN4ENNJFG66In the shareware program, the user name and E-mail address can then be verified using the public key. $ ./Verify MDIwEAYHKoZIzj0CAQYFK4EEAAYDHgAEgCFFicCn25bbndK3uqwcrx93mQx9KQQ9BAjn2w==\ 'Andrew Choi; akochoi@shaw.ca'\ TJZ4BCE7J3ZK95TUXU2BE97W8HB4DUMYFIBN4ENNJFG66 Verification result = OKNice, isnt it? Except I cant use these programs! The binaries resulting from linking with libcryptopp.a are simply too big! After stripping, they are 2.5M bytes each. It doesnt make sense to hide a 1M byte application with 2.5M bytes of encryption code (or does it :-)?). Ill just have to find another way.
|
Lists
Less-Known Facts About Emacs
Chinese Restaurants in Calgary
Calgary/Banff Tourist Attractions
Top-10 Reason I Stopped Working on Emacs
Misc
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Copyright © 2003, 2004, 2005 Andrew Choi (Contact Information). | Created with FCBlog |