Skip to content

Commit

Permalink
Ruby 3.0's openssl does not support the des3-wrap cipher.
Browse files Browse the repository at this point in the history
  • Loading branch information
postmodern committed Aug 9, 2024
1 parent 8f4c5f8 commit 4df9014
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 32 deletions.
39 changes: 21 additions & 18 deletions spec/crypto/cipher/des3_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,27 @@
expect(subject.name).to eq("DES-EDE3-CBC")
end

context "when given the mode: keyword argument" do
let(:mode) { :wrap }
let(:key) { "A" * 24 }

subject do
described_class.new(
direction: :encrypt,
mode: mode,
key: key
)
end

it "must set #mode" do
expect(subject.mode).to eq(mode)
end

it "must initialize an DES3 cipher with the mode and direction" do
expect(subject.name).to eq("DES3-#{mode.upcase}")
# NOTE: Ruby 3.0's openssl does not support des3-wrap
if RUBY_VERSION >= '3.1.0'
context "when given the mode: keyword argument" do
let(:mode) { :wrap }
let(:key) { "A" * 24 }

subject do
described_class.new(
direction: :encrypt,
mode: mode,
key: key
)
end

it "must set #mode" do
expect(subject.mode).to eq(mode)
end

it "must initialize an DES3 cipher with the mode and direction" do
expect(subject.name).to eq("DES3-#{mode.upcase}")
end
end
end
end
Expand Down
17 changes: 10 additions & 7 deletions spec/crypto/mixin_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -144,15 +144,18 @@
expect(new_cipher.name).to eq("DES-EDE3-CBC")
end

context "when the mode: keyword argument is given" do
let(:mode) { :wrap }
# NOTE: Ruby 3.0's openssl does not support des3-wrap
if RUBY_VERSION >= '3.1.0'
context "when the mode: keyword argument is given" do
let(:mode) { :wrap }

it "must use the given mode" do
new_cipher = subject.crypto_des3_cipher(mode: mode,
direction: direction,
key: key)
it "must use the given mode" do
new_cipher = subject.crypto_des3_cipher(mode: mode,
direction: direction,
key: key)

expect(new_cipher.name).to eq("DES3-#{mode.upcase}")
expect(new_cipher.name).to eq("DES3-#{mode.upcase}")
end
end
end
end
Expand Down
17 changes: 10 additions & 7 deletions spec/crypto_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -153,15 +153,18 @@
expect(new_cipher.name).to eq("DES-EDE3-CBC")
end

context "when the mode: keyword argument is given" do
let(:mode) { :wrap }
# NOTE: Ruby 3.0's openssl does not support des3-wrap
if RUBY_VERSION >= '3.1.0'
context "when the mode: keyword argument is given" do
let(:mode) { :wrap }

it "must use the given mode" do
new_cipher = subject.des3_cipher(mode: mode,
direction: direction,
key: key)
it "must use the given mode" do
new_cipher = subject.des3_cipher(mode: mode,
direction: direction,
key: key)

expect(new_cipher.name).to eq("DES3-#{mode.upcase}")
expect(new_cipher.name).to eq("DES3-#{mode.upcase}")
end
end
end
end
Expand Down

0 comments on commit 4df9014

Please sign in to comment.