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

Mockup & CodeGen, iPhone & iPad
($9.99)

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

Manu
($0.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 12-04-2008, 10:54 AM   #1 (permalink)
Tylenol is my friend
 
Join Date: Oct 2008
Location: Midwest
Posts: 150
Default Help with CommonCrypto CCCrypt and 3DES

I have a requirement that I have to decode and encode a string value with the 3DES algorithm.

Common Crypto which is part of the SDK, appears to have support for 3DES.
However, the documentation about the library is limited and google searches have only come up with limited information.

The one that I found, that I have been using as a base is this one:
Apple - Support - Discussions - Problems with CommonCrypto ...

Over the last few months I have gotten significantly better with Objective-C and this enviornment; I can read the code and understand most of what it is doing. However my attempts to tweek this version to work with 3DES and get the output I need, isn't working.

Anyone out there that can help me the last few inches?

Here is my current code with KEY, INPUT, and what I am looking for in an output:
Code:
	NSString *dateString = @"2008-11-24 13:14:17.231";
	NSString *sigKey = @"70-248-56-157-134-203-200-22-28-236-253-93-112-161-200-174-164-211-234-22-208-162-13-13";
	NSArray *sigKeyArray = [sigKey componentsSeparatedByString:@"-"];
	NSString *outVal = @"55-9-145-188-46-202-54-193-31-157-143-148-122-3-194-114-10-242-34-120-142-247-127-10";
	
	CCCryptorStatus ccStatus;
	uint8_t *bufferPtr = NULL;
	size_t bufferPtrSize = 0;
	size_t movedBytes = 0;
	size_t plainTextBufferSize = [dateString length];
	//uint8_t *iv = NULL; //kCCBlockSize3DES;
	
	bufferPtrSize = (plainTextBufferSize + kCCBlockSize3DES) & ~(kCCBlockSize3DES - 1);
	bufferPtr = malloc(bufferPtrSize * sizeof(uint8_t));
	memset((void *)bufferPtr, 0x0, bufferPtrSize);
//	memset((void *)iv, 0x0, 0);

	ccStatus = 	CCCrypt(
						kCCEncrypt,
						kCCAlgorithm3DES,
						kCCOptionPKCS7Padding,
						sigKeyArray,
						kCCKeySize3DES,
						nil,
						dateString,
						plainTextBufferSize,
						(void *)bufferPtr,
						bufferPtrSize,
						&movedBytes);
Any help, or even links to another example or a more detailed doc on how to use the library would be greatly appriciated.
__________________
-----
-) No matter what forum you join, you always start as a newbie. Even if you own the board.
-) There is no stupid question, if you think it is stupid don't answer it and it will fall of the screen
-) If you post some helpful solution, then that could lead to more helpful solutions. Soon, it is a chain reaction and then the forum becomes a monumental programming resource.
Fontano 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
» Stats
Members: 158,769
Threads: 89,202
Posts: 380,577
Top Poster: BrianSlick (7,129)
Welcome to our newest member, hpnotebooo
Powered by vBadvanced CMPS v3.1.0

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