Cose

object Cose

COSE support routines.

This package includes support for COSE as specified in RFC 9052.

Properties

Link copied to clipboard
const val COSE_KEY_ALG: Long = 3

The COSE Key common parameter for the key algorithm (int / tstr).

Link copied to clipboard
const val COSE_KEY_KID: Long = 2

The COSE Key common parameter for the key id (bstr).

Link copied to clipboard
const val COSE_KEY_KTY: Long = 1

The COSE Key common parameter for the key type (tstr / int).

Link copied to clipboard

The COSE Key type parameter for the EC curve (int / tstr).

Link copied to clipboard

The COSE Key type parameter for the private key (bstr).

Link copied to clipboard

The COSE Key type parameter for RSA private exponent d (bstr).

Link copied to clipboard

The COSE Key type parameter for RSA dP (bstr).

Link copied to clipboard

The COSE Key type parameter for RSA dQ (bstr).

Link copied to clipboard

The COSE Key type parameter for RSA public exponent e (bstr).

Link copied to clipboard

The COSE Key type parameter for RSA modulus n (bstr).

Link copied to clipboard

The COSE Key type parameter for RSA prime factor p (bstr).

Link copied to clipboard

The COSE Key type parameter for AKP private key (bstr).

Link copied to clipboard

The COSE Key type parameter for AKP public key (bstr).

Link copied to clipboard

The COSE Key type parameter for RSA prime factor q (bstr).

Link copied to clipboard

The COSE Key type parameter for RSA qInv (bstr).

Link copied to clipboard

The COSE Key type parameter for the X coordinate (bstr).

Link copied to clipboard

The COSE Key type parameter for the Y coordinate (bstr / bool).

Link copied to clipboard
const val COSE_KEY_TYPE_AKP: Long = 7

The COSE Key Type for Algorithm Key Pair (AKP).

Link copied to clipboard
const val COSE_KEY_TYPE_EC2: Long = 2

The COSE Key Type for EC2.

Link copied to clipboard
const val COSE_KEY_TYPE_OKP: Long = 1

The COSE Key Type for OKP.

Link copied to clipboard
const val COSE_KEY_TYPE_RSA: Long = 3

The COSE Key Type for RSA.

Link copied to clipboard
const val COSE_LABEL_ALG: Long = 1

The COSE label for conveying an algorithm.

Link copied to clipboard
const val COSE_LABEL_KID: Long = 4

The COSE label for conveying the key id (bstr) in the COSE header.

Link copied to clipboard
const val COSE_LABEL_TYP: Long = 16

The COSE label for conveying the token type (tstr or uint) similar to JWT typ.

Link copied to clipboard
const val COSE_LABEL_X5CHAIN: Long = 33

The COSE label for conveying an X.509 certificate chain.

Functions

Link copied to clipboard
suspend fun coseMac0(algorithm: Algorithm, key: SecretKey, message: ByteArray, includeMessageInPayload: Boolean, protectedHeaders: Map<CoseLabel, DataItem>, unprotectedHeaders: Map<CoseLabel, DataItem>): CoseMac0

Creates a COSE_Mac0 message authentication code.

Link copied to clipboard
suspend fun coseSign1Check(publicKey: PublicKey, detachedData: ByteArray?, signature: CoseSign1, signatureAlgorithm: Algorithm)

Checks a COSE_Sign1 signature.

Link copied to clipboard
suspend fun coseSign1Sign(signingKey: AsymmetricKey, message: ByteArray, includeMessageInPayload: Boolean, protectedHeaders: Map<CoseLabel, DataItem> = mapOf(), unprotectedHeaders: Map<CoseLabel, DataItem> = mapOf()): CoseSign1
suspend fun coseSign1Sign(key: EcPrivateKey, dataToSign: ByteArray, includeDataInPayload: Boolean, signatureAlgorithm: Algorithm, protectedHeaders: Map<CoseLabel, DataItem>, unprotectedHeaders: Map<CoseLabel, DataItem>): CoseSign1
suspend fun coseSign1Sign(secureArea: SecureArea, alias: String, message: ByteArray, includeMessageInPayload: Boolean, protectedHeaders: Map<CoseLabel, DataItem>, unprotectedHeaders: Map<CoseLabel, DataItem>, unlockReason: Reason = Reason.Unspecified): CoseSign1

Creates a COSE_Sign1 signature.