Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > Mac OS X Development Forums > Objective-C, Python, Ruby Development

Reply
 
LinkBack Thread Tools Display Modes
Old 01-09-2012, 10:46 PM   #1 (permalink)
Registered Member
 
Join Date: Nov 2011
Posts: 2
jsherk is on a distinguished road
Default objective-c how to remove encryption from this code

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

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);
jsherk is offline   Reply With Quote
Old 03-04-2012, 06:32 PM   #2 (permalink)
Registered Member
 
Join Date: Sep 2008
Posts: 118
Feldspar is on a distinguished road
Default

This is just a guess but try

Code:
- (void)connectionDidFinishLoading:(NSURLConnection *)connection{
    
    NSMutableData *theData = [[NSData dataFromBase64String:[[NSString alloc] initWithData:sync_data encoding:NSUTF8StringEncoding]] mutableCopy];
    if ([theData length] == 0) {
        [theData release];
        return;
    }
    sync_data = [theData mutableCopy];

    [theData release];
    
    NSDictionary *dictServer = nil;
    CFPropertyListRef plist = CFPropertyListCreateFromXMLData(kCFAllocatorDefault,(CFDataRef)sync_data, kCFPropertyListImmutable, NULL);
__________________
Music Visualizer ~ Rabbit Hole http://bit.ly/mmlGOi
Feldspar is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 496
13 members and 483 guests
AlanFloyd, andyzaharia, AppsBlogger, David-T, HemiMG, iAppDeveloper, imac74, Jaxen66, lovoyl, Paul Slocum, tiendung2992, unicornleo, usernametaken
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,684
Threads: 94,131
Posts: 402,932
Top Poster: BrianSlick (7,990)
Welcome to our newest member, tiendung2992
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 10:18 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0