Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,24 @@ public actor UsbReaderConnection: UsbReaderConnectionProtocol, Loggable {
}
}

public func calculateSignature(for dataToSign: Data, pin2: SecureData) async throws -> Data {
await ensureHandler()

guard let handler = cardHandler else {
UsbReaderConnection.logger().error("ID-CARD: Unable to calculate signature to sign with ID-card reader")
throw IdCardInternalError.readerProcessFailed
}

do {
return try await handler.calculateSignature(for: dataToSign, withPin2: pin2)
} catch {
guard let exception = error as? IdCardInternalError else {
throw IdCardError.sessionError
}
throw exception.getIdCardError()
}
}

// MARK: Handler

private func ensureHandler() async {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,5 @@ public protocol UsbReaderConnectionProtocol: Actor {
func isPUKChangeable() async throws -> Bool
func changeCode(_ codeType: CodeType, to newCode: Data, verifyCode: Data) async throws
func unblockCode(_ codeType: CodeType, puk: Data, newCode: Data) async throws
func calculateSignature(for dataToSign: Data, pin2: SecureData) async throws -> Data
}
4 changes: 3 additions & 1 deletion RIADigiDoc/DI/AppContainer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,9 @@ extension Container {
idCardRepository: self.idCardRepository(),
sharedMyEidSession: self.sharedMyEidSession(),
certificateUtil: self.certificateUtil(),
nameUtil: self.nameUtil()
nameUtil: self.nameUtil(),
dataStore: self.dataStore(),
userAgentUtil: self.userAgentUtil()
)
}
}
Expand Down
4 changes: 4 additions & 0 deletions RIADigiDoc/Domain/Repository/IdCard/IdCardRepository.swift
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,8 @@ actor IdCardRepository: IdCardRepositoryProtocol {
func unblockCode(_ codeType: CodeType, puk: Data, newCode: Data) async throws {
try await idCardService.unblockCode(codeType, puk: puk, newCode: newCode)
}

func calculateSignature(for dataToSign: Data, pin2: SecureData) async throws -> Data {
try await idCardService.calculateSignature(for: dataToSign, pin2: pin2)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,5 @@ public protocol IdCardRepositoryProtocol: Sendable {
func isPUKChangeable() async throws -> Bool
func changeCode(_ codeType: CodeType, to newCode: Data, verifyCode: Data) async throws
func unblockCode(_ codeType: CodeType, puk: Data, newCode: Data) async throws
func calculateSignature(for dataToSign: Data, pin2: SecureData) async throws -> Data
}
4 changes: 4 additions & 0 deletions RIADigiDoc/Domain/Service/IdCard/IdCardService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,8 @@ actor IdCardService: IdCardServiceProtocol {
func unblockCode(_ codeType: CodeType, puk: Data, newCode: Data) async throws {
try await usbReaderConnection.unblockCode(codeType, puk: puk, newCode: newCode)
}

func calculateSignature(for dataToSign: Data, pin2: SecureData) async throws -> Data {
try await usbReaderConnection.calculateSignature(for: dataToSign, pin2: pin2)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,5 @@ public protocol IdCardServiceProtocol: Sendable {
func isPUKChangeable() async throws -> Bool
func changeCode(_ codeType: CodeType, to newCode: Data, verifyCode: Data) async throws
func unblockCode(_ codeType: CodeType, puk: Data, newCode: Data) async throws
func calculateSignature(for dataToSign: Data, pin2: SecureData) async throws -> Data
}
12 changes: 7 additions & 5 deletions RIADigiDoc/RIADigiDocApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ struct RIADigiDocApp: App {
}

await librarySetup.setupLibraries()
await crashReportManager.evaluateCrashReporting()
fileUtil.removeSavedFilesDirectory(savedFilesDirectory: nil)
isInitialLanguageSelected = await dataStore.getIsInitialLanguageSelected()
await MainActor.run {
Expand All @@ -89,23 +90,24 @@ struct RIADigiDocApp: App {
ContentView()
.environment(pathManager)
.appNavigation(pathManager: pathManager)
.task {
await crashReportManager.evaluateCrashReporting()
}
.alert(
languageSettings.localized("Crash report title"),
isPresented: $crashReportManager.showCrashDialog
) {
Button(languageSettings.localized("Crash report send")) {
crashReportManager.sendReport()
Task {
await crashReportManager.sendReport()
}
}
Button(languageSettings.localized("Crash report always send")) {
Task {
await crashReportManager.alwaysSendReport()
}
}
Button(languageSettings.localized("Crash report dont send"), role: .cancel) {
crashReportManager.doNotSendReport()
Task {
await crashReportManager.doNotSendReport()
}
}
} message: {
Text(verbatim: languageSettings.localized("Crash report message"))
Expand Down
22 changes: 20 additions & 2 deletions RIADigiDoc/Supporting files/Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -1500,7 +1500,7 @@
},
"et" : {
"stringUnit" : {
"state" : "needs_review",
"state" : "translated",
"value" : "Ümbriku krüpteerimine ebaõnnestus"
}
}
Expand Down Expand Up @@ -1991,6 +1991,24 @@
}
}
},
"ID card conditional speech" : {
"comment" : "ID-card error messages where it’s used in sentences",
"extractionState" : "manual",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "ID-card's"
}
},
"et" : {
"stringUnit" : {
"state" : "translated",
"value" : "ID-kaardi"
}
}
}
},
"ID card connect card reader" : {
"comment" : "ID-card view initial message",
"extractionState" : "manual",
Expand Down Expand Up @@ -8049,4 +8067,4 @@
}
},
"version" : "1.1"
}
}
Loading