SecKeyGetBlockSize (persistPeer); causes poor access

SecKeyGetBlockSize (persistPeer); causes poor access. I have not worked with this before, so I'm not sure what might cause this error.

NSData* peerTag = [@"Test PublicKey" dataUsingEncoding:NSUTF8StringEncoding];

NSDictionary * peerPublicKeyAttr = [NSDictionary dictionaryWithObjectsAndKeys:
 (__bridge id)kSecClassKey, kSecClass,
 (__bridge id)kSecAttrKeyTypeRSA, kSecAttrKeyType,
 (__bridge id)kSecAttrKeyClassPublic, kSecAttrKeyClass,
 peerTag, kSecAttrApplicationTag,
 testPubKey, kSecValueData,
 kCFBooleanTrue, kSecReturnPersistentRef,
                                    nil];

OSStatus sanityCheck = noErr;
sanityCheck = SecItemDelete((__bridge CFDictionaryRef) peerPublicKeyAttr);
SecKeyRef persistPeer = NULL;
sanityCheck = SecItemAdd((__bridge CFDictionaryRef)peerPublicKeyAttr, (CFTypeRef *)&persistPeer);


NSData* passwordData = [@"password" dataUsingEncoding:NSUTF8StringEncoding];
NSData* encryptedPass = [[Methods sharedCenter]encrypt:passwordData usingKey:persistPeer];

size_t cipherBufferSize = SecKeyGetBlockSize(persistPeer);
+4
source share

Source: https://habr.com/ru/post/1536647/


All Articles