Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configurable-challenge-for-Active-Authentication #227

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
6 changes: 4 additions & 2 deletions Sources/NFCPassportReader/PassportReader.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public class PassportReader : NSObject {
private var caHandler : ChipAuthenticationHandler?
private var paceHandler : PACEHandler?
private var mrzKey : String = ""
private var aaChallenge: [UInt8]?
private var dataAmountToReadOverride : Int? = nil

private var scanCompletedHandler: ((NFCPassportModel?, NFCPassportReaderError?)->())!
Expand Down Expand Up @@ -63,10 +64,11 @@ public class PassportReader : NSObject {
dataAmountToReadOverride = amount
}

public func readPassport( mrzKey : String, tags : [DataGroupId] = [], skipSecureElements : Bool = true, skipCA : Bool = false, skipPACE : Bool = false, useExtendedMode : Bool = false, customDisplayMessage : ((NFCViewDisplayMessage) -> String?)? = nil) async throws -> NFCPassportModel {
public func readPassport( mrzKey : String, tags : [DataGroupId] = [], aaChallenge: [UInt8]? = nil, skipSecureElements : Bool = true, skipCA : Bool = false, skipPACE : Bool = false, useExtendedMode : Bool = false, customDisplayMessage : ((NFCViewDisplayMessage) -> String?)? = nil) async throws -> NFCPassportModel {

self.passport = NFCPassportModel()
self.mrzKey = mrzKey
self.aaChallenge = aaChallenge
self.skipCA = skipCA
self.skipPACE = skipPACE
self.useExtendedMode = useExtendedMode
Expand Down Expand Up @@ -267,7 +269,7 @@ extension PassportReader {

Logger.passportReader.info( "Performing Active Authentication" )

let challenge = generateRandomUInt8Array(8)
let challenge = aaChallenge ?? generateRandomUInt8Array(8)
Logger.passportReader.debug( "Generated Active Authentication challange - \(binToHexRep(challenge))")
let response = try await tagReader.doInternalAuthentication(challenge: challenge, useExtendedMode: useExtendedMode)
self.passport.verifyActiveAuthentication( challenge:challenge, signature:response.data )
Expand Down