Class: Sigstore::VerificationInput
- Inherits:
-
Verification::V1::Input
- Object
- Verification::V1::Input
- Sigstore::VerificationInput
- Defined in:
- lib/sigstore/models.rb
Instance Attribute Summary collapse
-
#hashed_input ⇒ Object
readonly
Returns the value of attribute hashed_input.
-
#sbundle ⇒ Object
readonly
Returns the value of attribute sbundle.
-
#trusted_root ⇒ Object
readonly
Returns the value of attribute trusted_root.
Instance Method Summary collapse
-
#initialize ⇒ VerificationInput
constructor
A new instance of VerificationInput.
Constructor Details
#initialize ⇒ VerificationInput
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/sigstore/models.rb', line 81 def initialize(*) super unless bundle.is_a?(Bundle::V1::Bundle) raise ArgumentError, "bundle must be a #{Bundle::V1::Bundle}, is #{bundle.class}" end @trusted_root = TrustedRoot.new(artifact_trust_root) @sbundle = SBundle.new(bundle) if sbundle. && !artifact raise Error::InvalidVerificationInput, "bundle with message_signature requires an artifact" end case artifact.data when :artifact_uri unless artifact.artifact_uri.start_with?("sha256:") raise Error::InvalidVerificationInput, "artifact_uri must be prefixed with 'sha256:'" end @hashed_input = Common::V1::HashOutput.new.tap do |hash_output| hash_output.algorithm = Common::V1::HashAlgorithm::SHA2_256 hexdigest = artifact.artifact_uri.split(":", 2).last hash_output.digest = Internal::Util.hex_decode(hexdigest) end when :artifact @hashed_input = Common::V1::HashOutput.new.tap do |hash_output| hash_output.algorithm = Common::V1::HashAlgorithm::SHA2_256 hash_output.digest = OpenSSL::Digest.new("SHA256").update(artifact.artifact).digest end else raise Error::InvalidVerificationInput, "Unsupported artifact data: #{artifact.data}" end freeze end |
Instance Attribute Details
#hashed_input ⇒ Object (readonly)
Returns the value of attribute hashed_input.
79 80 81 |
# File 'lib/sigstore/models.rb', line 79 def hashed_input @hashed_input end |
#sbundle ⇒ Object (readonly)
Returns the value of attribute sbundle.
79 80 81 |
# File 'lib/sigstore/models.rb', line 79 def sbundle @sbundle end |
#trusted_root ⇒ Object (readonly)
Returns the value of attribute trusted_root.
79 80 81 |
# File 'lib/sigstore/models.rb', line 79 def trusted_root @trusted_root end |