Skip to main content

Module checksum

Module checksum 

Source
Expand description

The checksum that proves a snapshot reached the server as the server sent it, and the rate limit that stops a client which keeps sending corrupt ones.

The signature is HMAC-SHA256, in lowercase hex, under the application’s encryption key, over Snapshot::signed_bytes. The child list is outside the signature because the browser rewrites it while morphing the DOM; every other part of the envelope is covered.

Constants§

MAX_FAILURES
How many corrupt snapshots one client may send before the rate limit stops it.

Functions§

ensure_allowed
Fails with TooManyChecksumFailures when the client is over the limit.
limit
Ten failures in ten minutes.
rate_limit_key
The cache key of one client, livewire-checksum-failures:{ip}.
record_failure
Counts one corrupt snapshot for the client.
reset
Forgets a client’s failures, which the tests use.
sign
Signs the snapshot’s signed_bytes() under the application’s encryption key.
verify
Whether the snapshot’s checksum matches, compared in constant time.
verify_or_error
Verifies or fails with LivewireError::CorruptPayload.