1
我試圖將密鑰添加到密鑰鏈中,然後使用密鑰鏈對數據進行加密。SecKeyGetBlockSize()上的EXC_BAD_ACCESS代碼= 1
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);
SecKeyGetBlockSize(key);
導致EXC_BAD_ACCESS碼= 1。
我還沒有用過這個,所以我不知道什麼會導致這個錯誤。我在這裏做錯了什麼?
哦抱歉複製粘貼錯誤。但我認爲我已經解決了這個問題,今天晚些時候我必須對它進行測試。 –
你有這個工作嗎?你的代碼中有什麼問題? – Shadowman