Skip to content

Commit

Permalink
Merge branch 'develop' into IOS-2935_cover_cryptokit_error_p256
Browse files Browse the repository at this point in the history
  • Loading branch information
tureck1y authored Mar 6, 2023
2 parents 5f97b10 + 4c32720 commit ecbae31
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
2 changes: 2 additions & 0 deletions TangemSdk/TangemSdk/Common/Core/CardSession.swift
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,8 @@ public class CardSession {

/// We need to remember the tag for the duration of the command to be able to compare this tag with new one on tag from connected/lost events
func rememberTag() {
guard case .tag = reader.tag.value else { return }

currentTag = reader.tag.value
}

Expand Down
12 changes: 7 additions & 5 deletions TangemSdk/TangemSdk/Operations/Command.swift
Original file line number Diff line number Diff line change
Expand Up @@ -91,18 +91,17 @@ extension Command {

private func transceiveInternal(in session: CardSession, completion: @escaping CompletionResult<CommandResponse>) {
do {
session.rememberTag()

Log.apdu("C-APDU serialization start".titleFormatted)
let commandApdu = try serialize(with: session.environment)
Log.apdu("C-APDU serialization finish".titleFormatted)


session.rememberTag()

transceive(apdu: commandApdu, in: session) { result in
session.releaseTag()
switch result {
case .success(let responseApdu):
do {

session.releaseTag()
Log.apdu("R-APDU deserialization start".titleFormatted)
let responseData = try self.deserialize(with: session.environment, from: responseApdu)
Log.apdu("R-APDU deserialization finish".titleFormatted)
Expand All @@ -129,11 +128,13 @@ extension Command {
self.requestPin(.passcode, session, completion: completion)
} else { fallthrough }
default:
session.releaseTag()
completion(.failure(error))
}
}
}
} catch {
session.releaseTag()
completion(.failure(error.toTangemSdkError()))
}
}
Expand Down Expand Up @@ -235,6 +236,7 @@ extension Command {
session.resume()
self.transceiveInternal(in: session, completion: completion)
case .failure(let error):
session.releaseTag()
completion(.failure(error))
}
}
Expand Down

0 comments on commit ecbae31

Please sign in to comment.