When calling SecKeyIsAlgorithmSupported (https://developer.apple.com/documentation/security/1644057-seckeyisalgorithmsupported?language=objc) with private key from secure enclave and parameters for algorithms and operations commonly not used for private keys causes crash on macOS. Same call with same parameters work on iOS.
I'm unit testing a utility with private key stored in secure enclave. When I call SecKeyIsAlgorithmSupported(:::) as below causes crash on macOS but not on iOS
SecKeyIsAlgorithmSupported(self.eccPrivateKey, kSecKeyOperationTypeVerify, kSecKeyAlgorithmECDSASignatureDigestX962SHA256); //where self.eccPrivateKey is key in secure enclave on my mac book pro.
Also crashes for these parameters :
SecKeyIsAlgorithmSupported(self.eccPrivateKey, kSecKeyOperationTypeEncrypt, kSecKeyAlgorithmECIESEncryptionCofactorX963SHA256AESGCM);
Crash
`2021-09-29 22:36:28.949061-0700 MSIDTestHostAppMac[98643:1430360] *** Assertion failure in CFTypeRef TKTokenCopyOperationResult(TKTokenRef, CFDataRef, CFIndex, CFArrayRef, CFIndex, CFTypeRef, CFTypeRef, CFErrorRef *)(), ctkclient.m:519
2021-09-29 22:36:28.955505-0700 MSIDTestHostAppMac[98643:1430360] [General] An uncaught exception was raised
2021-09-29 22:36:28.955662-0700 MSIDTestHostAppMac[98643:1430360] [General] Invalid keyOperation 1 requested
2021-09-29 22:36:28.955802-0700 MSIDTestHostAppMac[98643:1430360] [General] (
0 CoreFoundation 0x00007fff206641db __exceptionPreprocess + 242
1 libobjc.A.dylib 0x00007fff2039dd92 objc_exception_throw + 48
2 CoreFoundation 0x00007fff2068d352 +[NSException raise:format:arguments:] + 88
3 Foundation 0x00007fff214892ec -[NSAssertionHandler handleFailureInFunction:file:lineNumber:description:] + 166
4 Security 0x00007fff223fc7bd TKTokenCopyOperationResult + 381
5 Security 0x00007fff2245abcf __SecCTKKeyCopyOperationResult_block_invoke + 453
6 Security 0x00007fff224522b8 SecItemAuthDo + 103
7 Security 0x00007fff2245a6d2 SecCTKKeyCopyOperationResult + 480
8 Security 0x00007fff2245f13a SecKeyRunAlgorithmAndCopyResult + 251
9 Security 0x00007fff22460db5 SecKeyIsAlgorithmSupported + 100
10 IdentityCoreTests 0x0000000110130445 +[MSIDKeyOperationUtil isOperationSupportedByKey:algorithm:key:context:error:] + 325
11 IdentityCoreTests 0x000000010fe3cde7 -[MSIDKeyOperationUtilTest testIfOperationIsSupportedByKey] + 7287
12 CoreFoundation 0x00007fff205cd6fc __invoking___ + 140
13 CoreFoundation 0x00007fff205cd59d -[NSInvocation invoke] + 305
14 XCTest 0x000000010edc61f7 +[XCTFailableInvocation invokeStandardConventionInvocation:completion:] + 64
15 XCTest 0x000000010edc61b5 __65+[XCTFailableInvocation invokeInvocation:lastObservedErrorIssue:]_block_invoke_3 + 23
16 XCTest 0x000000010edc5c5b __81+[XCTFailableInvocation invokeWithAsynchronousWait:lastObservedErrorIssue:block:]_block_invoke.11 + 71
17 XCTest 0x000000010ee8ab0d +[XCTSwiftErrorObservation observeErrorsInBlock:] + 113`
The same calls do not crash on iOS and correctly return NO
Have opened a feedback : 9665871 as well