⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 helix.htm

📁 简单的加密算法
💻 HTM
字号:
<html>

<head>
<title>CHelix v1.06</title>
</head>

<body>

<p align="left"><font color="#000000" size="6" face="Arial"><strong>CHelix v1.06</strong></font></p>

<p><font color="#000000" size="3" face="Arial">Welcome to CHelix, a </font>
<font face="Arial">C++ implementation for the Helix Encryption and 
Authentication algorithm as presented in a November 2003 Dr. Dobb's Journal 
article by Niels Ferguson and Bruce Schneier. For further information please 
refer to the article and / or the web site for it at
<a href="http://www.macfergus.com/helix">http://www.macfergus.com/helix</a>.</font></p>

<p>&nbsp;</p>

<table border="0">
<TBODY>
  <tr>
    <td><font size="5" face="Arial"><strong>Contents</strong></font></td>
  </tr>
  <tr>
    <td><font face="Arial"><a href="#Features">Features</a></font></td>
  </tr>
  <tr>
    <td><font face="Arial"><a href="#Features">History</a></font></td>
  </tr>
  <tr>
    <td><font face="Arial"><a class="normal" href="#API">API</a></font></td>
  </tr>
  <tr>
    <td><font face="Arial"><a href="#Contact">Contacting the Author</a></font></td>
  </tr>
</TBODY>
</table>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p><font face="Arial"><big><a name="Features"></a></big><font color="#000000" size="5"><strong>
Features</strong></font></font></p>

<ul>
  <li><font face="Arial">Encrypts / Decrypts and produces a hash in one 
  operation.</font></li>
  <li><font face="Arial">Fast. Using just this C++ code on an AMD Athlon XP 
  2700+ and Visual Studio 6, I was able to get an encryption speed of 191 MB / 
  second with just the C++ code provided. This corresponds to c. 11 clock ticks 
  per byte. An even faster implementation could be achieved by re-implementing 
  the &quot;Block&quot; function in assembler and / or recompiling in VC.NET 
  2003.</font></li>
  <li><font face="Arial">The test program verifies the encryption and decryption 
  using the supplied test vectors from the Helix web site.</font></li>
  <li><font face="Arial">Encryption and Decryption can be done in place. To 
  achieve this simply set the OUT parameter in the Encrypt or Decrypt functions 
  to point to the buffer which is being encrypted / decrypted. For an example of 
  this check out the last test in the TestHelix.cpp module. </font></li>
</ul>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p><font face="Arial"><big><a name="History"></a></big><font color="#000000" size="5"><strong>History</strong></font></font></p>

<p><font color="#000000" size="3" face="Arial"><b>V1.0 (29 November 2003)</b></font>

<ul>
  <li><font face="Arial"><font size="3"><font color="#000000">Initial</font></font><font
    color="#000000" size="3"> Public Release.</font><big> </big></font></li>
</ul>

<p><font color="#000000" size="3" face="Arial"><b>V1.01 (30 November 2003)</b></font>

<ul>
  <li><font face="Arial">Following an email update from Niels Ferguson, the 
  following changes were made:</font></li>
  <li><font face="Arial">Removed the need for the doBlk function</font></li>
  <li><font face="Arial">Made the Block function inline.</font></li>
  <li><font face="Arial">Removed the unneeded code &quot;m_i8 &gt;&gt; 31&quot;</font></li>
  <li><font face="Arial">Removed the unneeded local variable tag in the Finish 
  method.</font></li>
  <li><font face="Arial">Removed the switch statement in preference for a lookup 
  array in Decrypt.</font></li>
  <li><font face="Arial">plaintext is now not released from Decrypt if the MAC's 
  do not match up.</font></li>
  <li><font face="Arial">Optimized the key method CHelix::Block by using 
  register local variables. This now gets the throughput on my machine up to 191 
  MB / second</font></li>
</ul>

<p><font color="#000000" size="3" face="Arial"><b>V1.02 (1 December 2003)</b></font>

<ul>
  <li><font face="Arial">Optimized the for loop in Finish. Now it is only called 
  3 times instead of 4.</font></li>
</ul>

<p><font color="#000000" size="3" face="Arial"><b>V1.03 (1 December 2003)</b></font><ul>
  <li><font face="Arial">Further optimizations as suggested by Serhiy Pavlov 
  boost the speed to 208 MB / second on my home machine. This corresponds to a 
  speed of 10.4 clock ticks per byte!,</font></li>
  <li><font face="Arial">Also produced a DLL version of the algorithm, so that 
  client applications which do not or cannot (e.g. Visual Basic) muck around 
  with the C++ source code can use the code.</font></li>
</ul>

<p><font color="#000000" size="3" face="Arial"><b>V1.04 (18 June 2004)</b></font><ul>
  <li><font face="Arial">Fixed a bug in the CHelix constructor. Thanks to 
  Richard Gyger for reporting this problem.</font></li>
</ul>

<p><font color="#000000" size="3" face="Arial"><b>V1.05 (17 September 2004)</b></font><ul>
  <li><font face="Arial">Fixed a number of warnings in the code when compiled in 
  VC .Net 2003 with the &quot;Force conformance in For Loop Scope&quot; compiler option is 
  set.</font></li>
</ul>

<p><font color="#000000" size="3" face="Arial"><b>V1.06 (28 October 2004)</b></font>
<ul>
  <li><font face="Arial">Fixed a problem in the decryption where the Helix_Decrypt_Masks bit masks were incorrectly
    defined. Thanks to Dwain Skinner for reporting and providing a fix for this problem.</font></li>
  <li><font face="Arial">Removed the declaration of #pragma intrinsic(_rotl) as recent Platform SDK's already
    have this defined.</font></li>
  <li><font face="Arial">Sample app provided with download, now uses console I/O for reporting its results.</font></li>
</ul>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<h2 class="rh1"><font face="Arial"><a name="API"></a>API</font></h2>

<p class="rh1"><font face="Arial">The API consists of the public methods of the CHelix
class. They consist of:</font></p>

<p class="rh1" align="left"><b><font face="Arial"><a href="#SetKey">CHelix::SetKey</a></font></b><br>
<font face="Arial"><b><a href="#Encrypt">CHelix::Encrypt</a><br>
</b>
</font><b><font face="Arial"><a href="#Decrypt">CHelix::Decrypt</a><br>
&nbsp;</font></b></p>

<font size="2">

<p><a name="SetKey"></a></font><font face="Arial" size="4"><b>CHelix::SetKey</b></font></p>

<p><font face="Arial" size="3"><b>BOOL SetKey(const BYTE* </b><i>pbyKey</i><b>, 
DWORD </b><i>
dwKeyLength</i><b>);</b></font></p>

<p class="label"><b><font face="Arial" size="3">Parameters</font></b></p>

<p class="dt"><font face="Arial" size="3"><i>pbyKey </i>Pointer to a data to 
encrypt.</font></p>

<p class="dt"><font face="Arial" size="3"><i>dwKeyLength </i>The length of the key
<i>&quot;pByKey&quot;</i> in bytes.</font></p>

<p class="label"><b><font face="Arial" size="3">Return Value</font></b></p>

<p class="dt"><font face="Arial" size="3">TRUE if the key was set otherwise FALSE.</font></p>

<p class="label"><b><font face="Arial" size="3">Remarks</font></b></p>

<p><font face="Arial" size="3">Initializes the helix instance using the secret 
value <i>&quot;pbyKey&quot;</i> and length <i>&quot;nLength&quot;</i>. The maximum value for the key 
is 32 bytes. The secret key should be known only to the sender and receiver.</font></p>

<p class="rh1" align="left">&nbsp;</p>

<font size="2">

<p><a name="Encrypt"></a></font><font face="Arial" size="4"><b>CHelix::Encrypt</b></font></p>

<p><b><font face="Arial">BOOL</font></b><font face="Arial" size="3"> <b>Encrypt(const BYTE* </b><i>
pbyPlainText</i><b>, DWORD </b><i>dwPlainTextSize</i><b>, const CHelixNonce&amp; </b>
<i>nonce</i><b>, BYTE* </b><i>pbyCipherText</i><b>, CHelixMAC&amp; </b><i>mac</i><b>);</b></font></p>

<p class="label"><b><font face="Arial" size="3">Parameters</font></b></p>

<p class="dt"><font face="Arial" size="3"><i>pbyPlainText </i>Pointer to the 
data to encrypt.</font></p>

<p class="dt"><font face="Arial" size="3"><i>dwPlainTextSize </i>The size in 
bytes of the 
data in <i>&quot;pbyPlainText&quot;</i>.</font></p>

<p class="dt"><font face="Arial"><i>nonce</i> The cryptographic nonce to use for 
the encryption. This is a 16 byte value which should be unique for each message 
to be encrypted.</font></p>

<p class="dt"><font face="Arial"><i>pbyCipherText</i> Pointer to the buffer 
which receives the encrypted data upon return of the function. The buffer should 
be the same size (or greater) than <i>&quot;dwPlainTextSize&quot;</i> bytes in size.</font></p>

<p class="dt"><font face="Arial"><i>mac</i> Pointer to the message 
authentication code (aka hash or digest) for the data which is filled in upon 
return. </font></p>

<p class="label"><b><font face="Arial" size="3">Return Value</font></b></p>

<p class="dt"><font face="Arial" size="3">TRUE if the data was encrypted 
successfully otherwise FALSE.</font></p>

<p class="label"><b><font face="Arial" size="3">Remarks</font></b></p>

<p><font face="Arial" size="3">To encrypt data in place, set <i>&quot;pbyCipherText&quot;</i> 
to be the same value as <i>&quot;pbyPlainText&quot;</i>.</font></p>

<p>&nbsp;</p>

<p><font face="Arial" size="4"><b><a name="Decrypt"></a>CHelix::Decrypt</b></font></p>

<p><b><font face="Arial" size="4">Decrypt();</font></b></p>

<p><font face="Arial" size="3"><b>BOOL</b> <b>Decrypt(</b></font><b><font face="Arial">const</font><font face="Arial"> 
BYTE* </font></b><font face="Arial"><i>pbyCipherText</i><b>, DWORD </b><i>
dwCipherTextSize</i><b>, const CHelixNonce&amp; </b><i>nonce</i><b>, const 
CHelixMAC&amp; </b><i>mac</i><b>, BYTE* </b><i>pbyPlainText</i></font><font face="Arial" size="3"><b>);</b></font></p>

<p class="label"><b><font face="Arial" size="3">Parameters</font></b></p>

<p class="dt"><font face="Arial" size="3"><i>pbyCipherText </i>Pointer to the 
data to decrypt.</font></p>

<p class="dt"><font face="Arial" size="3"><i>dwCipherTextSize </i>The size in 
bytes of 
the data in <i>&quot;pbyCipherText&quot;</i>.</font></p>

<p class="dt"><font face="Arial"><i>nonce</i> The cryptographic nonce to use for 
the decryption. This is the 16 byte value which should be transmitted with the 
encrypted data such as in a Message sequence number or other counter.</font></p>

<p class="dt"><font face="Arial"><i>mac</i> Pointer to the message 
authentication code (aka hash or digest) for the data. Again this should be 
transmitted with the encrypted data.</font></p>

<p class="dt"><font face="Arial"><i>pbyPlainText</i> Pointer to the buffer which 
receives the decrypted data upon return of the function. The buffer should be 
the same size (or greater) than <i>&quot;dwCipherTextSize&quot;</i> bytes in size.</font></p>

<p class="label"><b><font face="Arial" size="3">Return Value</font></b></p>

<p class="dt"><font face="Arial" size="3">TRUE if the received MAC <i>&quot;mac&quot;</i> 
is the same as the calculated mac from the actual received data otherwise FALSE.</font></p>

<p class="label"><b><font face="Arial" size="3">Remarks</font></b></p>

<p><font face="Arial" size="3">To decrypt data in place, set <i>&quot;pbyPlainText&quot;</i> 
to be the same value as <i>&quot;pbyCipherText&quot;</i>.</font></p>

<p>&nbsp;</p>

<p class="spacing">&nbsp;</p>

<p class="spacing">&nbsp;</p>

<p><font face="Arial"><a name="Contact"></a><font color="#000000" size="5"><strong>Contacting
the Author</strong></font></font></p>

<p><font color="#000000" size="3" face="Arial">PJ Naughter<br>
Email: <a href="mailto:pjna@naughter.com">pjna@naughter.com</a><br>
Web: <a href="http://www.naughter.com">http://www.naughter.com</a><br>
28 October 2004</font></p>
</body>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -