Skip to content

Latest commit

 

History

History
44 lines (33 loc) · 1.13 KB

README.md

File metadata and controls

44 lines (33 loc) · 1.13 KB

Module kmac

Kmac implementations for Keccak-based Message Authentication Codes

Implementations for:

  • KMAC128
  • KMAC256

See HERE for basic usage example of Mac.

// Using CryptoRand from KotlinCrypto/random repo as an example
import org.kotlincrypto.random.CryptoRand
// ...

fun main() {
    val key = CryptoRand.Default.nextBytes(ByteArray(100))

    // NIST.SP.800-185 derived functions
    val S = "My Customization".encodeToByteArray()

    // Macs
    KMAC128(key)
    // Return 123 bytes instead of the default
    // whenever doFinal() is called.
    KMAC256(key, S, outputLength = 123)
}

See HERE for basic usage example of Xof (i.e. Extendable-Output Functions).

fun main() {
    // NIST.SP.800-185 derived functions
    val S = "My Customization".encodeToByteArray()

    val xof: Xof<KMAC128> = KMAC128.xOf(key, S)
    KMAC256.xOf(key)
}