addDocument

fun addDocument(docType: String, encodedDeviceNamespaces: ByteArray, encodedDeviceSignature: ByteArray?, encodedDeviceMac: ByteArray?, issuerNameSpaces: Map<String?, List<ByteArray?>>, errors: Map<String?, Map<String?, Long?>>?, encodedIssuerAuth: ByteArray): DeviceResponseGenerator

Adds a new document to the device response.

Issuer-signed data is provided in issuerNameSpaces which maps from namespaces into a list of bytes of IssuerSignedItemBytes CBOR as defined in 18013-5 where each contains the digest-id, element name, issuer-generated random value and finally the element value. Each IssuerSignedItemBytes must be encoded so its digest matches with the digest in the MobileSecurityObject in the issuerAuth parameter.

The encodedIssuerAuth parameter contains the bytes of the IssuerAuth CBOR as defined in ISO/IEC 18013-5 section 9.1.2.4 Signing method and structure for MSO. That is, the payload for this COSE_Sign1 must be set to the MobileSecurityObjectBytes and the public key used to sign the payload must be included in a x5chain unprotected header element.

For device-signed data, the parameters encodedDeviceNamespaces, encodedDeviceSignature, and encodedDeviceMac are used. Of the latter two, exactly one of them must be non-null. The DeviceNameSpaces CBOR specified in ISO/IEC 18013-5 section 8.3.2.1 Device retrieval is to be set in encodedDeviceNamespaces, and either a ECDSA signature or a MAC over the DeviceAuthentication CBOR as defined in section 9.1.3 mdoc authentication should be set in encodedDeviceSignature or encodedDeviceMac respectively. Values for all parameters can be obtained from the ResultData class from either the Framework or this library.

If present, the errors parameter is a map from namespaces where each value is a map from data elements in said namespace to an error code from ISO/IEC 18013-5:2021 Table 9.

Return

the passed-in DeviceResponseGenerator.

Parameters

docType

the document type, for example org.iso.18013.5.1.mDL.

encodedDeviceNamespaces

bytes of the DeviceNameSpaces CBOR.

encodedDeviceSignature

bytes of a COSE_Sign1 for authenticating the device data.

encodedDeviceMac

bytes of a COSE_Mac0 for authenticating the device data.

issuerNameSpaces

the map described above.

errors

a map with errors as described above.

encodedIssuerAuth

the bytes of the COSE_Sign1 described above.


Adds a new document to the device response.

This can be used with the output DocumentGenerator for MDOC presentations.

Return

the generator.

Parameters

encodedDocument

the bytes of Document CBOR as defined in ISO/IEC 18013-5 section 8.3.2.1.2.2.

Throws

if ZK documents have already been added.