I use digital certificates to sign data files in my application. The following code snippet does not work when the call SecKeyRawVerifyreturns with -9809. This works on iPhone. I canβt even determine exactly what this error code means.
The preliminary security system calls for loading and creating SecTrustRef, from which the public key is obtained, it seems fine - no errors. The only small problem is that the call SecTrustEvaluatereturns kSecTrustResultUnspecified, but I assume that this is because the policy you are using is the template returned by the call SecPolicyCreateBasicX509.
Any help or understanding would be greatly appreciated.
thank
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]
);
drew source
share