Secure-NSUserDefaults icon indicating copy to clipboard operation
Secure-NSUserDefaults copied to clipboard

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

Open danoli3 opened this issue 3 years ago • 0 comments

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];

danoli3 avatar Aug 25 '22 14:08 danoli3