SecKeyRawVerify and OSError -9809

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]
                          );
+5
source share
2

, . SecKeyRawVerify , . - , , , , -9809.

CC_SHA1((const void *)[data bytes], [data length], (unsigned char *)hash);

status = SecKeyRawVerify (keyRef,
                          kSecPaddingPKCS1SHA1,
                          hash,
                          20,
                          (const uint8_t *)[signature bytes],
                          SecKeyGetBlockSize(keyRef)
                          );
+1

( ) /System/Library/Frameworks/Security.framework/Headers/SecureTransport.h errSSLCrypto. " ", .

: kSecTrustResultUnspecified , . ?

+3

All Articles