[Keychain-commit] SF.net SVN: keychain: [453] trunk/Frameworks/Keychain
Status: Abandoned
Brought to you by:
wadetregaskis
|
From: <wad...@us...> - 2008-03-29 21:33:32
|
Revision: 453
http://keychain.svn.sourceforge.net/keychain/?rev=453&view=rev
Author: wadetregaskis
Date: 2008-03-29 14:33:33 -0700 (Sat, 29 Mar 2008)
Log Message:
-----------
* [Patch courtesy of Nick Zitzmann] Updated for 64-bit and fixed a couple of endianness issues, as well as a few other minor things. Now have an Xcode 3.0 project file in addition to the Xcode 2.x.
Modified Paths:
--------------
trunk/Frameworks/Keychain/CDSA/CSSMControl.m
trunk/Frameworks/Keychain/CDSA/CSSMDefaults.h
trunk/Frameworks/Keychain/CDSA/CSSMDefaults.m
trunk/Frameworks/Keychain/CDSA/CSSMManagedModule.m
trunk/Frameworks/Keychain/CDSA/CSSMOpenDataStore.m
trunk/Frameworks/Keychain/CDSA/CSSMUtils.m
trunk/Frameworks/Keychain/CDSA/MDS.m
trunk/Frameworks/Keychain/Certificates/ABPersonAdditions.m
trunk/Frameworks/Keychain/Certificates/Certificate.m
trunk/Frameworks/Keychain/Certificates/CertificateGeneration.m
trunk/Frameworks/Keychain/Certificates/Policy.m
trunk/Frameworks/Keychain/Cryptography/FileUtilities.m
trunk/Frameworks/Keychain/Cryptography/Key.h
trunk/Frameworks/Keychain/Cryptography/Key.m
trunk/Frameworks/Keychain/Cryptography/KeychainUtils.h
trunk/Frameworks/Keychain/Cryptography/KeychainUtils.m
trunk/Frameworks/Keychain/Cryptography/MutableKey.h
trunk/Frameworks/Keychain/Cryptography/MutableKey.m
trunk/Frameworks/Keychain/Cryptography/NSDataAdditions.m
trunk/Frameworks/Keychain/Cryptography/Streams/ChainedOutputStream.h
trunk/Frameworks/Keychain/Cryptography/Streams/ChainedOutputStream.m
trunk/Frameworks/Keychain/Cryptography/Streams/DigestOutputStream.h
trunk/Frameworks/Keychain/Cryptography/Streams/DigestOutputStream.m
trunk/Frameworks/Keychain/Hashcash/Hashcash.m
trunk/Frameworks/Keychain/Keychain/Access.h
trunk/Frameworks/Keychain/Keychain/Access.m
trunk/Frameworks/Keychain/Keychain/AccessControlList.h
trunk/Frameworks/Keychain/Keychain/AccessControlList.m
trunk/Frameworks/Keychain/Keychain/Identity.h
trunk/Frameworks/Keychain/Keychain/Identity.m
trunk/Frameworks/Keychain/Keychain/Keychain.h
trunk/Frameworks/Keychain/Keychain/Keychain.m
trunk/Frameworks/Keychain/Keychain/KeychainItem.h
trunk/Frameworks/Keychain/Keychain/KeychainItem.m
trunk/Frameworks/Keychain/Keychain/KeychainSearch.h
trunk/Frameworks/Keychain/Keychain/KeychainSearch.m
trunk/Frameworks/Keychain/Keychain/KeychainSearchInternal.h
trunk/Frameworks/Keychain/Keychain/TrustedApplication.h
trunk/Frameworks/Keychain/Keychain/TrustedApplication.m
trunk/Frameworks/Keychain/Testers/CSSMUtilsTester.m
trunk/Frameworks/Keychain/Testers/CryptographicTester.m
trunk/Frameworks/Keychain/Testers/KeychainSearchTester.m
trunk/Frameworks/Keychain/Testers/KeychainTester.m
trunk/Frameworks/Keychain/Testers/MDSProber.m
trunk/Frameworks/Keychain/Testers/NSCalendarDateAdditionsTester.m
trunk/Frameworks/Keychain/Testers/OutputStreamsTester.m
trunk/Frameworks/Keychain/Utilities/NSCalendarDateAdditions.h
trunk/Frameworks/Keychain/Utilities/NSCalendarDateAdditions.m
trunk/Frameworks/Keychain/Utilities/SecurityUtils.m
trunk/Frameworks/Keychain/Utilities/UtilitySupport.m
trunk/Frameworks/Keychain/X509/x509.h
trunk/Frameworks/Keychain/X509/x509.m
trunk/Frameworks/Keychain/install
Added Paths:
-----------
trunk/Frameworks/Keychain/Keychain (Xcode 2.x).xcodeproj/
Removed Paths:
-------------
trunk/Frameworks/Keychain/Keychain (Xcode 2.x).xcodeproj/project.pbxproj
trunk/Frameworks/Keychain/Keychain.xcodeproj/
Modified: trunk/Frameworks/Keychain/CDSA/CSSMControl.m
===================================================================
--- trunk/Frameworks/Keychain/CDSA/CSSMControl.m 2008-03-29 19:22:15 UTC (rev 452)
+++ trunk/Frameworks/Keychain/CDSA/CSSMControl.m 2008-03-29 21:33:33 UTC (rev 453)
@@ -37,20 +37,25 @@
static BOOL haveDoneInit = NO;
if (!haveDoneInit) {
- int i;
-
- haveDoneInit = YES;
-
- memset(&defaultCredentials, 0, sizeof(CSSM_ACCESS_CREDENTIALS));
-
- srandom(time(0));
- defaultGUID.Data1 = random();
- defaultGUID.Data2 = random();
- defaultGUID.Data3 = random();
-
- for (i = 0; i < 16; i += 4) {
- *((uint32_t*)(&(keychainFrameworkInitVector[i]))) = random();
- }
+ int i;
+
+ haveDoneInit = YES;
+
+ memset(&defaultCredentials, 0, sizeof(CSSM_ACCESS_CREDENTIALS));
+
+#if __DARWIN_UNIX03
+ srandom((unsigned int)time(NULL));
+#else
+ srandom(time(NULL));
+#endif
+
+ defaultGUID.Data1 = (uint32_t)random();
+ defaultGUID.Data2 = (uint32_t)random();
+ defaultGUID.Data3 = (uint32_t)random();
+
+ for (i = 0; i < 16; i += 4) {
+ *((uint32_t*)(&(keychainFrameworkInitVector[i]))) = (uint32_t)random();
+ }
}
}
@@ -102,7 +107,7 @@
PSYSLOGCND(LOG_ERR, "Unable to initialize CSSM because of error #%"PRIu32".\n", (uint32_t)err);
PDEBUGC("CSSM_Init({%"PRIu32", %"PRIu32"}, %"PRIu32", ?, %"PRIu32", %p (%"PRIu32"), %p) returned error #%"PRIu32".\n",
(uint32_t)((NULL == customVersion) ? defaultVersion.Major : customVersion->Major),
- (uint32_t)((NULL == customVersion) ? &defaultVersion : customVersion),
+ (uint32_t)((NULL == customVersion) ? defaultVersion.Minor : customVersion->Minor),
(uint32_t)customScope,
/*GUIDAsString((NULL == customGUID) ? &defaultGUID : customGUID),*/
(uint32_t)customHierarchy,
Modified: trunk/Frameworks/Keychain/CDSA/CSSMDefaults.h
===================================================================
--- trunk/Frameworks/Keychain/CDSA/CSSMDefaults.h 2008-03-29 19:22:15 UTC (rev 452)
+++ trunk/Frameworks/Keychain/CDSA/CSSMDefaults.h 2008-03-29 21:33:33 UTC (rev 453)
@@ -54,7 +54,7 @@
Note that you should not rely on this being constant, or containing the same data as keychainFrameworkInitVectorData. */
-extern uint8 keychainFrameworkInitVector[16];
+extern uint8_t keychainFrameworkInitVector[16];
/*! @constant keychainFrameworkInitVectorData
@abstract A generic init vector for cryptographic operations.
@@ -68,13 +68,13 @@
@abstract A constant representing version 1 of the proprietary Keychain raw key format (used by the 'key' extension of NSData, and the corresponding 'data' method of Key).
@discussion The proprietary format used by the Keychain framework is not recommended for general purpose use. Nonetheless, it does support versioning in case it needs to be updated or extended in future. You shouldn't ever really need to use this constant, although you may find it useful to compare it with RAW_KEY_VERSION_CURRENT if you are looking for specific version support. */
-extern const uint32 RAW_KEY_VERSION_1;
+extern const uint32_t RAW_KEY_VERSION_1;
/*! @constant KEYHEADER_VERSION_1_SIZE
@abstract The size of a raw key header in the Keychain framework's proprietary format (version 1).
@discussion The proprietary format used by the Keychain framework is not recommended for general purpose use. If you must use it, you may use this constant to determine the expected size of a raw key header (i.e. the key metadata, not including the actual key itself, which varies in length for different key types and strengths). */
-extern const uint32 KEYHEADER_VERSION_1_SIZE;
+extern const uint32_t KEYHEADER_VERSION_1_SIZE;
/*! @function defaultModeForAlgorithm
Modified: trunk/Frameworks/Keychain/CDSA/CSSMDefaults.m
===================================================================
--- trunk/Frameworks/Keychain/CDSA/CSSMDefaults.m 2008-03-29 19:22:15 UTC (rev 452)
+++ trunk/Frameworks/Keychain/CDSA/CSSMDefaults.m 2008-03-29 21:33:33 UTC (rev 453)
@@ -22,11 +22,11 @@
/* The init vector really should be unique per cryptographic operation which uses it. It's presence is unfortunate and it is considered obsolete - it will be removed in a future version of the Keychain framework. */
-uint8 keychainFrameworkInitVector[16]; /* = { 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16 }; */
+uint8_t keychainFrameworkInitVector[16]; /* = { 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16 }; */
const CSSM_DATA keychainFrameworkInitVectorData = {16, keychainFrameworkInitVector};
-const uint32 RAW_KEY_VERSION_1 = 1;
-const uint32 KEYHEADER_VERSION_1_SIZE = 76;
+const uint32_t RAW_KEY_VERSION_1 = 1;
+const uint32_t KEYHEADER_VERSION_1_SIZE = 76;
CSSM_ENCRYPT_MODE defaultModeForAlgorithm(CSSM_ALGORITHMS algorithm) {
Modified: trunk/Frameworks/Keychain/CDSA/CSSMManagedModule.m
===================================================================
--- trunk/Frameworks/Keychain/CDSA/CSSMManagedModule.m 2008-03-29 19:22:15 UTC (rev 452)
+++ trunk/Frameworks/Keychain/CDSA/CSSMManagedModule.m 2008-03-29 21:33:33 UTC (rev 453)
@@ -33,18 +33,23 @@
return CSSM_OK;
}
-static int CSSMModuleMagicGenericCallbackContextNumber = 0;
+#ifdef __LP64__
+static int64_t CSSMModuleMagicGenericCallbackContextNumber = 0L;
+#else
+static int32_t CSSMModuleMagicGenericCallbackContextNumber = 0;
+#endif
+typedef size_t CSSM_SIZE; // for the 10.4 SDK
-void* genericCSSMMalloc(uint32 size, void *ref __unused) {
+void* genericCSSMMalloc(CSSM_SIZE size, void *ref __unused) {
return malloc(size);
}
-void* genericCSSMRealloc(void *ptr, uint32 newSize, void *ref __unused) {
+void* genericCSSMRealloc(void *ptr, CSSM_SIZE newSize, void *ref __unused) {
return realloc(ptr, newSize);
}
-void* genericCSSMCalloc(uint32 num, uint32 size, void *ref __unused) {
+void* genericCSSMCalloc(uint32 num, CSSM_SIZE size, void *ref __unused) {
return calloc(num, size);
}
@@ -133,7 +138,11 @@
// Unless of course the user provides their own callback & context, and do so for multiple instances. Bad user. We could put in junk to test for that, but I don't think it's worth it... the user should just be careful; it is noted that they cannot do that in the header documentation.
_callback = &CSSMModuleMagicGenericCallback;
+#ifdef __LP64__
+ _callbackContext = (void *)OSAtomicIncrement64(&CSSMModuleMagicGenericCallbackContextNumber);
+#else
_callbackContext = (void*)OSAtomicIncrement32(&CSSMModuleMagicGenericCallbackContextNumber);
+#endif
_version = keychainFrameworkDefaultCSSMVersion();
_memoryFunctions = *[[self class] defaultMemoryFunctions];
Modified: trunk/Frameworks/Keychain/CDSA/CSSMOpenDataStore.m
===================================================================
--- trunk/Frameworks/Keychain/CDSA/CSSMOpenDataStore.m 2008-03-29 19:22:15 UTC (rev 452)
+++ trunk/Frameworks/Keychain/CDSA/CSSMOpenDataStore.m 2008-03-29 21:33:33 UTC (rev 453)
@@ -54,7 +54,7 @@
- (NSArray*)ACLEntriesWithTag:(NSString*)tag {
CSSM_STRING theTag;
- uint32_t numberOfEntries;
+ uint32 numberOfEntries;
CSSM_ACL_ENTRY_INFO *result;
CSSM_RETURN err;
@@ -62,7 +62,7 @@
copyNSStringToString(tag, &theTag);
}
- err = CSSM_DL_GetDbAcl(myHandle, (const CSSM_STRING*)((nil != tag) ? &theTag : NULL), (uint32*)&numberOfEntries, &result);
+ err = CSSM_DL_GetDbAcl(myHandle, (const CSSM_STRING*)((nil != tag) ? &theTag : NULL), &numberOfEntries, &result);
if (CSSM_OK == err) {
NSMutableArray *finalResult = [NSMutableArray arrayWithCapacity:numberOfEntries];
Modified: trunk/Frameworks/Keychain/CDSA/CSSMUtils.m
===================================================================
--- trunk/Frameworks/Keychain/CDSA/CSSMUtils.m 2008-03-29 19:22:15 UTC (rev 452)
+++ trunk/Frameworks/Keychain/CDSA/CSSMUtils.m 2008-03-29 21:33:33 UTC (rev 453)
@@ -21,7 +21,7 @@
NSString* GUIDAsString(const CSSM_GUID *GUID) {
if (NULL != GUID) {
- return [NSString stringWithFormat:@"%08x-%04hx%04hx-%08x%08x", GUID->Data1, GUID->Data2, GUID->Data3, *((uint32_t*)(GUID->Data4)), *((uint32_t*)(GUID->Data4) + 1)];
+ return [NSString stringWithFormat:@"%08x-%04hx%04hx-%02x%02x%02x%02x%02x%02x%02x%02x", NSSwapBigIntToHost(GUID->Data1), NSSwapBigShortToHost(GUID->Data2), NSSwapBigShortToHost(GUID->Data3), GUID->Data4[0], GUID->Data4[1], GUID->Data4[2], GUID->Data4[3], GUID->Data4[4], GUID->Data4[5], GUID->Data4[6], GUID->Data4[7]];
} else {
PDEBUG(@"Invalid parameter - 'GUID' is NULL.\n");
return nil;
@@ -113,15 +113,15 @@
}
NSString* CSSMErrorName(CSSM_RETURN error) {
- return localizedStringWithFallback([NSString stringWithFormat:@"%lu", (unsigned long)error], @"CSSM Error Names");
+ return localizedStringWithFallback([NSString stringWithFormat:@"%u", error], @"CSSM Error Names");
}
NSString* CSSMErrorConstant(CSSM_RETURN error) {
- return localizedStringWithFallback([NSString stringWithFormat:@"%lu", (unsigned long)error], @"CSSM Error Constants");
+ return localizedStringWithFallback([NSString stringWithFormat:@"%u", error], @"CSSM Error Constants");
}
NSString* CSSMErrorDescription(CSSM_RETURN error) {
- return localizedStringWithFallback([NSString stringWithFormat:@"%lu", (unsigned long)error], @"CSSM Error Descriptions");
+ return localizedStringWithFallback([NSString stringWithFormat:@"%u", error], @"CSSM Error Descriptions");
}
NSString* CSSMErrorAsString(CSSM_RETURN error) {
@@ -133,7 +133,7 @@
return [NSString stringWithFormat:@"%@ (%@)", localizedStringWithFallback(errorRep, @"CSSM Errors"), localizedStringWithFallback(errorRep, @"CSSM Error Names")];
}*/
- NSString *codeAsString = [NSString stringWithFormat:@"%lu", (unsigned long)error];
+ NSString *codeAsString = [NSString stringWithFormat:@"%u", error];
NSString *errorConstant = localizedString(codeAsString, @"CSSM Error Constants");
NSString *errorName = localizedString(codeAsString, @"CSSM Error Names");
NSString *errorDescription = localizedString(codeAsString, @"CSSM Error Descriptions");
@@ -206,7 +206,7 @@
CSSM_DATE CSSMDateForCalendarDate(NSCalendarDate *date) {
CSSM_DATE result;
- int temp;
+ NSInteger temp;
if (date) {
NSCalendarDate *dateGMT = [date copy];
@@ -333,7 +333,7 @@
}
if (format) {
- int year;
+ NSInteger year;
result = [NSCalendarDate dateWithString:timeString calendarFormat:format];
@@ -359,10 +359,10 @@
if (!result) {
PDEBUG(@"Unable to read first part of \"%@\" - expecting yyyymmddHHMM.\n", timeString);
} else {
- unsigned int seconds = 0;
- int offsetHours = 0, offsetMinutes = 0;
+ NSUInteger seconds = 0;
+ NSInteger offsetHours = 0, offsetMinutes = 0;
double fractionalSeconds = 0.0;
- unsigned int index = 12;
+ NSUInteger index = 12;
char temp[5], *check, sign;
BOOL haveSeconds = NO, haveFractionalSeconds = NO, haveTimezone = NO, allGood = YES;
@@ -372,7 +372,7 @@
#define READ_NEXT_FIELD(size, strict) \
if ((!strict && (index < time->time.Length)) || RANGE_CHECK(size)) { \
- int actualSize = min(time->time.Length - index, size); \
+ NSInteger actualSize = min(time->time.Length - index, size); \
memcpy(temp, time->time.Data + index, actualSize); \
index += actualSize; \
temp[actualSize] = 0; \
@@ -528,7 +528,7 @@
Where YY is less than 50, the year shall be interpreted as 20YY. */
{
- int year = [dateGMT yearOfCommonEra];
+ NSInteger year = [dateGMT yearOfCommonEra];
if (1950 > year) {
PDEBUG(@"Date %@ cannot be represented in UTC time because the year is too early (must be at least 1950).\n", dateGMT);
@@ -661,8 +661,8 @@
NSString* descriptionOfAuthorizations(NSArray *authorizations) {
NSMutableString *result = [NSMutableString string];
- unsigned int authorizationsCount = [authorizations count];
- unsigned int i;
+ NSUInteger authorizationsCount = [authorizations count];
+ NSUInteger i;
if (0 < authorizationsCount) {
[result appendString:nameOfAuthorization((CSSM_ACL_AUTHORIZATION_TAG)[[authorizations objectAtIndex:0] intValue])];
@@ -683,8 +683,8 @@
NSString* descriptionOfAuthorizationsUsingConstants(NSArray *authorizations) {
NSMutableString *result = [NSMutableString string];
- unsigned int authorizationsCount = [authorizations count];
- unsigned int i;
+ NSUInteger authorizationsCount = [authorizations count];
+ NSUInteger i;
if (0 < authorizationsCount) {
[result appendString:nameOfAuthorizationConstant((CSSM_ACL_AUTHORIZATION_TAG)[[authorizations objectAtIndex:0] intValue])];
@@ -852,7 +852,7 @@
data->Length = 0;
if (theInt < 0x100) {
- data->Data = (uint8*)malloc(1);
+ data->Data = (uint8_t*)malloc(1);
if (NULL != data->Data) {
data->Length = 1;
@@ -860,7 +860,7 @@
data->Data[0] = (unsigned char)(theInt);
}
} else if (theInt < 0x10000) {
- data->Data = (uint8*)malloc(2);
+ data->Data = (uint8_t*)malloc(2);
if (NULL != data->Data) {
data->Length = 2;
@@ -869,7 +869,7 @@
data->Data[1] = (unsigned char)(theInt);
}
} else if (theInt < 0x1000000) {
- data->Data = (uint8*)malloc(3);
+ data->Data = (uint8_t*)malloc(3);
if (NULL != data->Data) {
data->Length = 3;
@@ -879,7 +879,7 @@
data->Data[2] = (unsigned char)(theInt);
}
} else {
- data->Data = (uint8*)malloc(4);
+ data->Data = (uint8_t*)malloc(4);
if (NULL != data->Data) {
data->Length = 4;
@@ -902,7 +902,7 @@
if ((NULL != data) && (NULL != result)) {
if (4 >= data->Length) {
unsigned int dex;
- uint8 *bp = data->Data;
+ uint8_t *bp = data->Data;
*result = 0;
Modified: trunk/Frameworks/Keychain/CDSA/MDS.m
===================================================================
--- trunk/Frameworks/Keychain/CDSA/MDS.m 2008-03-29 19:22:15 UTC (rev 452)
+++ trunk/Frameworks/Keychain/CDSA/MDS.m 2008-03-29 21:33:33 UTC (rev 453)
@@ -20,6 +20,13 @@
#import "CSSMUtils.h"
#import "CSSMTypes.h"
+// For pre-10.5 SDKs:
+#ifndef NSINTEGER_DEFINED
+typedef int NSInteger;
+typedef unsigned int NSUInteger;
+#define NSINTEGER_DEFINED
+#endif
+typedef size_t CSSM_SIZE;
CSSM_RETURN objectifyCSSMAttribute(const CSSM_DB_ATTRIBUTE_DATA *attribute, id *result) {
if ((nil != attribute) && (nil != result)) {
@@ -102,7 +109,7 @@
break;
case CSSM_DB_ATTRIBUTE_FORMAT_MULTI_UINT32:
if ((0 < attribute->Value[j].Length) && (0 == (attribute->Value[j].Length % 4))) {
- unsigned int k, limit = attribute->Value[j].Length / 4;
+ CSSM_SIZE k, limit = attribute->Value[j].Length / 4;
NSMutableArray *moreSubvalues = [NSMutableArray arrayWithCapacity:limit];
for (k = 0; (CSSM_OK == err) && (k < limit); ++k) {
@@ -137,7 +144,7 @@
}
if (CSSM_OK == err) {
- unsigned int count = [attributeValues count];
+ NSUInteger count = [attributeValues count];
if (0 == count) {
*result = nil;
@@ -853,7 +860,7 @@
if (NULL != mdsFunctions.DataGetFirst) {
CSSM_QUERY myQuery;
- unsigned int count = ((nil != attributes) ? [attributes count] : 0);
+ NSUInteger count = ((nil != attributes) ? [attributes count] : 0);
CSSM_DB_RECORD_ATTRIBUTE_DATA rawAttributes;
myQuery.RecordType = recordType;
@@ -866,7 +873,7 @@
rawAttributes.DataRecordType = recordType;
rawAttributes.SemanticInformation = 0;
- rawAttributes.NumberOfAttributes = count;
+ rawAttributes.NumberOfAttributes = (uint32_t)count;
if (0 < count) {
rawAttributes.AttributeData = myMemoryFunctions.malloc_func(sizeof(CSSM_DB_ATTRIBUTE_DATA) * count, myMemoryFunctions.AllocRef);
@@ -1049,7 +1056,7 @@
if ((nil != attributes) && (0 < [attributes count])) {
if (NULL != mdsFunctions.DataGetFirst) {
CSSM_QUERY myQuery;
- unsigned int count = [attributes count];
+ NSUInteger count = [attributes count];
CSSM_DB_RECORD_ATTRIBUTE_DATA rawAttributes;
myQuery.RecordType = recordType;
@@ -1062,7 +1069,7 @@
rawAttributes.DataRecordType = recordType;
rawAttributes.SemanticInformation = 0;
- rawAttributes.NumberOfAttributes = count;
+ rawAttributes.NumberOfAttributes = (uint32_t)count;
rawAttributes.AttributeData = myMemoryFunctions.malloc_func(sizeof(CSSM_DB_ATTRIBUTE_DATA) * count, myMemoryFunctions.AllocRef);
if (NULL != rawAttributes.AttributeData) {
Modified: trunk/Frameworks/Keychain/Certificates/ABPersonAdditions.m
===================================================================
--- trunk/Frameworks/Keychain/Certificates/ABPersonAdditions.m 2008-03-29 19:22:15 UTC (rev 452)
+++ trunk/Frameworks/Keychain/Certificates/ABPersonAdditions.m 2008-03-29 21:33:33 UTC (rev 453)
@@ -16,6 +16,12 @@
#import <Keychain/NSDataAdditions.h>
#import <Keychain/KeychainSearch.h>
+// For pre-10.5 SDKs:
+#ifndef NSINTEGER_DEFINED
+typedef int NSInteger;
+typedef unsigned int NSUInteger;
+#define NSINTEGER_DEFINED
+#endif
/*! @const kABCertificateProperty
@discussion An address book type identifying a property as being a certificate of some sort. The certificate is included as the data, in raw form. */
@@ -60,7 +66,7 @@
- (NSArray*)primaryCertificates {
id certList;
- int primaryCert;
+ NSInteger primaryCert;
certList = [self valueForProperty:kABCertificateRefProperty];
@@ -96,7 +102,7 @@
- (NSArray*)certificates {
NSMutableArray *certs = [NSMutableArray arrayWithCapacity:5];
id certList, theCert;
- int i;
+ NSInteger i;
certList = [self valueForProperty:kABCertificateRefProperty];
@@ -153,7 +159,7 @@
id certList;
ABMutableMultiValue *valueList;
char *bytes;
- int byteLength;
+ NSInteger byteLength;
NSData *certData;
int i;
Modified: trunk/Frameworks/Keychain/Certificates/Certificate.m
===================================================================
--- trunk/Frameworks/Keychain/Certificates/Certificate.m 2008-03-29 19:22:15 UTC (rev 452)
+++ trunk/Frameworks/Keychain/Certificates/Certificate.m 2008-03-29 21:33:33 UTC (rev 453)
@@ -126,8 +126,8 @@
if (tag) {
//CSSM_FIELD_PTR fields;
CSSM_DATA *rawResult;
- //UInt32 numberOfFields;
- UInt32 numberOfResults;
+ //uint32_t numberOfFields;
+ uint32 numberOfResults;
CSSM_DATA certData;
CSSM_CL_HANDLE CLhandle;
CSSM_HANDLE furtherResultsHandle;
@@ -324,7 +324,7 @@
- (NSString*)description {
CSSM_DATA certificateData;
- UInt32 numberOfFields, i;
+ uint32 numberOfFields, i;
CSSM_FIELD_PTR fields;
NSMutableString *result = [NSMutableString stringWithCapacity:4000];
@@ -354,7 +354,7 @@
[result appendString:[[[NSString alloc] initWithData:NSDataFromData(&fields[i].FieldValue) encoding:NSMacOSRomanStringEncoding] autorelease]];
[result appendString:@"\n\n"];
} else if (OIDsAreEqual(&fields[i].FieldOid, &CSSMOID_X509V1Version)) {
- //[result appendString:[NSString stringWithFormat:@"%@: %u\n\n", NSLocalizedStringFromTableInBundle(@"CSSMOID_X509V1Version", @"OID Names", [NSBundle bundleWithIdentifier:KEYCHAIN_BUNDLE_IDENTIFIER], nil), *((UInt32*)fields[i].FieldValue.Data) + 1]];
+ //[result appendString:[NSString stringWithFormat:@"%@: %u\n\n", NSLocalizedStringFromTableInBundle(@"CSSMOID_X509V1Version", @"OID Names", [NSBundle bundleWithIdentifier:KEYCHAIN_BUNDLE_IDENTIFIER], nil), *((uint32_t*)fields[i].FieldValue.Data) + 1]];
uint32_t temp;
if (DERToInt(&(fields[i].FieldValue), &temp)) {
Modified: trunk/Frameworks/Keychain/Certificates/CertificateGeneration.m
===================================================================
--- trunk/Frameworks/Keychain/Certificates/CertificateGeneration.m 2008-03-29 19:22:15 UTC (rev 452)
+++ trunk/Frameworks/Keychain/Certificates/CertificateGeneration.m 2008-03-29 21:33:33 UTC (rev 453)
@@ -31,7 +31,7 @@
NSEnumerator *extensionEnumerator;
Extension *current;
CSSM_X509_EXTENSION *currentRaw;
- uint32 index = 0, numberOfFields = 5; // always requires at least 5 user-supplied fields
+ uint32_t index = 0, numberOfFields = 5; // always requires at least 5 user-supplied fields
Key *pubKey = publicKey;
resetCSSMData(&result); // Make sure the result is empty, as we convert this to an NSData and return it no matter what happens.
@@ -75,31 +75,31 @@
}
fields[index].FieldOid = CSSMOID_X509V1IssuerNameCStruct;
- fields[index].FieldValue.Data = (uint8*)[issuer nameListRef];
+ fields[index].FieldValue.Data = (uint8_t*)[issuer nameListRef];
fields[index++].FieldValue.Length = sizeof(CSSM_X509_NAME);
fields[index].FieldOid = CSSMOID_X509V1SubjectNameCStruct;
- fields[index].FieldValue.Data = (uint8*)[subject nameListRef];
+ fields[index].FieldValue.Data = (uint8_t*)[subject nameListRef];
fields[index++].FieldValue.Length = sizeof(CSSM_X509_NAME);
if (from) {
fields[index].FieldOid = CSSMOID_X509V1ValidityNotBefore;
- fields[index].FieldValue.Data = (uint8*)from;
+ fields[index].FieldValue.Data = (uint8_t*)from;
fields[index++].FieldValue.Length = sizeof(CSSM_X509_TIME);
}
if (to) {
fields[index].FieldOid = CSSMOID_X509V1ValidityNotAfter;
- fields[index].FieldValue.Data = (uint8*)to;
+ fields[index].FieldValue.Data = (uint8_t*)to;
fields[index++].FieldValue.Length = sizeof(CSSM_X509_TIME);
}
fields[index].FieldOid = CSSMOID_CSSMKeyStruct;
- fields[index].FieldValue.Data = (uint8*)[pubKey CSSMKey];
+ fields[index].FieldValue.Data = (uint8_t*)[pubKey CSSMKey];
fields[index++].FieldValue.Length = sizeof(CSSM_KEY);
fields[index].FieldOid = CSSMOID_X509V1SignatureAlgorithmTBS;
- fields[index].FieldValue.Data = (uint8*)[signingAlgorithm algorithmIdentifierRef];
+ fields[index].FieldValue.Data = (uint8_t*)[signingAlgorithm algorithmIdentifierRef];
fields[index++].FieldValue.Length = sizeof(CSSM_X509_ALGORITHM_IDENTIFIER);
if (extensions) {
@@ -115,7 +115,7 @@
fields[index].FieldOid = CSSMOID_X509V3CertificateExtensionCStruct;
}
- fields[index].FieldValue.Data = (uint8*)currentRaw;
+ fields[index].FieldValue.Data = (uint8_t*)currentRaw;
fields[index++].FieldValue.Length = sizeof(CSSM_X509_EXTENSION);
}
}
Modified: trunk/Frameworks/Keychain/Certificates/Policy.m
===================================================================
--- trunk/Frameworks/Keychain/Certificates/Policy.m 2008-03-29 19:22:15 UTC (rev 452)
+++ trunk/Frameworks/Keychain/Certificates/Policy.m 2008-03-29 21:33:33 UTC (rev 453)
@@ -122,7 +122,7 @@
if (0 == err) {
[result addObject:[Policy policyWithPolicyRef:policyRef]];
- } else if (errSecItemNotFound != err) {
+ } else if (errSecPolicyNotFound != err) {
PSYSLOGND(LOG_ERR, @"Unable to retrieve results of policy search (for certificates of type %@, policies of type %@), error %@.\n", nameOfCertificateType(certificateType), nameOfOID(policyType), err, OSStatusAsString(err));
PDEBUG(@"SecPolicySearchCopyNext(%p, %p) returned error %@.\n", searchRef, policyRef, OSStatusAsString(err));
result = nil;
Modified: trunk/Frameworks/Keychain/Cryptography/FileUtilities.m
===================================================================
--- trunk/Frameworks/Keychain/Cryptography/FileUtilities.m 2008-03-29 19:22:15 UTC (rev 452)
+++ trunk/Frameworks/Keychain/Cryptography/FileUtilities.m 2008-03-29 21:33:33 UTC (rev 453)
@@ -34,8 +34,8 @@
CSSM_DATA result, original;
NSData *finalResult = nil;
int theFile;
- const unsigned long BUFFER_SIZE = 262144;
- unsigned long bufferSize;
+ const size_t BUFFER_SIZE = 262144;
+ size_t bufferSize;
struct stat fileStats;
if (nil == CSPModule) {
@@ -44,23 +44,23 @@
if ((err = CSSM_CSP_CreateDigestContext([CSPModule handle], algorithm, &ccHandle)) == CSSM_OK) {
if ((err = CSSM_DigestDataInit(ccHandle)) == CSSM_OK) {
- theFile = open([path UTF8String], O_RDONLY, 0);
+ theFile = open([path fileSystemRepresentation], O_RDONLY, 0);
if (theFile >= 0) {
if (0 == fstat(theFile, &fileStats)) {
- if (fileStats.st_size < BUFFER_SIZE) {
- bufferSize = fileStats.st_size;
- } else if ((fileStats.st_size / 2) < BUFFER_SIZE) {
- bufferSize = fileStats.st_size / 2;
- } else if ((fileStats.st_size / 3) < BUFFER_SIZE) {
- bufferSize = fileStats.st_size / 3;
+ if ((size_t)fileStats.st_size < BUFFER_SIZE) {
+ bufferSize = (size_t)fileStats.st_size;
+ } else if (((size_t)fileStats.st_size / 2) < BUFFER_SIZE) {
+ bufferSize = (size_t)fileStats.st_size / 2;
+ } else if (((size_t)fileStats.st_size / 3) < BUFFER_SIZE) {
+ bufferSize = (size_t)fileStats.st_size / 3;
} else {
bufferSize = BUFFER_SIZE; // 1/4 mibibyte at a time
}
original.Data = malloc(bufferSize);
- while ((original.Length = read(theFile, original.Data, bufferSize)) > 0) {
+ while ((original.Length = (uint32_t)read(theFile, original.Data, bufferSize)) > 0) {
if ((err = CSSM_DigestDataUpdate(ccHandle, &original, 1)) != CSSM_OK) {
PSYSLOGND(LOG_ERR, @"Unable to generate digest because of error %@.\n", CSSMErrorAsString(err));
PDEBUG(@"CSSM_DigestDataUpdate(%"PRIccHandle", %p, 1) returned error %@.\n", ccHandle, &original, CSSMErrorAsString(err));
Modified: trunk/Frameworks/Keychain/Cryptography/Key.h
===================================================================
--- trunk/Frameworks/Keychain/Cryptography/Key.h 2008-03-29 19:22:15 UTC (rev 452)
+++ trunk/Frameworks/Keychain/Cryptography/Key.h 2008-03-29 21:33:33 UTC (rev 453)
@@ -70,7 +70,7 @@
@discussion Be wary with this - this framework tries to preserve the version value for keys, but many other libraries do not (e.g. Apple's own Security framework). In fact, many real world applications provide no indication of such information to start with. Plus, this version number only applies to keys generated by the CDSA, not from other libraries. So, in summary, be wary of using this for anything important, as in a significant number of cases it may not be valid.
Generally the fallback is to the version of the CDSA under which this framework was compiled (2.0 at the time of writing). This fallback behaviour, at least, is fairly consistant across libraries (e.g. Apple's Security framework, again).
- @result The returned value is really just a uint32 describing the major version only. */
+ @result The returned value is really just a uint32_t describing the major version only. */
/*! @method init
@abstract Reject initialiser.
@@ -128,14 +128,14 @@
/*! @method attributes
@abstract Returns a mask representing the attributes of the receiver.
@discussion See <a href="file:///System/Library/Frameworks/Security.framework/Headers/cssmtype.h>cssmtype.h</a> for masks.
- @result The mask, which at time of writing is just a uint32. */
+ @result The mask, which at time of writing is just a uint32_t. */
- (CSSM_KEYATTR_FLAGS)attributes;
/*! @method usage
@abstract Returns a mask representing the valid uses for the receiver.
@discussion See <a href="file:///System/Library/Frameworks/Security.framework/Headers/cssmtype.h>cssmtype.h</a> for masks.
- @result The mask, which at time of writing is just a uint32. */
+ @result The mask, which at time of writing is just a uint32_t. */
- (CSSM_KEYUSE)usage;
Modified: trunk/Frameworks/Keychain/Cryptography/Key.m
===================================================================
--- trunk/Frameworks/Keychain/Cryptography/Key.m 2008-03-29 19:22:15 UTC (rev 452)
+++ trunk/Frameworks/Keychain/Cryptography/Key.m 2008-03-29 21:33:33 UTC (rev 453)
@@ -23,6 +23,8 @@
#import "Utilities/UtilitySupport.h"
#import "Utilities/Logging.h"
+// For pre-10.5 SDKs:
+typedef size_t CSSM_SIZE;
@implementation Key
@@ -189,9 +191,11 @@
if ((_error = CSSM_CSP_CreateSymmetricContext([_CSPModule handle], CSSM_ALGID_NONE, CSSM_ALGMODE_WRAP, NULL, NULL, NULL, CSSM_PADDING_NONE, NULL, &ccHandle)) == CSSM_OK) {
if (description) {
+ const char *descriptionCStr = [description UTF8String];
+
descPtr = &desc;
- desc.Length = [description cStringLength];
- desc.Data = (uint8_t*)[description cString];
+ desc.Length = strlen(descriptionCStr);
+ desc.Data = (uint8_t *)descriptionCStr;
} else {
descPtr = NULL;
}
@@ -279,9 +283,11 @@
}
if (description) {
+ const char *descriptionCStr = [description UTF8String];
+
descPtr = &desc;
- desc.Length = [description cStringLength];
- desc.Data = (uint8_t*)[description cString];
+ desc.Length = strlen(descriptionCStr);
+ desc.Data = (uint8_t *)descriptionCStr;
} else {
descPtr = NULL;
}
@@ -443,7 +449,7 @@
- (NSData*)data {
char *result;
NSData *finalResult = nil;
- int dataLength;
+ CSSM_SIZE dataLength;
if ((_CSSMKey->KeyHeader.BlobType != CSSM_KEYBLOB_RAW) && (_CSSMKey->KeyHeader.BlobType != CSSM_KEYBLOB_WRAPPED)) {
PDEBUG(@"Called on an internal (non-raw) key instance; cannot [automatically] extract raw key data.\n");
Modified: trunk/Frameworks/Keychain/Cryptography/KeychainUtils.h
===================================================================
--- trunk/Frameworks/Keychain/Cryptography/KeychainUtils.h 2008-03-29 19:22:15 UTC (rev 452)
+++ trunk/Frameworks/Keychain/Cryptography/KeychainUtils.h 2008-03-29 21:33:33 UTC (rev 453)
@@ -21,6 +21,12 @@
#import <Keychain/CSSMDefaults.h>
#import <Keychain/CSSMModule.h>
+// For pre-10.5 SDKs:
+#ifndef NSINTEGER_DEFINED
+typedef int NSInteger;
+typedef unsigned int NSUInteger;
+#define NSINTEGER_DEFINED
+#endif
/*! @function generateRandomData
@abstract Generates an arbitrary amount of random data using a given algorithm & seed.
@@ -32,7 +38,7 @@
@param CSPModule The CSP to use to generate the random data. Pass nil to use the current default CSP.
@result Returns 'lengthInBytes' bytes of generated data, or NULL if an error occurs. */
-char* generateRandomData(uint32 lengthInBytes, CSSM_ALGORITHMS algorithm, const char *seed, unsigned int seedLength, CSSMModule *CSPModule);
+char* generateRandomData(uint32_t lengthInBytes, CSSM_ALGORITHMS algorithm, const char *seed, NSUInteger seedLength, CSSMModule *CSPModule);
/*! @function generateRandomNSData
@abstract Generates an arbitrary amount of random data using a given algorithm & seed.
@@ -43,7 +49,7 @@
@param CSPModule The CSP to use to generate the random data. Pass nil to use the current default CSP.
@result Returns the generated data, or nil if an error occurs. */
-NSData* generateRandomNSData(uint32 lengthInBytes, CSSM_ALGORITHMS algorithm, NSData *seed, CSSMModule *CSPModule);
+NSData* generateRandomNSData(uint32_t lengthInBytes, CSSM_ALGORITHMS algorithm, NSData *seed, CSSMModule *CSPModule);
/*! @function generateGenericRandomData
@abstract Generates a given number of bytes of random data, using a default algorithm and no seed.
Modified: trunk/Frameworks/Keychain/Cryptography/KeychainUtils.m
===================================================================
--- trunk/Frameworks/Keychain/Cryptography/KeychainUtils.m 2008-03-29 19:22:15 UTC (rev 452)
+++ trunk/Frameworks/Keychain/Cryptography/KeychainUtils.m 2008-03-29 21:33:33 UTC (rev 453)
@@ -21,7 +21,7 @@
#import "Utilities/Logging.h"
-char* generateRandomData(uint32 lengthInBytes, CSSM_ALGORITHMS algorithm, const char *seed, unsigned int seedLength, CSSMModule *CSPModule) {
+char* generateRandomData(uint32_t lengthInBytes, CSSM_ALGORITHMS algorithm, const char *seed, NSUInteger seedLength, CSSMModule *CSPModule) {
CSSM_CC_HANDLE ccHandle;
static CSSM_CRYPTO_DATA rawSeed;
static CSSM_CRYPTO_DATA_PTR rawSeedPtr;
@@ -65,7 +65,7 @@
return finalResult;
}
-NSData* generateRandomNSData(uint32 lengthInBytes, CSSM_ALGORITHMS algorithm, NSData *seed, CSSMModule *CSPModule) {
+NSData* generateRandomNSData(uint32_t lengthInBytes, CSSM_ALGORITHMS algorithm, NSData *seed, CSSMModule *CSPModule) {
char *temp = generateRandomData(lengthInBytes, algorithm, (seed ? [seed bytes] : NULL), (seed ? [seed length] : 0), CSPModule);
if (temp) {
Modified: trunk/Frameworks/Keychain/Cryptography/MutableKey.h
===================================================================
--- trunk/Frameworks/Keychain/Cryptography/MutableKey.h 2008-03-29 19:22:15 UTC (rev 452)
+++ trunk/Frameworks/Keychain/Cryptography/MutableKey.h 2008-03-29 21:33:33 UTC (rev 453)
@@ -20,7 +20,7 @@
BOOL _freeWhenDone;
}
-+ (MutableKey*)generateKey:(CSSM_ALGORITHMS)algorithm size:(uint32)keySizeInBits validFrom:(NSCalendarDate*)validFrom validTo:(NSCalendarDate*)validTo usage:(uint32)keyUsage mutable:(BOOL)keyIsMutable extractable:(BOOL)keyIsExtractable sensitive:(BOOL)keyIsSensitive label:(NSString*)label module:(CSSMModule*)CSPModule;
++ (MutableKey*)generateKey:(CSSM_ALGORITHMS)algorithm size:(uint32_t)keySizeInBits validFrom:(NSCalendarDate*)validFrom validTo:(NSCalendarDate*)validTo usage:(uint32_t)keyUsage mutable:(BOOL)keyIsMutable extractable:(BOOL)keyIsExtractable sensitive:(BOOL)keyIsSensitive label:(NSString*)label module:(CSSMModule*)CSPModule;
+ (MutableKey*)keyWithKeyRef:(SecKeyRef)ke module:(CSSMModule*)CSPModule;
+ (MutableKey*)keyWithCSSMKey:(CSSM_KEY*)ke module:(CSSMModule*)CSPModule;
@@ -58,4 +58,4 @@
@end
-CSSM_RETURN generateKeyPair(CSSM_ALGORITHMS algorithm, uint32 keySizeInBits, NSCalendarDate *validFrom, NSCalendarDate *validTo, uint32 publicKeyUsage, uint32 privateKeyUsage, NSString *publicKeyLabel, NSString *privateKeyLabel, CSSMModule *CSPModule, MutableKey **publicKey, MutableKey **privateKey);
+CSSM_RETURN generateKeyPair(CSSM_ALGORITHMS algorithm, uint32_t keySizeInBits, NSCalendarDate *validFrom, NSCalendarDate *validTo, uint32_t publicKeyUsage, uint32_t privateKeyUsage, NSString *publicKeyLabel, NSString *privateKeyLabel, CSSMModule *CSPModule, MutableKey **publicKey, MutableKey **privateKey);
Modified: trunk/Frameworks/Keychain/Cryptography/MutableKey.m
===================================================================
--- trunk/Frameworks/Keychain/Cryptography/MutableKey.m 2008-03-29 19:22:15 UTC (rev 452)
+++ trunk/Frameworks/Keychain/Cryptography/MutableKey.m 2008-03-29 21:33:33 UTC (rev 453)
@@ -24,7 +24,7 @@
@implementation MutableKey
-+ (MutableKey*)generateKey:(CSSM_ALGORITHMS)algorithm size:(uint32)keySizeInBits validFrom:(NSCalendarDate*)validFrom validTo:(NSCalendarDate*)validTo usage:(uint32)keyUsage mutable:(BOOL)keyIsMutable extractable:(BOOL)keyIsExtractable sensitive:(BOOL)keyIsSensitive label:(NSString*)label module:(CSSMModule*)CSPModule {
++ (MutableKey*)generateKey:(CSSM_ALGORITHMS)algorithm size:(uint32_t)keySizeInBits validFrom:(NSCalendarDate*)validFrom validTo:(NSCalendarDate*)validTo usage:(uint32_t)keyUsage mutable:(BOOL)keyIsMutable extractable:(BOOL)keyIsExtractable sensitive:(BOOL)keyIsSensitive label:(NSString*)label module:(CSSMModule*)CSPModule {
CSSM_KEY *keyResult;
CSSM_CC_HANDLE cryptoContext;
CSSM_DATA *keyLabel;
@@ -192,7 +192,7 @@
@end
-CSSM_RETURN generateKeyPair(CSSM_ALGORITHMS algorithm, uint32 keySizeInBits, NSCalendarDate *validFrom, NSCalendarDate *validTo, uint32 publicKeyUsage, uint32 privateKeyUsage, NSString *publicKeyLabel, NSString *privateKeyLabel, CSSMModule *CSPModule, MutableKey **publicKey, MutableKey **privateKey) {
+CSSM_RETURN generateKeyPair(CSSM_ALGORITHMS algorithm, uint32_t keySizeInBits, NSCalendarDate *validFrom, NSCalendarDate *validTo, uint32_t publicKeyUsage, uint32_t privateKeyUsage, NSString *publicKeyLabel, NSString *privateKeyLabel, CSSMModule *CSPModule, MutableKey **publicKey, MutableKey **privateKey) {
if ((nil == validFrom) || (nil == validTo) || (nil == publicKeyLabel)) {
PSYSLOGND(LOG_ERR, @"Missing parameter(s) to generateKeyPair().\n");
PDEBUG(@"Invalid parameter(s) - validFrom = %p, validTo = %p, publicKeyLabel = %p.\n", validFrom, validTo, publicKeyLabel);
Modified: trunk/Frameworks/Keychain/Cryptography/NSDataAdditions.m
===================================================================
--- trunk/Frameworks/Keychain/Cryptography/NSDataAdditions.m 2008-03-29 19:22:15 UTC (rev 452)
+++ trunk/Frameworks/Keychain/Cryptography/NSDataAdditions.m 2008-03-29 21:33:33 UTC (rev 453)
@@ -22,13 +22,20 @@
#import "Utilities/UtilitySupport.h"
#import "Utilities/Logging.h"
+// For pre-10.5 SDKs:
+#ifndef NSINTEGER_DEFINED
+typedef int NSInteger;
+typedef unsigned int NSUInteger;
+#define NSINTEGER_DEFINED
+#endif
+typedef size_t CSSM_SIZE;
@implementation NSData (KeychainFramework)
- (NSData*)encryptedDataUsingKey:(Key*)key mode:(CSSM_ENCRYPT_MODE)mode padding:(CSSM_PADDING)padding {
CSSM_CC_HANDLE ccHandle;
CSSM_DATA result = {0, NULL}, original;
- uint32 outputLength;
+ CSSM_SIZE outputLength;
CSSM_RETURN err;
NSData *finalResult = nil;
CSSMModule *CSPModule = [key CSPModule];
@@ -109,7 +116,7 @@
- (NSData*)decryptedDataUsingKey:(Key*)key mode:(CSSM_ENCRYPT_MODE)mode padding:(CSSM_PADDING)padding {
CSSM_CC_HANDLE ccHandle;
CSSM_DATA result = {0, NULL}, original;
- uint32 outputLength;
+ CSSM_SIZE outputLength;
CSSM_RETURN err;
NSData *finalResult = nil;
CSSMModule *CSPModule = [key CSPModule];
@@ -418,7 +425,7 @@
- (MutableKey*)keyForModule:(CSSMModule*)CSPModule {
CSSM_KEY *result;
const char *bytes = [self bytes];
- uint32 version, myLength = [self length];
+ NSUInteger version = 0, myLength = [self length];
MutableKey *finalResult = nil;
if (myLength < 4) {
Modified: trunk/Frameworks/Keychain/Cryptography/Streams/ChainedOutputStream.h
===================================================================
--- trunk/Frameworks/Keychain/Cryptography/Streams/ChainedOutputStream.h 2008-03-29 19:22:15 UTC (rev 452)
+++ trunk/Frameworks/Keychain/Cryptography/Streams/ChainedOutputStream.h 2008-03-29 21:33:33 UTC (rev 453)
@@ -18,6 +18,12 @@
@abstract Defines the ChainedOutputStream class and key-value codings.
@discussion See the documentation for each individual element of this header for more information. */
+// For pre-10.5 SDKs:
+#ifndef NSINTEGER_DEFINED
+typedef int NSInteger;
+typedef unsigned int NSUInteger;
+#define NSINTEGER_DEFINED
+#endif
/*! @class ChainedOutputStream
@abstract An NSOutputStream subclass which can be chained to another NSOutputStream.
@@ -167,7 +173,7 @@
@discussion Works the same as NSOutputStream's version.
@result Returns a ChainedOutputStream (possibly the receiver) suitably initialised, or nil if an error occurs. */
-- (id)initToBuffer:(uint8_t*)buffer capacity:(unsigned int)capacity;
+- (id)initToBuffer:(uint8_t*)buffer capacity:(NSUInteger)capacity;
/*! @method initToFileAtPath:append:
@abstract Initialises the receiver to write received data to a file.
@@ -195,7 +201,7 @@
@param len The maximum length of valid data in 'buffer'. At most this many bytes will be written.
@result Returns the number of bytes written, which will always be less than or equal to 'len'. If the stream is full it will return 0. If an error occurs, -1 will be returned, and you will be able to obtain more information using the receivers streamError method. */
-- (int)write:(const uint8_t*)buffer maxLength:(unsigned int)len;
+- (NSInteger)write:(const uint8_t*)buffer maxLength:(NSUInteger)len;
/*! @method hasSpaceAvailable
@abstract Returns whether or not the receiver has room for additional data.
Modified: trunk/Frameworks/Keychain/Cryptography/Streams/ChainedOutputStream.m
===================================================================
--- trunk/Frameworks/Keychain/Cryptography/Streams/ChainedOutputStream.m 2008-03-29 19:22:15 UTC (rev 452)
+++ trunk/Frameworks/Keychain/Cryptography/Streams/ChainedOutputStream.m 2008-03-29 21:33:33 UTC (rev 453)
@@ -143,7 +143,7 @@
return self;
}
-- (id)initToBuffer:(uint8_t*)buffer capacity:(unsigned int)capacity {
+- (id)initToBuffer:(uint8_t*)buffer capacity:(NSUInteger)capacity {
if (self = [super init]) {
stream = [[NSOutputStream outputStreamToBuffer:buffer capacity:capacity] retain];
@@ -198,8 +198,8 @@
return self;
}
-- (int)write:(const uint8_t*)buffer maxLength:(unsigned int)len {
- int result;
+- (NSInteger)write:(const uint8_t*)buffer maxLength:(NSUInteger)len {
+ NSInteger result;
if (stream) {
result = [stream write:buffer maxLength:len];
Modified: trunk/Frameworks/Keychain/Cryptography/Streams/DigestOutputStream.h
===================================================================
--- trunk/Frameworks/Keychain/Cryptography/Streams/DigestOutputStream.h 2008-03-29 19:22:15 UTC (rev 452)
+++ trunk/Frameworks/Keychain/Cryptography/Streams/DigestOutputStream.h 2008-03-29 21:33:33 UTC (rev 453)
@@ -134,7 +134,7 @@
@param len The maximum length of valid data in 'buffer'. At most this many bytes will be written.
@result Returns the number of bytes written, which will always be less than or equal to 'len'. If the stream is full it will return 0. If an error occurs, -1 will be returned, and you will be able to obtain more information using the receivers streamError method. */
-- (int)write:(const uint8_t*)buffer maxLength:(unsigned int)len;
+- (NSInteger)write:(const uint8_t*)buffer maxLength:(NSUInteger)len;
/*! @method hasSpaceAvailable
@abstract Returns whether or not the receiver has room for additional data.
Modified: trunk/Frameworks/Keychain/Cryptography/Streams/DigestOutputStream.m
===================================================================
--- trunk/Frameworks/Keychain/Cryptography/Streams/DigestOutputStream.m 2008-03-29 19:22:15 UTC (rev 452)
+++ trunk/Frameworks/Keychain/Cryptography/Streams/DigestOutputStream.m 2008-03-29 21:33:33 UTC (rev 453)
@@ -149,12 +149,12 @@
return self;
}
-- (int)write:(const uint8_t*)buffer maxLength:(unsigned int)len {
+- (NSInteger)write:(const uint8_t*)buffer maxLength:(NSUInteger)len {
if (CSSM_INVALID_HANDLE == ccHandle) {
PDEBUG(@"Attempted to write to stream before opening it.\n");
return -1;
} else {
- int result = [super write:buffer maxLength:len];
+ NSInteger result = [super write:buffer maxLength:len];
if (0 < result) {
CSSM_DATA data = {result, (uint8_t*)buffer};
Modified: trunk/Frameworks/Keychain/Hashcash/Hashcash.m
===================================================================
--- trunk/Frameworks/Keychain/Hashcash/Hashcash.m 2008-03-29 19:22:15 UTC (rev 452)
+++ trunk/Frameworks/Keychain/Hashcash/Hashcash.m 2008-03-29 21:33:33 UTC (rev 453)
@@ -134,7 +134,7 @@
if ([scanner scanUpToString:@":" intoString:&dateString] && dateString) {
if ([dateString rangeOfCharacterFromSet:[[[self class] stampDateCharacterSet] invertedSet]].location == NSNotFound) {
- unsigned int theLength = strlen([dateString UTF8String]);
+ size_t theLength = strlen([dateString UTF8String]);
if ((theLength > 0) && (theLength <= strlen([kDefaultHashcashStringFormat UTF8String])) && ((theLength % 2) == 0)) {
_date = [[NSCalendarDate alloc] initWithString:dateString calendarFormat:[kDefaultHashcashStringFormat substringToIndex:theLength]];
@@ -457,7 +457,7 @@
BOOL findSuffixRecursively(CSSM_DATA buffers[3], unsigned int currentDepth, unsigned int bits, CSSM_CC_HANDLE handle) {
CSSM_RETURN err;
- unsigned int i;
+ size_t i;
assert(0 < buffers[1].Length);
@@ -581,14 +581,14 @@
if ((nil != scratch) && (CSSM_OK == (err = CSSM_CSP_CreateDigestContext([_CSPModule handle], CSSM_ALGID_SHA1, &ccHandle)))) {
char hashBuf[20];
- buffers[0].Data = (uint8*)[scratch UTF8String];
+ buffers[0].Data = (uint8_t*)[scratch UTF8String];
buffers[0].Length = strlen((char*)(buffers[0].Data));
buffers[1].Length = 0;
buffers[1].Data = NULL;
buffers[2].Length = 20;
- buffers[2].Data = (uint8*)&hashBuf;
+ buffers[2].Data = (uint8_t*)&hashBuf;
while (!found && (buffers[1].Length <= kHashcashSuffixLengthLimit)) {
++(buffers[1].Length);
@@ -646,7 +646,7 @@
#ifndef USE_BIT_COUNTING
if (digest) {
const uint8_t *data = [digest bytes];
- int length = [digest length];
+ NSInteger length = [digest length];
int bitsRemaining = _bits;
int index = 0;
Modified: trunk/Frameworks/Keychain/Keychain/Access.h
===================================================================
--- trunk/Frameworks/Keychain/Keychain/Access.h 2008-03-29 19:22:15 UTC (rev 452)
+++ trunk/Frameworks/Keychain/Keychain/Access.h 2008-03-29 21:33:33 UTC (rev 453)
@@ -24,7 +24,7 @@
@interface Access : NSCachedObject {
SecAccessRef _access;
- int _error;
+ OSStatus _error;
}
// Q) Why isn't there a mechanism to retrieve the name after creation?
@@ -188,7 +188,7 @@
Please note that this error code is local to the receiver only, and not any sort of shared global value.
@result The last error that occured, or zero if the last operation was successful. */
-- (int)lastError;
+- (OSStatus)lastError;
/*! @method accessRef
@abstract Returns the SecAccessRef the receiver is based on.
Modified: trunk/Frameworks/Keychain/Keychain/Access.m
===================================================================
--- trunk/Frameworks/Keychain/Keychain/Access.m 2008-03-29 19:22:15 UTC (rev 452)
+++ trunk/Frameworks/Keychain/Keychain/Access.m 2008-03-29 21:33:33 UTC (rev 453)
@@ -214,7 +214,7 @@
return [self accessControlListsForAction:CSSM_ACL_AUTHORIZATION_DERIVE];
}
-- (int)lastError {
+- (OSStatus)lastError {
return _error;
}
Modified: trunk/Frameworks/Keychain/Keychain/AccessControlList.h
===================================================================
--- trunk/Frameworks/Keychain/Keychain/AccessControlList.h 2008-03-29 19:22:15 UTC (rev 452)
+++ trunk/Frameworks/Keychain/Keychain/AccessControlList.h 2008-03-29 21:33:33 UTC (rev 453)
@@ -33,7 +33,7 @@
@interface AccessControlList : NSCachedObject {
SecACLRef _ACL;
- int _error;
+ OSStatus _error;
}
/*! @method accessControlListNamed:fromAccess:forApplications:requiringPassphrase:
Modified: trunk/Frameworks/Keychain/Keychain/AccessControlList.m
===================================================================
--- trunk/Frameworks/Keychain/Keychain/AccessControlList.m 2008-03-29 19:22:15 UTC (rev 452)
+++ trunk/Frameworks/Keychain/Keychain/AccessControlList.m 2008-03-29 21:33:33 UTC (rev 453)
@@ -21,6 +21,12 @@
#import <Security/Security.h>
+// For pre-10.5 SDKs:
+#ifndef NSINTEGER_DEFINED
+typedef int NSInteger;
+typedef unsigned int NSUInteger;
+#define NSINTEGER_DEFINED
+#endif
@interface AccessControlList (Internal)
@@ -476,7 +482,7 @@
}
- (BOOL)setAuthorizations:(NSArray*)authorizations {
- unsigned int authorizationsCount = [authorizations count];
+ NSUInteger authorizationsCount = [authorizations count];
CSSM_ACL_AUTHORIZATION_TAG *auths = ((0 < authorizationsCount) ? malloc(sizeof(CSSM_ACL_AUTHORIZATION_TAG) * authorizationsCount) : NULL);
uint32_t i;
@@ -484,7 +490,7 @@
auths[i] = [[authorizations objectAtIndex:i] intValue];
}
- _error = SecACLSetAuthorizations(_ACL, auths, authorizationsCount);
+ _error = SecACLSetAuthorizations(_ACL, auths, (uint32_t)authorizationsCount);
if (NULL != auths) {
free(auths);
@@ -499,7 +505,7 @@
}
- (BOOL)setAuthorizesAction:(CSSM_ACL_AUTHORIZATION_TAG)action to:(BOOL)value {
- UInt32 i, capacity = 10, count, newCount = 0;
+ uint32 i, capacity = 10, count, newCount = 0;
CSSM_ACL_AUTHORIZATION_TAG *currentAuths = NULL, *newAuths = NULL;
BOOL alreadySet = NO;
@@ -615,7 +621,7 @@
}
- (NSArray*)authorizations {
- UInt32 i, capacity = 10, count;
+ uint32 i, capacity = 10, count;
CSSM_ACL_AUTHORIZATION_TAG *auths = NULL;
NSMutableArray *result = nil;
@@ -642,7 +648,7 @@
}
- (BOOL)authorizesAction:(CSSM_ACL_AUTHORIZATION_TAG)action {
- UInt32 i, capacity = 10, count;
+ uint32 i, capacity = 10, count;
CSSM_ACL_AUTHORIZATION_TAG *auths = NULL;
BOOL result = NO;
Modified: trunk/Frameworks/Keychain/Keychain/Identity.h
===================================================================
--- trunk/Frameworks/Keychain/Keychain/Identity.h 2008-03-29 19:22:15 UTC (rev 452)
+++ trunk/Frameworks/Keychain/Keychain/Identity.h 2008-03-29 21:33:33 UTC (rev 453)
@@ -25,7 +25,7 @@
@interface Identity : NSCachedObject {
SecIdentityRef _identity;
- int _error;
+ OSStatus _error;
}
/*! @method identityWithIdentityRef:
@@ -91,7 +91,7 @@
Please note that this error code is local to the receiver only, and not any sort of shared global value.
@result The last error that occured, or zero if the last operation was successful. */
-- (int)lastError;
+- (OSStatus)lastError;
/*! @method identityRef
@abstract Returns a SecIdentityRef representing the receiver.
Modified: trunk/Frameworks/Keychain/Keychain/Identity.m
===================================================================
--- trunk/Frameworks/Keychain/Keychain/Identity.m 2008-03-29 19:22:15 UTC (rev 452)
+++ trunk/Frameworks/Keychain/Keychain/Identity.m 2008-03-29 21:33:33 UTC (rev 453)
@@ -132,7 +132,7 @@
return [NSString stringWithFormat:@"Certificate: %@\nPrivate key: %@", [[self certificate] description], [[self privateKey] description]];
}
-- (int)lastError {
+- (OSStatus)lastError {
return _error;
}
Modified: trunk/Frameworks/Keychain/Keychain/Keychain.h
===================================================================
--- trunk/Frameworks/Keychain/Keychain/Keychain.h 2008-03-29 19:22:15 UTC (rev 452)
+++ trunk/Frameworks/Keychain/Keychain/Keychain.h 2008-03-29 21:33:33 UTC (rev 453)
@@ -70,14 +70,14 @@
@interface Keychain : NSCachedObject {
SecKeychainRef _keychain;
- int _error;
+ OSStatus _error;
}
/*! @method keychainManagerVersion
@abstract Returns the major version number of the active keychain manager.
@discussion This may or may not be linked to the version number of a keychain. */
-+ (UInt32)keychainManagerVersion;
++ (uint32_t)keychainManagerVersion;
/*! @method setUserInteractionAllowed:
@abstract Sets whether or not any user interaction should occur when using keychains.
@@ -221,14 +221,14 @@
@discussion You should be careful about setting this value, as it may relate intricately to the keychain file format on disk. See the description for the version method for more details.
@param version The major version number. */
-- (void)setVersion:(UInt32)version;
+- (void)setVersion:(uint32_t)version;
/*! @method version
@abstract Returns the version of the receiver.
@discussion The version relates primarily to the format of the keychain file on disk, rather than how the receiver acts. At the time of writing, all keychain versions work the same. But MacOS 10.1 used a different format for storing keychains to 10.2. Indeed, 10.3 or another future release may change the format again.
@result The major version number. */
-- (UInt32)version;
+- (uint32_t)version;
/*! @method setLockOnSleep:
@abstract Sets whether or not the receiver will lock itself automatically when the system goes to sleep.
@@ -263,14 +263,14 @@
@discussion This is an idle timeout - if the receiver is unused for the specified interval of time, it locks itself. Note that since keychains are system-wide, other applications may use the receiver without your knowledge. Also not that this interval does not need to be 'reset' every time you use the receiver - the receiver keeps track of time and usage itself.
@param interval The number of seconds of idle time after which the receiver should lock itself. This may be 0, in which case the receiver will lock itself immediately after any operation. Since this setting is system-wide, you should be wary about setting this value to 0, or any other brief interval. */
-- (void)setInterval:(UInt32)interval;
+- (void)setInterval:(uint32_t)interval;
/*! @method interval
@abstract Returns the time in seconds after which a keychain automatically locks.
@discussion This is an idle timeout - if the receiver is unused for this interval of time, it locks itself. Note that since keychains are system-wide, other applications may use the receiver without your knowledge.
@result The time interval in seconds. This may be a non-zero number even if the receiver is not set to use it. */
-- (UInt32)interval;
+- (uint32_t)interval;
/*! @method lock
@abstract Locks the receiver.
@@ -408,7 +408,7 @@
@param authType The authentication type to be used. See <a href="file:///System/Library/Frameworks/Security.framework/Headers/SecKeychain.h>SecKeychain.h</a> for predefined types. You should use kSecAuthenticationTypeDefault if you have no preference or knowledge of the type to be used. Like the protocol parameter, this a 4-byte code, which may be user defined.
@result If a match is found, it is returned. Otherwise, or in case of an error, nil is returned. */
-- (NSString*)passwordForInternetServer:(NSString*)server forAccount:(NSString*)account port:(UInt...
[truncated message content] |