Skip to content

Commit

Permalink
Remove test code from command line utility
Browse files Browse the repository at this point in the history
  • Loading branch information
glebd committed Sep 1, 2012
1 parent 4d75127 commit f37d012
Showing 1 changed file with 0 additions and 67 deletions.
67 changes: 0 additions & 67 deletions objc/cocoafob.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,73 +13,6 @@
#import <CocoaFob/CFobLicGenerator.h>
#import <CocoaFob/CFobLicVerifier.h>

//#define TEST

#ifdef TEST
// This function just generates a registration code and then verifies it.
void smoketest()
{
// No need to obfuscate this as you won't ever distribute your private key.
NSString *privKey = @"-----BEGIN DSA PRIVATE KEY-----\n"
"MIH5AgEAAkEA8wm04e0QcQRoAVJWWnUw/4rQEKbLKjujJu6oyEv7Y2oT3itY5pbO\n"
"bgYCHEu9FBizqq7apsWYSF3YXiRjKlg10wIVALfs9eVL10PhoV6zczFpi3C7FzWN\n"
"AkBaPhALEKlgIltHsumHdTSBqaVoR1/bmlgw/BCC13IAsW40nkFNsK1OVwjo2ocn\n"
"3MwW4Rdq6uLm3DlENRZ5bYrTAkEA4reDYZKAl1vx+8EIMP/+2Z7ekydHfX0sTMDg\n"
"kxhtRm6qtcywg01X847Y9ySgNepqleD+Ka2Wbucj1pOry8MoDQIVAIXgAB9GBLh4\n"
"keUwLHBtpClnD5E8\n"
"-----END DSA PRIVATE KEY-----\n";
NSString *regName = @"decloner|Joe Bloggs";

CFobLicGenerator *generator = [[[CFobLicGenerator alloc] init] autorelease];

NSError *err = nil;
if (![generator setPrivateKey:privKey error:&err]) {
NSLog(@"Could not set private key: %@", err);
return;
}

NSString *regCode = [generator generateRegCodeForName:regName error:&err];
if (regCode == nil) {
NSLog(@"Could not generate serial number: %@", err);
return;
}

// Modelled after AquaticPrime's method of splitting public key to obfuscate it.
// It is probably better if you invent your own splitting pattern. Go wild.
NSMutableString *pubKeyBase64 = [NSMutableString string];
[pubKeyBase64 appendString:@"MIHxMIGoBgcqhkj"];
[pubKeyBase64 appendString:@"OOAQBMIGcAkEA8wm04e0QcQRoAVJW"];
[pubKeyBase64 appendString:@"WnUw/4rQEKbLKjujJu6o\n"];
[pubKeyBase64 appendString:@"yE"];
[pubKeyBase64 appendString:@"v7Y2oT3itY5pbObgYCHEu9FBizqq7apsWYSF3YX"];
[pubKeyBase64 appendString:@"iRjKlg10wIVALfs9eVL10Ph\n"];
[pubKeyBase64 appendString:@"oV6zczFpi3C7FzWNAkBaPhALEKlgIltHsumHdTSBqaVoR1/bmlgw"];
[pubKeyBase64 appendString:@"/BCC13IAsW40\n"];
[pubKeyBase64 appendString:@"nkFNsK1OVwjo2ocn"];
[pubKeyBase64 appendString:@"3M"];
[pubKeyBase64 appendString:@"wW"];
[pubKeyBase64 appendString:@"4Rdq6uLm3DlENRZ5bYrTA"];
[pubKeyBase64 appendString:@"0QAAkEA4reDYZKAl1vx+8EI\n"];
[pubKeyBase64 appendString:@"MP/+"];
[pubKeyBase64 appendString:@"2Z7ekydHfX0sTMDgkxhtRm6qtcywg01X847Y9ySgNepqleD+Ka2Wbucj1pOr\n"];
[pubKeyBase64 appendString:@"y8MoDQ==\n"];

NSString *pubKey = [CFobLicVerifier completePublicKeyPEM:pubKeyBase64];
CFobLicVerifier *verifier = [[[CFobLicVerifier alloc] init] autorelease];
if (![verifier setPublicKey:pubKey error:&err]) {
NSLog(@"Could not set public key on verifier %@", err);
return;
}

puts([regCode UTF8String]);
if ([verifier verifyRegCode:regCode forName:regName error:&err]) {
puts("PASS");
} else {
NSLog(@"FAIL: %@", err);
}
}
#endif

// Pass private key file name and registration name string to generate an autoreleased string containing registration code.
NSString *codegen(NSString *privKeyFileName, NSString *regName)
{
Expand Down

0 comments on commit f37d012

Please sign in to comment.