network-international / card-management-sdk-ios

SDKs to help card issuers to consume our APIs from iOS applications
Other
3 stars 1 forks source link

Update keychain usage, remove obsolete method #27

Closed akiselevn closed 7 months ago

akiselevn commented 7 months ago

Given

Previous solution relied on generation public key / private key / certificate for each needed request (retrieve card details / card lookup / retrieve pin). Although, it is advisable to delete the keys that are no longer needed, or reuse the same key pair for multiple requests, if possible. But it could be not so secure to expose generated keys tags and save it somewhere so it could be deleted later, or to reuse the same persistent private key for the long time (if it will be compromised we will not know about it) - SDK implementation used keys saved in keychain for crypto operations.

Problem

Possible impact on client’s devices:

A related discussion came up on Valet, a popular third-party Keychain library put out by Square. Apparently, 4KB is the "soft limit" and 16MB is the only known hard limit. Anything in-between risks a keychain error due to the system killing securityd. https://github.com/square/Valet/issues/246

Generating a new key pair for each user request and storing them in the keychain with different tags can result in a large number of keys in the keychain storage over time. This can have some negative effects, such as:

New SDK version

Do not use keychain as a persistent storage for generated keys (public / private), create certificate and do crypto operations on fly, then release that security data immediately after it was used.

Additional pros: