Class: Origami::Signature::PKCS1

Inherits:
Object
  • Object
show all
Defined in:
lib/origami/signature.rb

Overview

PKCS1 class used for adbe.x509.rsa_sha1.

Defined Under Namespace

Classes: PKCS1Error

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(signature) ⇒ PKCS1



350
351
352
# File 'lib/origami/signature.rb', line 350

def initialize(signature)
  @signature_object = decode_pkcs1(signature)
end

Class Method Details

.sign(certificate, key, data) ⇒ Object

Raises:



358
359
360
361
362
# File 'lib/origami/signature.rb', line 358

def self.sign(certificate, key, data)
  raise PKCS1Error, "Invalid key for certificate" unless certificate.check_private_key(key)

  new encode_pkcs1 key.sign(OpenSSL::Digest.new('SHA1'), data)
end

Instance Method Details

#to_derObject



364
365
366
# File 'lib/origami/signature.rb', line 364

def to_der
  @signature_object.to_der
end

#verify(certificate, chain, store, data) ⇒ Object



354
355
356
# File 'lib/origami/signature.rb', line 354

def verify(certificate, chain, store, data)
  store.verify(certificate, chain) and certificate.public_key.verify(OpenSSL::Digest.new('SHA1'), @signature_object.value, data)
end