# Null pointer iv with non-EBC block cipher

**URL:** <https://www.ruby-forum.com/t/null-pointer-iv-with-non-ebc-block-cipher/177367>\
**Category:** Ruby\
**Created:** [October 15, 2009, 7:23pm UTC](https://www.ruby-forum.com/t/null-pointer-iv-with-non-ebc-block-cipher/177367 "2009-10-15T19:23:52Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![dmarkow](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/bc8723/32.png) [@dmarkow](https://www.ruby-forum.com/u/dmarkow)\
**Post date:** [October 15, 2009, 7:23pm UTC](https://www.ruby-forum.com/t/null-pointer-iv-with-non-ebc-block-cipher/177367/1 "2009-10-15T19:23:52Z")

</div>

I’m not sure if this is an openssl problem with not checking for null  
before dereferencing pointers, but with ruby you can do the following  
cbc block cipher without specifying an IV:

require ‘openssl’  
key = “0599E113A7EE32A9”  
data =  
“1234567890~5J96LC303C1D22DD~20090930005944~http%3A%2F%2Flocalhost%3A8080%2Flogin%3B0%3B1~http%3A%2F%[2Fmix-stage.oracle.com](http://2Fmix-stage.oracle.com)%2F~00”

c1 = OpenSSL::Cipher::Cipher.new(“DES-CBC”)  
c1.padding = 0  
c1.encrypt  
c1.key = key  
e = c1.update data  
e \<\< c1.final

c2 = OpenSSL::Cipher::Cipher.new(“DES-CBC”)  
c2.padding = 0  
c2.decrypt  
c2.key = key  
d = c2.update e  
d \<\< c2.final

puts d

This works in MRI, but I don’t believe it should because the user didn’t  
specify an IV. IMHO, this is a bug. The responsibility may be openssl  
though for not raising the exception. Any thoughts?
