Mac

class Mac(@NotNull val macMode: MacModes) : KipherProvider

Data authenticity and integrity checks using Keyed hash-based message authentication code (HMACs).

Constructors

Link copied to clipboard
constructor(@NotNull macMode: MacModes)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

MacModes to be used for HMAC operations.

Functions

Link copied to clipboard
fun generateKey(@Nullable keyLength: Int? = macMode.keySize): ByteArray

Generate a key based on current macMode.mode, or by providing a custom keyLength.

Link copied to clipboard
fun generateMac(@NotNull data: ByteArray, @NotNull key: ByteArray): ByteArray

Generate HMAC for data using provided key.

fun generateMac(@NotNull data: Iterable<ByteArray>, @NotNull key: ByteArray): ByteArray

Generate HMAC for multiple data using provided key.

Link copied to clipboard
fun generateMacString(@NotNull data: ByteArray, @NotNull key: ByteArray): String

Generate HMAC for data using provided key in string format.

fun generateMacString(@NotNull data: Iterable<ByteArray>, @NotNull key: ByteArray): String

Generate HMAC for multiple data using provided key in string format.

Link copied to clipboard
fun verifyMac(@NotNull data: ByteArray, @NotNull expected: ByteArray, @NotNull key: ByteArray): Boolean
fun verifyMac(@NotNull data: ByteArray, @NotNull expected: String, @NotNull key: ByteArray): Boolean
fun verifyMac(@NotNull data: Iterable<ByteArray>, @NotNull expected: ByteArray, @NotNull key: ByteArray): Boolean

Verify if data matches expected hash using provided key.

fun verifyMac(@NotNull data: Iterable<ByteArray>, @NotNull expected: String, @NotNull key: ByteArray): Boolean

Verify if multiple data matches expected hash using provided key.