Sha256: d6ed039731eba0a2cfb805bc544c6900d9c100ca27057190393541e318db5fc6

Contents?: true

Size: 1.09 KB

Versions: 26

Compression:

Stored size: 1.09 KB

Contents

require 'spec_helper'

describe Xmlenc::Algorithms::RsaOaepMgf1p do
  let(:private_key) { OpenSSL::PKey::RSA.new(File.read('spec/fixtures/key.pem')) }
  let(:public_key) { private_key.public_key }
  let(:cipher_value) { Base64.decode64 "W6N0IhRF2AdgfzzkZSp/u1kH5KmH8L4W8k4mdNMboLsYgnBUV3lsRvoFrVTX\nluMVDtXY1ju7aAEUJP9eMRU676kvRR5nSVuAbWCAejgkHMtGShJHU1s/JMzb\nu3iaxsuyPosT7/iafinNIXumvqLM/WQl9KbsmcWoAmJISbK1+WJ2kahrXNav\n4+7vMJq90BOPl8bXIzeKIsps7OGwEvrFaJ5RzVjZXi9SDXXD1vd6tJBcCfcZ\n347Mat1tZkR3cYrCMhDdte3gYGUQLzUlMYucvWz1slzTX3rYea/vhgA+OLOp\ndZxwM4igx1d8j5jjmo8FR1rxwd0G4NHA1bZ6TOy/IA==\n" }
  let(:key) { %w(1e8c108fc0521dcad99ff2daad45af64).pack("H*") }


  describe 'decrypt' do
    subject { described_class.new(private_key) }

    it 'decrypts the cipher value' do
      expect(subject.decrypt(cipher_value)).to be == key
    end
  end

  describe 'encrypt' do
    subject { described_class.new(public_key) }

    it 'encrypts the key' do
      encrypted = subject.encrypt(key)
      expect(private_key.private_decrypt(encrypted, OpenSSL::PKey::RSA::PKCS1_OAEP_PADDING)).to be == key
    end
  end
end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
xmlenc-0.8.0 spec/lib/xmlenc/algorithms/rsa_oaep_mgf1p_spec.rb
xmlenc-0.7.1 spec/lib/xmlenc/algorithms/rsa_oaep_mgf1p_spec.rb
xmlenc-0.7.0 spec/lib/xmlenc/algorithms/rsa_oaep_mgf1p_spec.rb
xmlenc-0.6.9 spec/lib/xmlenc/algorithms/rsa_oaep_mgf1p_spec.rb
xmlenc-0.6.8 spec/lib/xmlenc/algorithms/rsa_oaep_mgf1p_spec.rb
xmlenc-0.6.6 spec/lib/xmlenc/algorithms/rsa_oaep_mgf1p_spec.rb
xmlenc-0.6.5 spec/lib/xmlenc/algorithms/rsa_oaep_mgf1p_spec.rb
xmlenc-0.6.4 spec/lib/xmlenc/algorithms/rsa_oaep_mgf1p_spec.rb
xmlenc-0.6.3 spec/lib/xmlenc/algorithms/rsa_oaep_mgf1p_spec.rb
xmlenc-0.6.2 spec/lib/xmlenc/algorithms/rsa_oaep_mgf1p_spec.rb
xmlenc-0.6.1 spec/lib/xmlenc/algorithms/rsa_oaep_mgf1p_spec.rb
xmlenc-0.6.0 spec/lib/xmlenc/algorithms/rsa_oaep_mgf1p_spec.rb
xmlenc-0.5.0 spec/lib/xmlenc/algorithms/rsa_oaep_mgf1p_spec.rb
xmlenc-0.4.1 spec/lib/xmlenc/algorithms/rsa_oaep_mgf1p_spec.rb
xmlenc-0.4.0 spec/lib/xmlenc/algorithms/rsa_oaep_mgf1p_spec.rb
xmlenc-0.3.0 spec/lib/xmlenc/algorithms/rsa_oaep_mgf1p_spec.rb
xmlenc-0.2.1 spec/lib/xmlenc/algorithms/rsa_oaep_mgf1p_spec.rb
xmlenc-0.2.0 spec/lib/xmlenc/algorithms/rsa_oaep_mgf1p_spec.rb
xmlenc-0.1.7 spec/lib/xmlenc/algorithms/rsa_oaep_mgf1p_spec.rb
xmlenc-0.1.6 spec/lib/xmlenc/algorithms/rsa_oaep_mgf1p_spec.rb