Sha256: fb28120f33dc47d1135f2cb7006e3ab6d8b10a95e5588876046a53934400dcbb

Contents?: true

Size: 971 Bytes

Versions: 10

Compression:

Stored size: 971 Bytes

Contents

RSpec.describe Epics::Key do

  subject { described_class.new( File.read(File.join( File.dirname(__FILE__), 'fixtures', 'e002.pem'))) }

  describe '#public_digest' do

    it 'will calculate the digest as the specification suggests' do
      expect(subject.public_digest).to eq("rwIxSUJAVEFDQ0sdYe+CybdspMllDG6ArNtdCzUbT1E=")
    end
  end


  describe '#sign' do
    let(:dsi) { OpenSSL::Digest::SHA256.new.digest("ruby is great") }

    it 'will generated a digest that can be verified with openssl key.verify_pss' do
      signed_digest = subject.sign(dsi)

      key = subject.key

      verification_result = key.verify_pss(
                              'SHA256',
                              Base64.decode64(signed_digest),
                              dsi,
                              salt_length: :digest,
                              mgf1_hash:   'SHA256',
                            )

      expect(verification_result).to eq(true)
    end

  end


end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
epics-2.7.0 spec/key_spec.rb
epics-2.6.0 spec/key_spec.rb
epics-2.5.0 spec/key_spec.rb
epics-2.4.0 spec/key_spec.rb
epics-2.3.0 spec/key_spec.rb
epics-2.2.0 spec/key_spec.rb
epics-2.1.2 spec/key_spec.rb
epics-2.1.1 spec/key_spec.rb
epics-2.1.0 spec/key_spec.rb
epics-2.0.0 spec/key_spec.rb