SecKeyRawVerify and OSError -9809

后端 未结 2 1309
一个人的身影
一个人的身影 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)
                              );
    

提交回复
热议问题