Class: Sigstore::Internal::Key::ED25519
- Inherits:
-
Sigstore::Internal::Key
- Object
- Sigstore::Internal::Key
- Sigstore::Internal::Key::ED25519
- Defined in:
- lib/sigstore/internal/key.rb
Instance Attribute Summary
Attributes inherited from Sigstore::Internal::Key
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ ED25519
constructor
A new instance of ED25519.
- #verify(_algo, signature, data) ⇒ Object
Methods inherited from Sigstore::Internal::Key
from_key_details, #public_to_der, read, #to_der, #to_pem
Methods included from Loggable
Constructor Details
#initialize ⇒ ED25519
Returns a new instance of ED25519.
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 |
# File 'lib/sigstore/internal/key.rb', line 157 def initialize(...) super unless @key_type == "ed25519" raise ArgumentError, "key_type must be ed25519, given #{@key_type}" end unless @key.is_a?(OpenSSL::PKey::PKey) && @key.oid == "ED25519" raise ArgumentError, "key must be an OpenSSL::PKey::PKey with oid ED25519, is #{@key.inspect}" end raise ArgumentError, "schema must be #{schema}" unless @schema == schema case @schema when "ed25519" # supported else raise ArgumentError, "Unsupported schema #{schema}" end end |
Class Method Details
.pkey_from_der(raw) ⇒ Object
144 145 146 147 148 149 150 151 152 153 154 155 |
# File 'lib/sigstore/internal/key.rb', line 144 def self.pkey_from_der(raw) if OpenSSL::PKey.respond_to?(:new_raw_public_key) OpenSSL::PKey.new_raw_public_key("ed25519", raw) else pem = <<~PEM -----BEGIN PUBLIC KEY----- MCowBQYDK2VwAyEA#{Internal::Util.base64_encode(raw)} -----END PUBLIC KEY----- PEM OpenSSL::PKey.read(pem) end end |
Instance Method Details
#verify(_algo, signature, data) ⇒ Object
177 178 179 |
# File 'lib/sigstore/internal/key.rb', line 177 def verify(_algo, signature, data) super(nil, signature, data) end |