Class LandmarkSequence

java.lang.Object
org.bouncycastle.cert.plants.LandmarkSequence

public final class LandmarkSequence extends Object
The published landmarks of a single issuance log, as defined by Section 6.4 of draft-ietf-plants-merkle-tree-certs.

A landmark consists of a landmark number, the tree size at the time it was allocated, and an expiration time in seconds since the POSIX Epoch (Section 6.4.1). Landmarks are numbered consecutively from zero; landmark 0 has tree size 0 and expiry 0, tree sizes are strictly increasing and expiries non-decreasing with the landmark number. A landmark that has not yet expired is active; landmark 0 never is. Each landmark has two landmark subtrees: the two subtrees of Section 4.5 that cover the entries added since the previous landmark, or [0, 0) twice for landmark 0.

A LandmarkSequence holds the window a CA publishes: the newest landmark, latest_landmark, and the consecutive landmarks below it down to at least one that has already expired. The published form (Section 6.4.3) is plain text, each line terminated by U+000A:

<latest_landmark>
<tree_size of landmark latest_landmark> <expiry of landmark latest_landmark>
<tree_size of landmark latest_landmark - 1> <expiry of landmark latest_landmark - 1>
...

Tree sizes are strictly decreasing and expiries non-increasing down the document, and the document must reach an expired landmark so that the active set is delimited. The draft-05 form, with a num_active_landmarks count in the header and no expiry times, is no longer read or written.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final long
    The largest landmark number or tree size the published form may carry, 2^48 - 1.
  • Constructor Summary

    Constructors
    Constructor
    Description
    LandmarkSequence(long latestLandmark, long[] treeSizesNewestFirst, long[] expiriesNewestFirst)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    List<long[]>
    Returns the active landmark subtrees as of the current time, oldest landmark first; see activeLandmarkSubtrees(long).
    List<long[]>
    activeLandmarkSubtrees(long nowSeconds)
    Returns the active landmark subtrees as of nowSeconds (Section 6.4.1): the two landmark subtrees of every landmark in the published window that has not yet expired and whose predecessor is also in the window, ordered oldest landmark first.
    Serializes the landmarks in the format defined by Section 6.4.3 (each line terminated with U+000A).
    long
    getExpiry(long landmarkNumber)
     
    long
     
    int
     
    long
     
    long
    getTreeSize(long landmarkNumber)
     
    boolean
    isActive(long landmarkNumber, long nowSeconds)
     
    long
    landmarkFor(long index)
    Finds the landmark a landmark-relative certificate for entry index is constructed against (Section 6.4.4 step 2): the lowest numbered landmark whose tree size is greater than index.
    long[]
    landmarkSubtreeFor(long index)
    Finds the landmark subtree a landmark-relative certificate for entry index is constructed against (Section 6.4.4 steps 2 and 3): the one of its landmark's two subtrees whose interval contains index.
    List<long[]>
    landmarkSubtrees(long landmarkNumber)
    Returns the two landmark subtrees of a landmark (Section 6.4.1): the subtrees of Section 4.5 covering the entries between the previous landmark's tree size and this one's, or [0, 0) twice for landmark 0.
    parse(String text)
    Parses a published landmark document (Section 6.4.3), requiring at least one landmark to have expired as of the current time.
    parse(String text, long nowSeconds)
    Parses a published landmark document (Section 6.4.3).

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • MAX_VALUE

      public static final long MAX_VALUE
      The largest landmark number or tree size the published form may carry, 2^48 - 1.
      See Also:
  • Constructor Details

    • LandmarkSequence

      public LandmarkSequence(long latestLandmark, long[] treeSizesNewestFirst, long[] expiriesNewestFirst)
      Parameters:
      latestLandmark - the landmark number of the newest landmark
      treeSizesNewestFirst - tree sizes for landmarks latestLandmark down to latestLandmark - n + 1; strictly decreasing
      expiriesNewestFirst - expiry times, in seconds since the Epoch, for the same landmarks in the same order; non-increasing
  • Method Details

    • parse

      public static LandmarkSequence parse(String text) throws IOException
      Parses a published landmark document (Section 6.4.3), requiring at least one landmark to have expired as of the current time.
      Throws:
      IOException - if the document does not strictly conform
    • parse

      public static LandmarkSequence parse(String text, long nowSeconds) throws IOException
      Parses a published landmark document (Section 6.4.3). The document must strictly conform: a header line holding latest_landmark, then one line per landmark of <tree_size> <expiry>, every line terminated by U+000A, no other whitespace, strictly decreasing tree sizes, non-increasing expiry times, and at least one expiry before nowSeconds.
      Parameters:
      text - the document
      nowSeconds - the current time in seconds since the Epoch
      Throws:
      IOException - if the document does not strictly conform
    • format

      public String format()
      Serializes the landmarks in the format defined by Section 6.4.3 (each line terminated with U+000A).
    • getLastLandmark

      public long getLastLandmark()
      Returns:
      latest_landmark, the landmark number of the newest landmark.
    • getOldestLandmark

      public long getOldestLandmark()
      Returns:
      the number of the oldest landmark this sequence holds.
    • getNumActiveLandmarks

      public int getNumActiveLandmarks()
      Returns:
      the number of landmarks published beyond the terminating one, that is num_active_landmarks as of publication (Section 6.4.3)
    • getTreeSize

      public long getTreeSize(long landmarkNumber)
      Returns:
      the tree size of the landmark with the given number.
    • getExpiry

      public long getExpiry(long landmarkNumber)
      Returns:
      the expiry time of the landmark with the given number, in seconds since the Epoch.
    • isActive

      public boolean isActive(long landmarkNumber, long nowSeconds)
      Returns:
      whether the landmark is active at nowSeconds, that is not yet expired (Section 6.4.1); landmark 0 is never active
    • landmarkSubtrees

      public List<long[]> landmarkSubtrees(long landmarkNumber)
      Returns the two landmark subtrees of a landmark (Section 6.4.1): the subtrees of Section 4.5 covering the entries between the previous landmark's tree size and this one's, or [0, 0) twice for landmark 0. The previous landmark must be within the published window.
      Returns:
      the two subtrees as {start, end} pairs, left then right
    • activeLandmarkSubtrees

      public List<long[]> activeLandmarkSubtrees()
      Returns the active landmark subtrees as of the current time, oldest landmark first; see activeLandmarkSubtrees(long).
    • activeLandmarkSubtrees

      public List<long[]> activeLandmarkSubtrees(long nowSeconds)
      Returns the active landmark subtrees as of nowSeconds (Section 6.4.1): the two landmark subtrees of every landmark in the published window that has not yet expired and whose predecessor is also in the window, ordered oldest landmark first. These are the subtrees a relying party predistributes as trusted (Section 7.4).
    • landmarkFor

      public long landmarkFor(long index)
      Finds the landmark a landmark-relative certificate for entry index is constructed against (Section 6.4.4 step 2): the lowest numbered landmark whose tree size is greater than index.
      Returns:
      the landmark number, or -1 if no published landmark contains the entry yet
    • landmarkSubtreeFor

      public long[] landmarkSubtreeFor(long index)
      Finds the landmark subtree a landmark-relative certificate for entry index is constructed against (Section 6.4.4 steps 2 and 3): the one of its landmark's two subtrees whose interval contains index.
      Returns:
      the subtree as a {start, end} pair, or null if no published landmark contains the entry yet or the landmark's predecessor is outside the published window