Class: Sigstore::TUF::Root

Inherits:
Object
  • Object
show all
Includes:
Loggable
Defined in:
lib/sigstore/tuf/root.rb

Constant Summary collapse

TYPE =
"root"

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Loggable

included, #logger

Constructor Details

#initialize(data) ⇒ Root

Returns a new instance of Root.

Raises:



30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/sigstore/tuf/root.rb', line 30

def initialize(data)
  type = data.fetch("_type")
  raise Error::InvalidData, "Expected type to be #{TYPE}, got #{type.inspect}" unless type == TYPE

  @spec_version = data.fetch("spec_version") { raise Error::InvalidData, "root missing spec_version" }
  @consistent_snapshot = data.fetch("consistent_snapshot") do
    raise Error::InvalidData, "root missing consistent_snapshot"
  end
  @version = data.fetch("version") { raise Error::InvalidData, "root missing version" }
  @expires = Time.iso8601(data.fetch("expires") { raise Error::InvalidData, "root missing expires" })
  keys = Keys.new data.fetch("keys")
  @roles = Roles.new data.fetch("roles"), keys
  @unrecognized_fields = data.fetch("unrecognized_fields", {})
end

Instance Attribute Details

#consistent_snapshotObject (readonly)

Returns the value of attribute consistent_snapshot.



28
29
30
# File 'lib/sigstore/tuf/root.rb', line 28

def consistent_snapshot
  @consistent_snapshot
end

#expiresObject (readonly)

Returns the value of attribute expires.



28
29
30
# File 'lib/sigstore/tuf/root.rb', line 28

def expires
  @expires
end

#versionObject (readonly)

Returns the value of attribute version.



28
29
30
# File 'lib/sigstore/tuf/root.rb', line 28

def version
  @version
end

Instance Method Details

#expired?(reference_time) ⇒ Boolean

Returns:

  • (Boolean)


49
50
51
# File 'lib/sigstore/tuf/root.rb', line 49

def expired?(reference_time)
  @expires < reference_time
end

#verify_delegate(type, bytes, signatures) ⇒ Object



45
46
47
# File 'lib/sigstore/tuf/root.rb', line 45

def verify_delegate(type, bytes, signatures)
  @roles.verify_delegate(type, bytes, signatures)
end