• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSTask Leaking...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSTask Leaking...


  • Subject: Re: NSTask Leaking...
  • From: Rob Keniger <email@hidden>
  • Date: Fri, 30 Jan 2009 12:29:00 +1000

This code won't compile for me. Where is the referenced libCdsaCrypt.h file?
--
Rob Keniger


On 30/01/2009, at 10:50 AM, Kirk Kerekes wrote:

// must include Security framework to use this
// Tiger or later for SHA256


#import "libCdsaCrypt.h"

@implementation NSData (DataDigest)

- (NSData *) digestWithCDSAType:(CSSM_ALGORITHMS) algorithm
{ // does not validate algorithm selection, let the framework worry about that.
NSData * result = nil;
int error = noErr;
CSSM_DATA inData;
CSSM_CSP_HANDLE cspHandle;
CSSM_DATA digestData;


error = cdsaCspAttach(&cspHandle);
if(!error)
{
inData.Data = (void *)[self bytes];
inData.Length = [self length];
/* calculate digest */
error = cdsaDigest(cspHandle, algorithm, &inData, &digestData);
if(!error)
{
result = [NSData dataWithBytesNoCopy: digestData.Data length: digestData.Length freeWhenDone: YES];
}
}
return result;
}


- (NSData *) md5Digest
{
	return [self digestWithCDSAType: CSSM_ALGID_MD5];
}

- (NSData *) sha1Digest
{
	return [self digestWithCDSAType: CSSM_ALGID_SHA1];
}

#ifndef CSSM_ALGID_SHA256
#define CSSM_ALGID_SHA256 0
#endif

- (NSData *) sha256Digest
{
return [self digestWithCDSAType: CSSM_ALGID_SHA256];
}



@end




_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >Re: NSTask Leaking... (From: Kirk Kerekes <email@hidden>)

  • Prev by Date: Re: Sub-pixel font smoothing with CGBitmapContext
  • Next by Date: Re: NSTask Leaking...
  • Previous by thread: Re: NSTask Leaking...
  • Next by thread: Re: NSTask Leaking...
  • Index(es):
    • Date
    • Thread