SessionEncryption

class SessionEncryption(val role: MdocRole, eSelfKey: EcPrivateKey, remotePublicKey: EcPublicKey, encodedSessionTranscript: ByteArray)

Helper class for implementing session encryption according to ISO/IEC 18013-5:2021 section 9.1.1 Session encryption.

The DeviceEngagement and Handover CBOR referenced in the parameters below must conform to the CDDL in ISO 18013-5.

All references to a "remote" device refer to a device with the opposite role. For example, SessionEncryption objects with the MdocRole.MDOC role will encrypt messages with the remote mdoc reader as the intended receiver, so the reader is the remote device.

Parameters

role

the role that the object should act as.

eSelfKey

The ephemeral private key e.g. in the MdocRole.MDOC_READER role, it's the ephemeral private key for the mdoc reader, and in the MdocRole.MDOC role it's the for the mdoc.

remotePublicKey

The public ephemeral key of the other end.

encodedSessionTranscript

The bytes of the SessionTranscript CBOR.

Constructors

Link copied to clipboard
constructor(role: MdocRole, eSelfKey: EcPrivateKey, remotePublicKey: EcPublicKey, encodedSessionTranscript: ByteArray)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

The number of messages decrypted with .decryptMessage.

Link copied to clipboard

The number of messages encrypted with .encryptMessage.

Link copied to clipboard

Functions

Link copied to clipboard
fun decryptMessage(messageData: ByteArray): Pair<ByteArray?, Long?>

Decrypts a message received from the remote device.

Link copied to clipboard
fun encryptMessage(messagePlaintext: ByteArray?, statusCode: Long?): ByteArray

Encrypt a message intended for the remote device.

Link copied to clipboard
fun setSendSessionEstablishment(sendSessionEstablishment: Boolean)

Configure whether to send SessionEstablishment as the first message. Only an object with the role MdocRole.MDOC_READER will want to do this.