ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-core:89825] [Ruby trunk Bug#15309] ECB is broken
       [not found] <redmine.issue-15309.20181116015544@ruby-lang.org>
@ 2018-11-16  1:55 ` sevkme
  2018-11-16  1:56 ` [ruby-core:89826] " sevkme
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 4+ messages in thread
From: sevkme @ 2018-11-16  1:55 UTC (permalink / raw
  To: ruby-core

Issue #15309 has been reported by sevk (kk kk).

----------------------------------------
Bug #15309: ECB is broken
https://bugs.ruby-lang.org/issues/15309

* Author: sevk (kk kk)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: ruby 2.5.3p105 (2018-10-18 revision 65156) [x86_64-linux]
* Backport: 2.3: UNKNOWN, 2.4: UNKNOWN, 2.5: UNKNOWN
----------------------------------------
~~~ ruby
#!/usr/bin/env ruby                                                                         
require 'openssl'

# AES-128 ECB mode test vectors
KEY        = ["2b7e151628aed2a6abf7158809cf4f3c"].pack("H*")
PLAINTEXT  = ["6bc1bee22e409f96e93d7e117393172a"].pack("H*")
CIPHERTEXT = ["3ad77bb40d7a3660a89ecaf32466ef97"].pack("H*")

cipher = OpenSSL::Cipher::Cipher.new("aes-128-ecb")
cipher.key = KEY
cipher.padding = 0 # Padding is enabled by default o_O

puts "test encry: "
cipher.encrypt
ciphertext = cipher.update(PLAINTEXT) << cipher.final

if ciphertext == CIPHERTEXT
  puts "OK!"
else
  puts "FAILED!"
end

puts "test decry: "
cipher.reset
cipher.decrypt
plaintext = cipher.update(CIPHERTEXT) << cipher.final

if plaintext == PLAINTEXT
  puts "OK!"
else
  puts "FAILED!"
end

~~~




-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [ruby-core:89826] [Ruby trunk Bug#15309] ECB is broken
       [not found] <redmine.issue-15309.20181116015544@ruby-lang.org>
  2018-11-16  1:55 ` [ruby-core:89825] [Ruby trunk Bug#15309] ECB is broken sevkme
@ 2018-11-16  1:56 ` sevkme
  2019-03-20  5:19 ` [ruby-core:91892] " hsbt
  2019-07-29 22:37 ` [ruby-core:94002] [Ruby master " merch-redmine
  3 siblings, 0 replies; 4+ messages in thread
From: sevkme @ 2018-11-16  1:56 UTC (permalink / raw
  To: ruby-core

Issue #15309 has been updated by sevk (kk kk).



test encry: 
FAILED!
test decry: 
OK!


----------------------------------------
Bug #15309: ECB is broken
https://bugs.ruby-lang.org/issues/15309#change-74885

* Author: sevk (kk kk)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: ruby 2.5.3p105 (2018-10-18 revision 65156) [x86_64-linux]
* Backport: 2.3: UNKNOWN, 2.4: UNKNOWN, 2.5: UNKNOWN
----------------------------------------
~~~ ruby
#!/usr/bin/env ruby                                                                         
require 'openssl'

# AES-128 ECB mode test vectors
KEY        = ["2b7e151628aed2a6abf7158809cf4f3c"].pack("H*")
PLAINTEXT  = ["6bc1bee22e409f96e93d7e117393172a"].pack("H*")
CIPHERTEXT = ["3ad77bb40d7a3660a89ecaf32466ef97"].pack("H*")

cipher = OpenSSL::Cipher::Cipher.new("aes-128-ecb")
cipher.key = KEY
cipher.padding = 0 # Padding is enabled by default o_O

puts "test encry: "
cipher.encrypt
ciphertext = cipher.update(PLAINTEXT) << cipher.final

if ciphertext == CIPHERTEXT
  puts "OK!"
else
  puts "FAILED!"
end

puts "test decry: "
cipher.reset
cipher.decrypt
plaintext = cipher.update(CIPHERTEXT) << cipher.final

if plaintext == PLAINTEXT
  puts "OK!"
else
  puts "FAILED!"
end

~~~




-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [ruby-core:91892] [Ruby trunk Bug#15309] ECB is broken
       [not found] <redmine.issue-15309.20181116015544@ruby-lang.org>
  2018-11-16  1:55 ` [ruby-core:89825] [Ruby trunk Bug#15309] ECB is broken sevkme
  2018-11-16  1:56 ` [ruby-core:89826] " sevkme
@ 2019-03-20  5:19 ` hsbt
  2019-07-29 22:37 ` [ruby-core:94002] [Ruby master " merch-redmine
  3 siblings, 0 replies; 4+ messages in thread
From: hsbt @ 2019-03-20  5:19 UTC (permalink / raw
  To: ruby-core

Issue #15309 has been updated by hsbt (Hiroshi SHIBATA).

Assignee set to rhenium (Kazuki Yamaguchi)
Status changed from Open to Assigned

----------------------------------------
Bug #15309: ECB is broken
https://bugs.ruby-lang.org/issues/15309#change-77216

* Author: sevk (kk kk)
* Status: Assigned
* Priority: Normal
* Assignee: rhenium (Kazuki Yamaguchi)
* Target version: 
* ruby -v: ruby 2.0 2.2 2.3 2.4 2.5 2.6
* Backport: 2.3: UNKNOWN, 2.4: UNKNOWN, 2.5: UNKNOWN
----------------------------------------
~~~ ruby
#!/usr/bin/env ruby                                                                         
require 'openssl'

# AES-128 ECB mode test vectors
KEY        = ["2b7e151628aed2a6abf7158809cf4f3c"].pack("H*")
PLAINTEXT  = ["6bc1bee22e409f96e93d7e117393172a"].pack("H*")
CIPHERTEXT = ["3ad77bb40d7a3660a89ecaf32466ef97"].pack("H*")

cipher = OpenSSL::Cipher::Cipher.new("aes-128-ecb")
cipher.key = KEY
cipher.padding = 0 # Padding is enabled by default o_O

puts "test encrypt : "
cipher.encrypt
ciphertext = cipher.update(PLAINTEXT) << cipher.final

if ciphertext == CIPHERTEXT
  puts "OK!"
else
  puts "FAILED!"
end

puts "test decrypt : "
cipher.reset
cipher.decrypt
plaintext = cipher.update(CIPHERTEXT) << cipher.final

if plaintext == PLAINTEXT
  puts "OK!"
else
  puts "FAILED!"
end

~~~




-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [ruby-core:94002] [Ruby master Bug#15309] ECB is broken
       [not found] <redmine.issue-15309.20181116015544@ruby-lang.org>
                   ` (2 preceding siblings ...)
  2019-03-20  5:19 ` [ruby-core:91892] " hsbt
@ 2019-07-29 22:37 ` merch-redmine
  3 siblings, 0 replies; 4+ messages in thread
From: merch-redmine @ 2019-07-29 22:37 UTC (permalink / raw
  To: ruby-core

Issue #15309 has been updated by jeremyevans0 (Jeremy Evans).

Status changed from Assigned to Closed

This is because `encrypt` is called after `key`, which goes against the documentation.  It is not specific to ECB. This is fixed by https://github.com/ruby/openssl/pull/263, which raises an exception for this broken code instead of silently failing.

----------------------------------------
Bug #15309: ECB is broken
https://bugs.ruby-lang.org/issues/15309#change-80213

* Author: sevk (kk kk)
* Status: Closed
* Priority: Normal
* Assignee: rhenium (Kazuki Yamaguchi)
* Target version: 
* ruby -v: ruby 2.0 2.2 2.3 2.4 2.5 2.6
* Backport: 2.3: UNKNOWN, 2.4: UNKNOWN, 2.5: UNKNOWN
----------------------------------------
~~~ ruby
#!/usr/bin/env ruby                                                                         
require 'openssl'

# AES-128 ECB mode test vectors
KEY        = ["2b7e151628aed2a6abf7158809cf4f3c"].pack("H*")
PLAINTEXT  = ["6bc1bee22e409f96e93d7e117393172a"].pack("H*")
CIPHERTEXT = ["3ad77bb40d7a3660a89ecaf32466ef97"].pack("H*")

cipher = OpenSSL::Cipher::Cipher.new("aes-128-ecb")
cipher.key = KEY
cipher.padding = 0 # Padding is enabled by default o_O

puts "test encrypt : "
cipher.encrypt
ciphertext = cipher.update(PLAINTEXT) << cipher.final

if ciphertext == CIPHERTEXT
  puts "OK!"
else
  puts "FAILED!"
end

puts "test decrypt : "
cipher.reset
cipher.decrypt
plaintext = cipher.update(CIPHERTEXT) << cipher.final

if plaintext == PLAINTEXT
  puts "OK!"
else
  puts "FAILED!"
end

~~~




-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-07-29 22:38 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <redmine.issue-15309.20181116015544@ruby-lang.org>
2018-11-16  1:55 ` [ruby-core:89825] [Ruby trunk Bug#15309] ECB is broken sevkme
2018-11-16  1:56 ` [ruby-core:89826] " sevkme
2019-03-20  5:19 ` [ruby-core:91892] " hsbt
2019-07-29 22:37 ` [ruby-core:94002] [Ruby master " merch-redmine

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).