Skip to content

ConstantTimeCompare

[Source]

Return true if the two ByteSeqs have equal contents. The time taken is independent of the contents, so comparing a secret against a value an attacker supplies does not tell them where the two first differ.

if ConstantTimeCompare(expected_mac, supplied_mac) then
  // ...
end

Sequences of different sizes are not equal, and that is answered before any byte is read.

primitive val ConstantTimeCompare

Constructors

create

[Source]

new val create()
: ConstantTimeCompare val^

Returns


Public Functions

apply[optional S: ByteSeq box]

[Source]

fun box apply[optional S: ByteSeq box](
  xs: S,
  ys: S)
: Bool val

Parameters

  • xs: S
  • ys: S

Returns


eq

[Source]

fun box eq(
  that: ConstantTimeCompare val)
: Bool val

Parameters

Returns


ne

[Source]

fun box ne(
  that: ConstantTimeCompare val)
: Bool val

Parameters

Returns