将SecKeyRef(公钥)转换为NSString

时间:2012-04-18 07:21:54

标签: iphone ios security cryptography

我正在使用Saving SecKeyRef device generated public/private key pair on disk这个例子,但是我一直在sanityCheck中得到-25300。有人可以告诉我出了什么问题或这个错误是什么意思 ? 唔谢谢

SecKeyRef publicKey;     SecKeyRef privateKey;

CFDictionaryRef keyDefinitions;
CFTypeRef keys[2];
CFTypeRef values[2];

keys[0] = kSecAttrKeyType;
values[0] = kSecAttrKeyTypeRSA;

keys[1] = kSecAttrKeySizeInBits;
int iByteSize = 2048;
values[1] = CFNumberCreate(NULL, kCFNumberIntType, &iByteSize);

keyDefinitions = CFDictionaryCreate(NULL, keys, values, sizeof(keys) / sizeof(keys[0]), NULL,NULL );

OSStatus status = SecKeyGeneratePair(keyDefinitions,&publicKey, &privateKey);
status = SecItemCopyMatching((CFDictionaryRef)publicKey, (CFTypeRef *)&publicKeyBits);//<--where error occur.

0 个答案:

没有答案