diff --git a/Package.resolved b/Package.resolved index 6f927ca..36f5a27 100644 --- a/Package.resolved +++ b/Package.resolved @@ -1,5 +1,5 @@ { - "originHash" : "3c60eb55cb4a02f67cb382900b7e167b7d424741343da03faed156ca08377032", + "originHash" : "371881ce715600630d3e326e503779cf78aeaeb59763d1e1769cb52629a30d30", "pins" : [ { "identity" : "blueecc", @@ -24,8 +24,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/eu-digital-identity-wallet/eudi-lib-ios-iso18013-data-model.git", "state" : { - "revision" : "29f30a92427733db0c7b9cea9616607a1df24284", - "version" : "0.4.0" + "revision" : "cf0a7936ffd94698754c9aa611d0724c3b70b527", + "version" : "0.4.1" } }, { @@ -33,8 +33,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/eu-digital-identity-wallet/eudi-lib-ios-iso18013-data-transfer.git", "state" : { - "revision" : "b774365cae01babdc2807d602e53ac2ddb7c6958", - "version" : "0.4.0" + "revision" : "34b0ca6d1f61e57e967d038a9d1954d25ae6a9dc", + "version" : "0.4.1" } }, { @@ -42,8 +42,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/eu-digital-identity-wallet/eudi-lib-ios-iso18013-security.git", "state" : { - "revision" : "6d335f19cb5bdb590bf2f5557c4d91dda146555b", - "version" : "0.3.0" + "revision" : "dca2b2aae09753cda3a1ac33d11e83dca40d2201", + "version" : "0.3.1" } }, { @@ -78,8 +78,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/eu-digital-identity-wallet/eudi-lib-ios-wallet-storage.git", "state" : { - "revision" : "32079a4b2425886a864efaaf2beeee234cb53efc", - "version" : "0.4.0" + "revision" : "627cea96c707da6ebb20039eeb467b96336aa8c3", + "version" : "0.4.1" } }, { diff --git a/Package.swift b/Package.swift index 5aa10e9..6b83076 100644 --- a/Package.swift +++ b/Package.swift @@ -15,8 +15,8 @@ let package = Package( dependencies: [ .package(url: "https://github.com/apple/swift-log.git", from: "1.5.3"), .package(url: "https://github.com/crspybits/swift-log-file", from: "0.1.0"), - .package(url: "https://github.com/eu-digital-identity-wallet/eudi-lib-ios-iso18013-data-transfer.git", exact: "0.4.0"), - .package(url: "https://github.com/eu-digital-identity-wallet/eudi-lib-ios-wallet-storage.git", exact: "0.4.0"), + .package(url: "https://github.com/eu-digital-identity-wallet/eudi-lib-ios-iso18013-data-transfer.git", exact: "0.4.1"), + .package(url: "https://github.com/eu-digital-identity-wallet/eudi-lib-ios-wallet-storage.git", exact: "0.4.1"), .package(url: "https://github.com/eu-digital-identity-wallet/eudi-lib-ios-siop-openid4vp-swift.git", exact: "0.6.1"), .package(url: "https://github.com/eu-digital-identity-wallet/eudi-lib-ios-openid4vci-swift.git", exact: "0.8.0"), ], diff --git a/Sources/EudiWalletKit/EudiWallet.swift b/Sources/EudiWalletKit/EudiWallet.swift index 0a55892..32d763c 100644 --- a/Sources/EudiWalletKit/EudiWallet.swift +++ b/Sources/EudiWalletKit/EudiWallet.swift @@ -103,8 +103,8 @@ public final class EudiWallet: ObservableObject, @unchecked Sendable { } else { // register default secure areas let kcSks = KeyChainSecureKeyStorage(serviceName: self.serviceName, accessGroup: accessGroup) - if SecureEnclave.isAvailable { SecureAreaRegistry.shared.register(secureArea: SecureEnclaveSecureArea(storage: kcSks)) } - SecureAreaRegistry.shared.register(secureArea: SoftwareSecureArea(storage: kcSks)) + if SecureEnclave.isAvailable { SecureAreaRegistry.shared.register(secureArea: SecureEnclaveSecureArea.create(storage: kcSks)) } + SecureAreaRegistry.shared.register(secureArea: SoftwareSecureArea.create(storage: kcSks)) } } @@ -382,7 +382,9 @@ public final class EudiWallet: ObservableObject, @unchecked Sendable { .compactMap(SignUpResponse.decomposeCBORSignupResponse(data:)).flatMap {$0} for dsd in docSamplesData { guard let pkCose = await CoseKeyPrivate.from(base64: dsd.pkData.base64EncodedString()) else { continue } - let docSample = Document(id: pkCose.privateKeyId, docType: dsd.docType, docDataType: .cbor, data: dsd.issData, secureAreaName: SecureAreaRegistry.DeviceSecureArea.software.rawValue, createdAt: Date.distantPast, modifiedAt: nil, displayName: dsd.docType == EuPidModel.euPidDocType ? "PID" : (dsd.docType == IsoMdlModel.isoDocType ? "mDL" : dsd.docType), status: .issued) + let id = UUID().uuidString + _ = try await pkCose.secureArea.createKey(id: id, keyOptions: nil) + let docSample = Document(id: id, docType: dsd.docType, docDataType: .cbor, data: dsd.issData, secureAreaName: SecureAreaRegistry.DeviceSecureArea.software.rawValue, createdAt: Date.distantPast, modifiedAt: nil, displayName: dsd.docType == EuPidModel.euPidDocType ? "PID" : (dsd.docType == IsoMdlModel.isoDocType ? "mDL" : dsd.docType), status: .issued) try await storage.storageService.saveDocument(docSample, allowOverwrite: true) } do { diff --git a/Sources/EudiWalletKit/EudiWalletKit.docc/SecureAreas.md b/Sources/EudiWalletKit/EudiWalletKit.docc/SecureAreas.md index 72706b8..045ec21 100644 --- a/Sources/EudiWalletKit/EudiWalletKit.docc/SecureAreas.md +++ b/Sources/EudiWalletKit/EudiWalletKit.docc/SecureAreas.md @@ -4,7 +4,7 @@ Eudi Wallet Kit supports custom key management through the implementation of Sec ### Secure areas -The wallet developer can customize cryptographic key operations by passing [SecureArea](https://eu-digital-identity-wallet.github.io/eudi-lib-ios-iso18013-data-model/documentation/mdocdatamodel18013/securearea) instances to the wallet. In the absence of custom instances, the wallet kit automatically generates [SecureEnclaveSecureArea](https://eu-digital-identity-wallet.github.io/eudi-lib-ios-iso18013-security/documentation/mdocsecurity18013/secureenclavesecurearea) (default) and [SecureEnclaveSecureArea](https://eu-digital-identity-wallet.github.io/eudi-lib-ios-iso18013-security/documentation/mdocsecurity18013/softwaresecurearea) secure areas. +The wallet developer can customize cryptographic key operations by passing [SecureArea](https://eu-digital-identity-wallet.github.io/eudi-lib-ios-iso18013-data-model/documentation/mdocdatamodel18013/securearea) instances to the wallet. In the absence of custom instances, the wallet kit automatically generates [SecureEnclaveSecureArea](https://eu-digital-identity-wallet.github.io/eudi-lib-ios-iso18013-security/documentation/mdocsecurity18013/secureenclavesecurearea) (default) and [SoftwareSecureArea](https://eu-digital-identity-wallet.github.io/eudi-lib-ios-iso18013-security/documentation/mdocsecurity18013/softwaresecurearea) secure areas. The secure area instance must be initialized with a secure key storage area implementing the [SecureKeyStorage](https://eu-digital-identity-wallet.github.io/eudi-lib-ios-iso18013-data-model/documentation/mdocdatamodel18013/securekeystorage) protocol. An iOS keychain-based storage is provided via the [KeyChainSecureKeyStorage](https://eu-digital-identity-wallet.github.io/eudi-lib-ios-wallet-storage/documentation/walletstorage/keychainsecurekeystorage) actor. diff --git a/Sources/EudiWalletKit/Extensions.swift b/Sources/EudiWalletKit/Extensions.swift index f0c284b..c7f5f24 100644 --- a/Sources/EudiWalletKit/Extensions.swift +++ b/Sources/EudiWalletKit/Extensions.swift @@ -65,7 +65,7 @@ extension MdocDataModel18013.CoseKeyPrivate { public static func from(base64: String) async -> MdocDataModel18013.CoseKeyPrivate? { guard let d = Data(base64Encoded: base64), let obj = try? CBOR.decode([UInt8](d)), let coseKey = CoseKey(cbor: obj), let cd = obj[-4], case let CBOR.byteString(rd) = cd else { return nil } let storage = await SecureAreaRegistry.shared.defaultSecurityArea!.getStorage() - let sampleSA = SampleDataSecureArea(storage: storage) + let sampleSA = SampleDataSecureArea.create(storage: storage) let keyData = NSMutableData(bytes: [0x04], length: [0x04].count) keyData.append(Data(coseKey.x)); keyData.append(Data(coseKey.y)); keyData.append(Data(rd)) sampleSA.x963Key = keyData as Data diff --git a/changelog.md b/changelog.md index 3e548dc..b9ae01d 100644 --- a/changelog.md +++ b/changelog.md @@ -1,3 +1,9 @@ +## v0.8.1 +### Breaking changes +- `SecureArea` protocol static factory method added: `nonisolated public static func create(storage: any KeyChainSecureKeyStorage) -> Self` +- Removed `SecureArea` protocol initializer: `init(storage: any KeyChainSecureKeyStorage)` (use the static factory method instead) +- Removed property `storage` from `SecureArea` protocol + ## v0.8.0 ### Secure area refactoring #### `EudiWallet` changes: