Looking at this line of Objective-C code, and admiting to not knowing much about Obj-C, shouldn't this line:
NSData *data = [NSData dataWithBytes:cstr length:input.length];
read:
NSData *data = [NSData dataWithBytes:cstr length:strlen(cstr)];
?