Commit 0ccdd16

mokha <mo@mokhan.ca>
2018-12-02 23:17:14
use the proper iv len for each algorithm
1 parent 81fa3ac
Changed files (2)
spec/support/shell_helper.rb
@@ -5,6 +5,7 @@ require 'English'
 RSpec.configure do |config|
   config.include(Module.new do
     def execute_shell(command)
+      puts command
       puts `#{command}`
       raise "command failed (#{$CHILD_STATUS}): #{command}" unless $CHILD_STATUS.success?
     end
spec/xml/kit/crypto/symmetric_cipher_spec.rb
@@ -12,7 +12,8 @@ RSpec.describe ::Xml::Kit::Crypto::SymmetricCipher do
       let(:openssl_algorithm) { Xml::Kit::Crypto::SymmetricCipher::ALGORITHMS[xml_algorithm].downcase }
       let(:bytes_length) { bit_length / 8 }
       let(:key) { SecureRandom.random_bytes(bytes_length) }
-      let(:iv) { SecureRandom.random_bytes(bytes_length) }
+      let(:iv) { SecureRandom.random_bytes(cipher.iv_len) }
+      let(:cipher) { OpenSSL::Cipher.new(openssl_algorithm) }
 
       describe 'encrypting and decrypting' do
         subject { described_class.new(xml_algorithm, key) }