【发布时间】:2012-05-25 15:17:03
【问题描述】:
我正在使用数字证书对我的应用程序中的数据文件进行签名。当对SecKeyRawVerify 的调用返回-9809 时,下面的代码片段将失败。这是在 iPhone 上运行的。我什至无法准确识别此错误代码的含义
先前的安全框架调用来加载和创建从中获取公钥的 SecTrustRef 似乎很好 - 没有错误。唯一的小问题是对SecTrustEvaluate 的调用返回kSecTrustResultUnspecified,但我认为这是因为我使用的策略是SecPolicyCreateBasicX509 调用返回的样板文件。
非常感谢任何帮助或见解。
谢谢
SecKeyRef keyRef = SecTrustCopyPublicKey (trustRef);
fileURL = [[NSBundle mainBundle] URLForResource:@"data" withExtension:@"txt"];
NSData *data = [NSData dataWithContentsOfURL:fileURL];
fileURL = [[NSBundle mainBundle] URLForResource:@"data" withExtension:@"sgn"];
NSData *signature = [NSData dataWithContentsOfURL:fileURL];
NSLog(@"Hash block size = %zu",SecKeyGetBlockSize(keyRef));
status = SecKeyRawVerify (keyRef,
kSecPaddingPKCS1SHA1,
(const uint8_t *)[data bytes],
(size_t)[data length],
(const uint8_t *)[signature bytes],
(size_t)[signature length]
);
【问题讨论】:
标签: ios objective-c security-framework