SecKeyRawVerify and OSError -9809

后端 未结 2 1290
一个人的身影
一个人的身影 2020-12-19 07:21

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

相关标签:
2条回答
  • 2020-12-19 07:47

    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)
                              );
    
    0 讨论(0)
  • 2020-12-19 07:58

    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?

    0 讨论(0)
提交回复
热议问题