SecKeyGetBlockSize(persistPeer);导致访问不良

时间:2014-04-15 18:31:53

标签: ios exc-bad-access

SecKeyGetBlockSize(persistPeer);导致访问不良。我之前没有使用过这个,所以我不确定会导致这个错误。

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

0 个答案:

没有答案