License Utility should generate CF obfuscated key strings
bdrister opened this issue · 3 comments
NSString version wouldn't be usable in a .c file; should just go ahead and use CFString since toll-free bridging would mean that it would work for the (discouraged) Obj-C implementation too.
I have a patch for this:
From 2bf1712c360a8d4ec45a24209bace8fd90ebf50e Mon Sep 17 00:00:00 2001
From: Richard Laing rlaing@mac.com
Date: Sun, 15 May 2011 10:09:01 +1200
Subject: [PATCH] Generate CFString code in utility
License Utility/Classes/KeyController.m | 22 +++++++++++-----------
1 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/License Utility/Classes/KeyController.m b/License Utility/Classes/KeyController.m
index fc2ab6b..fcbf777 100644
--- a/License Utility/Classes/KeyController.m
+++ b/License Utility/Classes/KeyController.m
@@ -148,10 +148,10 @@ static KeyController *sharedInstance = nil;
// Where we are now
int curPos = 0;
- NSMutableString *pubConstruct = [NSMutableString stringWithString:@"\n\t// This string is specially constructed to prevent key replacement \
- // *** Begin Public Key ***\n\tNSMutableString *key = [NSMutableString string];\n"];
-
while ((lengthLeft - WINDOW_THRESH) > 0) {
-
NSMutableString *pubConstruct = [NSMutableString stringWithString:@"\n\t// This string is specially constructed to prevent key replacement \
-
// **\* Begin Public Key ***\n\tCFMutableStringRef key = CFStringCreateMutable(NULL, 0);\n"];
-
while ((lengthLeft - WINDOW_THRESH) > 0) {
// Logic to check for repeats
int repeated = 0;
char charBuf = 0;
@@ -160,12 +160,12 @@ static KeyController *sharedInstance = nil;
// We have a repeat!
if (charBuf == [pubKey characterAtIndex:i]) {
// Print up to repeat -
[pubConstruct appendString:[NSString stringWithFormat:@"\t[key appendString:@\"%@\"];\n", [pubKey substringWithRange:NSMakeRange(curPos, (i-1) - curPos)]]];
-
[pubConstruct appendString:[NSString stringWithFormat:@"\tCFStringAppend(key, CFSTR(\"%@\"));\n", [pubKey substringWithRange:NSMakeRange(curPos, (i-1) - curPos)]]]; //Do the repeat
-
[pubConstruct appendString:[NSString stringWithFormat:@"\t[key appendString:@\"%@\"];\n", [pubKey substringWithRange:NSMakeRange(i-1, 1)]]];
-
[pubConstruct appendString:[NSString stringWithFormat:@"\t[key appendString:@\"%@\"];\n", [pubKey substringWithRange:NSMakeRange(i, 1)]]];
-
[pubConstruct appendString:[NSString stringWithFormat:@"\tCFStringAppend(key, CFSTR(\"%@\"));\n", [pubKey substringWithRange:NSMakeRange(i-1, 1)]]];
-
[pubConstruct appendString:[NSString stringWithFormat:@"\tCFStringAppend(key, CFSTR(\"%@\"));\n", [pubKey substringWithRange:NSMakeRange(i, 1)]]]; // Finish the line
-
[pubConstruct appendString:[NSString stringWithFormat:@"\t[key appendString:@\"%@\"];\n", [pubKey substringWithRange:NSMakeRange(i+1, (WINDOW_THRESH + curPos) - (i+1))]]];
-
[pubConstruct appendString:[NSString stringWithFormat:@"\tCFStringAppend(key, CFSTR(\"%@\"));\n", [pubKey substringWithRange:NSMakeRange(i+1, (WINDOW_THRESH + curPos) - (i+1))]]]; repeated = 1; break; }
@@ -173,13 +173,13 @@ static KeyController *sharedInstance = nil;
}
// No repeats
if (!repeated) -
[pubConstruct appendString:[NSString stringWithFormat:@"\t[key appendString:@\"%@\"];\n", [pubKey substringWithRange:NSMakeRange(curPos, WINDOW_THRESH)]]];
-
[pubConstruct appendString:[NSString stringWithFormat:@"\tCFStringAppend(key, CFSTR(\"%@\"));\n", [pubKey substringWithRange:NSMakeRange(curPos, WINDOW_THRESH)]]]; lengthLeft -= WINDOW_THRESH; curPos += WINDOW_THRESH;
}
- [pubConstruct appendString:[NSString stringWithFormat:@"\t[key appendString:@"%@"];\n\t// *** End Public Key *** \n", [pubKey substringWithRange:NSMakeRange(curPos, lengthLeft)]]];
- [pubConstruct appendString:[NSString stringWithFormat:@"\tCFStringAppend(key, CFSTR("%@"));\n\t// *** End Public Key *** \n", [pubKey substringWithRange:NSMakeRange(curPos, lengthLeft)]]];
// Populate key view
[rsaKeyView setString:pubConstruct];
[publicKeyView setString:[self publicKey]];
1.7.3.5
Thanks! However, this all got mangled in the GitHub comments. Could you just commit it on a fork and send a pull request?
I'll try and work it out.
Cheers
Richard
On 15 May 2011, at 11:50, bdrister wrote:
Thanks! However, this all got mangled in the GitHub comments. Could you just commit it on a fork and send a pull request?
Reply to this email directly or view it on GitHub:
#10 (comment)