Skip to content

Commit

Permalink
Merge branch 'main' into gh-pages
Browse files Browse the repository at this point in the history
  • Loading branch information
phisakel committed Dec 4, 2024
2 parents bb8bbe6 + cf0a793 commit 9c14e3f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
7 changes: 3 additions & 4 deletions Sources/MdocDataModel18013/SecureArea/SecureArea.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,8 @@ public protocol SecureArea: Actor {
static var name: String { get }
/// default Elliptic Curve type for the secure area
static var defaultEcCurve: CoseEcCurve { get }
/// reference to the secure-key-storage abstraction
var storage: any SecureKeyStorage { get }
/// initialize with a secure-key storage object
init(storage: any SecureKeyStorage)
nonisolated static func create(storage: any SecureKeyStorage) -> Self
/// make key and return the public key.
/// The public key is passed to the Open4VCI module
func createKey(id: String, keyOptions: KeyOptions?) async throws -> CoseKey
Expand All @@ -47,6 +45,7 @@ public protocol SecureArea: Actor {
func keyAgreement(id: String, publicKey: CoseKey, unlockData: Data?) async throws -> SharedSecret
/// returns information about the key with the given id
func getKeyInfo(id: String) async throws -> KeyInfo
/// return the storage instance
func getStorage() async -> any SecureKeyStorage
}

Expand All @@ -60,7 +59,7 @@ extension SecureArea {
logger.info("Unlocking key with id: \(id)")
return nil
}
public func getStorage() async -> any SecureKeyStorage { return storage }
//public func getStorage() async -> any SecureKeyStorage { return storage }
}


8 changes: 6 additions & 2 deletions Tests/MdocDataModel18013Tests/InMemoryP256SecureArea.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,17 @@ import Foundation
import SwiftCBOR

public actor InMemoryP256SecureArea: SecureArea {
public var storage: any MdocDataModel18013.SecureKeyStorage
var storage: any MdocDataModel18013.SecureKeyStorage
var key: P256.Signing.PrivateKey!
public nonisolated(unsafe) var x963Key: Data?

public init(storage: any MdocDataModel18013.SecureKeyStorage) {
init(storage: any MdocDataModel18013.SecureKeyStorage) {
self.storage = storage
}
nonisolated public static func create(storage: any MdocDataModel18013.SecureKeyStorage) -> InMemoryP256SecureArea {
InMemoryP256SecureArea(storage: storage)
}
public func getStorage() async -> any MdocDataModel18013.SecureKeyStorage { storage }

public func createKey(id: String, keyOptions: MdocDataModel18013.KeyOptions?) throws -> MdocDataModel18013.CoseKey {
key = if let x963Key { try P256.Signing.PrivateKey(x963Representation: x963Key) } else { P256.Signing.PrivateKey() }
Expand Down

0 comments on commit 9c14e3f

Please sign in to comment.