Hi
I am very new to objective-c and am finding it to be a very difficult to fully grasp how it works.
Anyways, the code below retrieves an encrypted xml plist file from my server and then decrypts for use in my iPhone app. But I just discovered that encryption is whole big issue that I really don't want to deal with right now, so I need to remove the encryption part (I have no problem doing that on server side).
So currently it's this:
SERVER SIDE: XML Plist file > Encrypt > Base64encode
IPHONE SIDE: request and receive file > base64decode > decrypt > XML Plist file.
I need to remove the decrypt part, so it's like this:
SERVER SIDE: XML Plist file > Base64encode
IPHONE SIDE: request and receive file > base64decode > XML Plist file.
I have played with this code but can't get it right. Any help appreciated. I am sure it's something to do with SecKeyWrapper, but not able to remove it.
Thanks
I am very new to objective-c and am finding it to be a very difficult to fully grasp how it works.
Anyways, the code below retrieves an encrypted xml plist file from my server and then decrypts for use in my iPhone app. But I just discovered that encryption is whole big issue that I really don't want to deal with right now, so I need to remove the encryption part (I have no problem doing that on server side).
So currently it's this:
SERVER SIDE: XML Plist file > Encrypt > Base64encode
IPHONE SIDE: request and receive file > base64decode > decrypt > XML Plist file.
I need to remove the decrypt part, so it's like this:
SERVER SIDE: XML Plist file > Base64encode
IPHONE SIDE: request and receive file > base64decode > XML Plist file.
I have played with this code but can't get it right. Any help appreciated. I am sure it's something to do with SecKeyWrapper, but not able to remove it.
Thanks
Code:
-(void)sync{
NSURL *url = [NSURL URLWithString:@"http://www.mydomain.com/plist-settings.php"]; //Retrieve file
NSURLRequest *request = [NSURLRequest requestWithURL:url cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:5.0];
[NSURLConnection connectionWithRequest:request delegate:self];
sync_data = [[NSMutableData alloc] init];
}
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)_data{
[sync_data appendData:_data];
}
- (void)connectionDidFinishLoading:(NSURLConnection *)connection{
char * key = "(mASFi14%12As./*";
NSData * symmetricKey = [NSData dataWithBytes:key length:16];
CCOptions pad = kCCOptionECBMode;
NSMutableData *theData = [[NSData dataFromBase64String:[[NSString alloc] initWithData:sync_data encoding:NSUTF8StringEncoding]] mutableCopy];
if ([theData length] == 0) {
[theData release];
return;
}
sync_data = [[[SecKeyWrapper sharedWrapper] doCipher:theData key:symmetricKey context:kCCDecrypt padding:&pad] mutableCopy];
[theData release];
NSDictionary *dictServer = nil;
CFPropertyListRef plist = CFPropertyListCreateFromXMLData(kCFAllocatorDefault,(CFDataRef)sync_data, kCFPropertyListImmutable, NULL);