ktor-utils / io.ktor.util / StatelessHmacNonceManager

StatelessHmacNonceManager

class StatelessHmacNonceManager : NonceManager

Stateless nonce manager implementation with HMAC verification and timeout. Every nonce provided by this manager consist of a random part, timestamp and HMAC.

Constructors

<init>

StatelessHmacNonceManager(key: ByteArray, algorithm: String = "HmacSHA256", timeoutMillis: Long = 60000, nonceGenerator: () -> String = { generateNonce() })

Helper constructor that makes a secret key from key ByteArray

StatelessHmacNonceManager(keySpec: SecretKeySpec, algorithm: String = "HmacSHA256", timeoutMillis: Long = 60000, nonceGenerator: () -> String = { generateNonce() })

Stateless nonce manager implementation with HMAC verification and timeout. Every nonce provided by this manager consist of a random part, timestamp and HMAC.

Properties

algorithm

val algorithm: String

HMAC algorithm name, HmacSHA256 by default

keySpec

val keySpec: SecretKeySpec

secret key spec for HMAC

nonceGenerator

val nonceGenerator: () -> String

function that produces random values

timeoutMillis

val timeoutMillis: Long

specifies the amount of time for a nonce to be considered valid

Functions

newNonce

suspend fun newNonce(): String

Generate new nonce instance

verifyNonce

suspend fun verifyNonce(nonce: String): Boolean

Verify nonce value