Skip to content

Commit

Permalink
Merge pull request #127 from niscy-eudiw/main
Browse files Browse the repository at this point in the history
Update package dependencies and fix secure area key creation method
  • Loading branch information
phisakel authored Dec 4, 2024
2 parents 1a8c422 + 98445bf commit 8bdf0a9
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 16 deletions.
18 changes: 9 additions & 9 deletions Package.resolved
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"originHash" : "3c60eb55cb4a02f67cb382900b7e167b7d424741343da03faed156ca08377032",
"originHash" : "371881ce715600630d3e326e503779cf78aeaeb59763d1e1769cb52629a30d30",
"pins" : [
{
"identity" : "blueecc",
Expand All @@ -24,26 +24,26 @@
"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"
}
},
{
"identity" : "eudi-lib-ios-iso18013-data-transfer",
"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"
}
},
{
"identity" : "eudi-lib-ios-iso18013-security",
"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"
}
},
{
Expand Down Expand Up @@ -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"
}
},
{
Expand Down
4 changes: 2 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
],
Expand Down
8 changes: 5 additions & 3 deletions Sources/EudiWalletKit/EudiWallet.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
}

Expand Down Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion Sources/EudiWalletKit/EudiWalletKit.docc/SecureAreas.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
2 changes: 1 addition & 1 deletion Sources/EudiWalletKit/Extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -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:
Expand Down

0 comments on commit 8bdf0a9

Please sign in to comment.