MdocNfcCceEngagementHelper

class MdocNfcCceEngagementHelper(val eDeviceKey: EcPublicKey, val onHandoverComplete: (connectionMethod: MdocConnectionMethod?, encodedDeviceEngagement: ByteString, handover: DataItem, eReaderKey: EcPublicKey) -> Unit, val onMessageReceived: suspend (ByteString) -> Unit, val onError: (error: Exception) -> Unit, val handoverPicker: suspend (connectionMethods: List<MdocConnectionMethod>) -> MdocConnectionMethod?? = null, val capabilities: Map<Capability, DataItem> = mapOf( Capability.READER_AUTH_ALL_SUPPORT to true.toDataItem(), Capability.EXTENDED_REQUEST_SUPPORT to true.toDataItem() ), val apduCommandMaxSize: Long = 65535, val apduResponseMaxSize: Long = 65536)

Helper used for NFC Concurrent Channel Engagement (CCE) on the mdoc side.

This implements NFC Concurrent Channel Engagement according to ISO/IEC 18013-5 Second Edition clause 9.5.

APDUs received from the NFC tag reader should be passed to the processApdu method.

The apduCommandMaxSize parameter is used to tell the mdoc reader that it needs to send its commands in APDUs no larger than this size and this value must be in 1..65535. The apduResponseMaxSize parameter is used to tell the mdoc reader the maximum response APDU payload size in 1..65536.

Parameters

eDeviceKey

EDeviceKey as per ISO/IEC 18013-5.

onHandoverComplete

the function to call when handover is complete. connectionMethod is the selected secondary channel MdocConnectionMethod, or null if no secondary channel was selected (NFC-only).

onMessageReceived

the function to call when a data message has been received over NFC.

onError

the function to call if an error occurs.

handoverPicker

a function to choose one of the secondary connection methods offered by the mdoc reader, or return null to use NFC only without a secondary channel.

apduCommandMaxSize

the maximum length of the command data field (1..65535).

apduResponseMaxSize

the maximum length of the response data field (1..65536).

Constructors

Link copied to clipboard
constructor(eDeviceKey: EcPublicKey, onHandoverComplete: (connectionMethod: MdocConnectionMethod?, encodedDeviceEngagement: ByteString, handover: DataItem, eReaderKey: EcPublicKey) -> Unit, onMessageReceived: suspend (ByteString) -> Unit, onError: (error: Exception) -> Unit, handoverPicker: suspend (connectionMethods: List<MdocConnectionMethod>) -> MdocConnectionMethod?? = null, capabilities: Map<Capability, DataItem> = mapOf( Capability.READER_AUTH_ALL_SUPPORT to true.toDataItem(), Capability.EXTENDED_REQUEST_SUPPORT to true.toDataItem() ), apduCommandMaxSize: Long = 65535, apduResponseMaxSize: Long = 65536)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

the capabilities to convey to the mdoc reader.

Link copied to clipboard
Link copied to clipboard
val handoverPicker: suspend (connectionMethods: List<MdocConnectionMethod>) -> MdocConnectionMethod??
Link copied to clipboard
val onError: (error: Exception) -> Unit
Link copied to clipboard
val onHandoverComplete: (connectionMethod: MdocConnectionMethod?, encodedDeviceEngagement: ByteString, handover: DataItem, eReaderKey: EcPublicKey) -> Unit
Link copied to clipboard
val onMessageReceived: suspend (ByteString) -> Unit

Functions

Link copied to clipboard
suspend fun processApdu(command: CommandApdu): ResponseApdu

Process APDUs received from the remote NFC tag reader.

Link copied to clipboard

Must be called when the session is deactivated, e.g. when the NFC tag reader leaves the field.

Link copied to clipboard
suspend fun sendMessage(message: ByteString)

Function for sending data via NFC.