You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+26-15Lines changed: 26 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -172,26 +172,35 @@ if case let .persistentReference(data) = try keychain.store(
172
172
173
173
#### CryptoKit
174
174
175
-
`SwiftSecurity` lets you natively store `CryptoKit` keys as native `SecKey` instances. [Keys supporting such conversion](https://developer.apple.com/documentation/cryptokit/storing_cryptokit_keys_in_the_keychain), like `P256`/`P384`/`P521.PrivateKey`, conform to `SecKeyConvertible` protocol.
175
+
`SwiftSecurity` lets you natively store `CryptoKit` keys as native `SecKey` instances. [Keys supporting such conversion](https://developer.apple.com/documentation/cryptokit/storing_cryptokit_keys_in_the_keychain), like `P256`/`P384`/`P521`, conform to `SecKeyConvertible` protocol.
Other key types, like `Curve25519.PrivateKey`, `SymmetricKey`, `SecureEnclave.P256.PrivateKey`, have no direct keychain corollary. In particular, `SecureEnclave.P256` is a persistent reference to the key inside `Secure Enclave`, not the key itself. These keys conform to `SecDataConvertible`, so store them as follows:
193
+
Other key types from `CryptoKit`, like `SymmetricKey`, `Curve25519`, `SecureEnclave.P256`, have no direct keychain corollary. In particular, `SecureEnclave.P256` is a persistent reference to the key inside `Secure Enclave`, not the key itself. These keys conform to `SecDataConvertible`, so store them as follows:
> `SecKey` is intended for asymmetric key storage. Only `ECPrimeRandom` (`CryptoKit -> P256/384/512`) and `RSA` algorithms are supported. See [On Cryptographic Key Formats](https://developer.apple.com/forums/thread/680554) for more info.
If your project uses [apple/swift-certificates](https://github.com/apple/swift-certificates) package, the `Certificate` will offer more functionality. In case of `Swift Package Manager` dependency resolve issues, copy `SecCertificateConvertible` conformance directly to your project.
209
218
210
-
#### Identity
219
+
#### Digital Identity
211
220
212
-
A digital identity (`SecIdentity`) is the combination of a certificate and the private key that matches the public key within certificate.
221
+
A digital identity is the combination of a certificate and the private key that matches the public key within certificate.
213
222
214
223
```swift
215
224
// Import digital identity from `PKCS #12` data
@@ -369,18 +378,19 @@ You can store, retrieve, and remove various types of values.
369
378
370
379
```swift
371
380
Foundation:
372
-
- Data // GenericPassword, InternetPassword
373
-
-String// GenericPassword, InternetPassword
381
+
- Data /* GenericPassword, InternetPassword*/
382
+
-String/* GenericPassword, InternetPassword*/
374
383
CryptoKit:
375
-
- SymmetricKey // GenericPassword
376
-
- Curve25519 -> PrivateKey // GenericPassword
377
-
- SecureEnclave.P256-> PrivateKey // GenericPassword (SE's Key Data is Persistent Reference)
- Certificate // SecCertificate (Drop-in replacement for X509.Certificate)
383
-
- PKCS12.Blob// Import as SecIdentity (SecCertificate and SecKey)
391
+
- Certificate /* SecCertificate */
392
+
- PKCS12.Blob:/* Import as SecIdentity */
393
+
- DigitalIdentity /* SecIdentity (The Pair of SecCertificate and SecKey) */
384
394
```
385
395
386
396
To add support for custom types, you can extend them by conforming to the following protocols.
@@ -456,6 +466,7 @@ The framework’s default behavior provides a reasonable balance between conveni
456
466
*[Sharing access to keychain items among a collection of apps](https://developer.apple.com/documentation/security/keychain_services/keychain_items/sharing_access_to_keychain_items_among_a_collection_of_apps/)
457
467
*[Storing CryptoKit Keys in the Keychain](https://developer.apple.com/documentation/cryptokit/storing_cryptokit_keys_in_the_keychain)
458
468
*[TN3137: On Mac keychain APIs and implementations](https://developer.apple.com/documentation/technotes/tn3137-on-mac-keychains)
0 commit comments