crypto / org.apache.tuweni.crypto.sodium / KeyDerivation / MasterKey

MasterKey

class MasterKey : Destroyable (source)

A KeyDerivation master key.

Functions

bytes

fun bytes(): Bytes

Obtain the bytes of this key. WARNING: This will cause the key to be copied into heap memory.

bytesArray

fun bytesArray(): ByteArray

Obtain the bytes of this key. WARNING: This will cause the key to be copied into heap memory. The returned array should be overwritten when no longer required.

deriveKey

fun deriveKey(length: Int, subkeyId: Long, context: ByteArray): Bytes
fun deriveKey(length: Int, subkeyId: Long, context: String): Bytes

Derive a sub key.

deriveKeyArray

fun deriveKeyArray(length: Int, subkeyId: Long, context: ByteArray): ByteArray
fun deriveKeyArray(length: Int, subkeyId: Long, context: String): ByteArray

Derive a sub key.

destroy

fun destroy(): Unit

equals

fun equals(other: Any?): Boolean

fromBytes

static fun fromBytes(bytes: Bytes): MasterKey
static fun fromBytes(bytes: ByteArray): MasterKey

Create a MasterKey from an array of bytes.

The byte array must be of length #length().

hashCode

fun hashCode(): Int

isDestroyed

fun isDestroyed(): Boolean

length

static fun length(): Int

Obtain the length of the key in bytes (32).

random

static fun random(): MasterKey

Generate a new key using a random generator.