Prioritize user privacy and data security in your app. Discuss best practices for data handling, user consent, and security measures to protect user information.

All subtopics
Posts under Privacy & Security topic

Post

Replies

Boosts

Views

Activity

Unknown CryptoTokenKit error encountered during SecKeyCreateSignature() with Secure Enclave private key
Hello. We have encountered a failure that we haven't seen before regarding use of Secure Enclave private keys and creating cryptographic signatures. We've used this code on thousands of iOS devices (from iOS 11.2 to iOS 14.6) without issue, and recently saw an error that we were not able to find documentation for. We are hoping to find out more details about the failure so that we can avoid it in the future. Steps to Reproduce On an iPhone 11 Pro running iOS 14.4.2, generate a private key in the Secure Enclave via SecKeyCreateRandomKey() with the following parameters. [ kSecAttrTokenID: kSecAttrTokenIDSecureEnclave, kSecAttrKeyType: kSecAttrKeyTypeECSECPrimeRandom, kSecAttrKeySizeInBits: 256, kSecPrivateKeyAttrs: [ kSecAttrAccessControl: SecAccessControlCreateWithFlags( kCFAllocatorDefault, kSecAttrAccessibleWhenUnlockedThisDeviceOnly, [.touchIDAny, .privateKeyUsage], nil )!, kSecAttrIsPermanent: true ], kSecAttrApplicationLabel: "unique label" // a customer identifier ] (Note that app is using deployment target of iOS 11.2, thus the use of .touchIDAny). Fetch the aformentioned key with SecItemCopyMatching(…) with the following parameters: [ kSecClass: kSecClassKey, kSecAttrKeyType: kSecAttrKeyTypeECSECPrimeRandom, kSecAttrKeySizeInBits: 256, kSecReturnRef: true, kSecUseOperationPrompt: "Verify your identity", kSecAttrApplicationLabel: "unique label" // a customer identifier ] Create a signature of a CFData by with the key from step #2: var error: Unmanaged<CFError>? let signature = SecKeyCreateSignature(key, .ecdsaSignatureMessageX962SHA256, data, &error) Expected Result The customer is prompted for Face ID, passes, and SecKeyCreateSignature(…) successfully returns a signature. Note that this method successfully works for us on thousands of devices, from iOS 11.2 to iOS 14.6. Actual Result In a rare isolated case, we are seeing the SecItemCopyMatching(…) succeed and then the SecKeyCreateSignature(…) call fails to display the Face ID prompt. Instead, SecKeyCreateSignature(…) immediately fails and populates an error with the following information: domain: CryptoTokenKit code: -3 localizedDescription: The operation couldn’t be completed. (CryptoTokenKit error -3.) description: "<sepk:p256 kid=1214c04d05261ee3>: unable to sign digest" UserInfo={NSDebugDescription=<sepk:p256 kid=1214c04d05261ee3>: unable to sign digest, AKSError=-536362999} On this particular iPhone 11 Pro device, the customer did not have any issues with this code around 6 months prior to the failure. The customer has more recently encountered the failure, and we have confirmed the device fail to create signatures 100% of the time with the above error. We have asked the customer to reboot the device to no avail, and we have confirmed that Face ID does indeed successfully work on the device's lock screen. The failure still continues. Additional Notes We are not able to find any information about this specific failure from the documentation or additional research on the web. We were able to deduce that that CryptoTokenKit error -3 maps to TKErrorCodeCorruptedData. In the documentation of TKErrorCodeCorruptedData, it is unclear if the corruption is referring to the private key or or to the dataToSign parameter of SecKeyCreateSignature(). Do you have any insight into why/when this error is returned, and how might we avoid it in the future? Thank you.
15
2
4.7k
Jan ’23
Unable to complete associated domain check
Hi, When attempting to perform a credential registration, I constantly get the error Application with identifier <...> is not associated with domain <domain> I've verified the following: The file is present on the required URL path https://123.com/.well-known/apple-app-site-association { "webcredentials": { "apps": [ "<PREFIX>.bundleID" ] } } Added the Capabilities to my domain Confirmed that the CA is valid and there are no redirects. Am I missing something? My device is able to properly access the file
3
0
4.4k
Feb ’24
Are App Attest or DeviceCheck supported on any Macs?
In the WWDC 2021 session Mitigate fraud with App Attest and DeviceCheck it is said that: App Attest is supported on devices that have a Secure Enclave, but there are cases, such as app extensions, where isSupported will still return false. The documentation shows that the following Macs have a Secure Enclave: MacBook Pro computers with Touch Bar (2016 and 2017) that contain the Apple T1 Chip Intel-based Mac computers that contain the Apple T2 Security Chip Mac computers with Apple silicon I'm using a 2018 15" MacBook Pro containing a T2 Security Chip for testing, however, DCAppAttestService.shared.isSupported always returns false in native macOS or Catalyst apps. DCDevice.current.isSupported also returns false. The documentation for DCAppAttestService shows availability on "macOS 11.0+" and "Mac Catalyst 14.0+". It appears to have been added in the macOS 11.3 SDK included in Xcode 12.5. DCDevice shows availability on "macOS 10.15+" and "Mac Catalyst 13.0+". Although both APIs are available on the listed OSes, I only ever see isSupported == false. Are App Attest or DeviceCheck functional on any Macs? If so: Are there more specific Macs that support the feature (e.g., Apple Silicon Macs only)? Are there any additional steps that need to be taken to use them (e.g., changes to entitlements, provisioning profiles or distribution through the Mac App Store)? In native macOS apps, it doesn't actually appear to be possible to add the App Attest capability in Xcode under "Signing & Capabilities". If not, I think it would be good to update the documentation with this limitation since I'd expect them to work based on the availability being "macOS 10.15+" or "macOS 11.0+" for DeviceCheck and App Attest, respectively. I imagine most others would make the same assumptions.
5
0
4.0k
Jun ’26
RSA decryption error: javax.crypto.BadPaddingException: Decryption error
We are using RSA (Public - Private key) encryption / decryption with padding #PKCS1, and it is working fine when we are running the app in "Debug" mode (Xcode 12.4) or generating the Appstore build from Xcode with 11 series. But when we are generating the Testflight/ Appstore build from Xcode 12.4 (or any other Xcode with 12 series), Server is unable to decrypt the messages and throwing "RSA decryption error: javax.crypto.BadPaddingException: Decryption error". Is there any changes in difference b/w Debug and Release mode, or this is an issue with Xcode 12.4? Any help is welcome :)
5
0
3.3k
Jan ’22
Creating new keychain for mac os app
I need to create a new keychain for my mac os app. Currently there is a function SecKeychainCreate in Appledocumentation. But this function will be deprecated in mac OS 12.0. Is there another way to create keychain using swift (without using terminal commands)? Or will mac provide new function for this in update? Anybody knows?
7
0
3.7k
Jan ’23
SecItemAdd returns errSecAuthFailed
Hello, I'm experiencing a weird issue on the iOS 15 simulator (unfortunately I don't have a device with 15 installed yet). The issue I see is that the call to SecItemAdd returns OSStatus -25293 (errSecAuthFailed). The attributes dictionary passed looks like this: var query: [String : Any] = [ kSecClass as String: kSecClassGenericPassword, kSecAttrAccount as String: key, kSecAttrService as String: service, kSecAttrAccessControl as String: getSecAccessControl(), kSecUseAuthenticationContext as String: context, kSecValueData as String: data         ] the getSecAccessControl returns a SecAccessControl created like this:         access = SecAccessControlCreateWithFlags(nil,   kSecAttrAccessibleWhenUnlockedThisDeviceOnly,   .userPresence,   &amp;error) if I do not add the kSecAttrAccessControl item I don't see any error. The same code works as expected on the simulator with iOS 14. Looking at the documentation didn't help, anybody has hints about this? Maybe it's bug I'm not aware of? Thank you in advance
19
2
11k
Jun ’22
Swift AES CBC 256 Encryption With Static 32bit Key and 32bit IV
We have the below Implementation in Android and the same has to be integrated into Swift. Key :- "d95acd54b4a821ff32c52825q931c194" IV :- "687b9509c25a34b8ad076346s8353d67" Here Both the Key and IV are 32 bits and below is the android code. public class AESEncryption { private static final String key = "d95acd54c6a821ff32c52825b931c194"; private static final String initVector = "687b9509c25a14b8ad076346d8353d67"; static byte[] bte = hexToBytes(initVector); public static String encrypt(String strToEncrypt) { try { CommonCode.showLog("log", bte.toString()); IvParameterSpec iv = new IvParameterSpec(bte); SecretKeySpec skeySpec = new SecretKeySpec(key.getBytes(StandardCharsets.UTF_8), "AES"); Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5PADDING"); CommonCode.showLog("IV after logs", iv.toString()); cipher.init(Cipher.ENCRYPT_MODE, skeySpec, iv); byte[] encrypted = cipher.doFinal(strToEncrypt.getBytes()); if (Build.VERSION.SDK_INT &gt;= Build.VERSION_CODES.O) { return Base64.getEncoder().encodeToString(encrypted).trim(); } else { return android.util.Base64.encodeToString(encrypted, android.util.Base64.DEFAULT).trim(); } } catch (Exception e) { CommonCode.showLog("Error while encrypting: ", e.toString()); } return null; } public static String decrypt(String strToDecrypt) { try { IvParameterSpec iv = new IvParameterSpec(bte); SecretKeySpec skeySpec = new SecretKeySpec(key.getBytes(StandardCharsets.UTF_8), "AES"); Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5PADDING"); cipher.init(Cipher.DECRYPT_MODE, skeySpec, iv); if (android.os.Build.VERSION.SDK_INT &gt;= android.os.Build.VERSION_CODES.O) { return new String(cipher.doFinal(Base64.getDecoder().decode(strToDecrypt))); } else { return new String(cipher.doFinal(android.util.Base64.decode(strToDecrypt, android.util.Base64.DEFAULT))); } } catch (Exception e) { CommonCode.showLog("Error while decrypting: " , e.toString()); } return null; } } How can we mimic the above in Swift? Here in Android they are using static byte[] bte = hexToBytes(initVector); to convert the 32bit IV into 16 bit Bytes Array I Have Tried the same approach on Swift below are the code snippet [Contents.swift](https://developer.apple.com/forums/content/attachment/60fab4f2-1496-4003-9f37-c195de95e94a)
9
0
11k
Dec ’24
App crashes when trying to get signature using private key
Hi, for some of our users the app crashes when we try to get the EdDSA signature using the private key. We use the following method from CryptoKit in the Curve25519.Signing.PrivateKey extension: public func signature<D>(for data: D) throws -> Data where D : DataProtocol The data that we want to sign is a string that is converted using the algorithm SHA256 Our implementation looks something like this: func foo(text: String) throws -> String { var algorithm = SHA256() algorithm.update(data: text.data(using: .utf8)!) guard self.hasPrivateKey else { // Error handling } do { let signature = try self.privateKey.signature(for: algorithm.finalize()) // App crashes here if not using do-catch statement // signature will be used and transformed to return String... } catch { // Error handling } } I would appreciate any hints on how to solve or inspect this. Many thanks.
3
0
1.2k
Oct ’21
SFAuthorizationpluginview dismiss in 20 second.
I have created a custom username/password lock screen using SFAuthorizationPluginView. When lock the screen the view appears. The cursor start blinking in TextField. However, it always automatically dismiss in 20 second if ideal. I could see the Mechanism dealloc gets called and dismiss the view. Based on my investigation, I think the system kill the view in 20second, and there is no ways to increase that and keep the custom screen for more time. Any help will be appreciate.
3
0
1.8k
Sep ’23
some change on keychain in ios 15 beta
We found that the error code of the keychain was different in ios 14 and ios 15. When the bio-information registered by the user is changed, if secItemCopyMatching is called, erSecItemNotFound is received in ios 14, but erSecAuthFailed is received in ios 15. In this case, iOS 15 cannot distinguish whether authentication has failed or bio-information has changed. I want to know if this is a bug in os or if it will proceed like this in the future. If we continue to give this error code in the future, I hope there will be a guide on how to distinguish the two error codes from the developer's point of view.
3
0
654
Dec ’21
Touch ID / Face ID biometryCurrentSet never fails on iOS 15
I've got some admittedly old Objective-C code handling Keychain items protected by Touch ID / Face ID that uses the access control flag kSecAccessControlTouchIDCurrentSet, accessing the items would fail with errSecItemNotFound when the user adds or removes a finger/face from the device, however on iOS 15.0 this is not happening. It does work on iOS 14.6 still. My deployment target is still iOS 11.0 so I haven't moved to kSecAccessControlBiometryCurrentSet as the replacement for the now deprecated TouchID value - but the enum raw values are the same so I don't see how that could be the cause. I can't see what the new error code is, because I'm not using Xcode 13, but I'll try and get the DeviceSupport copied in (official support for this is please!) to help search: Swift touchIDCurrentSet biometryCurrentSet Objective-C kSecAccessControlTouchIDCurrentSet kSecAccessControlBiometryCurrentSet
2
0
2.9k
Sep ’21
Fatal Exception: NSInvalidArgumentException SecKeyGetAlgorithmId called with NULL SecKeyRef on ios 15 only
As usual crash is happening on newer version of iOS 15 Crash log Fatal Exception: NSInvalidArgumentException 0 CoreFoundation 0x1814dc05c __exceptionPreprocess 1 libobjc.A.dylib 0x1999f6f54 objc_exception_throw 2 CoreFoundation 0x181533190 __CFDictionaryCreateGeneric 3 Security 0x18a239674 SecKeyGetAlgorithmId 4 Security 0x18a2d53d0 SecKeyGetSignatureAlgorithmForPadding 5 Security 0x18a2d5328 SecKeyRawSign 6 App Name 0x100bc90f8 -[login privatekeytouch] + 1484 (CprLoginContrl.m:1484) 7 libdispatch.dylib 0x18114cc04 _dispatch_call_block_and_release 8 libdispatch.dylib 0x18114e950 _dispatch_client_callout 9 libdispatch.dylib 0x18115cd30 _dispatch_main_queue_callback_4CF 10 CoreFoundation 0x181494ce4 CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE 11 CoreFoundation 0x18144eebc __CFRunLoopRun 12 CoreFoundation 0x1814623c8 CFRunLoopRunSpecific 13 GraphicsServices 0x19cc7338c GSEventRunModal 14 UIKitCore 0x183e080bc -[UIApplication _run] 15 UIKitCore 0x183b85be8 UIApplicationMain 16 App Name 0x10079a7b8 main + 22 (main.m:22) 17 ??? 0x101639a24 (Missing) crashed during SecKeyRawSign, anything has changed on ios 15?
7
0
3.2k
Sep ’21
Unlock keychain on headless system does not work on BigSur
I am trying to setup a headless machine (no GUI session whatsoever, only SSH) to CI/CD My pre-build steps is to setup a keychain, but it looks like unlocking the keychain using just a SSH session is not working on macOS 11.6 ec2-user@ip-172-31-40-2 code % security create-keychain -p Passw0rd dev ec2-user@ip-172-31-40-2 code % security list-keychain -d user -s dev ec2-user@ip-172-31-40-2 code % security set-keychain-settings -t 0 dev security: SecKeychainSetSettings dev: User interaction is not allowed. ec2-user@ip-172-31-40-2 code % security unlock-keychain -p Passw0rd dev ec2-user@ip-172-31-40-2 code % security set-keychain-settings -t 0 dev security: SecKeychainSetSettings dev: User interaction is not allowed. ec2-user@ip-172-31-40-2 code % security import ~/AppleWWDRCA.cer -t cert -k dev -A 1 certificate imported. ec2-user@ip-172-31-40-2 code % security import ~/AppleWWDRCAG3.cer -t cert -k dev -A 1 certificate imported. ec2-user@ip-172-31-40-2 code % security import ~/AppleRoot.cer -t cert -k dev -A 1 certificate imported. ec2-user@ip-172-31-40-2 code % security import ~/DevAuthCA.cer -t cert -k dev -A 1 certificate imported. ec2-user@ip-172-31-40-2 code % security import ~/apple_dev_key.p12 -k dev -A # this is my private key + cert security: SecKeychainItemImport: User interaction is not allowed. ec2-user@ip-172-31-40-2 code % security unlock-keychain -p Passw0rd dev ec2-user@ip-172-31-40-2 code % security import ~/apple_dev_key.p12 -k dev -A security: SecKeychainItemImport: User interaction is not allowed. When doing the same from agri session, I can see that despite the unlock-keychain command, a GUI prompt is presented to the user to unlock the keychain.
2
0
5.7k
Sep ’21
iOS 15 with FaceID authentication error when resetting FaceID
We use biometricID (faceID/touchID) authentication to access to a secret stored in keychain. We create the access control object with the biometryCurrentSet option as shown to make sure if FaceID / TouchID changes the entry should be invalidated. let secAccessControlObj = SecAccessControlCreateWithFlags(nil, kSecAttrAccessibleWhenPasscodeSetThisDeviceOnly, .biometryCurrentSet, accessControlError) Below is the set and get query, Set Query: [String(kSecClass): kSecClassGenericPassword,         String(kSecAttrAccount): group as AnyObject,         String(kSecAttrService): service as AnyObject,         String(kSecUseAuthenticationUI) : kSecUseAuthenticationUIAllow as AnyObject,         String(kSecAttrAccessControl) : secAccessControlObj,         String(kSecValueData) : value as AnyObject,         String(kSecAttrCreationDate) : Date() as AnyObject] Get Query: [String(kSecClass): kSecClassGenericPassword,         String(kSecAttrAccount): group as AnyObject,         String(kSecAttrService): service as AnyObject,         String(kSecUseAuthenticationUI) : kSecUseAuthenticationUIAllow as AnyObject,         String(kSecAttrAccessControl) : secAccessControlObj,         String(kSecValueData) : value as AnyObject,         String(kSecAttrCreationDate) : Date() as AnyObject] Steps: Set the value in keychain using the set query above Reset the faceID Use the get query to get the value from keychain by authenticating against TouchID/ FaceID. Result: When we try to get the value from keychain using SecItemCopyMatching(query as CFDictionary, result) we get the error code errSecAuthFailed (-25293) on iOS 15. Analysis: Prior to this (iOS 14 and below) the error code would be errSecItemNotFound which makes more sense. This is an issue for iOS 15 only as we also get errSecAuthFailed when user backgrounds the app while authenticating with FaceID/TouchID. This creates a ambiguity for us. In our testing when we backgrounded the app while authentication is in progress, we found the actual call to SecItemCopyMatching(::) was made when app's state was actually active but when the call returned the state had become background and the error code was again errSecAuthFailed This seems to be a bug with iOS 15 as it creates a ambiguity for the caller. I think the error code returned after resetting faceID should still be errSecItemNotFound in which case we can know the secret is actually lost since FaceID is reset and can treat errSecAuthFailed as error where the secret is actually not lost but just that failed temporarily. Please let us know if we need to file a bug
2
0
3k
Feb ’22
Unknown CryptoTokenKit error encountered during SecKeyCreateSignature() with Secure Enclave private key
Hello. We have encountered a failure that we haven't seen before regarding use of Secure Enclave private keys and creating cryptographic signatures. We've used this code on thousands of iOS devices (from iOS 11.2 to iOS 14.6) without issue, and recently saw an error that we were not able to find documentation for. We are hoping to find out more details about the failure so that we can avoid it in the future. Steps to Reproduce On an iPhone 11 Pro running iOS 14.4.2, generate a private key in the Secure Enclave via SecKeyCreateRandomKey() with the following parameters. [ kSecAttrTokenID: kSecAttrTokenIDSecureEnclave, kSecAttrKeyType: kSecAttrKeyTypeECSECPrimeRandom, kSecAttrKeySizeInBits: 256, kSecPrivateKeyAttrs: [ kSecAttrAccessControl: SecAccessControlCreateWithFlags( kCFAllocatorDefault, kSecAttrAccessibleWhenUnlockedThisDeviceOnly, [.touchIDAny, .privateKeyUsage], nil )!, kSecAttrIsPermanent: true ], kSecAttrApplicationLabel: "unique label" // a customer identifier ] (Note that app is using deployment target of iOS 11.2, thus the use of .touchIDAny). Fetch the aformentioned key with SecItemCopyMatching(…) with the following parameters: [ kSecClass: kSecClassKey, kSecAttrKeyType: kSecAttrKeyTypeECSECPrimeRandom, kSecAttrKeySizeInBits: 256, kSecReturnRef: true, kSecUseOperationPrompt: "Verify your identity", kSecAttrApplicationLabel: "unique label" // a customer identifier ] Create a signature of a CFData by with the key from step #2: var error: Unmanaged&lt;CFError&gt;? let signature = SecKeyCreateSignature(key, .ecdsaSignatureMessageX962SHA256, data, &amp;error) Expected Result The customer is prompted for Face ID, passes, and SecKeyCreateSignature(…) successfully returns a signature. Note that this method successfully works for us on thousands of devices, from iOS 11.2 to iOS 14.6. Actual Result In a rare isolated case, we are seeing the SecItemCopyMatching(…) succeed and then the SecKeyCreateSignature(…) call fails to display the Face ID prompt. Instead, SecKeyCreateSignature(…) immediately fails and populates an error with the following information: domain: CryptoTokenKit code: -3 localizedDescription: The operation couldn’t be completed. (CryptoTokenKit error -3.) description: "&lt;sepk:p256 kid=1214c04d05261ee3&gt;: unable to sign digest" UserInfo={NSDebugDescription=&lt;sepk:p256 kid=1214c04d05261ee3&gt;: unable to sign digest, AKSError=-536362999} On this particular iPhone 11 Pro device, the customer did not have any issues with this code around 6 months prior to the failure. The customer has more recently encountered the failure, and we have confirmed the device fail to create signatures 100% of the time with the above error. We have asked the customer to reboot the device to no avail, and we have confirmed that Face ID does indeed successfully work on the device's lock screen. The failure still continues. Additional Notes We are not able to find any information about this specific failure from the documentation or additional research on the web. We were able to deduce that that CryptoTokenKit error -3 maps to TKErrorCodeCorruptedData. In the documentation of TKErrorCodeCorruptedData, it is unclear if the corruption is referring to the private key or or to the dataToSign parameter of SecKeyCreateSignature(). Do you have any insight into why/when this error is returned, and how might we avoid it in the future? Thank you.
Replies
15
Boosts
2
Views
4.7k
Activity
Jan ’23
Unable to complete associated domain check
Hi, When attempting to perform a credential registration, I constantly get the error Application with identifier <...> is not associated with domain <domain> I've verified the following: The file is present on the required URL path https://123.com/.well-known/apple-app-site-association { "webcredentials": { "apps": [ "<PREFIX>.bundleID" ] } } Added the Capabilities to my domain Confirmed that the CA is valid and there are no redirects. Am I missing something? My device is able to properly access the file
Replies
3
Boosts
0
Views
4.4k
Activity
Feb ’24
Are App Attest or DeviceCheck supported on any Macs?
In the WWDC 2021 session Mitigate fraud with App Attest and DeviceCheck it is said that: App Attest is supported on devices that have a Secure Enclave, but there are cases, such as app extensions, where isSupported will still return false. The documentation shows that the following Macs have a Secure Enclave: MacBook Pro computers with Touch Bar (2016 and 2017) that contain the Apple T1 Chip Intel-based Mac computers that contain the Apple T2 Security Chip Mac computers with Apple silicon I'm using a 2018 15" MacBook Pro containing a T2 Security Chip for testing, however, DCAppAttestService.shared.isSupported always returns false in native macOS or Catalyst apps. DCDevice.current.isSupported also returns false. The documentation for DCAppAttestService shows availability on "macOS 11.0+" and "Mac Catalyst 14.0+". It appears to have been added in the macOS 11.3 SDK included in Xcode 12.5. DCDevice shows availability on "macOS 10.15+" and "Mac Catalyst 13.0+". Although both APIs are available on the listed OSes, I only ever see isSupported == false. Are App Attest or DeviceCheck functional on any Macs? If so: Are there more specific Macs that support the feature (e.g., Apple Silicon Macs only)? Are there any additional steps that need to be taken to use them (e.g., changes to entitlements, provisioning profiles or distribution through the Mac App Store)? In native macOS apps, it doesn't actually appear to be possible to add the App Attest capability in Xcode under "Signing & Capabilities". If not, I think it would be good to update the documentation with this limitation since I'd expect them to work based on the availability being "macOS 10.15+" or "macOS 11.0+" for DeviceCheck and App Attest, respectively. I imagine most others would make the same assumptions.
Replies
5
Boosts
0
Views
4.0k
Activity
Jun ’26
Passkeys in icloud keychain require website to support webauthn
Does Passkeys in icloud keychain require website to support webauthn ? Also how is this different from the javascript based webauthn implementation ?
Replies
2
Boosts
0
Views
1.9k
Activity
Dec ’21
RSA decryption error: javax.crypto.BadPaddingException: Decryption error
We are using RSA (Public - Private key) encryption / decryption with padding #PKCS1, and it is working fine when we are running the app in "Debug" mode (Xcode 12.4) or generating the Appstore build from Xcode with 11 series. But when we are generating the Testflight/ Appstore build from Xcode 12.4 (or any other Xcode with 12 series), Server is unable to decrypt the messages and throwing "RSA decryption error: javax.crypto.BadPaddingException: Decryption error". Is there any changes in difference b/w Debug and Release mode, or this is an issue with Xcode 12.4? Any help is welcome :)
Replies
5
Boosts
0
Views
3.3k
Activity
Jan ’22
Radio App being rejected on privacy issue
Dear Developers, Our app is an FM radio app, we are requesting users to fill a registration form so that we can use that information to give a directional idea of which channel is being heard in which city of the country. IOS platform continues to reject our app, based on Privacy issues. Need your help to get this sorted
Replies
1
Boosts
0
Views
800
Activity
Mar ’22
如何申请 端点安全权利
我找不到申请端点安全权利的入口。
Replies
0
Boosts
0
Views
1k
Activity
Jan ’23
Creating new keychain for mac os app
I need to create a new keychain for my mac os app. Currently there is a function SecKeychainCreate in Appledocumentation. But this function will be deprecated in mac OS 12.0. Is there another way to create keychain using swift (without using terminal commands)? Or will mac provide new function for this in update? Anybody knows?
Replies
7
Boosts
0
Views
3.7k
Activity
Jan ’23
SecItemAdd returns errSecAuthFailed
Hello, I'm experiencing a weird issue on the iOS 15 simulator (unfortunately I don't have a device with 15 installed yet). The issue I see is that the call to SecItemAdd returns OSStatus -25293 (errSecAuthFailed). The attributes dictionary passed looks like this: var query: [String : Any] = [ kSecClass as String: kSecClassGenericPassword, kSecAttrAccount as String: key, kSecAttrService as String: service, kSecAttrAccessControl as String: getSecAccessControl(), kSecUseAuthenticationContext as String: context, kSecValueData as String: data         ] the getSecAccessControl returns a SecAccessControl created like this:         access = SecAccessControlCreateWithFlags(nil,   kSecAttrAccessibleWhenUnlockedThisDeviceOnly,   .userPresence,   &amp;error) if I do not add the kSecAttrAccessControl item I don't see any error. The same code works as expected on the simulator with iOS 14. Looking at the documentation didn't help, anybody has hints about this? Maybe it's bug I'm not aware of? Thank you in advance
Replies
19
Boosts
2
Views
11k
Activity
Jun ’22
iOS 15 beta wipes out app data
When I open the app after a couple of hours, all of. the app data is getting wiped out (UserDefaults, keychain password). I'm on iOS 15 public beta 3. Has anyone faced similar issue, or how to debug and get it fixed?
Replies
11
Boosts
0
Views
8.5k
Activity
Nov ’21
Swift AES CBC 256 Encryption With Static 32bit Key and 32bit IV
We have the below Implementation in Android and the same has to be integrated into Swift. Key :- "d95acd54b4a821ff32c52825q931c194" IV :- "687b9509c25a34b8ad076346s8353d67" Here Both the Key and IV are 32 bits and below is the android code. public class AESEncryption { private static final String key = "d95acd54c6a821ff32c52825b931c194"; private static final String initVector = "687b9509c25a14b8ad076346d8353d67"; static byte[] bte = hexToBytes(initVector); public static String encrypt(String strToEncrypt) { try { CommonCode.showLog("log", bte.toString()); IvParameterSpec iv = new IvParameterSpec(bte); SecretKeySpec skeySpec = new SecretKeySpec(key.getBytes(StandardCharsets.UTF_8), "AES"); Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5PADDING"); CommonCode.showLog("IV after logs", iv.toString()); cipher.init(Cipher.ENCRYPT_MODE, skeySpec, iv); byte[] encrypted = cipher.doFinal(strToEncrypt.getBytes()); if (Build.VERSION.SDK_INT &gt;= Build.VERSION_CODES.O) { return Base64.getEncoder().encodeToString(encrypted).trim(); } else { return android.util.Base64.encodeToString(encrypted, android.util.Base64.DEFAULT).trim(); } } catch (Exception e) { CommonCode.showLog("Error while encrypting: ", e.toString()); } return null; } public static String decrypt(String strToDecrypt) { try { IvParameterSpec iv = new IvParameterSpec(bte); SecretKeySpec skeySpec = new SecretKeySpec(key.getBytes(StandardCharsets.UTF_8), "AES"); Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5PADDING"); cipher.init(Cipher.DECRYPT_MODE, skeySpec, iv); if (android.os.Build.VERSION.SDK_INT &gt;= android.os.Build.VERSION_CODES.O) { return new String(cipher.doFinal(Base64.getDecoder().decode(strToDecrypt))); } else { return new String(cipher.doFinal(android.util.Base64.decode(strToDecrypt, android.util.Base64.DEFAULT))); } } catch (Exception e) { CommonCode.showLog("Error while decrypting: " , e.toString()); } return null; } } How can we mimic the above in Swift? Here in Android they are using static byte[] bte = hexToBytes(initVector); to convert the 32bit IV into 16 bit Bytes Array I Have Tried the same approach on Swift below are the code snippet [Contents.swift](https://developer.apple.com/forums/content/attachment/60fab4f2-1496-4003-9f37-c195de95e94a)
Replies
9
Boosts
0
Views
11k
Activity
Dec ’24
Unique SNI for Apple leaf cert
Does Apple issuer have a guarantee that it's signed leaf certificates will have unique Subject and Issuer Name? Will it be the same after the leaf cert is renewed?
Replies
2
Boosts
0
Views
889
Activity
Oct ’21
App crashes when trying to get signature using private key
Hi, for some of our users the app crashes when we try to get the EdDSA signature using the private key. We use the following method from CryptoKit in the Curve25519.Signing.PrivateKey extension: public func signature<D>(for data: D) throws -> Data where D : DataProtocol The data that we want to sign is a string that is converted using the algorithm SHA256 Our implementation looks something like this: func foo(text: String) throws -> String { var algorithm = SHA256() algorithm.update(data: text.data(using: .utf8)!) guard self.hasPrivateKey else { // Error handling } do { let signature = try self.privateKey.signature(for: algorithm.finalize()) // App crashes here if not using do-catch statement // signature will be used and transformed to return String... } catch { // Error handling } } I would appreciate any hints on how to solve or inspect this. Many thanks.
Replies
3
Boosts
0
Views
1.2k
Activity
Oct ’21
i want to add lock app feature, like iOS lock.
Can I add a lock screen on my iOS app? my requirement is : whenever a user opens the app, he/she need to unlock the app first then only he/she can operate the app.
Replies
2
Boosts
0
Views
3k
Activity
Jul ’22
SFAuthorizationpluginview dismiss in 20 second.
I have created a custom username/password lock screen using SFAuthorizationPluginView. When lock the screen the view appears. The cursor start blinking in TextField. However, it always automatically dismiss in 20 second if ideal. I could see the Mechanism dealloc gets called and dismiss the view. Based on my investigation, I think the system kill the view in 20second, and there is no ways to increase that and keep the custom screen for more time. Any help will be appreciate.
Replies
3
Boosts
0
Views
1.8k
Activity
Sep ’23
some change on keychain in ios 15 beta
We found that the error code of the keychain was different in ios 14 and ios 15. When the bio-information registered by the user is changed, if secItemCopyMatching is called, erSecItemNotFound is received in ios 14, but erSecAuthFailed is received in ios 15. In this case, iOS 15 cannot distinguish whether authentication has failed or bio-information has changed. I want to know if this is a bug in os or if it will proceed like this in the future. If we continue to give this error code in the future, I hope there will be a guide on how to distinguish the two error codes from the developer's point of view.
Replies
3
Boosts
0
Views
654
Activity
Dec ’21
Touch ID / Face ID biometryCurrentSet never fails on iOS 15
I've got some admittedly old Objective-C code handling Keychain items protected by Touch ID / Face ID that uses the access control flag kSecAccessControlTouchIDCurrentSet, accessing the items would fail with errSecItemNotFound when the user adds or removes a finger/face from the device, however on iOS 15.0 this is not happening. It does work on iOS 14.6 still. My deployment target is still iOS 11.0 so I haven't moved to kSecAccessControlBiometryCurrentSet as the replacement for the now deprecated TouchID value - but the enum raw values are the same so I don't see how that could be the cause. I can't see what the new error code is, because I'm not using Xcode 13, but I'll try and get the DeviceSupport copied in (official support for this is please!) to help search: Swift touchIDCurrentSet biometryCurrentSet Objective-C kSecAccessControlTouchIDCurrentSet kSecAccessControlBiometryCurrentSet
Replies
2
Boosts
0
Views
2.9k
Activity
Sep ’21
Fatal Exception: NSInvalidArgumentException SecKeyGetAlgorithmId called with NULL SecKeyRef on ios 15 only
As usual crash is happening on newer version of iOS 15 Crash log Fatal Exception: NSInvalidArgumentException 0 CoreFoundation 0x1814dc05c __exceptionPreprocess 1 libobjc.A.dylib 0x1999f6f54 objc_exception_throw 2 CoreFoundation 0x181533190 __CFDictionaryCreateGeneric 3 Security 0x18a239674 SecKeyGetAlgorithmId 4 Security 0x18a2d53d0 SecKeyGetSignatureAlgorithmForPadding 5 Security 0x18a2d5328 SecKeyRawSign 6 App Name 0x100bc90f8 -[login privatekeytouch] + 1484 (CprLoginContrl.m:1484) 7 libdispatch.dylib 0x18114cc04 _dispatch_call_block_and_release 8 libdispatch.dylib 0x18114e950 _dispatch_client_callout 9 libdispatch.dylib 0x18115cd30 _dispatch_main_queue_callback_4CF 10 CoreFoundation 0x181494ce4 CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE 11 CoreFoundation 0x18144eebc __CFRunLoopRun 12 CoreFoundation 0x1814623c8 CFRunLoopRunSpecific 13 GraphicsServices 0x19cc7338c GSEventRunModal 14 UIKitCore 0x183e080bc -[UIApplication _run] 15 UIKitCore 0x183b85be8 UIApplicationMain 16 App Name 0x10079a7b8 main + 22 (main.m:22) 17 ??? 0x101639a24 (Missing) crashed during SecKeyRawSign, anything has changed on ios 15?
Replies
7
Boosts
0
Views
3.2k
Activity
Sep ’21
Unlock keychain on headless system does not work on BigSur
I am trying to setup a headless machine (no GUI session whatsoever, only SSH) to CI/CD My pre-build steps is to setup a keychain, but it looks like unlocking the keychain using just a SSH session is not working on macOS 11.6 ec2-user@ip-172-31-40-2 code % security create-keychain -p Passw0rd dev ec2-user@ip-172-31-40-2 code % security list-keychain -d user -s dev ec2-user@ip-172-31-40-2 code % security set-keychain-settings -t 0 dev security: SecKeychainSetSettings dev: User interaction is not allowed. ec2-user@ip-172-31-40-2 code % security unlock-keychain -p Passw0rd dev ec2-user@ip-172-31-40-2 code % security set-keychain-settings -t 0 dev security: SecKeychainSetSettings dev: User interaction is not allowed. ec2-user@ip-172-31-40-2 code % security import ~/AppleWWDRCA.cer -t cert -k dev -A 1 certificate imported. ec2-user@ip-172-31-40-2 code % security import ~/AppleWWDRCAG3.cer -t cert -k dev -A 1 certificate imported. ec2-user@ip-172-31-40-2 code % security import ~/AppleRoot.cer -t cert -k dev -A 1 certificate imported. ec2-user@ip-172-31-40-2 code % security import ~/DevAuthCA.cer -t cert -k dev -A 1 certificate imported. ec2-user@ip-172-31-40-2 code % security import ~/apple_dev_key.p12 -k dev -A # this is my private key + cert security: SecKeychainItemImport: User interaction is not allowed. ec2-user@ip-172-31-40-2 code % security unlock-keychain -p Passw0rd dev ec2-user@ip-172-31-40-2 code % security import ~/apple_dev_key.p12 -k dev -A security: SecKeychainItemImport: User interaction is not allowed. When doing the same from agri session, I can see that despite the unlock-keychain command, a GUI prompt is presented to the user to unlock the keychain.
Replies
2
Boosts
0
Views
5.7k
Activity
Sep ’21
iOS 15 with FaceID authentication error when resetting FaceID
We use biometricID (faceID/touchID) authentication to access to a secret stored in keychain. We create the access control object with the biometryCurrentSet option as shown to make sure if FaceID / TouchID changes the entry should be invalidated. let secAccessControlObj = SecAccessControlCreateWithFlags(nil, kSecAttrAccessibleWhenPasscodeSetThisDeviceOnly, .biometryCurrentSet, accessControlError) Below is the set and get query, Set Query: [String(kSecClass): kSecClassGenericPassword,         String(kSecAttrAccount): group as AnyObject,         String(kSecAttrService): service as AnyObject,         String(kSecUseAuthenticationUI) : kSecUseAuthenticationUIAllow as AnyObject,         String(kSecAttrAccessControl) : secAccessControlObj,         String(kSecValueData) : value as AnyObject,         String(kSecAttrCreationDate) : Date() as AnyObject] Get Query: [String(kSecClass): kSecClassGenericPassword,         String(kSecAttrAccount): group as AnyObject,         String(kSecAttrService): service as AnyObject,         String(kSecUseAuthenticationUI) : kSecUseAuthenticationUIAllow as AnyObject,         String(kSecAttrAccessControl) : secAccessControlObj,         String(kSecValueData) : value as AnyObject,         String(kSecAttrCreationDate) : Date() as AnyObject] Steps: Set the value in keychain using the set query above Reset the faceID Use the get query to get the value from keychain by authenticating against TouchID/ FaceID. Result: When we try to get the value from keychain using SecItemCopyMatching(query as CFDictionary, result) we get the error code errSecAuthFailed (-25293) on iOS 15. Analysis: Prior to this (iOS 14 and below) the error code would be errSecItemNotFound which makes more sense. This is an issue for iOS 15 only as we also get errSecAuthFailed when user backgrounds the app while authenticating with FaceID/TouchID. This creates a ambiguity for us. In our testing when we backgrounded the app while authentication is in progress, we found the actual call to SecItemCopyMatching(::) was made when app's state was actually active but when the call returned the state had become background and the error code was again errSecAuthFailed This seems to be a bug with iOS 15 as it creates a ambiguity for the caller. I think the error code returned after resetting faceID should still be errSecItemNotFound in which case we can know the secret is actually lost since FaceID is reset and can treat errSecAuthFailed as error where the secret is actually not lost but just that failed temporarily. Please let us know if we need to file a bug
Replies
2
Boosts
0
Views
3k
Activity
Feb ’22