<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">
  <channel>
    <title>Dieter Vanden Eynde</title>
    <link>http://www.dieterve.be</link>
    <description>Dieter Vanden Eynde Feed</description>
    <language>en-us</language>
    <generator>Symphony (build )</generator>
    
    <atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/dieterve" /><feedburner:info uri="dieterve" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
      <title>0-byte bugfix for perl blowfish package</title>
      <link>http://feedproxy.google.com/~r/dieterve/~3/bHKRtKQl5Dw/</link>
      <pubDate>Mon, 24 May 2010 14:50 +0100</pubDate>
      <guid isPermaLink="false">http://www.dieterve.be/article/0-byte-bugfix-for-perl-blowfish-package/</guid>
      <description>&lt;p&gt;I found a small bug in the &lt;a href="/article/using-blowfish-on-irc-via-perl"&gt;blowfish package&lt;/a&gt; I published a while back, more specifically in the decrypting method. Blowfish works with a &lt;a href="http://en.wikipedia.org/wiki/Block_size_%28cryptography%29"&gt;block size&lt;/a&gt; of 8 bytes (64 bits), if the package does not have enough bytes to fill 8 bytes it will fill the missing bytes with 0-bytes. In a &lt;a href="http://en.wikipedia.org/wiki/ASCII"&gt;ASCII&lt;/a&gt; context 8 bytes means 8 characters, meaning the any string length that cannot be divided by 8 will have 0-bytes as suffix. When outputting the decrypted string you will not see anything wrong but when doing checks (regular expressions for example) you will get incorrect results.&lt;/p&gt;

&lt;p&gt;The new version fixes this 0-byte bug.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Download:&lt;/strong&gt; &lt;a href="/downloads/Blowfish_v1_0_1.pm.zip"&gt;Blowfish_v1_0_1.pm.zip&lt;/a&gt; (1,6K)&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/dieterve/~4/bHKRtKQl5Dw" height="1" width="1"/&gt;</description>
    <feedburner:origLink>http://www.dieterve.be/article/0-byte-bugfix-for-perl-blowfish-package/</feedburner:origLink></item>
    <item>
      <title>Using blowfish on IRC via perl</title>
      <link>http://feedproxy.google.com/~r/dieterve/~3/xarVQnxk7B8/</link>
      <pubDate>Thu, 25 Feb 2010 19:39 +0100</pubDate>
      <guid isPermaLink="false">http://www.dieterve.be/article/using-blowfish-on-irc-via-perl/</guid>
      <description>&lt;p&gt;Security is a big issue nowadays and if you are a frequent &lt;a href="http://en.wikipedia.org/wiki/Internet_Relay_Chat"&gt;IRC&lt;/a&gt; user like me, its not always easy to chat securely. Luckily most servers support &lt;a href="http://en.wikipedia.org/wiki/SSL"&gt;SSL&lt;/a&gt; connections but not all. For the ones that don&amp;#8217;t support it or for the people that are completely paranoid there is another way to encrypt your communication which is the &lt;a href="http://en.wikipedia.org/wiki/Blowfish_%28cipher%29"&gt;blowfish&lt;/a&gt; algorithm. This algorithm will encrypt your data using a secret key. A second party can decrypt it using the same secret key. For IRC there is a plugin called &lt;a href="http://fish.secure.la/"&gt;fish&lt;/a&gt; which can be used by several IRC clients.&lt;/p&gt;

&lt;p&gt;My problem was that my IRC bot didn&amp;#8217;t support blowfish so it couldn&amp;#8217;t be used in encrypted channels. There isn&amp;#8217;t a straight forward package in Perl (my bot is written in perl) for encrypting/decrypting blowfish on IRC so I had to fabricate one. The package is available below.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Usage:&lt;/strong&gt;&lt;/p&gt;

&lt;pre class="brush: perl;"&gt;
    # package
    use Blowfish;
    
    # encrypt
    my $encrypted = Blowfish::encrypt('this is plaintext', 'secret_key');
    
    # decrypt
    my $decrypted = Blowfish::decrypt($encrypted, 'secret_key');

    # prints 'hwwnV0UVbDE1z2N0E0AZlBT/Mi965/OLpHf/'
    print $encrypted ."\n";
    
    # prints 'this is plaintext'
    print $decrypted ."\n";

    # send to irc channel
    print $ircSocket 'PRIVMSG #channel :+OK'. $encrypted;
&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt; Fixed a bug when decrypting, &lt;a href="/article/0-byte-bugfix-for-perl-blowfish-package"&gt;more details&lt;/a&gt;&lt;br /&gt;
&lt;strong&gt;Download:&lt;/strong&gt; &lt;a href="/downloads/Blowfish_v1_0_1.pm.zip"&gt;Blowfish_v1_0_1.pm.zip&lt;/a&gt; (1,6K)&lt;/p&gt;

&lt;p&gt;Suggestions and &lt;a href="/contact"&gt;feedback&lt;/a&gt; are more then welcome!&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/dieterve/~4/xarVQnxk7B8" height="1" width="1"/&gt;</description>
    <feedburner:origLink>http://www.dieterve.be/article/using-blowfish-on-irc-via-perl/</feedburner:origLink></item>
    <item>
      <title>Reading and writing simultaneously on a socket in Perl</title>
      <link>http://feedproxy.google.com/~r/dieterve/~3/Ze5LCzUDhTY/</link>
      <pubDate>Sat, 23 Jan 2010 20:46 +0100</pubDate>
      <guid isPermaLink="false">http://www.dieterve.be/article/reading-and-writing-simultaneously-on-a-socket-in-perl/</guid>
      <description>&lt;p&gt;&lt;img src="/workspace/art-img/perl.png" alt="Perl" class="right" /&gt;If you want to read and write simultaneously on a socket in Perl you have to set the socket to &lt;a href="http://en.wikipedia.org/wiki/Non-blocking_synchronization"&gt;non-blocking&lt;/a&gt; mode. A socket is by default exclusive to reading OR writing. This means you can not write to a socket while you are reading from it.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://search.cpan.org/~gbarr/IO-1.25/lib/IO/Socket/INET.pm"&gt;IO::Socket::INET&lt;/a&gt; has a parameter &amp;#8220;blocking&amp;#8221; which should handle this but that didn&amp;#8217;t work for me. However the &lt;a href="http://www.google.be/"&gt;search engine&lt;/a&gt; concept proved its purpose again and the following saved me:&lt;/p&gt;

&lt;pre class="brush: perl;"&gt;
# Create socket
my $sock = new IO::Socket::INET(PeerAddr    =&gt; 'localhost',
                                PeerPort    =&gt; '8080',
                                Proto       =&gt; 'tcp') or
                                    die "Can't connect to server: $!";

# Nonblocking mode
my $nonBlocking = 1;
ioctl($sock, 0x8004667e, \$nonBlocking);

# Read and write
...
&lt;/pre&gt;

&lt;p&gt;Create your socket and after that use the &lt;a href="http://en.wikipedia.org/wiki/Ioctl"&gt;ioctl&lt;/a&gt; function to manipulate it. Important is that you pass the variable by reference. Setting the argument directly or without reference does not work.&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/dieterve/~4/Ze5LCzUDhTY" height="1" width="1"/&gt;</description>
    <feedburner:origLink>http://www.dieterve.be/article/reading-and-writing-simultaneously-on-a-socket-in-perl/</feedburner:origLink></item>
    <item>
      <title>Salting passwords</title>
      <link>http://feedproxy.google.com/~r/dieterve/~3/WxO5EV_Fi_U/</link>
      <pubDate>Tue, 01 Dec 2009 14:50 +0100</pubDate>
      <guid isPermaLink="false">http://www.dieterve.be/article/salting-passwords/</guid>
      <description>&lt;p&gt;&lt;img src="/workspace/art-img/saltshaker.jpg" alt="Salt" class="right" /&gt; I wrote an article about this a few years ago but since I don&amp;#8217;t have a backup of old articles I might aswel write a new version with new information. To get started: What is salting passwords? Wikipedia has a &lt;a href="http://en.wikipedia.org/wiki/Salt_%28cryptography%29"&gt;detailed explanation&lt;/a&gt; for it but in short it means adding a prefix/suffix to your user passwords making them more complex without forcing users to use complexer passwords.&lt;/p&gt;

&lt;h3&gt;Example&lt;/h3&gt;

&lt;p&gt;User A has a password &amp;#8220;hello&amp;#8221;. This is a very simple password, a cracker/hacker/bot would crack it in a hartbeat. Why? Because it is only 5 characters short and it is a common word.&lt;/p&gt;

&lt;pre class="brush: plain"&gt;password: hello
md5: 5d41402abc4b2a76b9719d911017c592
cracktime: 0.023 seconds&lt;/pre&gt;

&lt;p&gt;As a developer you have the amazing power to make this more complex by adding a prefix or suffix to the password:&lt;/p&gt;

&lt;pre class="brush: php"&gt;
&amp;lt;?php
$password = 'hello';
$salt = 'EgO8LQhvFBNN';

// truncaten salt and password and creating a md5 hash
$aUser['password'] = md5($salt.$password);

# new userpassword: EgO8LQhvFBNNhello
# new password hash: af82d9692551c4d21d522e9cc81e8dee
?&amp;gt;
&lt;/pre&gt;

&lt;p&gt;This makes the password hash more complex and it will take a lot more time to crack. But with the hardware getting faster and faster we need to take extra precautions by hashing the salt and password individually first:&lt;/p&gt;

&lt;pre class="brush: php"&gt;
// truncaten salt and password and creating a md5 hash
$aUser['password'] = md5(md5($salt) . md5($password));
&lt;/pre&gt;

&lt;p&gt;You can choose to have a general salt for every user on your website but you could also choose to give every user a different salt. And you could change this user salt every time he log&amp;#8217;s in. This would result in a password hash that changes after every login making it much harder for crackers to use dictionary attacks.&lt;/p&gt;

&lt;p&gt;I can hear you thinking, what if the cracker gets his hands on the salts? All these precautions would be for nothing. &lt;strong&gt;Wrong.&lt;/strong&gt; Hashing a password is a mathematical calculation, which takes time. The more times you hash a password or salt the longer it will take to crack it. If you use a unique salt per user, a cracker has to recalculate the salt hash for every user. Instead of calculating it once and comparing it with all the other users.&lt;/p&gt;

&lt;p&gt;You can&amp;#8217;t stop a password from being cracked, you can only delay it.&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/dieterve/~4/WxO5EV_Fi_U" height="1" width="1"/&gt;</description>
    <feedburner:origLink>http://www.dieterve.be/article/salting-passwords/</feedburner:origLink></item>
  </channel>
</rss>

