Skip to content

Commit 73aa6e5

Browse files
committed
Add optional parameterId to mutual auth
1 parent deec449 commit 73aa6e5

2 files changed

Lines changed: 10 additions & 7 deletions

File tree

Sources/NFCPassportReader/PACEHandler.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,8 @@ public class PACEHandler {
104104
Logger.pace.debug("paceKey - \(binToHexRep(self.paceKey, asArray:true))" )
105105

106106
// First start the initial auth call
107-
_ = try await tagReader.sendMSESetATMutualAuth(oid: paceOID, keyType: paceKeyType)
108-
107+
_ = try await tagReader.sendMSESetATMutualAuth(oid: paceOID, keyType: paceKeyType, parameterId: paceInfo.getParameterId())
108+
109109
let decryptedNonce = try await self.doStep1()
110110

111111
let ephemeralParams = try await self.doStep2(passportNonce: decryptedNonce)

Sources/NFCPassportReader/TagReader.swift

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -110,14 +110,17 @@ public class TagReader {
110110

111111
return try await send( cmd: cmd )
112112
}
113-
114-
func sendMSESetATMutualAuth( oid: String, keyType: UInt8 ) async throws -> ResponseAPDU {
115-
113+
114+
func sendMSESetATMutualAuth( oid: String, keyType: UInt8, parameterId: Int? = nil ) async throws -> ResponseAPDU {
115+
116116
let oidBytes = oidToBytes(oid: oid, replaceTag: true)
117117
let keyTypeBytes = wrapDO( b: 0x83, arr:[keyType])
118118

119-
let data = oidBytes + keyTypeBytes
120-
119+
var data = oidBytes + keyTypeBytes
120+
if let parameterId {
121+
data += wrapDO(b: 0x84, arr: [UInt8(parameterId)])
122+
}
123+
121124
let cmd = NFCISO7816APDU(instructionClass: 00, instructionCode: 0x22, p1Parameter: 0xC1, p2Parameter: 0xA4, data: Data(data), expectedResponseLength: -1)
122125

123126
return try await send( cmd: cmd )

0 commit comments

Comments
 (0)