I am using digital certificates to sign data files in my App. The code fragment below fails when the call to SecKeyRawVerify
returns with -9809. This is runni
I've discovered what's happening. The SecKeyRawVerify
call takes the digest of your data as the input, not the data itself. The code below works - and incidentally, if the signature is not verified because the underlying data has changed, then the status return is -9809.
Thanks
CC_SHA1((const void *)[data bytes], [data length], (unsigned char *)hash);
status = SecKeyRawVerify (keyRef,
kSecPaddingPKCS1SHA1,
hash,
20,
(const uint8_t *)[signature bytes],
SecKeyGetBlockSize(keyRef)
);
That error is defined (along with other related ones) in /System/Library/Frameworks/Security.framework/Headers/SecureTransport.h
as errSSLCrypto
. The comment there calls it "underlying cryptographic error", which is not a particularly descriptive description.
One thought: kSecTrustResultUnspecified
means that the trust level is equal to the default system policy. Are all the certificates in the chain trusted?