matthiasplappert / Secure-NSUserDefaults

User defaults that cannot be modified or shared between devices.
203 stars 14 forks source link

Upgraded Security from MD5 to SHA256 - Archiver fixes for iOS 12 + #6

Open danoli3 opened 2 years ago

danoli3 commented 2 years ago

CC_MD5(cStr, (CC_LONG)[data length], digest); 'CC_MD5' is deprecated: first deprecated in iOS 13.0 - This function is cryptographically broken and should not be used in security contexts. Clients should migrate to SHA256 (or stronger)

Upgraded from CC_MD5 to CC_SHA256 and optimised code return. Old code commented out

 const char* utf8chars = [data bytes];
        unsigned char result[CC_SHA256_DIGEST_LENGTH];
        CC_SHA256(utf8chars, (CC_LONG)strlen(utf8chars), result);

NSMutableData *archivedData = [[NSKeyedArchiver archivedDataWithRootObject:object] mutableCopy]; 'archivedDataWithRootObject:' is deprecated: first deprecated in iOS 12.0 - Use +archivedDataWithRootObject:requiringSecureCoding:error: instead

Upgraded, with requiringSecureCoding NSMutableData *archivedData = [[NSKeyedArchiver archivedDataWithRootObject:object requiringSecureCoding:YES error:&error] mutableCopy];