    <rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:admin="http://webns.net/mvcb/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:content="http://purl.org/rss/1.0/modules/content/">
     <channel>
        <title>ACCU  :: Cryptographic Mistakes Made in Programming</title>
        <link>https://members.accu.org/index.php/journals/848</link>
        <description>Professionalism in Programming</description>
        <dc:language>en-us</dc:language> 
        <dc:creator>Administrator</dc:creator> 
        <admin:generatorAgent rdf:resource="http://www.xaraya.org" /> 
        <admin:errorReportsTo rdf:resource="mailto:webeditor@accu.org" />
       <sy:updatePeriod>hourly</sy:updatePeriod>
       <sy:updateFrequency>1</sy:updateFrequency>
       <docs>http://backend.userland.com/rss</docs>


        <h2>Journal Articles</h2>


<div class="xar-mod-head"><span class="xar-mod-title">CVu Journal Vol 17, #6 - Dec 2005 + Design of applications and programs</span></div>

<table border="0" cellpadding="1" cellspacing="0">
    <tbody>
    <tr>
        <td valign="top">
            Browse in :
       </td>
       <td valign="top">

                                            <a href="https://members.accu.org/index.php/journals/">All</a>

                     &gt;                         <a href="https://members.accu.org/index.php/journals/c76/">Journals</a>

                     &gt;                         <a href="https://members.accu.org/index.php/journals/c77/">CVu</a>

                     &gt;                         <a href="https://members.accu.org/index.php/journals/c93/">176</a>
                    (12)
<br />

                                            <a href="https://members.accu.org/index.php/journals/">All</a>

                     &gt;                         <a href="https://members.accu.org/index.php/journals/c13/">Topics</a>

                     &gt;                         <a href="https://members.accu.org/index.php/journals/c67/">Design</a>
                    (236)
<br />

                                            <a href="https://members.accu.org/index.php/journals/c93-67/">Any of these categories</a>

                    -                        <a href="https://members.accu.org/index.php/journals/c93+67/">All of these categories</a>
<br />
</td>
   </tr>
   </tbody>
</table>




<div class="xar-error">
   <p>
 <strong>Note:</strong> when you create a new publication type,
the articles module will automatically use the templates
<em>user-display-[publicationtype].xt</em>
and <em>user-summary-[publicationtype].xt</em>.
If those templates do not exist when you try to preview or display a new article,
you'll get this warning :-)  Please place your own templates in themes/<em>yourtheme</em>/modules/articles . The templates will get the extension .xt there. </p>
</div>
<div class="xar-norm xar-standard-box-padding">
   <h1><strong>Title:</strong>&nbsp;Cryptographic Mistakes Made in Programming</h1>
<p><strong>Author:</strong>&nbsp;</p>
<p>
<strong>Date:</strong> 02 December 2005 06:00:00 +00:00 or Fri, 02 December 2005 06:00:00 +00:00</p>
<p><strong>Summary:</strong>&nbsp;</p>
<p><strong>Body:</strong>&nbsp;<div class="sect1" lang="en">
<div class="titlepage">
<h2><a name="d0e20" id="d0e20"></a></h2>
</div>
<p>Cryptography is regarded by many, including some of its
practitioners, as a black art. This is not without good reason as
very few people truly understand the subject. Most cryptographers
are mathematicians, and now virtually all programmers are not true
mathematicians (unlike in the early days of computing). As a result
programmers who actually understand cryptography are very rare.</p>
<p>Hearing the warnings about attempting to program cryptography
algorithms yourself, it is often viewed as easier, and safer, to
use pre-built cryptographic libraries to handle any encryption
requirements. It's natural to assume if these libraries have been
constructed by cryptographic experts, then use of them should
result in secure data. Unfortunately this assumption is the root of
a lot of encryption mistakes by programmers.</p>
<p>In cryptography the strength of the algorithm plus the length of
the key are only one part of the security of encryption. Given poor
usage, or poor implementation the most secure encryption systems
can be broken. This is a common mistake in the field of
cryptographic programming; the assumption that strong cryptography
always makes the data secure. So what errors can we, as
programmers, make that turns a secure encryption algorithm into an
insecure system? To demonstrate this let's look at the only
encryption algorithm that is mathematically unbreakable, the one
time pad.</p>
<p>One time pad works via XOR'ing data bits with a pad as long as
the message. The pad is selected at random. The result is data that
is only de-cryptable with the pad and is unbreakable without the
pad. The one time pad is impracticable in the real world to
implement, but is ideal to demonstrate how programming mistakes can
ruin encryption, if the programmer isn't thinking when coding, even
this 'unbreakable' system can become breakable.</p>
<p>Let's look at a few of the more common mistakes that can be
made:</p>
</div>
<div class="sect1" lang="en">
<div class="titlepage">
<h2><a name="d0e32" id="d0e32"></a>Mistake 1:
Leaking Data Bits</h2>
</div>
<p>With eight bit ASCII, most characters used in English documents
are in the lower seven bits. Due to different development
platforms, some encryption libraries may be configured to assume a
seven bit ASCII input. If we mismatch the two we could end up
encrypting seven out of eight bits in our data and end up 'leaking'
one unencrypted bit per byte.</p>
<p>The resulting data will look encrypted, but could give clues
over the plain text in the encrypted data. Values greater the 128
decimal, are probably the pound sign in financial documents for
example.</p>
</div>
<div class="sect1" lang="en">
<div class="titlepage">
<h2><a name="d0e39" id="d0e39"></a>Mistake 2:
Repeating the Key</h2>
</div>
<p>Most public and symmetric key encryption systems (real world
cryptography) repeat the key. The longer the key and the less it ss
repeated in encrypting data, so is regarded as more secure. Data by
users may also be repeated, if this occurs then comparisons 'block
by block' could reveal the encryption key.</p>
<p>A good example of this is the weakness in WEP (Wireless
Encryption Protocol), the encryption standard used with 802.11B
wireless networks. This uses a 24bit field and a wireless access
point transmits a lot of similar packets, it is guaranteed to reuse
the same key stream at some point. By comparing two encrypted
packets its possible to find the plain encrypted text. Once that's
done its trivial to decrypt other encrypted data.</p>
<p>The algorithm WEP uses RC4 which most would accept as a decent
algorithm for most uses, what lets WEP down in this case, is how
the algorithm was used, and the data it was used to encrypt.</p>
</div>
<div class="sect1" lang="en">
<div class="titlepage">
<h2><a name="d0e48" id="d0e48"></a>Mistake 3:
Formatting the Data Prior to Encryption</h2>
</div>
<p>In the following logon system, a user types in a password. The
systems breaks the password up into chunks of three characters and
upcases each character. Separately each chunk is encrypted with the
algorithm and compared to the stored encrypted password to see if
it matches. Passwords are limited to letters and numbers only.</p>
<p>The algorithm is solid, but unfortunately the possible inputs to
it are now only 46,665. This is a low number and hence allows
anyone with access to the password file the possibility of working
out the password in less than a second.</p>
<p>The programmer has effectively ruined a secure encryption
system, by the way the data was processed prior to encryption.</p>
</div>
<div class="sect1" lang="en">
<div class="titlepage">
<h2><a name="d0e57" id="d0e57"></a>Mistake 4: Key
Selection</h2>
</div>
<p>A good algorithm (or one time pad) needs a truly random key.
Problems occur with generating random numbers on computers as
computer generated numbers aren't truly random. It has been known
for programmers to use their compilers default random number
generators to create keys, a repeatable process.</p>
<p>To get around this some programmers develop their own method's
of key randomisation, but these often fail to produce keys that
aren't predictable, or result in picking a key that's weaker than
could be.</p>
<p>Just because a key is random, doesn't mean it is secure.
Depending upon the algorithm some keys are stronger than others,
particularly with public key cryptography. This is similar to
physical locks as most lock pickers can, if they see a key, judge
how hard it will be to pick that lock. The same make of lock will
be easier to pick, or harder, depending on how the key is cut.</p>
<p>The failure to concentrate on good key generation is a major
drawback in many practical deployments of cryptography.</p>
</div>
<div class="sect1" lang="en">
<div class="titlepage">
<h2><a name="d0e68" id="d0e68"></a>Mistake 5:
Leaking Data and Keys</h2>
</div>
<p>We have encrypted data stored on media, we wish to work with
that data. so we load into memory our decryption key, decrypt all
the data off the media and work with the unencrypted data in
memory. The result? We are trusting the operating system of the
computer to keep the data in memory secure, and not dump memory to
disk. Virtual memory is a very large concern as both the plain
text, and encrypted text could be present to aid an attacker
working out the key. In the worst case scenario the key could be in
the virtual memory.</p>
</div>
<div class="sect1" lang="en">
<div class="titlepage">
<h2><a name="d0e73" id="d0e73"></a>Mistake 6:
Insecure Algorithm</h2>
</div>
<p>If the lock is weak, any length of key will result in weak
encryption. Several algorithms over the centuries have been proven
to have flaws that aid an attacker in decrypting data. It doesn't
mean you shouldn't use these weak algorithms, but only use them if
the data doesn't need to be secure, but instead just look secure.
This is often acceptable if the people who are after the data, lack
the resources to break the code.</p>
</div>
<div class="sect1" lang="en">
<div class="titlepage">
<h2><a name="d0e78" id="d0e78"></a>Conclusion</h2>
</div>
<p>Encryption needs to be approached carefully and not just assumed
to be an add-on. Many problems can be solved by taking care in
program design. For example if we keep most data encrypted and only
decrypt data when needed we can avoid having large samples of
decrypted data in memory. Other techniques involve being careful
over how the data is encrypted or what data is selected for
encryption.</p>
<div class="sect2" lang="en">
<div class="titlepage">
<h3><a name="d0e83" id="d0e83"></a>Be Sure To:</h3>
</div>
<div class="itemizedlist">
<ul type="disc">
<li>
<p>Pick a strong modern algorithm</p>
</li>
<li>
<p>Generate real random keys, that are not weak for your encryption
system.</p>
</li>
<li>
<p>Use a long key length if security is not secondary to
performance concerns.</p>
</li>
<li>
<p>Decrypt data only when needed</p>
</li>
<li>
<p>Be careful about pre-processing data prior to encryption.</p>
</li>
<li>
<p>Avoid encrypting the same data multiple times.</p>
</li>
</ul>
</div>
<p>Encryption many be a black art, but understanding how it works
isn't needed to incorporate secure encryption into programs.
Instead the programmer needs to know how poor implementation occurs
and how to avoid reproducing it, unless your aim is to just give
the your users the illusion their data is secure!</p>
</div>
</div>
</p>
<p><strong>Notes:</strong>&nbsp;</p>
<p><em>More fields may be available via dynamicdata ..</em></p>
</div>
</channel>
</rss>
