Permalink
Browse files

- Added new Unique Device Identifier, because [UIDevice currentDevice…

…].uniqueIdentifier is deprecated

- Fixed Singleton Macro defines
- Added NSString Category for SHA crypto methods
- Updated Project Settings
  • Loading branch information...
1 parent 9d3bda7 commit 557eff3a66730c5dfd8c7e45de67d7c39c0f1756 @carlj carlj committed Apr 3, 2012
@@ -3,10 +3,12 @@
archiveVersion = 1;
classes = {
};
- objectVersion = 45;
+ objectVersion = 46;
objects = {
/* Begin PBXBuildFile section */
+ 15B5B521152AF3170042EA2E /* MacAdress.m in Sources */ = {isa = PBXBuildFile; fileRef = 15B5B520152AF3170042EA2E /* MacAdress.m */; };
+ 15B5B527152AF4E80042EA2E /* NSString+SHA.m in Sources */ = {isa = PBXBuildFile; fileRef = 15B5B526152AF4E80042EA2E /* NSString+SHA.m */; };
1D3623260D0F684500981E51 /* CrashManagerDemoAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 1D3623250D0F684500981E51 /* CrashManagerDemoAppDelegate.m */; };
1D60589B0D05DD56006BFB54 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 29B97316FDCFA39411CA2CEA /* main.m */; };
1D60589F0D05DD5A006BFB54 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1D30AB110D05D00D00671497 /* Foundation.framework */; };
@@ -23,6 +25,10 @@
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
+ 15B5B51F152AF3170042EA2E /* MacAdress.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MacAdress.h; sourceTree = "<group>"; };
+ 15B5B520152AF3170042EA2E /* MacAdress.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MacAdress.m; sourceTree = "<group>"; };
+ 15B5B525152AF4E80042EA2E /* NSString+SHA.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSString+SHA.h"; sourceTree = "<group>"; };
+ 15B5B526152AF4E80042EA2E /* NSString+SHA.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSString+SHA.m"; sourceTree = "<group>"; };
1D30AB110D05D00D00671497 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
1D3623240D0F684500981E51 /* CrashManagerDemoAppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CrashManagerDemoAppDelegate.h; sourceTree = "<group>"; };
1D3623250D0F684500981E51 /* CrashManagerDemoAppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CrashManagerDemoAppDelegate.m; sourceTree = "<group>"; };
@@ -151,6 +157,10 @@
isa = PBXGroup;
children = (
39EF1F111299EC6B00261349 /* SynthesizeSingleton.h */,
+ 15B5B51F152AF3170042EA2E /* MacAdress.h */,
+ 15B5B520152AF3170042EA2E /* MacAdress.m */,
+ 15B5B525152AF4E80042EA2E /* NSString+SHA.h */,
+ 15B5B526152AF4E80042EA2E /* NSString+SHA.m */,
);
path = Support;
sourceTree = "<group>";
@@ -191,8 +201,11 @@
/* Begin PBXProject section */
29B97313FDCFA39411CA2CEA /* Project object */ = {
isa = PBXProject;
+ attributes = {
+ LastUpgradeCheck = 0430;
+ };
buildConfigurationList = C01FCF4E08A954540054247B /* Build configuration list for PBXProject "CrashManager" */;
- compatibilityVersion = "Xcode 3.1";
+ compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
hasScannedForEncodings = 1;
knownRegions = (
@@ -234,6 +247,8 @@
39EF1F181299EC6B00261349 /* StackTracer.m in Sources */,
39EF1F191299EC6B00261349 /* Mailer.m in Sources */,
39EF1F1A1299EC6B00261349 /* ModalViewPresenter.m in Sources */,
+ 15B5B521152AF3170042EA2E /* MacAdress.m in Sources */,
+ 15B5B527152AF4E80042EA2E /* NSString+SHA.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -275,7 +290,6 @@
GCC_C_LANGUAGE_STANDARD = c99;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
- PREBINDING = NO;
SDKROOT = iphoneos;
};
name = Debug;
@@ -289,7 +303,6 @@
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1";
- PREBINDING = NO;
SDKROOT = iphoneos;
};
name = Release;
@@ -28,7 +28,8 @@
#include <unistd.h>
#import "StackTracer.h"
#import <UIKit/UIKit.h>
-
+#import "MacAdress.h"
+#import "NSString+SHA.h"
/** Maximum number of stack frames to capture. */
#define kStackFramesToCapture 40
@@ -256,8 +257,8 @@ - (void) storeErrorReport:(NSException*) exception stackTrace:(NSArray*) stackTr
NSString* data = [NSString stringWithFormat:@"App: %@\nVersion: %@\nID: %@\n%@: %@\n%@",
[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleName"],
[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"],
- [UIDevice currentDevice].uniqueIdentifier,
- [exception name],
+ [[MacAdress macAdress] sha1],
+ [exception name],
[exception reason],
[[StackTracer sharedInstance] printableTrace:stackTrace]];
[data writeToFile:errorReportPath atomically:YES encoding:NSUTF8StringEncoding error:nil];
@@ -0,0 +1,16 @@
+//
+// MacAdress.h
+// VRM News
+//
+// Created by Carl Jahn on 21.11.11.
+// Copyright (c) 2011 NIDAG. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+
+@interface MacAdress : NSObject
+
++ (NSString *)macAdress;
+
+
+@end
@@ -0,0 +1,84 @@
+//
+// MacAdress.m
+// VRM News
+//
+// Created by Carl Jahn on 21.11.11.
+// Copyright (c) 2011 NIDAG. All rights reserved.
+//
+
+#import "MacAdress.h"
+
+#include <sys/socket.h>
+#include <sys/sysctl.h>
+#include <net/if.h>
+#include <net/if_dl.h>
+
+
+
+@implementation MacAdress
+
+
+
++ (NSString *)macAdress
+{
+
+ int mgmtInfoBase[6];
+ char *msgBuffer = NULL;
+ NSString *errorFlag = NULL;
+ size_t length;
+
+ // Setup the management Information Base (mib)
+ mgmtInfoBase[0] = CTL_NET; // Request network subsystem
+ mgmtInfoBase[1] = AF_ROUTE; // Routing table info
+ mgmtInfoBase[2] = 0;
+ mgmtInfoBase[3] = AF_LINK; // Request link layer information
+ mgmtInfoBase[4] = NET_RT_IFLIST; // Request all configured interfaces
+
+ // With all configured interfaces requested, get handle index
+ if ((mgmtInfoBase[5] = if_nametoindex("en0")) == 0)
+ errorFlag = @"if_nametoindex failure";
+ // Get the size of the data available (store in len)
+ else if (sysctl(mgmtInfoBase, 6, NULL, &length, NULL, 0) < 0)
+ errorFlag = @"sysctl mgmtInfoBase failure";
+ // Alloc memory based on above call
+ else if ((msgBuffer = malloc(length)) == NULL)
+ errorFlag = @"buffer allocation failure";
+ // Get system information, store in buffer
+ else if (sysctl(mgmtInfoBase, 6, msgBuffer, &length, NULL, 0) < 0)
+ {
+ free(msgBuffer);
+ errorFlag = @"sysctl msgBuffer failure";
+ }
+ else
+ {
+ // Map msgbuffer to interface message structure
+ struct if_msghdr *interfaceMsgStruct = (struct if_msghdr *) msgBuffer;
+
+ // Map to link-level socket structure
+ struct sockaddr_dl *socketStruct = (struct sockaddr_dl *) (interfaceMsgStruct + 1);
+
+ // Copy link layer address data in socket structure to an array
+ unsigned char macAddress[6];
+ memcpy(&macAddress, socketStruct->sdl_data + socketStruct->sdl_nlen, 6);
+
+ // Read from char array into a string object, into traditional Mac address format
+ NSString *macAddressString = [NSString stringWithFormat:@"%02X:%02X:%02X:%02X:%02X:%02X",
+ macAddress[0], macAddress[1], macAddress[2], macAddress[3], macAddress[4], macAddress[5]];
+ NSLog(@"Mac Address: %@", macAddressString);
+
+ // Release the buffer memory
+ free(msgBuffer);
+
+ return macAddressString;
+ }
+
+ // Error...
+ NSLog(@"Error: %@", errorFlag);
+
+ return errorFlag;
+
+}
+
+
+
+@end
@@ -0,0 +1,20 @@
+//
+// NSString+SHA.h
+// CrashManager
+//
+// Created by Carl Jahn on 03.04.12.
+// Copyright (c) 2012 NIDAG. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+
+@interface NSString (SHA)
+
+- (NSString *)sha1;
+- (NSString *)sha224;
+- (NSString *)sha256;
+- (NSString *)sha384;
+- (NSString *)sha512;
+
+
+@end
@@ -0,0 +1,126 @@
+//
+// NSString+SHA.m
+// CrashManager
+//
+// Created by Carl Jahn on 03.04.12.
+// Copyright (c) 2012 NIDAG. All rights reserved.
+//
+
+#import "NSString+SHA.h"
+#import <CommonCrypto/CommonDigest.h>
+
+@implementation NSString (SHA)
+
+- (NSString *)sha1 {
+ const char *cStr = [self UTF8String];
+ unsigned char result[CC_SHA1_DIGEST_LENGTH];
+ CC_SHA1(cStr, strlen(cStr), result);
+ NSString *s = [NSString stringWithFormat:
+ @"%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X",
+ result[0], result[1], result[2], result[3], result[4],
+ result[5], result[6], result[7],
+ result[8], result[9], result[10], result[11], result[12],
+ result[13], result[14], result[15],
+ result[16], result[17], result[18], result[19]
+ ];
+
+ return [s lowercaseString];
+}
+
+- (NSString *)sha224 {
+ const char *cStr = [self UTF8String];
+ unsigned char result[CC_SHA224_DIGEST_LENGTH];
+
+ CC_SHA224(cStr, strlen(cStr), result);
+ NSString *s = [NSString stringWithFormat:
+ @"%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X",
+ result[0], result[1], result[2], result[3], result[4],
+ result[5], result[6], result[7],
+ result[8], result[9], result[10], result[11], result[12],
+ result[13], result[14], result[15],
+ result[16], result[17], result[18], result[19], result[20],
+ result[21], result[22], result[23], result[24], result[25],
+ result[26], result[27]
+ ];
+
+
+
+ return [s lowercaseString];
+}
+
+- (NSString *)sha256 {
+ const char *cStr = [self UTF8String];
+ unsigned char result[CC_SHA256_DIGEST_LENGTH];
+
+ CC_SHA256(cStr, strlen(cStr), result);
+ NSString *s = [NSString stringWithFormat:
+ @"%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X",
+ result[0], result[1], result[2], result[3], result[4],
+ result[5], result[6], result[7],
+ result[8], result[9], result[10], result[11], result[12],
+ result[13], result[14], result[15],
+ result[16], result[17], result[18], result[19], result[20],
+ result[21], result[22], result[23], result[24], result[25],
+ result[26], result[27], result[28], result[29], result[30],
+ result[31]
+ ];
+
+
+
+ return [s lowercaseString];
+}
+- (NSString *)sha384 {
+ const char *cStr = [self UTF8String];
+ unsigned char result[CC_SHA384_DIGEST_LENGTH];
+
+ CC_SHA384(cStr, strlen(cStr), result);
+ NSString *s = [NSString stringWithFormat:
+ @"%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X",
+ result[0], result[1], result[2], result[3], result[4],
+ result[5], result[6], result[7],
+ result[8], result[9], result[10], result[11], result[12],
+ result[13], result[14], result[15],
+ result[16], result[17], result[18], result[19], result[20],
+ result[21], result[22], result[23], result[24], result[25],
+ result[26], result[27], result[28], result[29], result[30],
+ result[31], result[32], result[33], result[34], result[35],
+ result[36], result[37], result[38], result[39], result[40],
+ result[41], result[42], result[43], result[44], result[45],
+ result[46], result[47]
+ ];
+
+
+
+ return [s lowercaseString];
+}
+
+- (NSString *)sha512 {
+ const char *cStr = [self UTF8String];
+ unsigned char result[CC_SHA512_DIGEST_LENGTH];
+
+ CC_SHA512(cStr, strlen(cStr), result);
+ NSString *s = [NSString stringWithFormat:
+ @"%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X",
+ result[0], result[1], result[2], result[3], result[4],
+ result[5], result[6], result[7],
+ result[8], result[9], result[10], result[11], result[12],
+ result[13], result[14], result[15],
+ result[16], result[17], result[18], result[19], result[20],
+ result[21], result[22], result[23], result[24], result[25],
+ result[26], result[27], result[28], result[29], result[30],
+ result[31], result[32], result[33], result[34], result[35],
+ result[36], result[37], result[38], result[39], result[40],
+ result[41], result[42], result[43], result[44], result[45],
+ result[46], result[47], result[48], result[49], result[50],
+ result[51], result[52], result[53], result[54], result[55],
+ result[56], result[57], result[58], result[59], result[60],
+ result[61], result[62], result[63]
+ ];
+
+
+ return [s lowercaseString];
+
+}
+
+
+@end
@@ -138,7 +138,7 @@ static volatile __CLASSNAME__* _##__CLASSNAME__##_sharedInstance = nil; \
} \
} \
} \
- return _##__CLASSNAME__##_sharedInstance; \
+ return (__CLASSNAME__*) _##__CLASSNAME__##_sharedInstance; \
} \
\
+ (void)purgeSharedInstance \
@@ -183,7 +183,7 @@ static volatile __CLASSNAME__* _##__CLASSNAME__##_sharedInstance = nil; \
return [super retainCount]; \
} \
\
-- (void)release \
+- (oneway void)release \
{ \
NSAssert1(1==0, @"SynthesizeSingleton: %@ ERROR: -(void)release method did not get swizzled.", self); \
} \

0 comments on commit 557eff3

Please sign in to comment.