1226031Sstas<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2226031Sstas<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
3226031Sstas<title>Heimdal crypto library: DES - Data Encryption Standard crypto interface</title>
4226031Sstas<link href="doxygen.css" rel="stylesheet" type="text/css">
5226031Sstas<link href="tabs.css" rel="stylesheet" type="text/css">
6226031Sstas</head><body>
7226031Sstas<p>
8226031Sstas<a href="http://www.h5l.org/"><img src="http://www.h5l.org/keyhole-heimdal.png" alt="keyhole logo"/></a>
9226031Sstas</p>
10226031Sstas<!-- end of header marker -->
11226031Sstas<!-- Generated by Doxygen 1.5.6 -->
12226031Sstas<div class="navigation" id="top">
13226031Sstas  <div class="tabs">
14226031Sstas    <ul>
15226031Sstas      <li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
16226031Sstas      <li><a href="modules.html"><span>Modules</span></a></li>
17226031Sstas      <li><a href="examples.html"><span>Examples</span></a></li>
18226031Sstas    </ul>
19226031Sstas  </div>
20226031Sstas  <div class="navpath"><a class="el" href="index.html">Heimdal crypto library</a>
21226031Sstas  </div>
22226031Sstas</div>
23226031Sstas<div class="contents">
24226031Sstas<h1><a class="anchor" name="page_des">DES - Data Encryption Standard crypto interface </a></h1>See the library functions here: <a class="el" href="group__hcrypto__des.html">DES crypto functions</a><p>
25226031SstasDES was created by IBM, modififed by NSA and then adopted by NBS (now NIST) and published ad FIPS PUB 46 (updated by FIPS 46-1).<p>
26226031SstasSince the 19th May 2005 DES was withdrawn by NIST and should no longer be used. See <a class="el" href="page_evp.html">EVP - generic crypto interface</a> for replacement encryption algorithms and interfaces.<p>
27226031SstasRead more the iteresting history of DES on Wikipedia <a href="http://www.wikipedia.org/wiki/Data_Encryption_Standard">http://www.wikipedia.org/wiki/Data_Encryption_Standard</a> .<h2><a class="anchor" name="des_keygen">
28226031SstasDES key generation</a></h2>
29226031SstasTo generate a DES key safely you have to use the code-snippet below. This is because the <a class="el" href="group__hcrypto__des.html#gd70d485549f7444589f3283e938c0258">DES_random_key()</a> can fail with an abort() in case of and failure to start the random generator.<p>
30226031SstasThere is a replacement function <a class="el" href="group__hcrypto__des.html#gcd3642bcd8a7e93ea977786e5b540d5f">DES_new_random_key()</a>, however that function does not exists in OpenSSL.<p>
31226031Sstas<div class="fragment"><pre class="fragment"> DES_cblock key;
32226031Sstas <span class="keywordflow">do</span> {
33226031Sstas     <span class="keywordflow">if</span> (RAND_rand(&amp;key, <span class="keyword">sizeof</span>(key)) != 1)
34226031Sstas          <span class="keywordflow">goto</span> failure;
35226031Sstas     <a class="code" href="group__hcrypto__des.html#g4179bef43ceb72cc2034f39e7d2d5ae4">DES_set_odd_parity</a>(key);
36226031Sstas } <span class="keywordflow">while</span> (<a class="code" href="group__hcrypto__des.html#g0d8a49cafee4be6cd3922bfb6323fd2d">DES_is_weak_key</a>(&amp;key));
37226031Sstas</pre></div><h2><a class="anchor" name="des_impl">
38226031SstasDES implementation history</a></h2>
39226031SstasThere was no complete BSD licensed, fast, GPL compatible implementation of DES, so Love wrote the part that was missing, fast key schedule setup and adapted the interface to the orignal libdes.<p>
40226031SstasThe document that got me started for real was "Efficient Implementation of the Data Encryption Standard" by Dag Arne Osvik. I never got to the PC1 transformation was working, instead I used table-lookup was used for all key schedule setup. The document was very useful since it de-mystified other implementations for me.<p>
41226031SstasThe core DES function (SBOX + P transformation) is from Richard Outerbridge public domain DES implementation. My sanity is saved thanks to his work. Thank you Richard. </div>
42226031Sstas<hr size="1"><address style="text-align: right;"><small>
43234027SstasGenerated on Wed Jan 11 14:07:38 2012 for Heimdal crypto library by&nbsp;<a href="http://www.doxygen.org/index.html"><img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.6</small></address>
44226031Sstas</body>
45226031Sstas</html>
46