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

Returns a new instance of PKCS1.



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

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

Class Method Details

.sign(certificate, key, data) ⇒ Object

Raises:



366
367
368
369
370
# File 'lib/origami/signature.rb', line 366

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

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

Instance Method Details

#to_derObject



372
373
374
# File 'lib/origami/signature.rb', line 372

def to_der
    @signature_object.to_der
end

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



362
363
364
# File 'lib/origami/signature.rb', line 362

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