Keychain private key signing error

When performing biometric authentication, some times we are getting these kind of errors when i try to sign the data with private key that we get it from keychain. I was searching for document related to this but i could not.Can someone help me on this?

Error message and error code

Remote alert invalidated -4 UI canceled by system -4 unable to sign digest -3 Canceled by another authentication -4 Caller is not running foreground -1004 Caller moved to background -4 No identities are enrolled  -7 User has denied the use of biometry for this app -1018 Application retry limit exceeded -1 Face ID interlocked -8 Biometry lost -4 match failed -1

// To get signed data using private key SecKeyRef privateKeyReferences = [self getPrivateKey:keyNames]; if(!privateKeyReferences) { NSLog(@"Error retrieving private key"); return nil; } NSError *error; NSData *signature = CFBridgingRelease(SecKeyCreateSignature(privateKeyReferences, kSecKeyAlgorithmECDSASignatureMessageX962SHA256, (CFDataRef) data, (void *)&error)); if(!signature) { NSString *errorMessage = [NSString stringWithFormat:@"Error signing data %@.", error]; NSLog(@"%@", errorMessage); return nil; } return signature;

OK, let’s start with same basics. What platform is this on?

Also, can you repost your code snippet and format it as a code block. It’s impossible to read as it currently is. See Quinn’s Top Ten DevForums Tips for advice on how to craft a more actionable post.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

I am facing the issue not specify to any iOS version but could see from iOS 13 . This is the minimum OS version that we have for the app.

These are some different errors that we got for few users during signing the data using private key .

Remote alert invalidated	-4
UI canceled by system	-4
unable to sign digest	-3
Canceled by another authentication	-4
Caller is not running foreground	-1004
Caller moved to background	-4
No identities are enrolled 	-7
User has denied the use of biometry for this app	-1018
Application retry limit exceeded	-1
Face ID interlocked	-8
Biometry lost	-4
match failed	-1

// To get signed data using private key

- (NSData *)getSignatureUsingPrivateKey:(NSString *)keyNames
                    data:(NSData *)data {
  SecKeyRef privateKeyReferences = [self getPrivateKeyRef:keyNames];
  if(!privateKeyReferences) {
    NSLog(@"Error retrieving private key");
    return nil;
  }
  NSError *error;
  NSData *signature = CFBridgingRelease(SecKeyCreateSignature(privateKeyReferences, kSecKeyAlgorithmECDSASignatureMessageX962SHA256, (CFDataRef) data, (void *)&error));
  if(!signature) {
    NSString *errorMessage = [NSString stringWithFormat:@"Error during signing %@.", error];
    NSLog(@"%@", errorMessage);
    return nil;
  }
  return signature;
}
Keychain private key signing error
 
 
Q