buildCwt

suspend fun buildCwt(type: String, key: AsymmetricKey, protectedHeaders: Map<CoseLabel, DataItem> = mapOf(), unprotectedHeaders: Map<CoseLabel, DataItem> = mapOf(), creationTime: Instant = Clock.System.now(), expiresIn: Duration? = null, body: suspend MapBuilder<*>.() -> Unit): ByteArray

Creates a CWT message signed with the given key.

CWT header contains type, signature algorithm and, unless the key is AsymmetricKey.Anonymous, key identification (either kid or x5chain). The body of the CWT will have issuance time (iat) and optionally expiration time (exp), unless creationTime is set to Instant.DISTANT_PAST

Return

signed CWT

Parameters

type

CWT type as String

key

private key to sign CWT and provide key identifying information in the CWT header

protectedHeaders

headers that are covered by the signature

creationTime

CWT issuance timestamp (iat)

expiresIn

validity duration for the CWT (if any)

body

JSON object builder block for CWT body


suspend fun buildCwt(type: DataItem, key: AsymmetricKey, protectedHeaders: Map<CoseLabel, DataItem> = mapOf(), unprotectedHeaders: Map<CoseLabel, DataItem> = mapOf(), creationTime: Instant = Clock.System.now(), expiresIn: Duration? = null, builderAction: suspend MapBuilder<*>.() -> Unit): ByteArray

Creates a CWT message signed with the given key.

CWT header contains type, signature algorithm and, unless the key is AsymmetricKey.Anonymous, key identification (either kid or x5chain). The body of the CWT will have issuance time (iat) and optionally expiration time (exp), unless creationTime is set to Instant.DISTANT_PAST

Return

signed CWT

Parameters

type

CWT type as DataItem, must be a Tstr or an Uint

key

private key to sign CWT and provide key identifying information in the CWT header

protectedHeaders

headers that are covered by the signature

creationTime

CWT issuance timestamp (iat)

expiresIn

validity duration for the CWT (if any)

builderAction

JSON object builder block for CWT body