|
14 | 14 |
|
15 | 15 | #import "Crashlytics/Shared/FIRCLSMachO/FIRCLSMachOBinary.h" |
16 | 16 |
|
17 | | -#import "Crashlytics/Shared/FIRCLSMachO/FIRCLSMachOSlice.h" |
18 | | - |
19 | 17 | #import <CommonCrypto/CommonHMAC.h> |
| 18 | +#import "Crashlytics/Crashlytics/Helpers/FIRCLSUtility.h" |
| 19 | +#import "Crashlytics/Shared/FIRCLSByteUtility.h" |
| 20 | +#import "Crashlytics/Shared/FIRCLSMachO/FIRCLSMachOSlice.h" |
20 | 21 |
|
21 | | -static void FIRCLSSafeHexToString(const uint8_t* value, size_t length, char* outputBuffer); |
22 | | -static NSString* FIRCLSNSDataToNSString(NSData* data); |
23 | | -static NSString* FIRCLSHashBytes(const void* bytes, size_t length); |
24 | 22 | static NSString* FIRCLSHashNSString(NSString* value); |
25 | 23 |
|
26 | 24 | @interface FIRCLSMachOBinary () |
@@ -116,58 +114,6 @@ + (NSString*)hashNSString:(NSString*)value { |
116 | 114 |
|
117 | 115 | @end |
118 | 116 |
|
119 | | -// TODO: Functions copied from the SDK. We should figure out a way to share this. |
120 | | -static void FIRCLSSafeHexToString(const uint8_t* value, size_t length, char* outputBuffer) { |
121 | | - const char hex[] = "0123456789abcdef"; |
122 | | - |
123 | | - if (!value) { |
124 | | - outputBuffer[0] = '\0'; |
125 | | - return; |
126 | | - } |
127 | | - |
128 | | - for (size_t i = 0; i < length; ++i) { |
129 | | - unsigned char c = value[i]; |
130 | | - outputBuffer[i * 2] = hex[c >> 4]; |
131 | | - outputBuffer[i * 2 + 1] = hex[c & 0x0F]; |
132 | | - } |
133 | | - |
134 | | - outputBuffer[length * 2] = '\0'; // null terminate |
135 | | -} |
136 | | - |
137 | | -static NSString* FIRCLSNSDataToNSString(NSData* data) { |
138 | | - NSString* string; |
139 | | - char* buffer; |
140 | | - size_t size; |
141 | | - NSUInteger length; |
142 | | - |
143 | | - // we need 2 hex char for every byte of data, plus one more spot for a |
144 | | - // null terminator |
145 | | - length = [data length]; |
146 | | - size = (length * 2) + 1; |
147 | | - buffer = calloc(1, sizeof(char) * size); |
148 | | - |
149 | | - if (!buffer) { |
150 | | - return nil; |
151 | | - } |
152 | | - |
153 | | - FIRCLSSafeHexToString([data bytes], length, buffer); |
154 | | - |
155 | | - string = [NSString stringWithUTF8String:buffer]; |
156 | | - |
157 | | - free(buffer); |
158 | | - |
159 | | - return string; |
160 | | -} |
161 | | - |
162 | | -static NSString* FIRCLSHashBytes(const void* bytes, size_t length) { |
163 | | - uint8_t digest[CC_SHA1_DIGEST_LENGTH] = {0}; |
164 | | - CC_SHA1(bytes, (CC_LONG)length, digest); |
165 | | - |
166 | | - NSData* result = [NSData dataWithBytes:digest length:CC_SHA1_DIGEST_LENGTH]; |
167 | | - |
168 | | - return FIRCLSNSDataToNSString(result); |
169 | | -} |
170 | | - |
171 | 117 | static NSString* FIRCLSHashNSString(NSString* value) { |
172 | 118 | const char* s = [value cStringUsingEncoding:NSUTF8StringEncoding]; |
173 | 119 |
|
|
0 commit comments