Class StateSealer.Builder

java.lang.Object
com.revetsec.StateSealer.Builder
Enclosing class:
StateSealer

@NotThreadSafe @CheckReturnValue public static final class StateSealer.Builder extends Object
Builds a StateSealer.

build() checks the keys together and runs a self-test: it seals and opens a fixed value with the active key, checks that an altered copy does not open and that the value does not open under another context, and checks that a fixed input seals to its known bytes.

Since:
1.0.0
Author:
Mark Allen
  • Method Details

    • verificationKeys

      Sets the keys that open values sealed earlier under other keys, such as the previous active key during a rotation. They never seal.
      Parameters:
      verificationKeys - at most 16 keys, each with its own key ID and its own key bytes, none of them the active key; null restores the default, none. The list is copied
      Returns:
      this builder
      Throws:
      NullPointerException - if the list contains null
      Since:
      1.0.0
    • clock

      Sets the clock that supplies the current time for sealing and opening.
      Parameters:
      clock - the clock; null restores the default, Clock.systemUTC()
      Returns:
      this builder
      Since:
      1.0.0
    • maximumSealedLength

      Sets the longest sealed value, in characters, that seal returns and unsealResult decodes. Also bounds each newly emitted WebAuthn store-record chunk. Historical WebAuthn framed-record opening retains its fixed 16,384-character chunk ceiling when this emission setting is lowered; authentication, expiry, record framing and admitted-time checks still apply.
      Parameters:
      maximumSealedLength - from 1,024 to 16,384; null restores the default, 3,800. build() checks the range
      Returns:
      this builder
      Since:
      1.0.0
    • build

      Builds the sealer.
      Returns:
      a new sealer
      Throws:
      IllegalArgumentException - if the maximum sealed length is out of range, there are more than 16 verification keys, or two keys share a key ID or key bytes
      IllegalStateException - if the platform's cryptographic provider refuses HMAC-SHA256 or AES-GCM, cannot supply random bytes, or fails the self-test
      Since:
      1.0.0