Стартовый пул
32
dcpcrypt/CHANGELOG.txt
Normal file
@@ -0,0 +1,32 @@
|
||||
|
||||
Change in v2.0.4.1 by Graeme Geldenhuys (2010)
|
||||
|
||||
* Version number bumped to v2.0.4.1
|
||||
|
||||
* More fixes for 64-bit support
|
||||
|
||||
* Removed a lot of compiler warnings - tested with FPC 2.4.1
|
||||
|
||||
|
||||
Change in v2.0.4 by Graeme Geldenhuys (2009)
|
||||
|
||||
* Version number bumped to v2.0.4
|
||||
|
||||
* Split the Lazarus package into two separate packages
|
||||
- one is runtime only package and GUI toolkit independent.
|
||||
- one is Lazarus design-time only package which installs
|
||||
components in component palette.
|
||||
|
||||
* Updated code to be compilable with FPC 2.4.0-rc1
|
||||
|
||||
* Updated code to be compilable with 64-bit FPC 2.4.0-rc1.
|
||||
- Tested under 32-bit & 64-bit Linux on x86 systems.
|
||||
|
||||
|
||||
Changes since DCPCrypt v2 Beta 3:
|
||||
|
||||
* Ported DCPCrypt to Lazarus by Barko in 2006
|
||||
|
||||
|
||||
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
|
||||
|
||||
84
dcpcrypt/Docs/BlockCiphers.html
Normal file
@@ -0,0 +1,84 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>DCPcrypt v2: Users Guide - Block Ciphers</title>
|
||||
</head>
|
||||
<body>
|
||||
<p align="center"><font size="+2"><b>DCPcrypt Cryptographic Component Library v2</b></font><br>
|
||||
<font size="+1">Copyright © 1999-2002 David Barton<br>
|
||||
<a href="http://www.cityinthesky.co.uk/">http://www.cityinthesky.co.uk/</a><br>
|
||||
<a href="mailto:crypto@cityinthesky.co.uk">crypto@cityinthesky.co.uk</a></font>
|
||||
<p><font size="+2">Block Ciphers - TDCP_blockcipher</font>
|
||||
<p>All block ciphers are inherited from the TDCP_blockcipher component via either the TDCP_blockcipher64 and TDCP_blockcipher128 components (the latter implement the block size specific code).
|
||||
<p>The TDCP_blockcipher component extends the TDCP_cipher component to provide chaining mode functions. Functions available are:
|
||||
<pre>
|
||||
property <a href="Ciphers.html#Initialized">Initialized</a>: boolean;
|
||||
property <a href="Ciphers.html#Id">Id</a>: integer;
|
||||
property <a href="Ciphers.html#Algorithm">Algorithm</a>: string;
|
||||
property <a href="Ciphers.html#MaxKeySize">MaxKeySize</a>: integer;
|
||||
property <a href="#BlockSize">BlockSize</a>: integer;
|
||||
property <a href="#CipherMode">CipherMode</a>: TDCP_ciphermode;
|
||||
|
||||
class function <a href="Ciphers.html#SelfTest">SelfTest</a>: boolean;
|
||||
|
||||
procedure <a href="#SetIV">SetIV</a>(const Value);
|
||||
procedure <a href="#GetIV">GetIV</a>(var Value);
|
||||
|
||||
procedure <a href="Ciphers.html#Init">Init</a>(const Key; Size: longword; InitVector: pointer);
|
||||
procedure <a href="Ciphers.html#InitStr">InitStr</a>(const Key: string; HashType: TDCP_hashclass);
|
||||
procedure <a href="Ciphers.html#Burn">Burn</a>;
|
||||
procedure <a href="Ciphers.html#Reset">Reset</a>;
|
||||
procedure <a href="Ciphers.html#Encrypt">Encrypt</a>(const Indata; var Outdata; Size: longword);
|
||||
procedure <a href="Ciphers.html#Decrypt">Decrypt</a>(const Indata; var Outdata; Size: longword);
|
||||
function <a href="Ciphers.html#EncryptStream">EncryptStream</a>(InStream, OutStream: TStream; Size: longword): longword;
|
||||
function <a href="Ciphers.html#DecryptStream">DecryptStream</a>(InStream, OutStream: TStream; Size: longword): longword;
|
||||
function <a href="Ciphers.html#EncryptString">EncryptString</a>(const Str: string): string;
|
||||
function <a href="Ciphers.html#DecryptString">DecryptString</a>(const Str: string): string;
|
||||
procedure <a href="#EncryptECB">EncryptECB</a>(const Indata; var Outdata);
|
||||
procedure <a href="#DecryptECB">DecryptECB</a>(const Indata; var Outdata);
|
||||
procedure <a href="#EncryptCBC">EncryptCBC</a>(const Indata; var Outdata; Size: longword);
|
||||
procedure <a href="#DecryptCBC">DecryptCBC</a>(const Indata; var Outdata; Size: longword);
|
||||
procedure <a href="#EncryptCFB8bit">EncryptCFB8bit</a>(const Indata; var Outdata; Size: longword);
|
||||
procedure <a href="#DecryptCFB8bit">DecryptCFB8bit</a>(const Indata; var Outdata; Size: longword);
|
||||
procedure <a href="#EncryptCFBblock">EncryptCFBblock</a>(const Indata; var Outdata; Size: longword);
|
||||
procedure <a href="#DecryptCFBblock">DecryptCFBblock</a>(const Indata; var Outdata; Size: longword);
|
||||
procedure <a href="#EncryptOFB">EncryptOFB</a>(const Indata; var Outdata; Size: longword);
|
||||
procedure <a href="#DecryptOFB">DecryptOFB</a>(const Indata; var Outdata; Size: longword);
|
||||
procedure <a href="#EncryptCTR">EncryptCTR</a>(const Indata; var Outdata; Size: longword);
|
||||
procedure <a href="#DecryptCTR">DecryptCTR</a>(const Indata; var Outdata; Size: longword);
|
||||
</pre>
|
||||
<hr>
|
||||
<p><font size="+2">Function descriptions</font>
|
||||
<p><font size="+1"><a name="BlockSize">property BlockSize: integer;</a></font>
|
||||
<p>This contains the block size of the cipher in BITS.
|
||||
<p><font size="+1"><a name="CipherMode">property CipherMode: TDCP_ciphermode;</a></font>
|
||||
<p>This is the current chaining mode used when <a href="Ciphers.html#Encrypt">Encrypt</a> is called. The available modes are:
|
||||
<ul>
|
||||
<li>cmCBC - Cipher block chaining.
|
||||
<li>cmCFB8bit - 8bit cipher feedback.
|
||||
<li>cmCFBblock - Cipher feedback (using the block size of the algorithm).
|
||||
<li>cmOFB - Output feedback.
|
||||
<li>cmCTR - Counter.
|
||||
</ul>
|
||||
<p>Each chaining mode has it's own pro's and cons. See any good book on cryptography or the NIST publication SP800-38A for details on each.
|
||||
<p><font size="+1"><a name="SetIV">procedure SetIV(const Value);</a></font>
|
||||
<p>Use this procedure to set the current chaining mode information to Value. This variable should be the same size as the block size. When <a href="Ciphers.html#Reset">Reset</a> is called subsequent to this, the chaining information will be set back to Value.
|
||||
<p><font size="+1"><a name="GetIV">procedure GetIV(var Value);</a></font>
|
||||
<p>This returns in Value the current chaining mode information, to get the initial chaining mode information you need to call <a href="Ciphers.html#Reset">Reset</a> before calling GetIV. The variable passed in Value must be at least the same size as the block size otherwise you will get a buffer overflow.
|
||||
<p><font size="+1"><a name="EncryptCBC">procedure EncryptCBC(const Indata; var Outdata; Size: longword);</a></font><br>
|
||||
<font size="+1"><a name="DecryptCBC">procedure DecryptCBC(const Indata; var Outdata; Size: longword);</a></font><br>
|
||||
<font size="+1"><a name="EncryptCFB8bit">procedure EncryptCFB8bit(const Indata; var Outdata; Size: longword);</a></font><br>
|
||||
<font size="+1"><a name="DecryptCFB8bit">procedure DecryptCFB8bit(const Indata; var Outdata; Size: longword);</a></font><br>
|
||||
<font size="+1"><a name="EncryptCFBblock">procedure EncryptCFBblock(const Indata; var Outdata; Size: longword);</a></font><br>
|
||||
<font size="+1"><a name="DecryptCFBblock">procedure DecryptCFBblock(const Indata; var Outdata; Size: longword);</a></font><br>
|
||||
<font size="+1"><a name="EncryptOFB">procedure EncryptOFB(const Indata; var Outdata; Size: longword);</a></font><br>
|
||||
<font size="+1"><a name="DecryptOFB">procedure DecryptOFB(const Indata; var Outdata; Size: longword);</a></font><br>
|
||||
<font size="+1"><a name="EncryptCTR">procedure EncryptCTR(const Indata; var Outdata; Size: longword);</a></font><br>
|
||||
<font size="+1"><a name="DecryptCTR">procedure DecryptCTR(const Indata; var Outdata; Size: longword);</a></font>
|
||||
<p>These procedures encrypt/decrypt Size bytes of data from Indata and places the result in Outdata. These all employ chaining mode methods of encryption/decryption and so may need to be used inconjunction with <a href="Ciphers.html#Reset">Reset</a>. The CBC method uses short block encryption as specified in Bruce Schneier's "Applied Cryptography" for data blocks that are not multiples of the block size.
|
||||
<p>
|
||||
<p><a href="Index.html">Index</a>, <a href="Ciphers.html">Ciphers</a>, <a href="Hashes.html">Hashes</a>
|
||||
<p>
|
||||
<p><em>DCPcrypt is copyrighted © 1999-2002 David Barton.<br>
|
||||
All trademarks are property of their respective owners.</em>
|
||||
</body>
|
||||
</html>
|
||||
273
dcpcrypt/Docs/Ciphers.html
Normal file
@@ -0,0 +1,273 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>DCPcrypt v2: Users Guide - Ciphers</title>
|
||||
</head>
|
||||
<body>
|
||||
<p align="center"><font size="+2"><b>DCPcrypt Cryptographic Component Library v2</b></font><br>
|
||||
<font size="+1">Copyright © 1999-2002 David Barton<br>
|
||||
<a href="http://www.cityinthesky.co.uk/">http://www.cityinthesky.co.uk/</a><br>
|
||||
<a href="mailto:crypto@cityinthesky.co.uk">crypto@cityinthesky.co.uk</a></font>
|
||||
<p><font size="+2">Ciphers - TDCP_cipher</font>
|
||||
<p>All ciphers are inherited from the TDCP_cipher component either directly for stream ciphers (such as RC4) or via the TDCP_blockcipher component.
|
||||
<p>The TDCP_cipher component implements key initialisation features and the basic encryption/decryption interface. Functions available are:
|
||||
<pre>
|
||||
property <a href="#Initialized">Initialized</a>: boolean;
|
||||
property <a href="#Id">Id</a>: integer;
|
||||
property <a href="#Algorithm">Algorithm</a>: string;
|
||||
property <a href="#MaxKeySize">MaxKeySize</a>: integer;
|
||||
|
||||
class function <a href="#SelfTest">SelfTest</a>: boolean;
|
||||
|
||||
procedure <a href="#Init">Init</a>(const Key; Size: longword; InitVector: pointer);
|
||||
procedure <a href="#InitStr">InitStr</a>(const Key: string; HashType: TDCP_hashclass);
|
||||
procedure <a href="#Burn">Burn</a>;
|
||||
procedure <a href="#Reset">Reset</a>;
|
||||
procedure <a href="#Encrypt">Encrypt</a>(const Indata; var Outdata; Size: longword);
|
||||
procedure <a href="#Decrypt">Decrypt</a>(const Indata; var Outdata; Size: longword);
|
||||
function <a href="#EncryptStream">EncryptStream</a>(InStream, OutStream: TStream; Size: longword): longword;
|
||||
function <a href="#DecryptStream">DecryptStream</a>(InStream, OutStream: TStream; Size: longword): longword;
|
||||
function <a href="#EncryptString">EncryptString</a>(const Str: string): string;
|
||||
function <a href="#DecryptString">DecryptString</a>(const Str: string): string;
|
||||
</pre>
|
||||
<p>Example usage:
|
||||
<ul>
|
||||
<li><a href="#Example1">Example 1</a> - String encryption.
|
||||
<li><a href="#Example2">Example 2</a> - File encryption.
|
||||
<li><a href="#Example3">Example 3</a> - General encryption.
|
||||
</ul>
|
||||
<hr>
|
||||
<p><font size="+2">Function descriptions</font>
|
||||
<p><font size="+1"><a name="Initialized">property Initialized: boolean;</a></font>
|
||||
<p>Once key initialization has been performed this property is set to true, otherwise it is set to false. Calling <a href="#Burn">Burn</a> will immediately set this to false.
|
||||
<p><font size="+1"><a name="Id">property Id: integer;</a></font>
|
||||
<p>Every algorithm I implement gets given a unique ID number so that if I use several different algorithms within a program I can determine which one was used. This is a purely arbitrary numbering system.
|
||||
<p><font size="+1"><a name="Algorithm">property Algorithm: string;</a></font>
|
||||
<p>This contains the name of the algorithm implemented within the component.
|
||||
<p><font size="+1"><a name="MaxKeySize">property MaxKeySize: integer;</a></font>
|
||||
<p>This is the maximum size of key you can pass to the cipher (in bits!).
|
||||
<p><font size="+1"><a name="SelfTest">class function SelfTest: boolean;</a></font>
|
||||
<p>In order to test whether the implementations have all been compiled correctly you can call the SelfTest function. This compares the results of several encryption/decryption operations with known results for the algorithms (so called test vectors). If all the tests are passed then true is returned. If ANY of the tests are failed then false is returned. You may want to run this function for all the components when you first install the DCPcrypt package and again if you modify any of the source files, you don't need to run this everytime your program is run. Note: this only performs a selection of tests, it is not exhaustive.
|
||||
<p><font size="+1"><a name="Init">procedure Init(const Key; Size: longword; InitVector: pointer);</a></font>
|
||||
<p>This procedure initializes the cipher with the keying material supplied in Key. The Size of the keying material is specified in <b>BITS</b>. The InitVector is a pointer to chaining information (only used for block ciphers). The variable that this points to should be equal to the block size of the algorithm. If <em>nil</em> is specified then (if necessary) an initialization vector is automatically generated from the key. Note: the method for generating automatic IVs is different from DCPcrypt v1.31, if this is a problem uncomment the DCPcrypt v1.31 compatibility mode line in DCPcrypt2.pas.
|
||||
<p>Init example: use the hash of a string to initialize the cipher
|
||||
<pre>
|
||||
<b>procedure</b> TForm1.Button1Click(Sender: TObject);
|
||||
<b>var</b>
|
||||
Cipher: TDCP_rc4;
|
||||
Hash: TDCP_sha1;
|
||||
Digest: <b>array</b>[0..19] <b>of byte</b>; <em>// SHA-1 produces a 160bit (20byte) output</em>
|
||||
<b>begin</b>
|
||||
Hash:= TDCP_sha1.Create(Self);
|
||||
Hash.Init; <em>// initialize the hash</em>
|
||||
Hash.UpdateStr(Edit1.Text); <em>// generate a hash of Edit1.Text</em>
|
||||
Hash.Final(Digest); <em>// save the hash in Digest</em>
|
||||
Hash.Free;
|
||||
Cipher:= TDCP_rc4.Create(Self);
|
||||
Cipher.Init(Digest,Sizeof(Digest)*8,<b>nil</b>); <em>// remember size is in BITS (hence sizeof*8)</em>
|
||||
...
|
||||
</pre>
|
||||
<p><font size="+1"><a name="InitStr">procedure InitStr(const Key: string; HashType: TDCP_hashclass);</a></font>
|
||||
<p>This procedure initializes the cipher with a hash of the key string using the specified hash type (in a way similar to the example above). To replicate the behaviour from DCPcrypt v2 Beta 1 use Cipher.InitStr(KeyStr,TDCP_sha1).
|
||||
<p>InitStr example: prompt the user for a passphrase to initialize the cipher
|
||||
<pre>
|
||||
<b>procedure</b> TForm1.Button1Click(Sender: TObject);
|
||||
<b>var</b>
|
||||
Cipher: TDCP_rc4;
|
||||
<b>begin</b>
|
||||
Cipher:= TDCP_rc4.Create(Self);
|
||||
Cipher.InitStr(InputBox('Passphrase','Enter a passphrase',''),TDCP_sha1); <em>// prompt for a passphrase</em>
|
||||
...
|
||||
</pre>
|
||||
<p><font size="+1"><a name="Burn">procedure Burn;</a></font>
|
||||
<p>Once you have finished encrypting/decrypting all your data call Burn to erase all keying information. This is automatically called once the cipher is freed, however it is a good habit to call this procedure explicitly.
|
||||
<p><font size="+1"><a name="Reset">procedure Reset;</a></font>
|
||||
<p>Stream ciphers (and block ciphers in chaining modes) generally store chaining information that is dependant on the information already encrypted. Consequently decrypting a block of information immediately after encrypting it won't result in the original information because when you called the decrypt procedure the chaining information was different from when you called the encrypt procedure. Hence use Reset to restore the chaining information to it's original state.
|
||||
<p>Remember that calling <a href="#EncryptString">EncryptString</a>, <a href="#DecryptString">DecryptString</a>, <a href="#EncryptStream">EncryptStream</a> and <a href="#DecryptStream">DecryptStream</a> will also affect the chaining information.
|
||||
<p>Reset example: encrypting and decrypting
|
||||
<pre>
|
||||
<b>function</b> TestCipher: <b>boolean</b>;
|
||||
<b>const</b>
|
||||
InData: <b>array</b>[0..9] <b>of byte</b>= ($01,$23,$45,$56,$67,$78,$89,$10,$AB,$FF);
|
||||
<b>var</b>
|
||||
Cipher: TDCP_rc4;
|
||||
Data: <b>array</b>[0..9] <b>of byte</b>;
|
||||
<b>begin</b>
|
||||
Cipher:= TDCP_rc4.Create(<b>nil</b>);
|
||||
Cipher.InitStr('Hello World',TDCP_sha1); <em>// initialize the cipher</em>
|
||||
Cipher.Encrypt(InData,Data,Sizeof(Data)); <em>// encrypt some known data</em>
|
||||
Cipher.Decrypt(Data,Data,Sizeof(Data)); <em>// now decrypt it</em>
|
||||
Cipher.Burn; <em>// clear keying information</em>
|
||||
Cipher.Free;
|
||||
Result:= CompareMem(@InData,@Data,Sizeof(Data)); <em>// compare input and output</em>
|
||||
<b>end</b>;
|
||||
</pre>
|
||||
The above will ALWAYS result in false due to the chaining information.
|
||||
<pre>
|
||||
<b>function</b> TestCipher: <b>boolean</b>;
|
||||
<b>const</b>
|
||||
InData: <b>array</b>[0..9] <b>of byte</b>= ($01,$23,$45,$56,$67,$78,$89,$10,$AB,$FF);
|
||||
<b>var</b>
|
||||
Cipher: TDCP_rc4;
|
||||
Data: <b>array</b>[0..9] <b>of byte</b>;
|
||||
<b>begin</b>
|
||||
Cipher:= TDCP_rc4.Create(<b>nil</b>);
|
||||
Cipher.InitStr('Hello World',TDCP_sha1); <em>// initialize the cipher</em>
|
||||
Cipher.Encrypt(InData,Data,Sizeof(Data)); <em>// encrypt some known data</em>
|
||||
Cipher.Reset; <em><b>// reset chaining information</b></em>
|
||||
Cipher.Decrypt(Data,Data,Sizeof(Data)); <em>// now decrypt it</em>
|
||||
Cipher.Burn; <em>// clear keying information</em>
|
||||
Cipher.Free;
|
||||
Result:= CompareMem(@InData,@Data,Sizeof(Data)); <em>// compare input and output</em>
|
||||
<b>end</b>;
|
||||
</pre>
|
||||
The above <em>should</em> always return true.
|
||||
<p><font size="+1"><a name="Encrypt">procedure Encrypt(const Indata; var Outdata; Size: longword);</a></font>
|
||||
<p>Encrypt Size bytes from Indata and place it in Outdata. Block ciphers encrypt the data using the method specified by the <a href="BlockCiphers.html#CipherMode">CipherMode</a> property. Also see the notes on <a href="#Reset">Reset</a>.
|
||||
<p><font size="+1"><a name="Decrypt">procedure Decrypt(const Indata; var Outdata; Size: longword);</a></font>
|
||||
<p>Decrypt Size bytes from Indata and place it in Outdata. Block ciphers decrypt the data using the method specified by the <a href="BlockCiphers.html#CipherMode">CipherMode</a> property. Also see the notes on <a href="#Reset">Reset</a>.
|
||||
<p><font size="+1"><a name="EncryptStream">function EncryptStream(InStream, OutStream: TStream; Size: longword): longword;</a></font>
|
||||
<p>Encrypt Size bytes from the InStream and place it in the OutStream, returns the number of bytes read from the InStream. Encryption is done by calling the <a href="#Encrypt">Encrypt</a> procedure. Also see the notes on <a href="#Reset">Reset</a>.
|
||||
<p><font size="+1"><a name="DecryptStream">function DecryptStream(InStream, OutStream: TStream; Size: longword): longword;</a></font>
|
||||
<p>Decrypt Size bytes from the InStream and place it in the OutStream, returns the number of bytes read from the InStream. Decryption is done by calling the <a href="#Decrypt">Decrypt</a> procedure. Also see the notes on <a href="#Reset">Reset</a>.
|
||||
<p><font size="+1"><a name="EncryptString">function EncryptString(const Str: string): string;</a></font>
|
||||
<p>Encrypt the string Str then Base64 encode it and return the result. For stream ciphers the <a href="#Encrypt">Encrypt</a> procedure is called to do the encryption, for block ciphers the <a href="BlockCiphers.html#EncryptCFB8bit">CFB8bit</a> method is always used. Base64 encoding is used to ensure that the output string doesn't contain non-printing characters.
|
||||
<p><font size="+1"><a name="DecryptString">function DecryptString(const Str: string): string;</a></font>
|
||||
<p>Base64 decode the string then decrypt it and return the result. For stream ciphers the <a href="#Decrypt">Decrypt</a> procedure is called to do the decryption, for block ciphers the <a href="BlockCiphers.html#DecryptCFB8bit">CFB8bit</a> method is always used.
|
||||
<hr>
|
||||
<p><font size="+2"><a name="Example1">Example 1: String encryption</a></font>
|
||||
<p>This example shows how you can encrypt the contents of a TMemo and leave the contents printable.
|
||||
<pre>
|
||||
<b>procedure</b> TForm1.btnEncryptClick(Sender: TObject);
|
||||
<b>var</b>
|
||||
i: <b>integer</b>;
|
||||
Cipher: TDCP_rc4;
|
||||
KeyStr: string;
|
||||
<b>begin</b>
|
||||
KeyStr:= '';
|
||||
<b>if</b> InputQuery('Passphrase','Enter passphrase',KeyStr) <b>then</b> <em>// get the passphrase</em>
|
||||
<b>begin</b>
|
||||
Cipher:= TDCP_rc4.Create(Self);
|
||||
Cipher.InitStr(KeyStr,TDCP_sha1); <em>// initialize the cipher with a hash of the passphrase</em>
|
||||
<b>for</b> i:= 0 <b>to</b> Memo1.Lines.Count-1 <b>do</b> <em>// encrypt the contents of the memo</em>
|
||||
Memo1.Lines[i]:= Cipher.EncryptString(Memo1.Lines[i]);
|
||||
Cipher.Burn;
|
||||
Cipher.Free;
|
||||
<b>end</b>;
|
||||
<b>end</b>;
|
||||
|
||||
<b>procedure</b> TForm1.btnDecryptClick(Sender: TObject);
|
||||
<b>var</b>
|
||||
i: <b>integer</b>;
|
||||
Cipher: TDCP_rc4;
|
||||
KeyStr: string;
|
||||
<b>begin</b>
|
||||
KeyStr:= '';
|
||||
<b>if</b> InputQuery('Passphrase','Enter passphrase',KeyStr) <b>then</b> <em>// get the passphrase</em>
|
||||
<b>begin</b>
|
||||
Cipher:= TDCP_rc4.Create(Self);
|
||||
Cipher.InitStr(KeyStr,TDCP_sha1); <em>// initialize the cipher with a hash of the passphrase</em>
|
||||
<b>for</b> i:= 0 <b>to</b> Memo1.Lines.Count-1 <b>do</b> <em>// decrypt the contents of the memo</em>
|
||||
Memo1.Lines[i]:= Cipher.DecryptString(Memo1.Lines[i]);
|
||||
Cipher.Burn;
|
||||
Cipher.Free;
|
||||
<b>end</b>;
|
||||
<b>end</b>;
|
||||
</pre>
|
||||
<hr>
|
||||
<p><font size="+2"><a name="Example2">Example 2: File encryption</a></font>
|
||||
<p>This example shows how you can encrypt the contents of a file, takes the input and output file names from two edit boxes: boxInputFile and boxOutputFile.
|
||||
<pre>
|
||||
<b>procedure</b> TForm1.btnEncryptClick(Sender: TObject);
|
||||
<b>var</b>
|
||||
Cipher: TDCP_rc4;
|
||||
KeyStr: string;
|
||||
Source, Dest: TFileStream;
|
||||
<b>begin</b>
|
||||
KeyStr:= '';
|
||||
<b>if</b> InputQuery('Passphrase','Enter passphrase',KeyStr) <b>then</b> <em>// get the passphrase</em>
|
||||
<b>begin</b>
|
||||
<b>try</b>
|
||||
Source:= TFileStream.Create(boxInputFile.Text,fmOpenRead);
|
||||
Dest:= TFileStream.Create(boxOutputFile.Text,fmCreate);
|
||||
Cipher:= TDCP_rc4.Create(Self);
|
||||
Cipher.InitStr(KeyStr,TDCP_sha1); <em>// initialize the cipher with a hash of the passphrase</em>
|
||||
Cipher.EncryptStream(Source,Dest,Source.Size); <em>// encrypt the contents of the file</em>
|
||||
Cipher.Burn;
|
||||
Cipher.Free;
|
||||
Dest.Free;
|
||||
Source.Free;
|
||||
MessageDlg('File encrypted',mtInformation,[mbOK],0);
|
||||
<b>except</b>
|
||||
MessageDlg('File IO error',mtError,[mbOK],0);
|
||||
<b>end</b>;
|
||||
<b>end</b>;
|
||||
<b>end</b>;
|
||||
|
||||
<b>procedure</b> TForm1.btnDecryptClick(Sender: TObject);
|
||||
<b>var</b>
|
||||
Cipher: TDCP_rc4;
|
||||
KeyStr: string;
|
||||
Source, Dest: TFileStream;
|
||||
<b>begin</b>
|
||||
KeyStr:= '';
|
||||
<b>if</b> InputQuery('Passphrase','Enter passphrase',KeyStr) <b>then</b> <em>// get the passphrase</em>
|
||||
<b>begin</b>
|
||||
<b>try</b>
|
||||
Source:= TFileStream.Create(boxInputFile.Text,fmOpenRead);
|
||||
Dest:= TFileStream.Create(boxOutputFile.Text,fmCreate);
|
||||
Cipher:= TDCP_rc4.Create(Self);
|
||||
Cipher.InitStr(KeyStr,TDCP_sha1); <em>// initialize the cipher with a hash of the passphrase</em>
|
||||
Cipher.DecryptStream(Source,Dest,Source.Size); <em>// decrypt the contents of the file</em>
|
||||
Cipher.Burn;
|
||||
Cipher.Free;
|
||||
Dest.Free;
|
||||
Source.Free;
|
||||
MessageDlg('File decrypted',mtInformation,[mbOK],0);
|
||||
<b>except</b>
|
||||
MessageDlg('File IO error',mtError,[mbOK],0);
|
||||
<b>end</b>;
|
||||
<b>end</b>;
|
||||
<b>end</b>;
|
||||
</pre>
|
||||
<hr>
|
||||
<p><font size="+2"><a name="Example3">Example 3: General encryption</a></font>
|
||||
<p>This hypothetical example shows how you might encrypt a packet of information before transmission across a network.
|
||||
<pre>
|
||||
<b>type</b>
|
||||
TSomePacket= <b>record</b>
|
||||
Date: <b>double</b>;
|
||||
ToUserID: <b>integer</b>;
|
||||
FromUserID: <b>integer</b>;
|
||||
MsgLen: <b>integer</b>;
|
||||
Msg: string;
|
||||
<b>end</b>;
|
||||
|
||||
<b>procedure</b> EncryptPacket(Cipher: TDCP_cipher; <b>var</b> Packet: TSomePacket);
|
||||
<em>// encrypt the information packet with the cipher
|
||||
// if the cipher isn't initialized then prompt for passphrase</em>
|
||||
<b>begin</b>
|
||||
<b>if</b> Cipher= <b>nil then</b>
|
||||
<b>raise</b> Exception.Create('Cipher hasn''t been created!')
|
||||
<b>else
|
||||
begin</b>
|
||||
<b>if not</b> Cipher.Initialized <b>then</b> <em>// check the cipher has been initialized</em>
|
||||
Cipher.InitStr(InputBox('Passphrase','Enter passphrase',''),TDCP_sha1);
|
||||
<b>if</b> Cipher <b>is</b> TDCP_blockcipher <b>then</b> <em>// if a block cipher use CFB 8bit as encrypting small packets</em>
|
||||
TDCP_blockcipher(Cipher).CipherMode:= cmCFB8bit;
|
||||
<em>// encrypt the record part by part, could do this in one go if it was a packed record</em>
|
||||
Cipher.Encrypt(Packet.Date,Packet.Date,Sizeof(Packet.Date));
|
||||
Cipher.Encrypt(Packet.ToUserID,Packet.ToUserID,Sizeof(Packet.ToUserID));
|
||||
Cipher.Encrypt(Packet.FromUserID,Packet.FromUserID,Sizeof(Packet.FromUserID));
|
||||
Cipher.Encrypt(Packet.MsgLen,Packet.MsgLen,Sizeof(Packet.MsgLen));
|
||||
Cipher.Encrypt(Packet.Msg[1],Packet.Msg[1],Length(Packet.Msg)); <em>// slightly different for strings</em>
|
||||
<em>// don't bother resetting the cipher, instead keep the chaining information</em>
|
||||
<b>end</b>;
|
||||
<b>end</b>;
|
||||
</pre>
|
||||
<p>
|
||||
<p><a href="Index.html">Index</a>, <a href="BlockCiphers.html">Block Ciphers</a>, <a href="Hashes.html">Hashes</a>
|
||||
<p>
|
||||
<p><em>DCPcrypt is copyrighted © 1999-2002 David Barton.<br>
|
||||
All trademarks are property of their respective owners.</em>
|
||||
</body>
|
||||
</html>
|
||||
BIN
dcpcrypt/Docs/DCPciphers/TDCP_3DES.bmp
Normal file
|
After Width: | Height: | Size: 406 B |
BIN
dcpcrypt/Docs/DCPciphers/TDCP_BLOWFISH.bmp
Normal file
|
After Width: | Height: | Size: 406 B |
BIN
dcpcrypt/Docs/DCPciphers/TDCP_CAST128.bmp
Normal file
|
After Width: | Height: | Size: 406 B |
BIN
dcpcrypt/Docs/DCPciphers/TDCP_CAST256.bmp
Normal file
|
After Width: | Height: | Size: 406 B |
BIN
dcpcrypt/Docs/DCPciphers/TDCP_DES.bmp
Normal file
|
After Width: | Height: | Size: 406 B |
BIN
dcpcrypt/Docs/DCPciphers/TDCP_GOST.bmp
Normal file
|
After Width: | Height: | Size: 406 B |
BIN
dcpcrypt/Docs/DCPciphers/TDCP_ICE.bmp
Normal file
|
After Width: | Height: | Size: 406 B |
BIN
dcpcrypt/Docs/DCPciphers/TDCP_ICE2.bmp
Normal file
|
After Width: | Height: | Size: 406 B |
BIN
dcpcrypt/Docs/DCPciphers/TDCP_IDEA.bmp
Normal file
|
After Width: | Height: | Size: 406 B |
BIN
dcpcrypt/Docs/DCPciphers/TDCP_MARS.bmp
Normal file
|
After Width: | Height: | Size: 406 B |
BIN
dcpcrypt/Docs/DCPciphers/TDCP_MISTY1.bmp
Normal file
|
After Width: | Height: | Size: 406 B |
BIN
dcpcrypt/Docs/DCPciphers/TDCP_RC2.bmp
Normal file
|
After Width: | Height: | Size: 406 B |
BIN
dcpcrypt/Docs/DCPciphers/TDCP_RC4.bmp
Normal file
|
After Width: | Height: | Size: 406 B |
BIN
dcpcrypt/Docs/DCPciphers/TDCP_RC5.bmp
Normal file
|
After Width: | Height: | Size: 406 B |
BIN
dcpcrypt/Docs/DCPciphers/TDCP_RC6.bmp
Normal file
|
After Width: | Height: | Size: 406 B |
BIN
dcpcrypt/Docs/DCPciphers/TDCP_RIJNDAEL.bmp
Normal file
|
After Width: | Height: | Size: 406 B |
BIN
dcpcrypt/Docs/DCPciphers/TDCP_SERPENT.bmp
Normal file
|
After Width: | Height: | Size: 406 B |
BIN
dcpcrypt/Docs/DCPciphers/TDCP_TEA.bmp
Normal file
|
After Width: | Height: | Size: 406 B |
BIN
dcpcrypt/Docs/DCPciphers/TDCP_THINICE.bmp
Normal file
|
After Width: | Height: | Size: 406 B |
BIN
dcpcrypt/Docs/DCPciphers/TDCP_TWOFISH.bmp
Normal file
|
After Width: | Height: | Size: 406 B |
BIN
dcpcrypt/Docs/DCPhashes/TDCP_HAVAL.bmp
Normal file
|
After Width: | Height: | Size: 406 B |
BIN
dcpcrypt/Docs/DCPhashes/TDCP_MD4.bmp
Normal file
|
After Width: | Height: | Size: 406 B |
BIN
dcpcrypt/Docs/DCPhashes/TDCP_MD5.bmp
Normal file
|
After Width: | Height: | Size: 406 B |
BIN
dcpcrypt/Docs/DCPhashes/TDCP_RIPEMD128.bmp
Normal file
|
After Width: | Height: | Size: 406 B |
BIN
dcpcrypt/Docs/DCPhashes/TDCP_RIPEMD160.bmp
Normal file
|
After Width: | Height: | Size: 406 B |
BIN
dcpcrypt/Docs/DCPhashes/TDCP_SHA1.bmp
Normal file
|
After Width: | Height: | Size: 406 B |
BIN
dcpcrypt/Docs/DCPhashes/TDCP_SHA256.bmp
Normal file
|
After Width: | Height: | Size: 406 B |
BIN
dcpcrypt/Docs/DCPhashes/TDCP_SHA384.bmp
Normal file
|
After Width: | Height: | Size: 406 B |
BIN
dcpcrypt/Docs/DCPhashes/TDCP_SHA512.bmp
Normal file
|
After Width: | Height: | Size: 406 B |
BIN
dcpcrypt/Docs/DCPhashes/TDCP_TIGER.bmp
Normal file
|
After Width: | Height: | Size: 406 B |
107
dcpcrypt/Docs/Hashes.html
Normal file
@@ -0,0 +1,107 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>DCPcrypt v2: Users Guide - Hash Algorithms</title>
|
||||
</head>
|
||||
<body>
|
||||
<p align="center"><font size="+2"><b>DCPcrypt Cryptographic Component Library v2</b></font><br>
|
||||
<font size="+1">Copyright © 1999-2002 David Barton<br>
|
||||
<a href="http://www.cityinthesky.co.uk/">http://www.cityinthesky.co.uk/</a><br>
|
||||
<a href="mailto:crypto@cityinthesky.co.uk">crypto@cityinthesky.co.uk</a></font>
|
||||
<p><font size="+2">Hash Algorithms - TDCP_hash</font>
|
||||
<p>All hashes are derived from the TDCP_hash component. It provides a range of functions to allow the hashing of virtually every type of data.
|
||||
<p>Functions available are:
|
||||
<pre>
|
||||
property <a href="#Initialized">Initialized</a>: boolean;
|
||||
property <a href="#Id">Id: integer</a>;
|
||||
property <a href="#Algorithm">Algorithm</a>: string;
|
||||
property <a href="#HashSize">HashSize</a>: integer;
|
||||
|
||||
class function <a href="#SelfTest">SelfTest</a>: boolean;
|
||||
|
||||
procedure <a href="#Init">Init</a>;
|
||||
procedure <a href="#Final">Final</a>(var Digest);
|
||||
procedure <a href="#Burn">Burn</a>;
|
||||
|
||||
procedure <a href="#Update">Update</a>(const Buffer; Size: longword);
|
||||
procedure <a href="#UpdateStream">UpdateStream</a>(Stream: TStream; Size: longword);
|
||||
procedure <a href="#UpdateStr">UpdateStr</a>(const Str: string);
|
||||
</pre>
|
||||
<p>Example usage:
|
||||
<ul>
|
||||
<li><a href="#Example1">Example 1</a> - File hashing.
|
||||
</ul>
|
||||
<hr>
|
||||
<p><font size="+1"><a name="Initialized">property Initialized: boolean;</a></font>
|
||||
<p>This is set to true after <a href="#Init">Init</a> has been called.
|
||||
<p><font size="+1"><a name="Id">property Id: integer;</a></font>
|
||||
<p>Every algorithm I implement gets given a unique ID number so that if I use several different algorithms within a program I can determine which one was used. This is a purely arbitrary numbering system.
|
||||
<p><font size="+1"><a name="Algorithm">property Algorithm: string;</a></font>
|
||||
<p>This is the name of the algorithm implemented in the component.
|
||||
<p><font size="+1"><a name="HashSize">property HashSize: integer;</a></font>
|
||||
<p>This is the size of the output of the hash algorithm in BITS.
|
||||
<p><font size="+1"><a name="SelfTest">class function SelfTest: boolean;</a></font>
|
||||
<p>In order to test whether the implementations have all been compiled correctly you can call the SelfTest function. This compares the results of several hash operations with known results for the algorithms (so called test vectors). If all the tests are passed then true is returned. If ANY of the tests are failed then false is returned. You may want to run this function for all the components when you first install the DCPcrypt package and again if you modify any of the source files, you don't need to run this everytime your program is run. Note: this only performs a selection of tests, it is not exhaustive.
|
||||
<p><font size="+1"><a name="Init">procedure Init;</a></font>
|
||||
<p>Call this procedure to initialize the hash algorithm, this must be called before using the <a href="#Update">Update</a> procedure.
|
||||
<p><font size="+1"><a name="Final">procedure Final(var Digest);</a></font>
|
||||
<p>This procedure returns the final message digest (hash) in Digest. This variable must be the same size as the hash size. This procedure also calls <a href="#Burn">Burn</a> to clear any stored information.
|
||||
<p><font size="+1"><a name="Burn">procedure Burn;</a></font>
|
||||
<p>Call this procedure if you want to abort the hashing operation (normally <a href="#Final">Final</a> is used). This clears all information stored within the hash. Before the hash can be used again <a href="#Init">Init</a> must be called.
|
||||
<p><font size="+1"><a name="Update">procedure Update(const Buffer; Size: longword);</a></font>
|
||||
<p>This procedure hashes Size bytes of Buffer. To get the hash result call <a href="#Final">Final</a>.
|
||||
<p>Update example:
|
||||
<pre>
|
||||
<b>procedure</b> HashBuffer(<b>const</b> Buffer; Size: <b>longint</b>; <b>var</b> Output);
|
||||
<b>var</b>
|
||||
Hash: TDCP_ripemd160;
|
||||
<b>begin</b>
|
||||
Hash:= TDCP_ripemd160.Create(<b>nil</b>);
|
||||
Hash.Init;
|
||||
Hash.Update(Buffer,Size);
|
||||
Hash.Final(Output);
|
||||
Hash.Free;
|
||||
<b>end</b>;
|
||||
</pre>
|
||||
<p><font size="+1"><a name="UpdateStream">procedure UpdateStream(Stream: TStream; Size: longword);</a></font>
|
||||
<p>This procedure hashes Size bytes from Stream. To get the hash result call <a href="#Final">Final</a>.
|
||||
<p><font size="+1"><a name="UpdateStr">procedure UpdateStr(const Str: string);</a></font>
|
||||
<p>This procedure hashes the string Str. To get the hash result call <a href="#Final">Final</a>.
|
||||
<hr>
|
||||
<p><font size="+2"><a name="Example1">Example 1 - File hashing</a></font>
|
||||
<p>This example shows how you can hash the contents of a file
|
||||
<pre>
|
||||
<b>procedure</b> TForm1.Button1Click(Sender: TObject);
|
||||
<b>var</b>
|
||||
Hash: TDCP_ripemd160;
|
||||
Digest: <b>array</b>[0..19] <b>of</b> <b>byte</b>; <em>// RipeMD-160 produces a 160bit digest (20bytes)</em>
|
||||
Source: TFileStream;
|
||||
i: <b>integer</b>;
|
||||
s: string;
|
||||
<b>begin</b>
|
||||
Source:= <b>nil</b>;
|
||||
<b>try</b>
|
||||
Source:= TFileStream.Create(Edit1.Text,fmOpenRead); <em>// open the file specified by Edit1</em>
|
||||
<b>except</b>
|
||||
MessageDlg('Unable to open file',mtError,[mbOK],0);
|
||||
<b>end</b>;
|
||||
<b>if</b> Source <> <b>nil then</b>
|
||||
<b>begin</b>
|
||||
Hash:= TDCP_ripemd160.Create(Self); <em>// create the hash</em>
|
||||
Hash.Init; <em>// initialize it</em>
|
||||
Hash.UpdateStream(Source,Source.Size); <em>// hash the stream contents</em>
|
||||
Hash.Final(Digest); <em>// produce the digest</em>
|
||||
Source.Free;
|
||||
s:= '';
|
||||
<b>for</b> i:= 0 <b>to</b> 19 <b>do</b>
|
||||
s:= s + IntToHex(Digest[i],2);
|
||||
Edit2.Text:= s; <em>// display the digest</em>
|
||||
<b>end</b>;
|
||||
<b>end</b>;
|
||||
</pre>
|
||||
<p>
|
||||
<p><a href="Index.html">Index</a>, <a href="Ciphers.html">Ciphers</a>, <a href="BlockCiphers.html">Block Ciphers</a>
|
||||
<p>
|
||||
<p><em>DCPcrypt is copyrighted © 1999-2002 David Barton.<br>
|
||||
All trademarks are property of their respective owners.</em>
|
||||
</body>
|
||||
</html>
|
||||
270
dcpcrypt/Docs/Index.html
Normal file
@@ -0,0 +1,270 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>DCPcrypt v2: Users Guide - Index</title>
|
||||
</head>
|
||||
<body>
|
||||
<p align="center"><font size="+2"><b>DCPcrypt Cryptographic Component Library v2 Beta 3</b></font><br>
|
||||
<font size="+1">Copyright © 1999-2002 David Barton<br>
|
||||
<a href="http://www.cityinthesky.co.uk/">http://www.cityinthesky.co.uk/</a><br>
|
||||
<a href="mailto:crypto@cityinthesky.co.uk">crypto@cityinthesky.co.uk</a></font>
|
||||
<p><font size="+2">Introduction</font>
|
||||
<p>DCPcrypt is a collection of cryptographic components for the Borland Delphi(tm), C++ Builder(tm) and Kylix(tm) programming languages. The supported versions are Delphi 4, 5, 6 and 7, C++ Builder (3?), 4, 5, 6 and Kylix 1 (untested) and 2.
|
||||
<p>The idea behind DCPcrypt is that it should be possible to "drop in" any algorithm implementation to replace another with minimum or no code changes. To aid in this goal all cryptographic components are descended from one of several base classes, TDCP_cipher for encryption algorithms and TDCP_hash for message digest algorithms.
|
||||
<p>
|
||||
<table>
|
||||
<tr>
|
||||
<td valign="center"><a href="http://www.opensource.org/docs/definition.php"><img src="osi-certified-120x100.png" border="0"></a></td>
|
||||
<td valign="center">
|
||||
<p>DCPcrypt is open source software (released under the <a href="MIT_license.txt">MIT license</a>) and as such there is no charge for inclusion in other software. However, I am currently a student and if you are making money from my software I would really appreciate a donation of some sort, whether financial or a license for the software you develop (<em>or if anyone wants to sponsor a Mathematical Modelling (Masters) student for their final year...</em>). Please note THIS IS NOT COMPULSORY IN ANY WAY. See <a href="http://www.cityinthesky.co.uk/cryptography.html">http://www.cityinthesky.co.uk/cryptography.html</a> for details on donations.
|
||||
<p>This software is OSI Certified Open Source Software. OSI Certified is a certification mark of the <a href="http://www.opensource.org/">Open Source Initiative</a>.
|
||||
<p>If you maintain a website then a link to my page at <a href="http://www.cityinthesky.co.uk/">http://www.cityinthesky.co.uk/</a> would be great!
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<p>
|
||||
<p><font size="+2">What's New</font>
|
||||
<p>Changes since DCPcrypt v2 Beta 2:
|
||||
<ul>
|
||||
<li>Corrected C++ Builder compilation problem.
|
||||
</ul>
|
||||
<p>Changes since DCPcrypt v2 Beta 1:
|
||||
<ul>
|
||||
<li>Renamed source code files for hashes and ciphers to DCPxxx.pas
|
||||
<li>Change the format of Cipher.InitStr so that the hash algorithm used to generate the key is explicitly specified. In order to get the same functionality as before, use TDCP_sha1. e.g. Cipher.InitStr('Hello World',TDCP_sha1);
|
||||
<li>Block ciphers are now inherited from an intermediate component that implements the block size specific chaining mode encryption routines.
|
||||
<li>Remove the internal component registration, it was more hassle than it was worth. If there is a demand for this to be put back then I might...
|
||||
<li>Added the full range of operation modes for Haval. By changing the defines at the top of DCPhaval.pas you can specify the number of passes and the output hash size.
|
||||
<li>Added the Tiger hash algorithm (192bit digest).
|
||||
<li>Changed the name of the file containing TDCP_ripemd160 for consistency to DCPripemd160 from DCPrmd160.
|
||||
<li>GOST no longer appears on the component palette pending verifying what the actual standard is (the code is still included however).
|
||||
<li>Added the RipeMD-128 hash algorithm (128bit digest).
|
||||
<li>Added the Serpent block cipher (AES finalist).
|
||||
<li>Added the SHA-256,384,512 hash algorithms (256, 384, 512bit digest respectively).
|
||||
<li>Added CTR chaining mode to all block ciphers.
|
||||
</ul>
|
||||
<p>
|
||||
<p><font size="+2">Installation</font>
|
||||
<p>
|
||||
<table>
|
||||
<tr>
|
||||
<td width="120">Delphi</td>
|
||||
<td>Open the appropriate package, DCPdelphiX.dpk where X is your version of Delphi (either 4, 5 or 6). Then press the install button.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td width="120">C++ Builder</td>
|
||||
<td>Create a new design time package and add all the .pas files from the DCPcrypt2.zip archive including all those in the Ciphers and Hashes subdirectories. Then press the install button.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td width="120">Kylix</td>
|
||||
<td>Open the DCPkylix.dpk package and then press the install button (note: Kylix 1 users may need to create a new package as with C++ Builder as this is a Kylix 2 package).</td>
|
||||
</tr>
|
||||
<table>
|
||||
<p>You may need to add the directory containing DCPcrypt (and the Ciphers and Hashes subdirectories) to your library search path (found under Environment Options).
|
||||
<p>Once installed you will find two extra pages of components on your component palette, namely DCPciphers and DCPhashes. You can now place these components onto the form of your application to start using the algorithms.
|
||||
<p>
|
||||
<p><font size="+2">Usage</font>
|
||||
<p>Please note that an appreciation of the basic principles of encryption/decryption and key management is needed to ensure the correct usage of the ciphers implemented within this package. A good introduction on this subject is provided by Bruce Schneier's "Applied Cryptography" (ISBN: 0-471-11709-9) also see the NIST publication SP800-38A for information on the block cipher chaining modes.
|
||||
<ul>
|
||||
<li><a href="Ciphers.html">Ciphers</a> - the basic building block of DCPcrypt, the TDCP_cipher component.
|
||||
<li><a href="BlockCiphers.html">Block Ciphers</a> - the base of all block ciphers, the TDCP_blockcipher component.
|
||||
<li><a href="Hashes.html">Hashes</a> - the base of all hash algorithms, the TDCP_hash component.
|
||||
</ul>
|
||||
<p>DCPcrypt v2 contains the following ciphers and hash algorithms:
|
||||
<p>
|
||||
<table bgcolor="#FFFFCC" align="center">
|
||||
<tr>
|
||||
<td colspan="4" align="center"><font size="+1"><b>Ciphers</b></font></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><b>Name</b></td>
|
||||
<td><b>Patents</b></td>
|
||||
<td><b>Block Size</b></td>
|
||||
<td><b>Max Key Size*</b></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Blowfish</td>
|
||||
<td>None</td>
|
||||
<td>64 bits</td>
|
||||
<td>448 bits</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Cast-128</td>
|
||||
<td>None</td>
|
||||
<td>64 bits</td>
|
||||
<td>128 bits</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Cast-256</td>
|
||||
<td>Patented?</td>
|
||||
<td>128 bits</td>
|
||||
<td>256 bits</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>DES</td>
|
||||
<td>None</td>
|
||||
<td>64 bits**</td>
|
||||
<td>64 bits</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>3DES</td>
|
||||
<td>None</td>
|
||||
<td>64 bits</td>
|
||||
<td>192 bits</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Ice</td>
|
||||
<td>None?</td>
|
||||
<td>64 bits</td>
|
||||
<td>64 bits</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Thin Ice</td>
|
||||
<td>None?</td>
|
||||
<td>64 bits</td>
|
||||
<td>64 bits</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Ice 2</td>
|
||||
<td>None?</td>
|
||||
<td>64 bits</td>
|
||||
<td>128 bits</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>IDEA</td>
|
||||
<td>Free for non-commercial use</td>
|
||||
<td>64 bits</td>
|
||||
<td>128 bits</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>MARS</td>
|
||||
<td>Patented?</td>
|
||||
<td>128 bits</td>
|
||||
<td>1248 bits</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Misty1</td>
|
||||
<td>Free for non-commercial use</td>
|
||||
<td>64 bits</td>
|
||||
<td>128 bits</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>RC2</td>
|
||||
<td>None</td>
|
||||
<td>64 bits</td>
|
||||
<td>1024 bits</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>RC4</td>
|
||||
<td>None</td>
|
||||
<td>N/A</td>
|
||||
<td>2048 bits</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>RC5</td>
|
||||
<td>Patented</td>
|
||||
<td>64 bits</td>
|
||||
<td>2048 bits</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>RC6</td>
|
||||
<td>Patented</td>
|
||||
<td>128 bits</td>
|
||||
<td>2048 bits</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Rijndael (AES)</td>
|
||||
<td>None</td>
|
||||
<td>128 bits</td>
|
||||
<td>256 bits</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Serpent</td>
|
||||
<td>None</td>
|
||||
<td>128 bits</td>
|
||||
<td>256 bits</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>TEA</td>
|
||||
<td>None</td>
|
||||
<td>64 bits</td>
|
||||
<td>128 bits</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Twofish</td>
|
||||
<td>None</td>
|
||||
<td>128 bits</td>
|
||||
<td>256 bits</td>
|
||||
</tr>
|
||||
</table>
|
||||
<p>* although the quoted maximum key size may extremely large it doen't mean that the algorithm is secure to the same level.<br>
|
||||
** a 64bit key is used for DES then every 8th bit is discarded (parity) so the effective size is 56 bits.
|
||||
<p>
|
||||
<table bgcolor="#FFFFCC" align="center">
|
||||
<tr>
|
||||
<td colspan="3" align="center"><font size="+1"><b>Hash Algorithms</b><font></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><b>Name</b></td>
|
||||
<td><b>Patents</b></td>
|
||||
<td><b>Digest Size</b></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Haval</td>
|
||||
<td>None</td>
|
||||
<td>128, 160, 192, 224, 256 bits*</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>MD4</td>
|
||||
<td>None</td>
|
||||
<td>128 bits</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>MD5</td>
|
||||
<td>None</td>
|
||||
<td>128 bits</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>RipeMD-128</td>
|
||||
<td>None</td>
|
||||
<td>128 bits</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>RipeMD-160</td>
|
||||
<td>None</td>
|
||||
<td>160 bits</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>SHA-1</td>
|
||||
<td>None</td>
|
||||
<td>160 bits</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>SHA-256</td>
|
||||
<td>None</td>
|
||||
<td>256 bits</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>SHA-384</td>
|
||||
<td>None</td>
|
||||
<td>384 bits</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>SHA-512</td>
|
||||
<td>None</td>
|
||||
<td>512 bits</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Tiger</td>
|
||||
<td>None</td>
|
||||
<td>192 bits</td>
|
||||
</tr>
|
||||
</table>
|
||||
<p>* The different digest sizes of Haval can be accessed by uncommenting the $defines at the start of DCPhaval.pas.
|
||||
<p>
|
||||
<p><font size="+2">Contact</font>
|
||||
<p>I appreciate knowing what DCPcrypt is being used for and also if you have any queries or bug reports please email me at <a href="mailto:crypto@cityinthesky.co.uk">crypto@cityinthesky.co.uk</a>.
|
||||
<p>
|
||||
<p><em>DCPcrypt is copyrighted © 1999-2003 David Barton.<br>
|
||||
All trademarks are property of their respective owners.</em>
|
||||
</body>
|
||||
</html>
|
||||
21
dcpcrypt/Docs/MIT_license.txt
Normal file
@@ -0,0 +1,21 @@
|
||||
The MIT License
|
||||
|
||||
Copyright (c) <year> <copyright holders>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a
|
||||
copy of this software and associated documentation files (the "Software"),
|
||||
to deal in the Software without restriction, including without limitation
|
||||
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
and/or sell copies of the Software, and to permit persons to whom the
|
||||
Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
BIN
dcpcrypt/Docs/osi-certified-120x100.png
Normal file
|
After Width: | Height: | Size: 6.8 KiB |
203
dcpcrypt/Hashes/DCPhaval3.inc
Normal file
@@ -0,0 +1,203 @@
|
||||
temp:= (t2 and (t4 xor t3) xor t6 and t0 xor t5 and t1 xor t4);
|
||||
t7:= ((temp shr 7) or (temp shl 25)) + ((t7 shr 11) or (t7 shl 21)) + w[ 0];
|
||||
temp:= (t1 and (t3 xor t2) xor t5 and t7 xor t4 and t0 xor t3);
|
||||
t6:= ((temp shr 7) or (temp shl 25)) + ((t6 shr 11) or (t6 shl 21)) + w[ 1];
|
||||
temp:= (t0 and (t2 xor t1) xor t4 and t6 xor t3 and t7 xor t2);
|
||||
t5:= ((temp shr 7) or (temp shl 25)) + ((t5 shr 11) or (t5 shl 21)) + w[ 2];
|
||||
temp:= (t7 and (t1 xor t0) xor t3 and t5 xor t2 and t6 xor t1);
|
||||
t4:= ((temp shr 7) or (temp shl 25)) + ((t4 shr 11) or (t4 shl 21)) + w[ 3];
|
||||
temp:= (t6 and (t0 xor t7) xor t2 and t4 xor t1 and t5 xor t0);
|
||||
t3:= ((temp shr 7) or (temp shl 25)) + ((t3 shr 11) or (t3 shl 21)) + w[ 4];
|
||||
temp:= (t5 and (t7 xor t6) xor t1 and t3 xor t0 and t4 xor t7);
|
||||
t2:= ((temp shr 7) or (temp shl 25)) + ((t2 shr 11) or (t2 shl 21)) + w[ 5];
|
||||
temp:= (t4 and (t6 xor t5) xor t0 and t2 xor t7 and t3 xor t6);
|
||||
t1:= ((temp shr 7) or (temp shl 25)) + ((t1 shr 11) or (t1 shl 21)) + w[ 6];
|
||||
temp:= (t3 and (t5 xor t4) xor t7 and t1 xor t6 and t2 xor t5);
|
||||
t0:= ((temp shr 7) or (temp shl 25)) + ((t0 shr 11) or (t0 shl 21)) + w[ 7];
|
||||
|
||||
temp:= (t2 and (t4 xor t3) xor t6 and t0 xor t5 and t1 xor t4);
|
||||
t7:= ((temp shr 7) or (temp shl 25)) + ((t7 shr 11) or (t7 shl 21)) + w[ 8];
|
||||
temp:= (t1 and (t3 xor t2) xor t5 and t7 xor t4 and t0 xor t3);
|
||||
t6:= ((temp shr 7) or (temp shl 25)) + ((t6 shr 11) or (t6 shl 21)) + w[ 9];
|
||||
temp:= (t0 and (t2 xor t1) xor t4 and t6 xor t3 and t7 xor t2);
|
||||
t5:= ((temp shr 7) or (temp shl 25)) + ((t5 shr 11) or (t5 shl 21)) + w[10];
|
||||
temp:= (t7 and (t1 xor t0) xor t3 and t5 xor t2 and t6 xor t1);
|
||||
t4:= ((temp shr 7) or (temp shl 25)) + ((t4 shr 11) or (t4 shl 21)) + w[11];
|
||||
temp:= (t6 and (t0 xor t7) xor t2 and t4 xor t1 and t5 xor t0);
|
||||
t3:= ((temp shr 7) or (temp shl 25)) + ((t3 shr 11) or (t3 shl 21)) + w[12];
|
||||
temp:= (t5 and (t7 xor t6) xor t1 and t3 xor t0 and t4 xor t7);
|
||||
t2:= ((temp shr 7) or (temp shl 25)) + ((t2 shr 11) or (t2 shl 21)) + w[13];
|
||||
temp:= (t4 and (t6 xor t5) xor t0 and t2 xor t7 and t3 xor t6);
|
||||
t1:= ((temp shr 7) or (temp shl 25)) + ((t1 shr 11) or (t1 shl 21)) + w[14];
|
||||
temp:= (t3 and (t5 xor t4) xor t7 and t1 xor t6 and t2 xor t5);
|
||||
t0:= ((temp shr 7) or (temp shl 25)) + ((t0 shr 11) or (t0 shl 21)) + w[15];
|
||||
|
||||
temp:= (t2 and (t4 xor t3) xor t6 and t0 xor t5 and t1 xor t4);
|
||||
t7:= ((temp shr 7) or (temp shl 25)) + ((t7 shr 11) or (t7 shl 21)) + w[16];
|
||||
temp:= (t1 and (t3 xor t2) xor t5 and t7 xor t4 and t0 xor t3);
|
||||
t6:= ((temp shr 7) or (temp shl 25)) + ((t6 shr 11) or (t6 shl 21)) + w[17];
|
||||
temp:= (t0 and (t2 xor t1) xor t4 and t6 xor t3 and t7 xor t2);
|
||||
t5:= ((temp shr 7) or (temp shl 25)) + ((t5 shr 11) or (t5 shl 21)) + w[18];
|
||||
temp:= (t7 and (t1 xor t0) xor t3 and t5 xor t2 and t6 xor t1);
|
||||
t4:= ((temp shr 7) or (temp shl 25)) + ((t4 shr 11) or (t4 shl 21)) + w[19];
|
||||
temp:= (t6 and (t0 xor t7) xor t2 and t4 xor t1 and t5 xor t0);
|
||||
t3:= ((temp shr 7) or (temp shl 25)) + ((t3 shr 11) or (t3 shl 21)) + w[20];
|
||||
temp:= (t5 and (t7 xor t6) xor t1 and t3 xor t0 and t4 xor t7);
|
||||
t2:= ((temp shr 7) or (temp shl 25)) + ((t2 shr 11) or (t2 shl 21)) + w[21];
|
||||
temp:= (t4 and (t6 xor t5) xor t0 and t2 xor t7 and t3 xor t6);
|
||||
t1:= ((temp shr 7) or (temp shl 25)) + ((t1 shr 11) or (t1 shl 21)) + w[22];
|
||||
temp:= (t3 and (t5 xor t4) xor t7 and t1 xor t6 and t2 xor t5);
|
||||
t0:= ((temp shr 7) or (temp shl 25)) + ((t0 shr 11) or (t0 shl 21)) + w[23];
|
||||
|
||||
temp:= (t2 and (t4 xor t3) xor t6 and t0 xor t5 and t1 xor t4);
|
||||
t7:= ((temp shr 7) or (temp shl 25)) + ((t7 shr 11) or (t7 shl 21)) + w[24];
|
||||
temp:= (t1 and (t3 xor t2) xor t5 and t7 xor t4 and t0 xor t3);
|
||||
t6:= ((temp shr 7) or (temp shl 25)) + ((t6 shr 11) or (t6 shl 21)) + w[25];
|
||||
temp:= (t0 and (t2 xor t1) xor t4 and t6 xor t3 and t7 xor t2);
|
||||
t5:= ((temp shr 7) or (temp shl 25)) + ((t5 shr 11) or (t5 shl 21)) + w[26];
|
||||
temp:= (t7 and (t1 xor t0) xor t3 and t5 xor t2 and t6 xor t1);
|
||||
t4:= ((temp shr 7) or (temp shl 25)) + ((t4 shr 11) or (t4 shl 21)) + w[27];
|
||||
temp:= (t6 and (t0 xor t7) xor t2 and t4 xor t1 and t5 xor t0);
|
||||
t3:= ((temp shr 7) or (temp shl 25)) + ((t3 shr 11) or (t3 shl 21)) + w[28];
|
||||
temp:= (t5 and (t7 xor t6) xor t1 and t3 xor t0 and t4 xor t7);
|
||||
t2:= ((temp shr 7) or (temp shl 25)) + ((t2 shr 11) or (t2 shl 21)) + w[29];
|
||||
temp:= (t4 and (t6 xor t5) xor t0 and t2 xor t7 and t3 xor t6);
|
||||
t1:= ((temp shr 7) or (temp shl 25)) + ((t1 shr 11) or (t1 shl 21)) + w[30];
|
||||
temp:= (t3 and (t5 xor t4) xor t7 and t1 xor t6 and t2 xor t5);
|
||||
t0:= ((temp shr 7) or (temp shl 25)) + ((t0 shr 11) or (t0 shl 21)) + w[31];
|
||||
|
||||
temp:= (t5 and (t3 and not t0 xor t1 and t2 xor t4 xor t6) xor t1 and (t3 xor t2) xor t0 and t2 xor t6);
|
||||
t7:= ((temp shr 7) or (temp shl 25)) + ((t7 shr 11) or (t7 shl 21)) + w[ 5] + $452821E6;
|
||||
temp:= (t4 and (t2 and not t7 xor t0 and t1 xor t3 xor t5) xor t0 and (t2 xor t1) xor t7 and t1 xor t5);
|
||||
t6:= ((temp shr 7) or (temp shl 25)) + ((t6 shr 11) or (t6 shl 21)) + w[14] + $38D01377;
|
||||
temp:= (t3 and (t1 and not t6 xor t7 and t0 xor t2 xor t4) xor t7 and (t1 xor t0) xor t6 and t0 xor t4);
|
||||
t5:= ((temp shr 7) or (temp shl 25)) + ((t5 shr 11) or (t5 shl 21)) + w[26] + $BE5466CF;
|
||||
temp:= (t2 and (t0 and not t5 xor t6 and t7 xor t1 xor t3) xor t6 and (t0 xor t7) xor t5 and t7 xor t3);
|
||||
t4:= ((temp shr 7) or (temp shl 25)) + ((t4 shr 11) or (t4 shl 21)) + w[18] + $34E90C6C;
|
||||
temp:= (t1 and (t7 and not t4 xor t5 and t6 xor t0 xor t2) xor t5 and (t7 xor t6) xor t4 and t6 xor t2);
|
||||
t3:= ((temp shr 7) or (temp shl 25)) + ((t3 shr 11) or (t3 shl 21)) + w[11] + $C0AC29B7;
|
||||
temp:= (t0 and (t6 and not t3 xor t4 and t5 xor t7 xor t1) xor t4 and (t6 xor t5) xor t3 and t5 xor t1);
|
||||
t2:= ((temp shr 7) or (temp shl 25)) + ((t2 shr 11) or (t2 shl 21)) + w[28] + $C97C50DD;
|
||||
temp:= (t7 and (t5 and not t2 xor t3 and t4 xor t6 xor t0) xor t3 and (t5 xor t4) xor t2 and t4 xor t0);
|
||||
t1:= ((temp shr 7) or (temp shl 25)) + ((t1 shr 11) or (t1 shl 21)) + w[ 7] + $3F84D5B5;
|
||||
temp:= (t6 and (t4 and not t1 xor t2 and t3 xor t5 xor t7) xor t2 and (t4 xor t3) xor t1 and t3 xor t7);
|
||||
t0:= ((temp shr 7) or (temp shl 25)) + ((t0 shr 11) or (t0 shl 21)) + w[16] + $B5470917;
|
||||
|
||||
temp:= (t5 and (t3 and not t0 xor t1 and t2 xor t4 xor t6) xor t1 and (t3 xor t2) xor t0 and t2 xor t6);
|
||||
t7:= ((temp shr 7) or (temp shl 25)) + ((t7 shr 11) or (t7 shl 21)) + w[ 0] + $9216D5D9;
|
||||
temp:= (t4 and (t2 and not t7 xor t0 and t1 xor t3 xor t5) xor t0 and (t2 xor t1) xor t7 and t1 xor t5);
|
||||
t6:= ((temp shr 7) or (temp shl 25)) + ((t6 shr 11) or (t6 shl 21)) + w[23] + $8979FB1B;
|
||||
temp:= (t3 and (t1 and not t6 xor t7 and t0 xor t2 xor t4) xor t7 and (t1 xor t0) xor t6 and t0 xor t4);
|
||||
t5:= ((temp shr 7) or (temp shl 25)) + ((t5 shr 11) or (t5 shl 21)) + w[20] + $D1310BA6;
|
||||
temp:= (t2 and (t0 and not t5 xor t6 and t7 xor t1 xor t3) xor t6 and (t0 xor t7) xor t5 and t7 xor t3);
|
||||
t4:= ((temp shr 7) or (temp shl 25)) + ((t4 shr 11) or (t4 shl 21)) + w[22] + $98DFB5AC;
|
||||
temp:= (t1 and (t7 and not t4 xor t5 and t6 xor t0 xor t2) xor t5 and (t7 xor t6) xor t4 and t6 xor t2);
|
||||
t3:= ((temp shr 7) or (temp shl 25)) + ((t3 shr 11) or (t3 shl 21)) + w[ 1] + $2FFD72DB;
|
||||
temp:= (t0 and (t6 and not t3 xor t4 and t5 xor t7 xor t1) xor t4 and (t6 xor t5) xor t3 and t5 xor t1);
|
||||
t2:= ((temp shr 7) or (temp shl 25)) + ((t2 shr 11) or (t2 shl 21)) + w[10] + $D01ADFB7;
|
||||
temp:= (t7 and (t5 and not t2 xor t3 and t4 xor t6 xor t0) xor t3 and (t5 xor t4) xor t2 and t4 xor t0);
|
||||
t1:= ((temp shr 7) or (temp shl 25)) + ((t1 shr 11) or (t1 shl 21)) + w[ 4] + $B8E1AFED;
|
||||
temp:= (t6 and (t4 and not t1 xor t2 and t3 xor t5 xor t7) xor t2 and (t4 xor t3) xor t1 and t3 xor t7);
|
||||
t0:= ((temp shr 7) or (temp shl 25)) + ((t0 shr 11) or (t0 shl 21)) + w[ 8] + $6A267E96;
|
||||
|
||||
temp:= (t5 and (t3 and not t0 xor t1 and t2 xor t4 xor t6) xor t1 and (t3 xor t2) xor t0 and t2 xor t6);
|
||||
t7:= ((temp shr 7) or (temp shl 25)) + ((t7 shr 11) or (t7 shl 21)) + w[30] + $BA7C9045;
|
||||
temp:= (t4 and (t2 and not t7 xor t0 and t1 xor t3 xor t5) xor t0 and (t2 xor t1) xor t7 and t1 xor t5);
|
||||
t6:= ((temp shr 7) or (temp shl 25)) + ((t6 shr 11) or (t6 shl 21)) + w[ 3] + $F12C7F99;
|
||||
temp:= (t3 and (t1 and not t6 xor t7 and t0 xor t2 xor t4) xor t7 and (t1 xor t0) xor t6 and t0 xor t4);
|
||||
t5:= ((temp shr 7) or (temp shl 25)) + ((t5 shr 11) or (t5 shl 21)) + w[21] + $24A19947;
|
||||
temp:= (t2 and (t0 and not t5 xor t6 and t7 xor t1 xor t3) xor t6 and (t0 xor t7) xor t5 and t7 xor t3);
|
||||
t4:= ((temp shr 7) or (temp shl 25)) + ((t4 shr 11) or (t4 shl 21)) + w[ 9] + $B3916CF7;
|
||||
temp:= (t1 and (t7 and not t4 xor t5 and t6 xor t0 xor t2) xor t5 and (t7 xor t6) xor t4 and t6 xor t2);
|
||||
t3:= ((temp shr 7) or (temp shl 25)) + ((t3 shr 11) or (t3 shl 21)) + w[17] + $0801F2E2;
|
||||
temp:= (t0 and (t6 and not t3 xor t4 and t5 xor t7 xor t1) xor t4 and (t6 xor t5) xor t3 and t5 xor t1);
|
||||
t2:= ((temp shr 7) or (temp shl 25)) + ((t2 shr 11) or (t2 shl 21)) + w[24] + $858EFC16;
|
||||
temp:= (t7 and (t5 and not t2 xor t3 and t4 xor t6 xor t0) xor t3 and (t5 xor t4) xor t2 and t4 xor t0);
|
||||
t1:= ((temp shr 7) or (temp shl 25)) + ((t1 shr 11) or (t1 shl 21)) + w[29] + $636920D8;
|
||||
temp:= (t6 and (t4 and not t1 xor t2 and t3 xor t5 xor t7) xor t2 and (t4 xor t3) xor t1 and t3 xor t7);
|
||||
t0:= ((temp shr 7) or (temp shl 25)) + ((t0 shr 11) or (t0 shl 21)) + w[ 6] + $71574E69;
|
||||
|
||||
temp:= (t5 and (t3 and not t0 xor t1 and t2 xor t4 xor t6) xor t1 and (t3 xor t2) xor t0 and t2 xor t6);
|
||||
t7:= ((temp shr 7) or (temp shl 25)) + ((t7 shr 11) or (t7 shl 21)) + w[19] + $A458FEA3;
|
||||
temp:= (t4 and (t2 and not t7 xor t0 and t1 xor t3 xor t5) xor t0 and (t2 xor t1) xor t7 and t1 xor t5);
|
||||
t6:= ((temp shr 7) or (temp shl 25)) + ((t6 shr 11) or (t6 shl 21)) + w[12] + $F4933D7E;
|
||||
temp:= (t3 and (t1 and not t6 xor t7 and t0 xor t2 xor t4) xor t7 and (t1 xor t0) xor t6 and t0 xor t4);
|
||||
t5:= ((temp shr 7) or (temp shl 25)) + ((t5 shr 11) or (t5 shl 21)) + w[15] + $0D95748F;
|
||||
temp:= (t2 and (t0 and not t5 xor t6 and t7 xor t1 xor t3) xor t6 and (t0 xor t7) xor t5 and t7 xor t3);
|
||||
t4:= ((temp shr 7) or (temp shl 25)) + ((t4 shr 11) or (t4 shl 21)) + w[13] + $728EB658;
|
||||
temp:= (t1 and (t7 and not t4 xor t5 and t6 xor t0 xor t2) xor t5 and (t7 xor t6) xor t4 and t6 xor t2);
|
||||
t3:= ((temp shr 7) or (temp shl 25)) + ((t3 shr 11) or (t3 shl 21)) + w[ 2] + $718BCD58;
|
||||
temp:= (t0 and (t6 and not t3 xor t4 and t5 xor t7 xor t1) xor t4 and (t6 xor t5) xor t3 and t5 xor t1);
|
||||
t2:= ((temp shr 7) or (temp shl 25)) + ((t2 shr 11) or (t2 shl 21)) + w[25] + $82154AEE;
|
||||
temp:= (t7 and (t5 and not t2 xor t3 and t4 xor t6 xor t0) xor t3 and (t5 xor t4) xor t2 and t4 xor t0);
|
||||
t1:= ((temp shr 7) or (temp shl 25)) + ((t1 shr 11) or (t1 shl 21)) + w[31] + $7B54A41D;
|
||||
temp:= (t6 and (t4 and not t1 xor t2 and t3 xor t5 xor t7) xor t2 and (t4 xor t3) xor t1 and t3 xor t7);
|
||||
t0:= ((temp shr 7) or (temp shl 25)) + ((t0 shr 11) or (t0 shl 21)) + w[27] + $C25A59B5;
|
||||
|
||||
temp:= (t3 and (t5 and t4 xor t6 xor t0) xor t5 and t2 xor t4 and t1 xor t0);
|
||||
t7:= ((temp shr 7) or (temp shl 25)) + ((t7 shr 11) or (t7 shl 21)) + w[19] + $9C30D539;
|
||||
temp:= (t2 and (t4 and t3 xor t5 xor t7) xor t4 and t1 xor t3 and t0 xor t7);
|
||||
t6:= ((temp shr 7) or (temp shl 25)) + ((t6 shr 11) or (t6 shl 21)) + w[ 9] + $2AF26013;
|
||||
temp:= (t1 and (t3 and t2 xor t4 xor t6) xor t3 and t0 xor t2 and t7 xor t6);
|
||||
t5:= ((temp shr 7) or (temp shl 25)) + ((t5 shr 11) or (t5 shl 21)) + w[ 4] + $C5D1B023;
|
||||
temp:= (t0 and (t2 and t1 xor t3 xor t5) xor t2 and t7 xor t1 and t6 xor t5);
|
||||
t4:= ((temp shr 7) or (temp shl 25)) + ((t4 shr 11) or (t4 shl 21)) + w[20] + $286085F0;
|
||||
temp:= (t7 and (t1 and t0 xor t2 xor t4) xor t1 and t6 xor t0 and t5 xor t4);
|
||||
t3:= ((temp shr 7) or (temp shl 25)) + ((t3 shr 11) or (t3 shl 21)) + w[28] + $CA417918;
|
||||
temp:= (t6 and (t0 and t7 xor t1 xor t3) xor t0 and t5 xor t7 and t4 xor t3);
|
||||
t2:= ((temp shr 7) or (temp shl 25)) + ((t2 shr 11) or (t2 shl 21)) + w[17] + $B8DB38EF;
|
||||
temp:= (t5 and (t7 and t6 xor t0 xor t2) xor t7 and t4 xor t6 and t3 xor t2);
|
||||
t1:= ((temp shr 7) or (temp shl 25)) + ((t1 shr 11) or (t1 shl 21)) + w[ 8] + $8E79DCB0;
|
||||
temp:= (t4 and (t6 and t5 xor t7 xor t1) xor t6 and t3 xor t5 and t2 xor t1);
|
||||
t0:= ((temp shr 7) or (temp shl 25)) + ((t0 shr 11) or (t0 shl 21)) + w[22] + $603A180E;
|
||||
|
||||
temp:= (t3 and (t5 and t4 xor t6 xor t0) xor t5 and t2 xor t4 and t1 xor t0);
|
||||
t7:= ((temp shr 7) or (temp shl 25)) + ((t7 shr 11) or (t7 shl 21)) + w[29] + $6C9E0E8B;
|
||||
temp:= (t2 and (t4 and t3 xor t5 xor t7) xor t4 and t1 xor t3 and t0 xor t7);
|
||||
t6:= ((temp shr 7) or (temp shl 25)) + ((t6 shr 11) or (t6 shl 21)) + w[14] + $B01E8A3E;
|
||||
temp:= (t1 and (t3 and t2 xor t4 xor t6) xor t3 and t0 xor t2 and t7 xor t6);
|
||||
t5:= ((temp shr 7) or (temp shl 25)) + ((t5 shr 11) or (t5 shl 21)) + w[25] + $D71577C1;
|
||||
temp:= (t0 and (t2 and t1 xor t3 xor t5) xor t2 and t7 xor t1 and t6 xor t5);
|
||||
t4:= ((temp shr 7) or (temp shl 25)) + ((t4 shr 11) or (t4 shl 21)) + w[12] + $BD314B27;
|
||||
temp:= (t7 and (t1 and t0 xor t2 xor t4) xor t1 and t6 xor t0 and t5 xor t4);
|
||||
t3:= ((temp shr 7) or (temp shl 25)) + ((t3 shr 11) or (t3 shl 21)) + w[24] + $78AF2FDA;
|
||||
temp:= (t6 and (t0 and t7 xor t1 xor t3) xor t0 and t5 xor t7 and t4 xor t3);
|
||||
t2:= ((temp shr 7) or (temp shl 25)) + ((t2 shr 11) or (t2 shl 21)) + w[30] + $55605C60;
|
||||
temp:= (t5 and (t7 and t6 xor t0 xor t2) xor t7 and t4 xor t6 and t3 xor t2);
|
||||
t1:= ((temp shr 7) or (temp shl 25)) + ((t1 shr 11) or (t1 shl 21)) + w[16] + $E65525F3;
|
||||
temp:= (t4 and (t6 and t5 xor t7 xor t1) xor t6 and t3 xor t5 and t2 xor t1);
|
||||
t0:= ((temp shr 7) or (temp shl 25)) + ((t0 shr 11) or (t0 shl 21)) + w[26] + $AA55AB94;
|
||||
|
||||
temp:= (t3 and (t5 and t4 xor t6 xor t0) xor t5 and t2 xor t4 and t1 xor t0);
|
||||
t7:= ((temp shr 7) or (temp shl 25)) + ((t7 shr 11) or (t7 shl 21)) + w[31] + $57489862;
|
||||
temp:= (t2 and (t4 and t3 xor t5 xor t7) xor t4 and t1 xor t3 and t0 xor t7);
|
||||
t6:= ((temp shr 7) or (temp shl 25)) + ((t6 shr 11) or (t6 shl 21)) + w[15] + $63E81440;
|
||||
temp:= (t1 and (t3 and t2 xor t4 xor t6) xor t3 and t0 xor t2 and t7 xor t6);
|
||||
t5:= ((temp shr 7) or (temp shl 25)) + ((t5 shr 11) or (t5 shl 21)) + w[ 7] + $55CA396A;
|
||||
temp:= (t0 and (t2 and t1 xor t3 xor t5) xor t2 and t7 xor t1 and t6 xor t5);
|
||||
t4:= ((temp shr 7) or (temp shl 25)) + ((t4 shr 11) or (t4 shl 21)) + w[ 3] + $2AAB10B6;
|
||||
temp:= (t7 and (t1 and t0 xor t2 xor t4) xor t1 and t6 xor t0 and t5 xor t4);
|
||||
t3:= ((temp shr 7) or (temp shl 25)) + ((t3 shr 11) or (t3 shl 21)) + w[ 1] + $B4CC5C34;
|
||||
temp:= (t6 and (t0 and t7 xor t1 xor t3) xor t0 and t5 xor t7 and t4 xor t3);
|
||||
t2:= ((temp shr 7) or (temp shl 25)) + ((t2 shr 11) or (t2 shl 21)) + w[ 0] + $1141E8CE;
|
||||
temp:= (t5 and (t7 and t6 xor t0 xor t2) xor t7 and t4 xor t6 and t3 xor t2);
|
||||
t1:= ((temp shr 7) or (temp shl 25)) + ((t1 shr 11) or (t1 shl 21)) + w[18] + $A15486AF;
|
||||
temp:= (t4 and (t6 and t5 xor t7 xor t1) xor t6 and t3 xor t5 and t2 xor t1);
|
||||
t0:= ((temp shr 7) or (temp shl 25)) + ((t0 shr 11) or (t0 shl 21)) + w[27] + $7C72E993;
|
||||
|
||||
temp:= (t3 and (t5 and t4 xor t6 xor t0) xor t5 and t2 xor t4 and t1 xor t0);
|
||||
t7:= ((temp shr 7) or (temp shl 25)) + ((t7 shr 11) or (t7 shl 21)) + w[13] + $B3EE1411;
|
||||
temp:= (t2 and (t4 and t3 xor t5 xor t7) xor t4 and t1 xor t3 and t0 xor t7);
|
||||
t6:= ((temp shr 7) or (temp shl 25)) + ((t6 shr 11) or (t6 shl 21)) + w[ 6] + $636FBC2A;
|
||||
temp:= (t1 and (t3 and t2 xor t4 xor t6) xor t3 and t0 xor t2 and t7 xor t6);
|
||||
t5:= ((temp shr 7) or (temp shl 25)) + ((t5 shr 11) or (t5 shl 21)) + w[21] + $2BA9C55D;
|
||||
temp:= (t0 and (t2 and t1 xor t3 xor t5) xor t2 and t7 xor t1 and t6 xor t5);
|
||||
t4:= ((temp shr 7) or (temp shl 25)) + ((t4 shr 11) or (t4 shl 21)) + w[10] + $741831F6;
|
||||
temp:= (t7 and (t1 and t0 xor t2 xor t4) xor t1 and t6 xor t0 and t5 xor t4);
|
||||
t3:= ((temp shr 7) or (temp shl 25)) + ((t3 shr 11) or (t3 shl 21)) + w[23] + $CE5C3E16;
|
||||
temp:= (t6 and (t0 and t7 xor t1 xor t3) xor t0 and t5 xor t7 and t4 xor t3);
|
||||
t2:= ((temp shr 7) or (temp shl 25)) + ((t2 shr 11) or (t2 shl 21)) + w[11] + $9B87931E;
|
||||
temp:= (t5 and (t7 and t6 xor t0 xor t2) xor t7 and t4 xor t6 and t3 xor t2);
|
||||
t1:= ((temp shr 7) or (temp shl 25)) + ((t1 shr 11) or (t1 shl 21)) + w[ 5] + $AFD6BA33;
|
||||
temp:= (t4 and (t6 and t5 xor t7 xor t1) xor t6 and t3 xor t5 and t2 xor t1);
|
||||
t0:= ((temp shr 7) or (temp shl 25)) + ((t0 shr 11) or (t0 shl 21)) + w[ 2] + $6C24CF5C;
|
||||
272
dcpcrypt/Hashes/DCPhaval4.inc
Normal file
@@ -0,0 +1,272 @@
|
||||
temp:= (t3 and (t0 xor t1) xor t5 and t6 xor t4 and t2 xor t0);
|
||||
t7:= ((temp shr 7) or (temp shl 25)) + ((t7 shr 11) or (t7 shl 21)) + w[ 0];
|
||||
temp:= (t2 and (t7 xor t0) xor t4 and t5 xor t3 and t1 xor t7);
|
||||
t6:= ((temp shr 7) or (temp shl 25)) + ((t6 shr 11) or (t6 shl 21)) + w[ 1];
|
||||
temp:= (t1 and (t6 xor t7) xor t3 and t4 xor t2 and t0 xor t6);
|
||||
t5:= ((temp shr 7) or (temp shl 25)) + ((t5 shr 11) or (t5 shl 21)) + w[ 2];
|
||||
temp:= (t0 and (t5 xor t6) xor t2 and t3 xor t1 and t7 xor t5);
|
||||
t4:= ((temp shr 7) or (temp shl 25)) + ((t4 shr 11) or (t4 shl 21)) + w[ 3];
|
||||
temp:= (t7 and (t4 xor t5) xor t1 and t2 xor t0 and t6 xor t4);
|
||||
t3:= ((temp shr 7) or (temp shl 25)) + ((t3 shr 11) or (t3 shl 21)) + w[ 4];
|
||||
temp:= (t6 and (t3 xor t4) xor t0 and t1 xor t7 and t5 xor t3);
|
||||
t2:= ((temp shr 7) or (temp shl 25)) + ((t2 shr 11) or (t2 shl 21)) + w[ 5];
|
||||
temp:= (t5 and (t2 xor t3) xor t7 and t0 xor t6 and t4 xor t2);
|
||||
t1:= ((temp shr 7) or (temp shl 25)) + ((t1 shr 11) or (t1 shl 21)) + w[ 6];
|
||||
temp:= (t4 and (t1 xor t2) xor t6 and t7 xor t5 and t3 xor t1);
|
||||
t0:= ((temp shr 7) or (temp shl 25)) + ((t0 shr 11) or (t0 shl 21)) + w[ 7];
|
||||
|
||||
temp:= (t3 and (t0 xor t1) xor t5 and t6 xor t4 and t2 xor t0);
|
||||
t7:= ((temp shr 7) or (temp shl 25)) + ((t7 shr 11) or (t7 shl 21)) + w[ 8];
|
||||
temp:= (t2 and (t7 xor t0) xor t4 and t5 xor t3 and t1 xor t7);
|
||||
t6:= ((temp shr 7) or (temp shl 25)) + ((t6 shr 11) or (t6 shl 21)) + w[ 9];
|
||||
temp:= (t1 and (t6 xor t7) xor t3 and t4 xor t2 and t0 xor t6);
|
||||
t5:= ((temp shr 7) or (temp shl 25)) + ((t5 shr 11) or (t5 shl 21)) + w[10];
|
||||
temp:= (t0 and (t5 xor t6) xor t2 and t3 xor t1 and t7 xor t5);
|
||||
t4:= ((temp shr 7) or (temp shl 25)) + ((t4 shr 11) or (t4 shl 21)) + w[11];
|
||||
temp:= (t7 and (t4 xor t5) xor t1 and t2 xor t0 and t6 xor t4);
|
||||
t3:= ((temp shr 7) or (temp shl 25)) + ((t3 shr 11) or (t3 shl 21)) + w[12];
|
||||
temp:= (t6 and (t3 xor t4) xor t0 and t1 xor t7 and t5 xor t3);
|
||||
t2:= ((temp shr 7) or (temp shl 25)) + ((t2 shr 11) or (t2 shl 21)) + w[13];
|
||||
temp:= (t5 and (t2 xor t3) xor t7 and t0 xor t6 and t4 xor t2);
|
||||
t1:= ((temp shr 7) or (temp shl 25)) + ((t1 shr 11) or (t1 shl 21)) + w[14];
|
||||
temp:= (t4 and (t1 xor t2) xor t6 and t7 xor t5 and t3 xor t1);
|
||||
t0:= ((temp shr 7) or (temp shl 25)) + ((t0 shr 11) or (t0 shl 21)) + w[15];
|
||||
|
||||
temp:= (t3 and (t0 xor t1) xor t5 and t6 xor t4 and t2 xor t0);
|
||||
t7:= ((temp shr 7) or (temp shl 25)) + ((t7 shr 11) or (t7 shl 21)) + w[16];
|
||||
temp:= (t2 and (t7 xor t0) xor t4 and t5 xor t3 and t1 xor t7);
|
||||
t6:= ((temp shr 7) or (temp shl 25)) + ((t6 shr 11) or (t6 shl 21)) + w[17];
|
||||
temp:= (t1 and (t6 xor t7) xor t3 and t4 xor t2 and t0 xor t6);
|
||||
t5:= ((temp shr 7) or (temp shl 25)) + ((t5 shr 11) or (t5 shl 21)) + w[18];
|
||||
temp:= (t0 and (t5 xor t6) xor t2 and t3 xor t1 and t7 xor t5);
|
||||
t4:= ((temp shr 7) or (temp shl 25)) + ((t4 shr 11) or (t4 shl 21)) + w[19];
|
||||
temp:= (t7 and (t4 xor t5) xor t1 and t2 xor t0 and t6 xor t4);
|
||||
t3:= ((temp shr 7) or (temp shl 25)) + ((t3 shr 11) or (t3 shl 21)) + w[20];
|
||||
temp:= (t6 and (t3 xor t4) xor t0 and t1 xor t7 and t5 xor t3);
|
||||
t2:= ((temp shr 7) or (temp shl 25)) + ((t2 shr 11) or (t2 shl 21)) + w[21];
|
||||
temp:= (t5 and (t2 xor t3) xor t7 and t0 xor t6 and t4 xor t2);
|
||||
t1:= ((temp shr 7) or (temp shl 25)) + ((t1 shr 11) or (t1 shl 21)) + w[22];
|
||||
temp:= (t4 and (t1 xor t2) xor t6 and t7 xor t5 and t3 xor t1);
|
||||
t0:= ((temp shr 7) or (temp shl 25)) + ((t0 shr 11) or (t0 shl 21)) + w[23];
|
||||
|
||||
temp:= (t3 and (t0 xor t1) xor t5 and t6 xor t4 and t2 xor t0);
|
||||
t7:= ((temp shr 7) or (temp shl 25)) + ((t7 shr 11) or (t7 shl 21)) + w[24];
|
||||
temp:= (t2 and (t7 xor t0) xor t4 and t5 xor t3 and t1 xor t7);
|
||||
t6:= ((temp shr 7) or (temp shl 25)) + ((t6 shr 11) or (t6 shl 21)) + w[25];
|
||||
temp:= (t1 and (t6 xor t7) xor t3 and t4 xor t2 and t0 xor t6);
|
||||
t5:= ((temp shr 7) or (temp shl 25)) + ((t5 shr 11) or (t5 shl 21)) + w[26];
|
||||
temp:= (t0 and (t5 xor t6) xor t2 and t3 xor t1 and t7 xor t5);
|
||||
t4:= ((temp shr 7) or (temp shl 25)) + ((t4 shr 11) or (t4 shl 21)) + w[27];
|
||||
temp:= (t7 and (t4 xor t5) xor t1 and t2 xor t0 and t6 xor t4);
|
||||
t3:= ((temp shr 7) or (temp shl 25)) + ((t3 shr 11) or (t3 shl 21)) + w[28];
|
||||
temp:= (t6 and (t3 xor t4) xor t0 and t1 xor t7 and t5 xor t3);
|
||||
t2:= ((temp shr 7) or (temp shl 25)) + ((t2 shr 11) or (t2 shl 21)) + w[29];
|
||||
temp:= (t5 and (t2 xor t3) xor t7 and t0 xor t6 and t4 xor t2);
|
||||
t1:= ((temp shr 7) or (temp shl 25)) + ((t1 shr 11) or (t1 shl 21)) + w[30];
|
||||
temp:= (t4 and (t1 xor t2) xor t6 and t7 xor t5 and t3 xor t1);
|
||||
t0:= ((temp shr 7) or (temp shl 25)) + ((t0 shr 11) or (t0 shl 21)) + w[31];
|
||||
|
||||
temp:= (t1 and (t6 and not t0 xor t2 and t5 xor t3 xor t4) xor t2 and (t6 xor t5) xor t0 and t5 xor t4);
|
||||
t7:= ((temp shr 7) or (temp shl 25)) + ((t7 shr 11) or (t7 shl 21)) + w[ 5] + $452821E6;
|
||||
temp:= (t0 and (t5 and not t7 xor t1 and t4 xor t2 xor t3) xor t1 and (t5 xor t4) xor t7 and t4 xor t3);
|
||||
t6:= ((temp shr 7) or (temp shl 25)) + ((t6 shr 11) or (t6 shl 21)) + w[14] + $38D01377;
|
||||
temp:= (t7 and (t4 and not t6 xor t0 and t3 xor t1 xor t2) xor t0 and (t4 xor t3) xor t6 and t3 xor t2);
|
||||
t5:= ((temp shr 7) or (temp shl 25)) + ((t5 shr 11) or (t5 shl 21)) + w[26] + $BE5466CF;
|
||||
temp:= (t6 and (t3 and not t5 xor t7 and t2 xor t0 xor t1) xor t7 and (t3 xor t2) xor t5 and t2 xor t1);
|
||||
t4:= ((temp shr 7) or (temp shl 25)) + ((t4 shr 11) or (t4 shl 21)) + w[18] + $34E90C6C;
|
||||
temp:= (t5 and (t2 and not t4 xor t6 and t1 xor t7 xor t0) xor t6 and (t2 xor t1) xor t4 and t1 xor t0);
|
||||
t3:= ((temp shr 7) or (temp shl 25)) + ((t3 shr 11) or (t3 shl 21)) + w[11] + $C0AC29B7;
|
||||
temp:= (t4 and (t1 and not t3 xor t5 and t0 xor t6 xor t7) xor t5 and (t1 xor t0) xor t3 and t0 xor t7);
|
||||
t2:= ((temp shr 7) or (temp shl 25)) + ((t2 shr 11) or (t2 shl 21)) + w[28] + $C97C50DD;
|
||||
temp:= (t3 and (t0 and not t2 xor t4 and t7 xor t5 xor t6) xor t4 and (t0 xor t7) xor t2 and t7 xor t6);
|
||||
t1:= ((temp shr 7) or (temp shl 25)) + ((t1 shr 11) or (t1 shl 21)) + w[ 7] + $3F84D5B5;
|
||||
temp:= (t2 and (t7 and not t1 xor t3 and t6 xor t4 xor t5) xor t3 and (t7 xor t6) xor t1 and t6 xor t5);
|
||||
t0:= ((temp shr 7) or (temp shl 25)) + ((t0 shr 11) or (t0 shl 21)) + w[16] + $B5470917;
|
||||
|
||||
temp:= (t1 and (t6 and not t0 xor t2 and t5 xor t3 xor t4) xor t2 and (t6 xor t5) xor t0 and t5 xor t4);
|
||||
t7:= ((temp shr 7) or (temp shl 25)) + ((t7 shr 11) or (t7 shl 21)) + w[ 0] + $9216D5D9;
|
||||
temp:= (t0 and (t5 and not t7 xor t1 and t4 xor t2 xor t3) xor t1 and (t5 xor t4) xor t7 and t4 xor t3);
|
||||
t6:= ((temp shr 7) or (temp shl 25)) + ((t6 shr 11) or (t6 shl 21)) + w[23] + $8979FB1B;
|
||||
temp:= (t7 and (t4 and not t6 xor t0 and t3 xor t1 xor t2) xor t0 and (t4 xor t3) xor t6 and t3 xor t2);
|
||||
t5:= ((temp shr 7) or (temp shl 25)) + ((t5 shr 11) or (t5 shl 21)) + w[20] + $D1310BA6;
|
||||
temp:= (t6 and (t3 and not t5 xor t7 and t2 xor t0 xor t1) xor t7 and (t3 xor t2) xor t5 and t2 xor t1);
|
||||
t4:= ((temp shr 7) or (temp shl 25)) + ((t4 shr 11) or (t4 shl 21)) + w[22] + $98DFB5AC;
|
||||
temp:= (t5 and (t2 and not t4 xor t6 and t1 xor t7 xor t0) xor t6 and (t2 xor t1) xor t4 and t1 xor t0);
|
||||
t3:= ((temp shr 7) or (temp shl 25)) + ((t3 shr 11) or (t3 shl 21)) + w[ 1] + $2FFD72DB;
|
||||
temp:= (t4 and (t1 and not t3 xor t5 and t0 xor t6 xor t7) xor t5 and (t1 xor t0) xor t3 and t0 xor t7);
|
||||
t2:= ((temp shr 7) or (temp shl 25)) + ((t2 shr 11) or (t2 shl 21)) + w[10] + $D01ADFB7;
|
||||
temp:= (t3 and (t0 and not t2 xor t4 and t7 xor t5 xor t6) xor t4 and (t0 xor t7) xor t2 and t7 xor t6);
|
||||
t1:= ((temp shr 7) or (temp shl 25)) + ((t1 shr 11) or (t1 shl 21)) + w[ 4] + $B8E1AFED;
|
||||
temp:= (t2 and (t7 and not t1 xor t3 and t6 xor t4 xor t5) xor t3 and (t7 xor t6) xor t1 and t6 xor t5);
|
||||
t0:= ((temp shr 7) or (temp shl 25)) + ((t0 shr 11) or (t0 shl 21)) + w[ 8] + $6A267E96;
|
||||
|
||||
temp:= (t1 and (t6 and not t0 xor t2 and t5 xor t3 xor t4) xor t2 and (t6 xor t5) xor t0 and t5 xor t4);
|
||||
t7:= ((temp shr 7) or (temp shl 25)) + ((t7 shr 11) or (t7 shl 21)) + w[30] + $BA7C9045;
|
||||
temp:= (t0 and (t5 and not t7 xor t1 and t4 xor t2 xor t3) xor t1 and (t5 xor t4) xor t7 and t4 xor t3);
|
||||
t6:= ((temp shr 7) or (temp shl 25)) + ((t6 shr 11) or (t6 shl 21)) + w[ 3] + $F12C7F99;
|
||||
temp:= (t7 and (t4 and not t6 xor t0 and t3 xor t1 xor t2) xor t0 and (t4 xor t3) xor t6 and t3 xor t2);
|
||||
t5:= ((temp shr 7) or (temp shl 25)) + ((t5 shr 11) or (t5 shl 21)) + w[21] + $24A19947;
|
||||
temp:= (t6 and (t3 and not t5 xor t7 and t2 xor t0 xor t1) xor t7 and (t3 xor t2) xor t5 and t2 xor t1);
|
||||
t4:= ((temp shr 7) or (temp shl 25)) + ((t4 shr 11) or (t4 shl 21)) + w[ 9] + $B3916CF7;
|
||||
temp:= (t5 and (t2 and not t4 xor t6 and t1 xor t7 xor t0) xor t6 and (t2 xor t1) xor t4 and t1 xor t0);
|
||||
t3:= ((temp shr 7) or (temp shl 25)) + ((t3 shr 11) or (t3 shl 21)) + w[17] + $0801F2E2;
|
||||
temp:= (t4 and (t1 and not t3 xor t5 and t0 xor t6 xor t7) xor t5 and (t1 xor t0) xor t3 and t0 xor t7);
|
||||
t2:= ((temp shr 7) or (temp shl 25)) + ((t2 shr 11) or (t2 shl 21)) + w[24] + $858EFC16;
|
||||
temp:= (t3 and (t0 and not t2 xor t4 and t7 xor t5 xor t6) xor t4 and (t0 xor t7) xor t2 and t7 xor t6);
|
||||
t1:= ((temp shr 7) or (temp shl 25)) + ((t1 shr 11) or (t1 shl 21)) + w[29] + $636920D8;
|
||||
temp:= (t2 and (t7 and not t1 xor t3 and t6 xor t4 xor t5) xor t3 and (t7 xor t6) xor t1 and t6 xor t5);
|
||||
t0:= ((temp shr 7) or (temp shl 25)) + ((t0 shr 11) or (t0 shl 21)) + w[ 6] + $71574E69;
|
||||
|
||||
temp:= (t1 and (t6 and not t0 xor t2 and t5 xor t3 xor t4) xor t2 and (t6 xor t5) xor t0 and t5 xor t4);
|
||||
t7:= ((temp shr 7) or (temp shl 25)) + ((t7 shr 11) or (t7 shl 21)) + w[19] + $A458FEA3;
|
||||
temp:= (t0 and (t5 and not t7 xor t1 and t4 xor t2 xor t3) xor t1 and (t5 xor t4) xor t7 and t4 xor t3);
|
||||
t6:= ((temp shr 7) or (temp shl 25)) + ((t6 shr 11) or (t6 shl 21)) + w[12] + $F4933D7E;
|
||||
temp:= (t7 and (t4 and not t6 xor t0 and t3 xor t1 xor t2) xor t0 and (t4 xor t3) xor t6 and t3 xor t2);
|
||||
t5:= ((temp shr 7) or (temp shl 25)) + ((t5 shr 11) or (t5 shl 21)) + w[15] + $0D95748F;
|
||||
temp:= (t6 and (t3 and not t5 xor t7 and t2 xor t0 xor t1) xor t7 and (t3 xor t2) xor t5 and t2 xor t1);
|
||||
t4:= ((temp shr 7) or (temp shl 25)) + ((t4 shr 11) or (t4 shl 21)) + w[13] + $728EB658;
|
||||
temp:= (t5 and (t2 and not t4 xor t6 and t1 xor t7 xor t0) xor t6 and (t2 xor t1) xor t4 and t1 xor t0);
|
||||
t3:= ((temp shr 7) or (temp shl 25)) + ((t3 shr 11) or (t3 shl 21)) + w[ 2] + $718BCD58;
|
||||
temp:= (t4 and (t1 and not t3 xor t5 and t0 xor t6 xor t7) xor t5 and (t1 xor t0) xor t3 and t0 xor t7);
|
||||
t2:= ((temp shr 7) or (temp shl 25)) + ((t2 shr 11) or (t2 shl 21)) + w[25] + $82154AEE;
|
||||
temp:= (t3 and (t0 and not t2 xor t4 and t7 xor t5 xor t6) xor t4 and (t0 xor t7) xor t2 and t7 xor t6);
|
||||
t1:= ((temp shr 7) or (temp shl 25)) + ((t1 shr 11) or (t1 shl 21)) + w[31] + $7B54A41D;
|
||||
temp:= (t2 and (t7 and not t1 xor t3 and t6 xor t4 xor t5) xor t3 and (t7 xor t6) xor t1 and t6 xor t5);
|
||||
t0:= ((temp shr 7) or (temp shl 25)) + ((t0 shr 11) or (t0 shl 21)) + w[27] + $C25A59B5;
|
||||
|
||||
temp:= (t6 and (t2 and t0 xor t1 xor t5) xor t2 and t3 xor t0 and t4 xor t5);
|
||||
t7:= ((temp shr 7) or (temp shl 25)) + ((t7 shr 11) or (t7 shl 21)) + w[19] + $9C30D539;
|
||||
temp:= (t5 and (t1 and t7 xor t0 xor t4) xor t1 and t2 xor t7 and t3 xor t4);
|
||||
t6:= ((temp shr 7) or (temp shl 25)) + ((t6 shr 11) or (t6 shl 21)) + w[ 9] + $2AF26013;
|
||||
temp:= (t4 and (t0 and t6 xor t7 xor t3) xor t0 and t1 xor t6 and t2 xor t3);
|
||||
t5:= ((temp shr 7) or (temp shl 25)) + ((t5 shr 11) or (t5 shl 21)) + w[ 4] + $C5D1B023;
|
||||
temp:= (t3 and (t7 and t5 xor t6 xor t2) xor t7 and t0 xor t5 and t1 xor t2);
|
||||
t4:= ((temp shr 7) or (temp shl 25)) + ((t4 shr 11) or (t4 shl 21)) + w[20] + $286085F0;
|
||||
temp:= (t2 and (t6 and t4 xor t5 xor t1) xor t6 and t7 xor t4 and t0 xor t1);
|
||||
t3:= ((temp shr 7) or (temp shl 25)) + ((t3 shr 11) or (t3 shl 21)) + w[28] + $CA417918;
|
||||
temp:= (t1 and (t5 and t3 xor t4 xor t0) xor t5 and t6 xor t3 and t7 xor t0);
|
||||
t2:= ((temp shr 7) or (temp shl 25)) + ((t2 shr 11) or (t2 shl 21)) + w[17] + $B8DB38EF;
|
||||
temp:= (t0 and (t4 and t2 xor t3 xor t7) xor t4 and t5 xor t2 and t6 xor t7);
|
||||
t1:= ((temp shr 7) or (temp shl 25)) + ((t1 shr 11) or (t1 shl 21)) + w[ 8] + $8E79DCB0;
|
||||
temp:= (t7 and (t3 and t1 xor t2 xor t6) xor t3 and t4 xor t1 and t5 xor t6);
|
||||
t0:= ((temp shr 7) or (temp shl 25)) + ((t0 shr 11) or (t0 shl 21)) + w[22] + $603A180E;
|
||||
|
||||
temp:= (t6 and (t2 and t0 xor t1 xor t5) xor t2 and t3 xor t0 and t4 xor t5);
|
||||
t7:= ((temp shr 7) or (temp shl 25)) + ((t7 shr 11) or (t7 shl 21)) + w[29] + $6C9E0E8B;
|
||||
temp:= (t5 and (t1 and t7 xor t0 xor t4) xor t1 and t2 xor t7 and t3 xor t4);
|
||||
t6:= ((temp shr 7) or (temp shl 25)) + ((t6 shr 11) or (t6 shl 21)) + w[14] + $B01E8A3E;
|
||||
temp:= (t4 and (t0 and t6 xor t7 xor t3) xor t0 and t1 xor t6 and t2 xor t3);
|
||||
t5:= ((temp shr 7) or (temp shl 25)) + ((t5 shr 11) or (t5 shl 21)) + w[25] + $D71577C1;
|
||||
temp:= (t3 and (t7 and t5 xor t6 xor t2) xor t7 and t0 xor t5 and t1 xor t2);
|
||||
t4:= ((temp shr 7) or (temp shl 25)) + ((t4 shr 11) or (t4 shl 21)) + w[12] + $BD314B27;
|
||||
temp:= (t2 and (t6 and t4 xor t5 xor t1) xor t6 and t7 xor t4 and t0 xor t1);
|
||||
t3:= ((temp shr 7) or (temp shl 25)) + ((t3 shr 11) or (t3 shl 21)) + w[24] + $78AF2FDA;
|
||||
temp:= (t1 and (t5 and t3 xor t4 xor t0) xor t5 and t6 xor t3 and t7 xor t0);
|
||||
t2:= ((temp shr 7) or (temp shl 25)) + ((t2 shr 11) or (t2 shl 21)) + w[30] + $55605C60;
|
||||
temp:= (t0 and (t4 and t2 xor t3 xor t7) xor t4 and t5 xor t2 and t6 xor t7);
|
||||
t1:= ((temp shr 7) or (temp shl 25)) + ((t1 shr 11) or (t1 shl 21)) + w[16] + $E65525F3;
|
||||
temp:= (t7 and (t3 and t1 xor t2 xor t6) xor t3 and t4 xor t1 and t5 xor t6);
|
||||
t0:= ((temp shr 7) or (temp shl 25)) + ((t0 shr 11) or (t0 shl 21)) + w[26] + $AA55AB94;
|
||||
|
||||
temp:= (t6 and (t2 and t0 xor t1 xor t5) xor t2 and t3 xor t0 and t4 xor t5);
|
||||
t7:= ((temp shr 7) or (temp shl 25)) + ((t7 shr 11) or (t7 shl 21)) + w[31] + $57489862;
|
||||
temp:= (t5 and (t1 and t7 xor t0 xor t4) xor t1 and t2 xor t7 and t3 xor t4);
|
||||
t6:= ((temp shr 7) or (temp shl 25)) + ((t6 shr 11) or (t6 shl 21)) + w[15] + $63E81440;
|
||||
temp:= (t4 and (t0 and t6 xor t7 xor t3) xor t0 and t1 xor t6 and t2 xor t3);
|
||||
t5:= ((temp shr 7) or (temp shl 25)) + ((t5 shr 11) or (t5 shl 21)) + w[ 7] + $55CA396A;
|
||||
temp:= (t3 and (t7 and t5 xor t6 xor t2) xor t7 and t0 xor t5 and t1 xor t2);
|
||||
t4:= ((temp shr 7) or (temp shl 25)) + ((t4 shr 11) or (t4 shl 21)) + w[ 3] + $2AAB10B6;
|
||||
temp:= (t2 and (t6 and t4 xor t5 xor t1) xor t6 and t7 xor t4 and t0 xor t1);
|
||||
t3:= ((temp shr 7) or (temp shl 25)) + ((t3 shr 11) or (t3 shl 21)) + w[ 1] + $B4CC5C34;
|
||||
temp:= (t1 and (t5 and t3 xor t4 xor t0) xor t5 and t6 xor t3 and t7 xor t0);
|
||||
t2:= ((temp shr 7) or (temp shl 25)) + ((t2 shr 11) or (t2 shl 21)) + w[ 0] + $1141E8CE;
|
||||
temp:= (t0 and (t4 and t2 xor t3 xor t7) xor t4 and t5 xor t2 and t6 xor t7);
|
||||
t1:= ((temp shr 7) or (temp shl 25)) + ((t1 shr 11) or (t1 shl 21)) + w[18] + $A15486AF;
|
||||
temp:= (t7 and (t3 and t1 xor t2 xor t6) xor t3 and t4 xor t1 and t5 xor t6);
|
||||
t0:= ((temp shr 7) or (temp shl 25)) + ((t0 shr 11) or (t0 shl 21)) + w[27] + $7C72E993;
|
||||
|
||||
temp:= (t6 and (t2 and t0 xor t1 xor t5) xor t2 and t3 xor t0 and t4 xor t5);
|
||||
t7:= ((temp shr 7) or (temp shl 25)) + ((t7 shr 11) or (t7 shl 21)) + w[13] + $B3EE1411;
|
||||
temp:= (t5 and (t1 and t7 xor t0 xor t4) xor t1 and t2 xor t7 and t3 xor t4);
|
||||
t6:= ((temp shr 7) or (temp shl 25)) + ((t6 shr 11) or (t6 shl 21)) + w[ 6] + $636FBC2A;
|
||||
temp:= (t4 and (t0 and t6 xor t7 xor t3) xor t0 and t1 xor t6 and t2 xor t3);
|
||||
t5:= ((temp shr 7) or (temp shl 25)) + ((t5 shr 11) or (t5 shl 21)) + w[21] + $2BA9C55D;
|
||||
temp:= (t3 and (t7 and t5 xor t6 xor t2) xor t7 and t0 xor t5 and t1 xor t2);
|
||||
t4:= ((temp shr 7) or (temp shl 25)) + ((t4 shr 11) or (t4 shl 21)) + w[10] + $741831F6;
|
||||
temp:= (t2 and (t6 and t4 xor t5 xor t1) xor t6 and t7 xor t4 and t0 xor t1);
|
||||
t3:= ((temp shr 7) or (temp shl 25)) + ((t3 shr 11) or (t3 shl 21)) + w[23] + $CE5C3E16;
|
||||
temp:= (t1 and (t5 and t3 xor t4 xor t0) xor t5 and t6 xor t3 and t7 xor t0);
|
||||
t2:= ((temp shr 7) or (temp shl 25)) + ((t2 shr 11) or (t2 shl 21)) + w[11] + $9B87931E;
|
||||
temp:= (t0 and (t4 and t2 xor t3 xor t7) xor t4 and t5 xor t2 and t6 xor t7);
|
||||
t1:= ((temp shr 7) or (temp shl 25)) + ((t1 shr 11) or (t1 shl 21)) + w[ 5] + $AFD6BA33;
|
||||
temp:= (t7 and (t3 and t1 xor t2 xor t6) xor t3 and t4 xor t1 and t5 xor t6);
|
||||
t0:= ((temp shr 7) or (temp shl 25)) + ((t0 shr 11) or (t0 shl 21)) + w[ 2] + $6C24CF5C;
|
||||
|
||||
temp:= (t0 and (t4 and not t2 xor t5 and not t6 xor t1 xor t6 xor t3) xor t5 and (t1 and t2 xor t4 xor t6) xor t2 and t6 xor t3);
|
||||
t7:= ((temp shr 7) or (temp shl 25)) + ((t7 shr 11) or (t7 shl 21)) + w[24] + $7A325381;
|
||||
temp:= (t7 and (t3 and not t1 xor t4 and not t5 xor t0 xor t5 xor t2) xor t4 and (t0 and t1 xor t3 xor t5) xor t1 and t5 xor t2);
|
||||
t6:= ((temp shr 7) or (temp shl 25)) + ((t6 shr 11) or (t6 shl 21)) + w[ 4] + $28958677;
|
||||
temp:= (t6 and (t2 and not t0 xor t3 and not t4 xor t7 xor t4 xor t1) xor t3 and (t7 and t0 xor t2 xor t4) xor t0 and t4 xor t1);
|
||||
t5:= ((temp shr 7) or (temp shl 25)) + ((t5 shr 11) or (t5 shl 21)) + w[ 0] + $3B8F4898;
|
||||
temp:= (t5 and (t1 and not t7 xor t2 and not t3 xor t6 xor t3 xor t0) xor t2 and (t6 and t7 xor t1 xor t3) xor t7 and t3 xor t0);
|
||||
t4:= ((temp shr 7) or (temp shl 25)) + ((t4 shr 11) or (t4 shl 21)) + w[14] + $6B4BB9AF;
|
||||
temp:= (t4 and (t0 and not t6 xor t1 and not t2 xor t5 xor t2 xor t7) xor t1 and (t5 and t6 xor t0 xor t2) xor t6 and t2 xor t7);
|
||||
t3:= ((temp shr 7) or (temp shl 25)) + ((t3 shr 11) or (t3 shl 21)) + w[ 2] + $C4BFE81B;
|
||||
temp:= (t3 and (t7 and not t5 xor t0 and not t1 xor t4 xor t1 xor t6) xor t0 and (t4 and t5 xor t7 xor t1) xor t5 and t1 xor t6);
|
||||
t2:= ((temp shr 7) or (temp shl 25)) + ((t2 shr 11) or (t2 shl 21)) + w[ 7] + $66282193;
|
||||
temp:= (t2 and (t6 and not t4 xor t7 and not t0 xor t3 xor t0 xor t5) xor t7 and (t3 and t4 xor t6 xor t0) xor t4 and t0 xor t5);
|
||||
t1:= ((temp shr 7) or (temp shl 25)) + ((t1 shr 11) or (t1 shl 21)) + w[28] + $61D809CC;
|
||||
temp:= (t1 and (t5 and not t3 xor t6 and not t7 xor t2 xor t7 xor t4) xor t6 and (t2 and t3 xor t5 xor t7) xor t3 and t7 xor t4);
|
||||
t0:= ((temp shr 7) or (temp shl 25)) + ((t0 shr 11) or (t0 shl 21)) + w[23] + $FB21A991;
|
||||
|
||||
temp:= (t0 and (t4 and not t2 xor t5 and not t6 xor t1 xor t6 xor t3) xor t5 and (t1 and t2 xor t4 xor t6) xor t2 and t6 xor t3);
|
||||
t7:= ((temp shr 7) or (temp shl 25)) + ((t7 shr 11) or (t7 shl 21)) + w[26] + $487CAC60;
|
||||
temp:= (t7 and (t3 and not t1 xor t4 and not t5 xor t0 xor t5 xor t2) xor t4 and (t0 and t1 xor t3 xor t5) xor t1 and t5 xor t2);
|
||||
t6:= ((temp shr 7) or (temp shl 25)) + ((t6 shr 11) or (t6 shl 21)) + w[ 6] + $5DEC8032;
|
||||
temp:= (t6 and (t2 and not t0 xor t3 and not t4 xor t7 xor t4 xor t1) xor t3 and (t7 and t0 xor t2 xor t4) xor t0 and t4 xor t1);
|
||||
t5:= ((temp shr 7) or (temp shl 25)) + ((t5 shr 11) or (t5 shl 21)) + w[30] + $EF845D5D;
|
||||
temp:= (t5 and (t1 and not t7 xor t2 and not t3 xor t6 xor t3 xor t0) xor t2 and (t6 and t7 xor t1 xor t3) xor t7 and t3 xor t0);
|
||||
t4:= ((temp shr 7) or (temp shl 25)) + ((t4 shr 11) or (t4 shl 21)) + w[20] + $E98575B1;
|
||||
temp:= (t4 and (t0 and not t6 xor t1 and not t2 xor t5 xor t2 xor t7) xor t1 and (t5 and t6 xor t0 xor t2) xor t6 and t2 xor t7);
|
||||
t3:= ((temp shr 7) or (temp shl 25)) + ((t3 shr 11) or (t3 shl 21)) + w[18] + $DC262302;
|
||||
temp:= (t3 and (t7 and not t5 xor t0 and not t1 xor t4 xor t1 xor t6) xor t0 and (t4 and t5 xor t7 xor t1) xor t5 and t1 xor t6);
|
||||
t2:= ((temp shr 7) or (temp shl 25)) + ((t2 shr 11) or (t2 shl 21)) + w[25] + $EB651B88;
|
||||
temp:= (t2 and (t6 and not t4 xor t7 and not t0 xor t3 xor t0 xor t5) xor t7 and (t3 and t4 xor t6 xor t0) xor t4 and t0 xor t5);
|
||||
t1:= ((temp shr 7) or (temp shl 25)) + ((t1 shr 11) or (t1 shl 21)) + w[19] + $23893E81;
|
||||
temp:= (t1 and (t5 and not t3 xor t6 and not t7 xor t2 xor t7 xor t4) xor t6 and (t2 and t3 xor t5 xor t7) xor t3 and t7 xor t4);
|
||||
t0:= ((temp shr 7) or (temp shl 25)) + ((t0 shr 11) or (t0 shl 21)) + w[ 3] + $D396ACC5;
|
||||
|
||||
temp:= (t0 and (t4 and not t2 xor t5 and not t6 xor t1 xor t6 xor t3) xor t5 and (t1 and t2 xor t4 xor t6) xor t2 and t6 xor t3);
|
||||
t7:= ((temp shr 7) or (temp shl 25)) + ((t7 shr 11) or (t7 shl 21)) + w[22] + $0F6D6FF3;
|
||||
temp:= (t7 and (t3 and not t1 xor t4 and not t5 xor t0 xor t5 xor t2) xor t4 and (t0 and t1 xor t3 xor t5) xor t1 and t5 xor t2);
|
||||
t6:= ((temp shr 7) or (temp shl 25)) + ((t6 shr 11) or (t6 shl 21)) + w[11] + $83F44239;
|
||||
temp:= (t6 and (t2 and not t0 xor t3 and not t4 xor t7 xor t4 xor t1) xor t3 and (t7 and t0 xor t2 xor t4) xor t0 and t4 xor t1);
|
||||
t5:= ((temp shr 7) or (temp shl 25)) + ((t5 shr 11) or (t5 shl 21)) + w[31] + $2E0B4482;
|
||||
temp:= (t5 and (t1 and not t7 xor t2 and not t3 xor t6 xor t3 xor t0) xor t2 and (t6 and t7 xor t1 xor t3) xor t7 and t3 xor t0);
|
||||
t4:= ((temp shr 7) or (temp shl 25)) + ((t4 shr 11) or (t4 shl 21)) + w[21] + $A4842004;
|
||||
temp:= (t4 and (t0 and not t6 xor t1 and not t2 xor t5 xor t2 xor t7) xor t1 and (t5 and t6 xor t0 xor t2) xor t6 and t2 xor t7);
|
||||
t3:= ((temp shr 7) or (temp shl 25)) + ((t3 shr 11) or (t3 shl 21)) + w[ 8] + $69C8F04A;
|
||||
temp:= (t3 and (t7 and not t5 xor t0 and not t1 xor t4 xor t1 xor t6) xor t0 and (t4 and t5 xor t7 xor t1) xor t5 and t1 xor t6);
|
||||
t2:= ((temp shr 7) or (temp shl 25)) + ((t2 shr 11) or (t2 shl 21)) + w[27] + $9E1F9B5E;
|
||||
temp:= (t2 and (t6 and not t4 xor t7 and not t0 xor t3 xor t0 xor t5) xor t7 and (t3 and t4 xor t6 xor t0) xor t4 and t0 xor t5);
|
||||
t1:= ((temp shr 7) or (temp shl 25)) + ((t1 shr 11) or (t1 shl 21)) + w[12] + $21C66842;
|
||||
temp:= (t1 and (t5 and not t3 xor t6 and not t7 xor t2 xor t7 xor t4) xor t6 and (t2 and t3 xor t5 xor t7) xor t3 and t7 xor t4);
|
||||
t0:= ((temp shr 7) or (temp shl 25)) + ((t0 shr 11) or (t0 shl 21)) + w[ 9] + $F6E96C9A;
|
||||
|
||||
temp:= (t0 and (t4 and not t2 xor t5 and not t6 xor t1 xor t6 xor t3) xor t5 and (t1 and t2 xor t4 xor t6) xor t2 and t6 xor t3);
|
||||
t7:= ((temp shr 7) or (temp shl 25)) + ((t7 shr 11) or (t7 shl 21)) + w[ 1] + $670C9C61;
|
||||
temp:= (t7 and (t3 and not t1 xor t4 and not t5 xor t0 xor t5 xor t2) xor t4 and (t0 and t1 xor t3 xor t5) xor t1 and t5 xor t2);
|
||||
t6:= ((temp shr 7) or (temp shl 25)) + ((t6 shr 11) or (t6 shl 21)) + w[29] + $ABD388F0;
|
||||
temp:= (t6 and (t2 and not t0 xor t3 and not t4 xor t7 xor t4 xor t1) xor t3 and (t7 and t0 xor t2 xor t4) xor t0 and t4 xor t1);
|
||||
t5:= ((temp shr 7) or (temp shl 25)) + ((t5 shr 11) or (t5 shl 21)) + w[ 5] + $6A51A0D2;
|
||||
temp:= (t5 and (t1 and not t7 xor t2 and not t3 xor t6 xor t3 xor t0) xor t2 and (t6 and t7 xor t1 xor t3) xor t7 and t3 xor t0);
|
||||
t4:= ((temp shr 7) or (temp shl 25)) + ((t4 shr 11) or (t4 shl 21)) + w[15] + $D8542F68;
|
||||
temp:= (t4 and (t0 and not t6 xor t1 and not t2 xor t5 xor t2 xor t7) xor t1 and (t5 and t6 xor t0 xor t2) xor t6 and t2 xor t7);
|
||||
t3:= ((temp shr 7) or (temp shl 25)) + ((t3 shr 11) or (t3 shl 21)) + w[17] + $960FA728;
|
||||
temp:= (t3 and (t7 and not t5 xor t0 and not t1 xor t4 xor t1 xor t6) xor t0 and (t4 and t5 xor t7 xor t1) xor t5 and t1 xor t6);
|
||||
t2:= ((temp shr 7) or (temp shl 25)) + ((t2 shr 11) or (t2 shl 21)) + w[10] + $AB5133A3;
|
||||
temp:= (t2 and (t6 and not t4 xor t7 and not t0 xor t3 xor t0 xor t5) xor t7 and (t3 and t4 xor t6 xor t0) xor t4 and t0 xor t5);
|
||||
t1:= ((temp shr 7) or (temp shl 25)) + ((t1 shr 11) or (t1 shl 21)) + w[16] + $6EEF0B6C;
|
||||
temp:= (t1 and (t5 and not t3 xor t6 and not t7 xor t2 xor t7 xor t4) xor t6 and (t2 and t3 xor t5 xor t7) xor t3 and t7 xor t4);
|
||||
t0:= ((temp shr 7) or (temp shl 25)) + ((t0 shr 11) or (t0 shl 21)) + w[13] + $137A3BE4;
|
||||
|
||||
339
dcpcrypt/Hashes/DCPhaval5.inc
Normal file
@@ -0,0 +1,339 @@
|
||||
temp:= (t2 and (t6 xor t1) xor t5 and t4 xor t0 and t3 xor t6);
|
||||
t7:= ((temp shr 7) or (temp shl 25)) + ((t7 shr 11) or (t7 shl 21)) + w[ 0];
|
||||
temp:= (t1 and (t5 xor t0) xor t4 and t3 xor t7 and t2 xor t5);
|
||||
t6:= ((temp shr 7) or (temp shl 25)) + ((t6 shr 11) or (t6 shl 21)) + w[ 1];
|
||||
temp:= (t0 and (t4 xor t7) xor t3 and t2 xor t6 and t1 xor t4);
|
||||
t5:= ((temp shr 7) or (temp shl 25)) + ((t5 shr 11) or (t5 shl 21)) + w[ 2];
|
||||
temp:= (t7 and (t3 xor t6) xor t2 and t1 xor t5 and t0 xor t3);
|
||||
t4:= ((temp shr 7) or (temp shl 25)) + ((t4 shr 11) or (t4 shl 21)) + w[ 3];
|
||||
temp:= (t6 and (t2 xor t5) xor t1 and t0 xor t4 and t7 xor t2);
|
||||
t3:= ((temp shr 7) or (temp shl 25)) + ((t3 shr 11) or (t3 shl 21)) + w[ 4];
|
||||
temp:= (t5 and (t1 xor t4) xor t0 and t7 xor t3 and t6 xor t1);
|
||||
t2:= ((temp shr 7) or (temp shl 25)) + ((t2 shr 11) or (t2 shl 21)) + w[ 5];
|
||||
temp:= (t4 and (t0 xor t3) xor t7 and t6 xor t2 and t5 xor t0);
|
||||
t1:= ((temp shr 7) or (temp shl 25)) + ((t1 shr 11) or (t1 shl 21)) + w[ 6];
|
||||
temp:= (t3 and (t7 xor t2) xor t6 and t5 xor t1 and t4 xor t7);
|
||||
t0:= ((temp shr 7) or (temp shl 25)) + ((t0 shr 11) or (t0 shl 21)) + w[ 7];
|
||||
|
||||
temp:= (t2 and (t6 xor t1) xor t5 and t4 xor t0 and t3 xor t6);
|
||||
t7:= ((temp shr 7) or (temp shl 25)) + ((t7 shr 11) or (t7 shl 21)) + w[ 8];
|
||||
temp:= (t1 and (t5 xor t0) xor t4 and t3 xor t7 and t2 xor t5);
|
||||
t6:= ((temp shr 7) or (temp shl 25)) + ((t6 shr 11) or (t6 shl 21)) + w[ 9];
|
||||
temp:= (t0 and (t4 xor t7) xor t3 and t2 xor t6 and t1 xor t4);
|
||||
t5:= ((temp shr 7) or (temp shl 25)) + ((t5 shr 11) or (t5 shl 21)) + w[10];
|
||||
temp:= (t7 and (t3 xor t6) xor t2 and t1 xor t5 and t0 xor t3);
|
||||
t4:= ((temp shr 7) or (temp shl 25)) + ((t4 shr 11) or (t4 shl 21)) + w[11];
|
||||
temp:= (t6 and (t2 xor t5) xor t1 and t0 xor t4 and t7 xor t2);
|
||||
t3:= ((temp shr 7) or (temp shl 25)) + ((t3 shr 11) or (t3 shl 21)) + w[12];
|
||||
temp:= (t5 and (t1 xor t4) xor t0 and t7 xor t3 and t6 xor t1);
|
||||
t2:= ((temp shr 7) or (temp shl 25)) + ((t2 shr 11) or (t2 shl 21)) + w[13];
|
||||
temp:= (t4 and (t0 xor t3) xor t7 and t6 xor t2 and t5 xor t0);
|
||||
t1:= ((temp shr 7) or (temp shl 25)) + ((t1 shr 11) or (t1 shl 21)) + w[14];
|
||||
temp:= (t3 and (t7 xor t2) xor t6 and t5 xor t1 and t4 xor t7);
|
||||
t0:= ((temp shr 7) or (temp shl 25)) + ((t0 shr 11) or (t0 shl 21)) + w[15];
|
||||
|
||||
temp:= (t2 and (t6 xor t1) xor t5 and t4 xor t0 and t3 xor t6);
|
||||
t7:= ((temp shr 7) or (temp shl 25)) + ((t7 shr 11) or (t7 shl 21)) + w[16];
|
||||
temp:= (t1 and (t5 xor t0) xor t4 and t3 xor t7 and t2 xor t5);
|
||||
t6:= ((temp shr 7) or (temp shl 25)) + ((t6 shr 11) or (t6 shl 21)) + w[17];
|
||||
temp:= (t0 and (t4 xor t7) xor t3 and t2 xor t6 and t1 xor t4);
|
||||
t5:= ((temp shr 7) or (temp shl 25)) + ((t5 shr 11) or (t5 shl 21)) + w[18];
|
||||
temp:= (t7 and (t3 xor t6) xor t2 and t1 xor t5 and t0 xor t3);
|
||||
t4:= ((temp shr 7) or (temp shl 25)) + ((t4 shr 11) or (t4 shl 21)) + w[19];
|
||||
temp:= (t6 and (t2 xor t5) xor t1 and t0 xor t4 and t7 xor t2);
|
||||
t3:= ((temp shr 7) or (temp shl 25)) + ((t3 shr 11) or (t3 shl 21)) + w[20];
|
||||
temp:= (t5 and (t1 xor t4) xor t0 and t7 xor t3 and t6 xor t1);
|
||||
t2:= ((temp shr 7) or (temp shl 25)) + ((t2 shr 11) or (t2 shl 21)) + w[21];
|
||||
temp:= (t4 and (t0 xor t3) xor t7 and t6 xor t2 and t5 xor t0);
|
||||
t1:= ((temp shr 7) or (temp shl 25)) + ((t1 shr 11) or (t1 shl 21)) + w[22];
|
||||
temp:= (t3 and (t7 xor t2) xor t6 and t5 xor t1 and t4 xor t7);
|
||||
t0:= ((temp shr 7) or (temp shl 25)) + ((t0 shr 11) or (t0 shl 21)) + w[23];
|
||||
|
||||
temp:= (t2 and (t6 xor t1) xor t5 and t4 xor t0 and t3 xor t6);
|
||||
t7:= ((temp shr 7) or (temp shl 25)) + ((t7 shr 11) or (t7 shl 21)) + w[24];
|
||||
temp:= (t1 and (t5 xor t0) xor t4 and t3 xor t7 and t2 xor t5);
|
||||
t6:= ((temp shr 7) or (temp shl 25)) + ((t6 shr 11) or (t6 shl 21)) + w[25];
|
||||
temp:= (t0 and (t4 xor t7) xor t3 and t2 xor t6 and t1 xor t4);
|
||||
t5:= ((temp shr 7) or (temp shl 25)) + ((t5 shr 11) or (t5 shl 21)) + w[26];
|
||||
temp:= (t7 and (t3 xor t6) xor t2 and t1 xor t5 and t0 xor t3);
|
||||
t4:= ((temp shr 7) or (temp shl 25)) + ((t4 shr 11) or (t4 shl 21)) + w[27];
|
||||
temp:= (t6 and (t2 xor t5) xor t1 and t0 xor t4 and t7 xor t2);
|
||||
t3:= ((temp shr 7) or (temp shl 25)) + ((t3 shr 11) or (t3 shl 21)) + w[28];
|
||||
temp:= (t5 and (t1 xor t4) xor t0 and t7 xor t3 and t6 xor t1);
|
||||
t2:= ((temp shr 7) or (temp shl 25)) + ((t2 shr 11) or (t2 shl 21)) + w[29];
|
||||
temp:= (t4 and (t0 xor t3) xor t7 and t6 xor t2 and t5 xor t0);
|
||||
t1:= ((temp shr 7) or (temp shl 25)) + ((t1 shr 11) or (t1 shl 21)) + w[30];
|
||||
temp:= (t3 and (t7 xor t2) xor t6 and t5 xor t1 and t4 xor t7);
|
||||
t0:= ((temp shr 7) or (temp shl 25)) + ((t0 shr 11) or (t0 shl 21)) + w[31];
|
||||
|
||||
temp:= (t3 and (t4 and not t0 xor t1 and t2 xor t6 xor t5) xor t1 and (t4 xor t2) xor t0 and t2 xor t5);
|
||||
t7:= ((temp shr 7) or (temp shl 25)) + ((t7 shr 11) or (t7 shl 21)) + w[ 5] + $452821E6;
|
||||
temp:= (t2 and (t3 and not t7 xor t0 and t1 xor t5 xor t4) xor t0 and (t3 xor t1) xor t7 and t1 xor t4);
|
||||
t6:= ((temp shr 7) or (temp shl 25)) + ((t6 shr 11) or (t6 shl 21)) + w[14] + $38D01377;
|
||||
temp:= (t1 and (t2 and not t6 xor t7 and t0 xor t4 xor t3) xor t7 and (t2 xor t0) xor t6 and t0 xor t3);
|
||||
t5:= ((temp shr 7) or (temp shl 25)) + ((t5 shr 11) or (t5 shl 21)) + w[26] + $BE5466CF;
|
||||
temp:= (t0 and (t1 and not t5 xor t6 and t7 xor t3 xor t2) xor t6 and (t1 xor t7) xor t5 and t7 xor t2);
|
||||
t4:= ((temp shr 7) or (temp shl 25)) + ((t4 shr 11) or (t4 shl 21)) + w[18] + $34E90C6C;
|
||||
temp:= (t7 and (t0 and not t4 xor t5 and t6 xor t2 xor t1) xor t5 and (t0 xor t6) xor t4 and t6 xor t1);
|
||||
t3:= ((temp shr 7) or (temp shl 25)) + ((t3 shr 11) or (t3 shl 21)) + w[11] + $C0AC29B7;
|
||||
temp:= (t6 and (t7 and not t3 xor t4 and t5 xor t1 xor t0) xor t4 and (t7 xor t5) xor t3 and t5 xor t0);
|
||||
t2:= ((temp shr 7) or (temp shl 25)) + ((t2 shr 11) or (t2 shl 21)) + w[28] + $C97C50DD;
|
||||
temp:= (t5 and (t6 and not t2 xor t3 and t4 xor t0 xor t7) xor t3 and (t6 xor t4) xor t2 and t4 xor t7);
|
||||
t1:= ((temp shr 7) or (temp shl 25)) + ((t1 shr 11) or (t1 shl 21)) + w[ 7] + $3F84D5B5;
|
||||
temp:= (t4 and (t5 and not t1 xor t2 and t3 xor t7 xor t6) xor t2 and (t5 xor t3) xor t1 and t3 xor t6);
|
||||
t0:= ((temp shr 7) or (temp shl 25)) + ((t0 shr 11) or (t0 shl 21)) + w[16] + $B5470917;
|
||||
|
||||
temp:= (t3 and (t4 and not t0 xor t1 and t2 xor t6 xor t5) xor t1 and (t4 xor t2) xor t0 and t2 xor t5);
|
||||
t7:= ((temp shr 7) or (temp shl 25)) + ((t7 shr 11) or (t7 shl 21)) + w[ 0] + $9216D5D9;
|
||||
temp:= (t2 and (t3 and not t7 xor t0 and t1 xor t5 xor t4) xor t0 and (t3 xor t1) xor t7 and t1 xor t4);
|
||||
t6:= ((temp shr 7) or (temp shl 25)) + ((t6 shr 11) or (t6 shl 21)) + w[23] + $8979FB1B;
|
||||
temp:= (t1 and (t2 and not t6 xor t7 and t0 xor t4 xor t3) xor t7 and (t2 xor t0) xor t6 and t0 xor t3);
|
||||
t5:= ((temp shr 7) or (temp shl 25)) + ((t5 shr 11) or (t5 shl 21)) + w[20] + $D1310BA6;
|
||||
temp:= (t0 and (t1 and not t5 xor t6 and t7 xor t3 xor t2) xor t6 and (t1 xor t7) xor t5 and t7 xor t2);
|
||||
t4:= ((temp shr 7) or (temp shl 25)) + ((t4 shr 11) or (t4 shl 21)) + w[22] + $98DFB5AC;
|
||||
temp:= (t7 and (t0 and not t4 xor t5 and t6 xor t2 xor t1) xor t5 and (t0 xor t6) xor t4 and t6 xor t1);
|
||||
t3:= ((temp shr 7) or (temp shl 25)) + ((t3 shr 11) or (t3 shl 21)) + w[ 1] + $2FFD72DB;
|
||||
temp:= (t6 and (t7 and not t3 xor t4 and t5 xor t1 xor t0) xor t4 and (t7 xor t5) xor t3 and t5 xor t0);
|
||||
t2:= ((temp shr 7) or (temp shl 25)) + ((t2 shr 11) or (t2 shl 21)) + w[10] + $D01ADFB7;
|
||||
temp:= (t5 and (t6 and not t2 xor t3 and t4 xor t0 xor t7) xor t3 and (t6 xor t4) xor t2 and t4 xor t7);
|
||||
t1:= ((temp shr 7) or (temp shl 25)) + ((t1 shr 11) or (t1 shl 21)) + w[ 4] + $B8E1AFED;
|
||||
temp:= (t4 and (t5 and not t1 xor t2 and t3 xor t7 xor t6) xor t2 and (t5 xor t3) xor t1 and t3 xor t6);
|
||||
t0:= ((temp shr 7) or (temp shl 25)) + ((t0 shr 11) or (t0 shl 21)) + w[ 8] + $6A267E96;
|
||||
|
||||
temp:= (t3 and (t4 and not t0 xor t1 and t2 xor t6 xor t5) xor t1 and (t4 xor t2) xor t0 and t2 xor t5);
|
||||
t7:= ((temp shr 7) or (temp shl 25)) + ((t7 shr 11) or (t7 shl 21)) + w[30] + $BA7C9045;
|
||||
temp:= (t2 and (t3 and not t7 xor t0 and t1 xor t5 xor t4) xor t0 and (t3 xor t1) xor t7 and t1 xor t4);
|
||||
t6:= ((temp shr 7) or (temp shl 25)) + ((t6 shr 11) or (t6 shl 21)) + w[ 3] + $F12C7F99;
|
||||
temp:= (t1 and (t2 and not t6 xor t7 and t0 xor t4 xor t3) xor t7 and (t2 xor t0) xor t6 and t0 xor t3);
|
||||
t5:= ((temp shr 7) or (temp shl 25)) + ((t5 shr 11) or (t5 shl 21)) + w[21] + $24A19947;
|
||||
temp:= (t0 and (t1 and not t5 xor t6 and t7 xor t3 xor t2) xor t6 and (t1 xor t7) xor t5 and t7 xor t2);
|
||||
t4:= ((temp shr 7) or (temp shl 25)) + ((t4 shr 11) or (t4 shl 21)) + w[ 9] + $B3916CF7;
|
||||
temp:= (t7 and (t0 and not t4 xor t5 and t6 xor t2 xor t1) xor t5 and (t0 xor t6) xor t4 and t6 xor t1);
|
||||
t3:= ((temp shr 7) or (temp shl 25)) + ((t3 shr 11) or (t3 shl 21)) + w[17] + $0801F2E2;
|
||||
temp:= (t6 and (t7 and not t3 xor t4 and t5 xor t1 xor t0) xor t4 and (t7 xor t5) xor t3 and t5 xor t0);
|
||||
t2:= ((temp shr 7) or (temp shl 25)) + ((t2 shr 11) or (t2 shl 21)) + w[24] + $858EFC16;
|
||||
temp:= (t5 and (t6 and not t2 xor t3 and t4 xor t0 xor t7) xor t3 and (t6 xor t4) xor t2 and t4 xor t7);
|
||||
t1:= ((temp shr 7) or (temp shl 25)) + ((t1 shr 11) or (t1 shl 21)) + w[29] + $636920D8;
|
||||
temp:= (t4 and (t5 and not t1 xor t2 and t3 xor t7 xor t6) xor t2 and (t5 xor t3) xor t1 and t3 xor t6);
|
||||
t0:= ((temp shr 7) or (temp shl 25)) + ((t0 shr 11) or (t0 shl 21)) + w[ 6] + $71574E69;
|
||||
|
||||
temp:= (t3 and (t4 and not t0 xor t1 and t2 xor t6 xor t5) xor t1 and (t4 xor t2) xor t0 and t2 xor t5);
|
||||
t7:= ((temp shr 7) or (temp shl 25)) + ((t7 shr 11) or (t7 shl 21)) + w[19] + $A458FEA3;
|
||||
temp:= (t2 and (t3 and not t7 xor t0 and t1 xor t5 xor t4) xor t0 and (t3 xor t1) xor t7 and t1 xor t4);
|
||||
t6:= ((temp shr 7) or (temp shl 25)) + ((t6 shr 11) or (t6 shl 21)) + w[12] + $F4933D7E;
|
||||
temp:= (t1 and (t2 and not t6 xor t7 and t0 xor t4 xor t3) xor t7 and (t2 xor t0) xor t6 and t0 xor t3);
|
||||
t5:= ((temp shr 7) or (temp shl 25)) + ((t5 shr 11) or (t5 shl 21)) + w[15] + $0D95748F;
|
||||
temp:= (t0 and (t1 and not t5 xor t6 and t7 xor t3 xor t2) xor t6 and (t1 xor t7) xor t5 and t7 xor t2);
|
||||
t4:= ((temp shr 7) or (temp shl 25)) + ((t4 shr 11) or (t4 shl 21)) + w[13] + $728EB658;
|
||||
temp:= (t7 and (t0 and not t4 xor t5 and t6 xor t2 xor t1) xor t5 and (t0 xor t6) xor t4 and t6 xor t1);
|
||||
t3:= ((temp shr 7) or (temp shl 25)) + ((t3 shr 11) or (t3 shl 21)) + w[ 2] + $718BCD58;
|
||||
temp:= (t6 and (t7 and not t3 xor t4 and t5 xor t1 xor t0) xor t4 and (t7 xor t5) xor t3 and t5 xor t0);
|
||||
t2:= ((temp shr 7) or (temp shl 25)) + ((t2 shr 11) or (t2 shl 21)) + w[25] + $82154AEE;
|
||||
temp:= (t5 and (t6 and not t2 xor t3 and t4 xor t0 xor t7) xor t3 and (t6 xor t4) xor t2 and t4 xor t7);
|
||||
t1:= ((temp shr 7) or (temp shl 25)) + ((t1 shr 11) or (t1 shl 21)) + w[31] + $7B54A41D;
|
||||
temp:= (t4 and (t5 and not t1 xor t2 and t3 xor t7 xor t6) xor t2 and (t5 xor t3) xor t1 and t3 xor t6);
|
||||
t0:= ((temp shr 7) or (temp shl 25)) + ((t0 shr 11) or (t0 shl 21)) + w[27] + $C25A59B5;
|
||||
|
||||
temp:= (t4 and (t1 and t3 xor t2 xor t5) xor t1 and t0 xor t3 and t6 xor t5);
|
||||
t7:= ((temp shr 7) or (temp shl 25)) + ((t7 shr 11) or (t7 shl 21)) + w[19] + $9C30D539;
|
||||
temp:= (t3 and (t0 and t2 xor t1 xor t4) xor t0 and t7 xor t2 and t5 xor t4);
|
||||
t6:= ((temp shr 7) or (temp shl 25)) + ((t6 shr 11) or (t6 shl 21)) + w[ 9] + $2AF26013;
|
||||
temp:= (t2 and (t7 and t1 xor t0 xor t3) xor t7 and t6 xor t1 and t4 xor t3);
|
||||
t5:= ((temp shr 7) or (temp shl 25)) + ((t5 shr 11) or (t5 shl 21)) + w[ 4] + $C5D1B023;
|
||||
temp:= (t1 and (t6 and t0 xor t7 xor t2) xor t6 and t5 xor t0 and t3 xor t2);
|
||||
t4:= ((temp shr 7) or (temp shl 25)) + ((t4 shr 11) or (t4 shl 21)) + w[20] + $286085F0;
|
||||
temp:= (t0 and (t5 and t7 xor t6 xor t1) xor t5 and t4 xor t7 and t2 xor t1);
|
||||
t3:= ((temp shr 7) or (temp shl 25)) + ((t3 shr 11) or (t3 shl 21)) + w[28] + $CA417918;
|
||||
temp:= (t7 and (t4 and t6 xor t5 xor t0) xor t4 and t3 xor t6 and t1 xor t0);
|
||||
t2:= ((temp shr 7) or (temp shl 25)) + ((t2 shr 11) or (t2 shl 21)) + w[17] + $B8DB38EF;
|
||||
temp:= (t6 and (t3 and t5 xor t4 xor t7) xor t3 and t2 xor t5 and t0 xor t7);
|
||||
t1:= ((temp shr 7) or (temp shl 25)) + ((t1 shr 11) or (t1 shl 21)) + w[ 8] + $8E79DCB0;
|
||||
temp:= (t5 and (t2 and t4 xor t3 xor t6) xor t2 and t1 xor t4 and t7 xor t6);
|
||||
t0:= ((temp shr 7) or (temp shl 25)) + ((t0 shr 11) or (t0 shl 21)) + w[22] + $603A180E;
|
||||
|
||||
temp:= (t4 and (t1 and t3 xor t2 xor t5) xor t1 and t0 xor t3 and t6 xor t5);
|
||||
t7:= ((temp shr 7) or (temp shl 25)) + ((t7 shr 11) or (t7 shl 21)) + w[29] + $6C9E0E8B;
|
||||
temp:= (t3 and (t0 and t2 xor t1 xor t4) xor t0 and t7 xor t2 and t5 xor t4);
|
||||
t6:= ((temp shr 7) or (temp shl 25)) + ((t6 shr 11) or (t6 shl 21)) + w[14] + $B01E8A3E;
|
||||
temp:= (t2 and (t7 and t1 xor t0 xor t3) xor t7 and t6 xor t1 and t4 xor t3);
|
||||
t5:= ((temp shr 7) or (temp shl 25)) + ((t5 shr 11) or (t5 shl 21)) + w[25] + $D71577C1;
|
||||
temp:= (t1 and (t6 and t0 xor t7 xor t2) xor t6 and t5 xor t0 and t3 xor t2);
|
||||
t4:= ((temp shr 7) or (temp shl 25)) + ((t4 shr 11) or (t4 shl 21)) + w[12] + $BD314B27;
|
||||
temp:= (t0 and (t5 and t7 xor t6 xor t1) xor t5 and t4 xor t7 and t2 xor t1);
|
||||
t3:= ((temp shr 7) or (temp shl 25)) + ((t3 shr 11) or (t3 shl 21)) + w[24] + $78AF2FDA;
|
||||
temp:= (t7 and (t4 and t6 xor t5 xor t0) xor t4 and t3 xor t6 and t1 xor t0);
|
||||
t2:= ((temp shr 7) or (temp shl 25)) + ((t2 shr 11) or (t2 shl 21)) + w[30] + $55605C60;
|
||||
temp:= (t6 and (t3 and t5 xor t4 xor t7) xor t3 and t2 xor t5 and t0 xor t7);
|
||||
t1:= ((temp shr 7) or (temp shl 25)) + ((t1 shr 11) or (t1 shl 21)) + w[16] + $E65525F3;
|
||||
temp:= (t5 and (t2 and t4 xor t3 xor t6) xor t2 and t1 xor t4 and t7 xor t6);
|
||||
t0:= ((temp shr 7) or (temp shl 25)) + ((t0 shr 11) or (t0 shl 21)) + w[26] + $AA55AB94;
|
||||
|
||||
temp:= (t4 and (t1 and t3 xor t2 xor t5) xor t1 and t0 xor t3 and t6 xor t5);
|
||||
t7:= ((temp shr 7) or (temp shl 25)) + ((t7 shr 11) or (t7 shl 21)) + w[31] + $57489862;
|
||||
temp:= (t3 and (t0 and t2 xor t1 xor t4) xor t0 and t7 xor t2 and t5 xor t4);
|
||||
t6:= ((temp shr 7) or (temp shl 25)) + ((t6 shr 11) or (t6 shl 21)) + w[15] + $63E81440;
|
||||
temp:= (t2 and (t7 and t1 xor t0 xor t3) xor t7 and t6 xor t1 and t4 xor t3);
|
||||
t5:= ((temp shr 7) or (temp shl 25)) + ((t5 shr 11) or (t5 shl 21)) + w[ 7] + $55CA396A;
|
||||
temp:= (t1 and (t6 and t0 xor t7 xor t2) xor t6 and t5 xor t0 and t3 xor t2);
|
||||
t4:= ((temp shr 7) or (temp shl 25)) + ((t4 shr 11) or (t4 shl 21)) + w[ 3] + $2AAB10B6;
|
||||
temp:= (t0 and (t5 and t7 xor t6 xor t1) xor t5 and t4 xor t7 and t2 xor t1);
|
||||
t3:= ((temp shr 7) or (temp shl 25)) + ((t3 shr 11) or (t3 shl 21)) + w[ 1] + $B4CC5C34;
|
||||
temp:= (t7 and (t4 and t6 xor t5 xor t0) xor t4 and t3 xor t6 and t1 xor t0);
|
||||
t2:= ((temp shr 7) or (temp shl 25)) + ((t2 shr 11) or (t2 shl 21)) + w[ 0] + $1141E8CE;
|
||||
temp:= (t6 and (t3 and t5 xor t4 xor t7) xor t3 and t2 xor t5 and t0 xor t7);
|
||||
t1:= ((temp shr 7) or (temp shl 25)) + ((t1 shr 11) or (t1 shl 21)) + w[18] + $A15486AF;
|
||||
temp:= (t5 and (t2 and t4 xor t3 xor t6) xor t2 and t1 xor t4 and t7 xor t6);
|
||||
t0:= ((temp shr 7) or (temp shl 25)) + ((t0 shr 11) or (t0 shl 21)) + w[27] + $7C72E993;
|
||||
|
||||
temp:= (t4 and (t1 and t3 xor t2 xor t5) xor t1 and t0 xor t3 and t6 xor t5);
|
||||
t7:= ((temp shr 7) or (temp shl 25)) + ((t7 shr 11) or (t7 shl 21)) + w[13] + $B3EE1411;
|
||||
temp:= (t3 and (t0 and t2 xor t1 xor t4) xor t0 and t7 xor t2 and t5 xor t4);
|
||||
t6:= ((temp shr 7) or (temp shl 25)) + ((t6 shr 11) or (t6 shl 21)) + w[ 6] + $636FBC2A;
|
||||
temp:= (t2 and (t7 and t1 xor t0 xor t3) xor t7 and t6 xor t1 and t4 xor t3);
|
||||
t5:= ((temp shr 7) or (temp shl 25)) + ((t5 shr 11) or (t5 shl 21)) + w[21] + $2BA9C55D;
|
||||
temp:= (t1 and (t6 and t0 xor t7 xor t2) xor t6 and t5 xor t0 and t3 xor t2);
|
||||
t4:= ((temp shr 7) or (temp shl 25)) + ((t4 shr 11) or (t4 shl 21)) + w[10] + $741831F6;
|
||||
temp:= (t0 and (t5 and t7 xor t6 xor t1) xor t5 and t4 xor t7 and t2 xor t1);
|
||||
t3:= ((temp shr 7) or (temp shl 25)) + ((t3 shr 11) or (t3 shl 21)) + w[23] + $CE5C3E16;
|
||||
temp:= (t7 and (t4 and t6 xor t5 xor t0) xor t4 and t3 xor t6 and t1 xor t0);
|
||||
t2:= ((temp shr 7) or (temp shl 25)) + ((t2 shr 11) or (t2 shl 21)) + w[11] + $9B87931E;
|
||||
temp:= (t6 and (t3 and t5 xor t4 xor t7) xor t3 and t2 xor t5 and t0 xor t7);
|
||||
t1:= ((temp shr 7) or (temp shl 25)) + ((t1 shr 11) or (t1 shl 21)) + w[ 5] + $AFD6BA33;
|
||||
temp:= (t5 and (t2 and t4 xor t3 xor t6) xor t2 and t1 xor t4 and t7 xor t6);
|
||||
t0:= ((temp shr 7) or (temp shl 25)) + ((t0 shr 11) or (t0 shl 21)) + w[ 2] + $6C24CF5C;
|
||||
|
||||
temp:= (t3 and (t5 and not t0 xor t2 and not t1 xor t4 xor t1 xor t6) xor t2 and (t4 and t0 xor t5 xor t1) xor t0 and t1 xor t6);
|
||||
t7:= ((temp shr 7) or (temp shl 25)) + ((t7 shr 11) or (t7 shl 21)) + w[24] + $7A325381;
|
||||
temp:= (t2 and (t4 and not t7 xor t1 and not t0 xor t3 xor t0 xor t5) xor t1 and (t3 and t7 xor t4 xor t0) xor t7 and t0 xor t5);
|
||||
t6:= ((temp shr 7) or (temp shl 25)) + ((t6 shr 11) or (t6 shl 21)) + w[ 4] + $28958677;
|
||||
temp:= (t1 and (t3 and not t6 xor t0 and not t7 xor t2 xor t7 xor t4) xor t0 and (t2 and t6 xor t3 xor t7) xor t6 and t7 xor t4);
|
||||
t5:= ((temp shr 7) or (temp shl 25)) + ((t5 shr 11) or (t5 shl 21)) + w[ 0] + $3B8F4898;
|
||||
temp:= (t0 and (t2 and not t5 xor t7 and not t6 xor t1 xor t6 xor t3) xor t7 and (t1 and t5 xor t2 xor t6) xor t5 and t6 xor t3);
|
||||
t4:= ((temp shr 7) or (temp shl 25)) + ((t4 shr 11) or (t4 shl 21)) + w[14] + $6B4BB9AF;
|
||||
temp:= (t7 and (t1 and not t4 xor t6 and not t5 xor t0 xor t5 xor t2) xor t6 and (t0 and t4 xor t1 xor t5) xor t4 and t5 xor t2);
|
||||
t3:= ((temp shr 7) or (temp shl 25)) + ((t3 shr 11) or (t3 shl 21)) + w[ 2] + $C4BFE81B;
|
||||
temp:= (t6 and (t0 and not t3 xor t5 and not t4 xor t7 xor t4 xor t1) xor t5 and (t7 and t3 xor t0 xor t4) xor t3 and t4 xor t1);
|
||||
t2:= ((temp shr 7) or (temp shl 25)) + ((t2 shr 11) or (t2 shl 21)) + w[ 7] + $66282193;
|
||||
temp:= (t5 and (t7 and not t2 xor t4 and not t3 xor t6 xor t3 xor t0) xor t4 and (t6 and t2 xor t7 xor t3) xor t2 and t3 xor t0);
|
||||
t1:= ((temp shr 7) or (temp shl 25)) + ((t1 shr 11) or (t1 shl 21)) + w[28] + $61D809CC;
|
||||
temp:= (t4 and (t6 and not t1 xor t3 and not t2 xor t5 xor t2 xor t7) xor t3 and (t5 and t1 xor t6 xor t2) xor t1 and t2 xor t7);
|
||||
t0:= ((temp shr 7) or (temp shl 25)) + ((t0 shr 11) or (t0 shl 21)) + w[23] + $FB21A991;
|
||||
|
||||
temp:= (t3 and (t5 and not t0 xor t2 and not t1 xor t4 xor t1 xor t6) xor t2 and (t4 and t0 xor t5 xor t1) xor t0 and t1 xor t6);
|
||||
t7:= ((temp shr 7) or (temp shl 25)) + ((t7 shr 11) or (t7 shl 21)) + w[26] + $487CAC60;
|
||||
temp:= (t2 and (t4 and not t7 xor t1 and not t0 xor t3 xor t0 xor t5) xor t1 and (t3 and t7 xor t4 xor t0) xor t7 and t0 xor t5);
|
||||
t6:= ((temp shr 7) or (temp shl 25)) + ((t6 shr 11) or (t6 shl 21)) + w[ 6] + $5DEC8032;
|
||||
temp:= (t1 and (t3 and not t6 xor t0 and not t7 xor t2 xor t7 xor t4) xor t0 and (t2 and t6 xor t3 xor t7) xor t6 and t7 xor t4);
|
||||
t5:= ((temp shr 7) or (temp shl 25)) + ((t5 shr 11) or (t5 shl 21)) + w[30] + $EF845D5D;
|
||||
temp:= (t0 and (t2 and not t5 xor t7 and not t6 xor t1 xor t6 xor t3) xor t7 and (t1 and t5 xor t2 xor t6) xor t5 and t6 xor t3);
|
||||
t4:= ((temp shr 7) or (temp shl 25)) + ((t4 shr 11) or (t4 shl 21)) + w[20] + $E98575B1;
|
||||
temp:= (t7 and (t1 and not t4 xor t6 and not t5 xor t0 xor t5 xor t2) xor t6 and (t0 and t4 xor t1 xor t5) xor t4 and t5 xor t2);
|
||||
t3:= ((temp shr 7) or (temp shl 25)) + ((t3 shr 11) or (t3 shl 21)) + w[18] + $DC262302;
|
||||
temp:= (t6 and (t0 and not t3 xor t5 and not t4 xor t7 xor t4 xor t1) xor t5 and (t7 and t3 xor t0 xor t4) xor t3 and t4 xor t1);
|
||||
t2:= ((temp shr 7) or (temp shl 25)) + ((t2 shr 11) or (t2 shl 21)) + w[25] + $EB651B88;
|
||||
temp:= (t5 and (t7 and not t2 xor t4 and not t3 xor t6 xor t3 xor t0) xor t4 and (t6 and t2 xor t7 xor t3) xor t2 and t3 xor t0);
|
||||
t1:= ((temp shr 7) or (temp shl 25)) + ((t1 shr 11) or (t1 shl 21)) + w[19] + $23893E81;
|
||||
temp:= (t4 and (t6 and not t1 xor t3 and not t2 xor t5 xor t2 xor t7) xor t3 and (t5 and t1 xor t6 xor t2) xor t1 and t2 xor t7);
|
||||
t0:= ((temp shr 7) or (temp shl 25)) + ((t0 shr 11) or (t0 shl 21)) + w[ 3] + $D396ACC5;
|
||||
|
||||
temp:= (t3 and (t5 and not t0 xor t2 and not t1 xor t4 xor t1 xor t6) xor t2 and (t4 and t0 xor t5 xor t1) xor t0 and t1 xor t6);
|
||||
t7:= ((temp shr 7) or (temp shl 25)) + ((t7 shr 11) or (t7 shl 21)) + w[22] + $0F6D6FF3;
|
||||
temp:= (t2 and (t4 and not t7 xor t1 and not t0 xor t3 xor t0 xor t5) xor t1 and (t3 and t7 xor t4 xor t0) xor t7 and t0 xor t5);
|
||||
t6:= ((temp shr 7) or (temp shl 25)) + ((t6 shr 11) or (t6 shl 21)) + w[11] + $83F44239;
|
||||
temp:= (t1 and (t3 and not t6 xor t0 and not t7 xor t2 xor t7 xor t4) xor t0 and (t2 and t6 xor t3 xor t7) xor t6 and t7 xor t4);
|
||||
t5:= ((temp shr 7) or (temp shl 25)) + ((t5 shr 11) or (t5 shl 21)) + w[31] + $2E0B4482;
|
||||
temp:= (t0 and (t2 and not t5 xor t7 and not t6 xor t1 xor t6 xor t3) xor t7 and (t1 and t5 xor t2 xor t6) xor t5 and t6 xor t3);
|
||||
t4:= ((temp shr 7) or (temp shl 25)) + ((t4 shr 11) or (t4 shl 21)) + w[21] + $A4842004;
|
||||
temp:= (t7 and (t1 and not t4 xor t6 and not t5 xor t0 xor t5 xor t2) xor t6 and (t0 and t4 xor t1 xor t5) xor t4 and t5 xor t2);
|
||||
t3:= ((temp shr 7) or (temp shl 25)) + ((t3 shr 11) or (t3 shl 21)) + w[ 8] + $69C8F04A;
|
||||
temp:= (t6 and (t0 and not t3 xor t5 and not t4 xor t7 xor t4 xor t1) xor t5 and (t7 and t3 xor t0 xor t4) xor t3 and t4 xor t1);
|
||||
t2:= ((temp shr 7) or (temp shl 25)) + ((t2 shr 11) or (t2 shl 21)) + w[27] + $9E1F9B5E;
|
||||
temp:= (t5 and (t7 and not t2 xor t4 and not t3 xor t6 xor t3 xor t0) xor t4 and (t6 and t2 xor t7 xor t3) xor t2 and t3 xor t0);
|
||||
t1:= ((temp shr 7) or (temp shl 25)) + ((t1 shr 11) or (t1 shl 21)) + w[12] + $21C66842;
|
||||
temp:= (t4 and (t6 and not t1 xor t3 and not t2 xor t5 xor t2 xor t7) xor t3 and (t5 and t1 xor t6 xor t2) xor t1 and t2 xor t7);
|
||||
t0:= ((temp shr 7) or (temp shl 25)) + ((t0 shr 11) or (t0 shl 21)) + w[ 9] + $F6E96C9A;
|
||||
|
||||
temp:= (t3 and (t5 and not t0 xor t2 and not t1 xor t4 xor t1 xor t6) xor t2 and (t4 and t0 xor t5 xor t1) xor t0 and t1 xor t6);
|
||||
t7:= ((temp shr 7) or (temp shl 25)) + ((t7 shr 11) or (t7 shl 21)) + w[ 1] + $670C9C61;
|
||||
temp:= (t2 and (t4 and not t7 xor t1 and not t0 xor t3 xor t0 xor t5) xor t1 and (t3 and t7 xor t4 xor t0) xor t7 and t0 xor t5);
|
||||
t6:= ((temp shr 7) or (temp shl 25)) + ((t6 shr 11) or (t6 shl 21)) + w[29] + $ABD388F0;
|
||||
temp:= (t1 and (t3 and not t6 xor t0 and not t7 xor t2 xor t7 xor t4) xor t0 and (t2 and t6 xor t3 xor t7) xor t6 and t7 xor t4);
|
||||
t5:= ((temp shr 7) or (temp shl 25)) + ((t5 shr 11) or (t5 shl 21)) + w[ 5] + $6A51A0D2;
|
||||
temp:= (t0 and (t2 and not t5 xor t7 and not t6 xor t1 xor t6 xor t3) xor t7 and (t1 and t5 xor t2 xor t6) xor t5 and t6 xor t3);
|
||||
t4:= ((temp shr 7) or (temp shl 25)) + ((t4 shr 11) or (t4 shl 21)) + w[15] + $D8542F68;
|
||||
temp:= (t7 and (t1 and not t4 xor t6 and not t5 xor t0 xor t5 xor t2) xor t6 and (t0 and t4 xor t1 xor t5) xor t4 and t5 xor t2);
|
||||
t3:= ((temp shr 7) or (temp shl 25)) + ((t3 shr 11) or (t3 shl 21)) + w[17] + $960FA728;
|
||||
temp:= (t6 and (t0 and not t3 xor t5 and not t4 xor t7 xor t4 xor t1) xor t5 and (t7 and t3 xor t0 xor t4) xor t3 and t4 xor t1);
|
||||
t2:= ((temp shr 7) or (temp shl 25)) + ((t2 shr 11) or (t2 shl 21)) + w[10] + $AB5133A3;
|
||||
temp:= (t5 and (t7 and not t2 xor t4 and not t3 xor t6 xor t3 xor t0) xor t4 and (t6 and t2 xor t7 xor t3) xor t2 and t3 xor t0);
|
||||
t1:= ((temp shr 7) or (temp shl 25)) + ((t1 shr 11) or (t1 shl 21)) + w[16] + $6EEF0B6C;
|
||||
temp:= (t4 and (t6 and not t1 xor t3 and not t2 xor t5 xor t2 xor t7) xor t3 and (t5 and t1 xor t6 xor t2) xor t1 and t2 xor t7);
|
||||
t0:= ((temp shr 7) or (temp shl 25)) + ((t0 shr 11) or (t0 shl 21)) + w[13] + $137A3BE4;
|
||||
|
||||
temp:= (t1 and (t3 and t4 and t6 xor not t5) xor t3 and t0 xor t4 and t5 xor t6 and t2);
|
||||
t7:= ((temp shr 7) or (temp shl 25)) + ((t7 shr 11) or (t7 shl 21)) + w[27] + $BA3BF050;
|
||||
temp:= (t0 and (t2 and t3 and t5 xor not t4) xor t2 and t7 xor t3 and t4 xor t5 and t1);
|
||||
t6:= ((temp shr 7) or (temp shl 25)) + ((t6 shr 11) or (t6 shl 21)) + w[ 3] + $7EFB2A98;
|
||||
temp:= (t7 and (t1 and t2 and t4 xor not t3) xor t1 and t6 xor t2 and t3 xor t4 and t0);
|
||||
t5:= ((temp shr 7) or (temp shl 25)) + ((t5 shr 11) or (t5 shl 21)) + w[21] + $A1F1651D;
|
||||
temp:= (t6 and (t0 and t1 and t3 xor not t2) xor t0 and t5 xor t1 and t2 xor t3 and t7);
|
||||
t4:= ((temp shr 7) or (temp shl 25)) + ((t4 shr 11) or (t4 shl 21)) + w[26] + $39AF0176;
|
||||
temp:= (t5 and (t7 and t0 and t2 xor not t1) xor t7 and t4 xor t0 and t1 xor t2 and t6);
|
||||
t3:= ((temp shr 7) or (temp shl 25)) + ((t3 shr 11) or (t3 shl 21)) + w[17] + $66CA593E;
|
||||
temp:= (t4 and (t6 and t7 and t1 xor not t0) xor t6 and t3 xor t7 and t0 xor t1 and t5);
|
||||
t2:= ((temp shr 7) or (temp shl 25)) + ((t2 shr 11) or (t2 shl 21)) + w[11] + $82430E88;
|
||||
temp:= (t3 and (t5 and t6 and t0 xor not t7) xor t5 and t2 xor t6 and t7 xor t0 and t4);
|
||||
t1:= ((temp shr 7) or (temp shl 25)) + ((t1 shr 11) or (t1 shl 21)) + w[20] + $8CEE8619;
|
||||
temp:= (t2 and (t4 and t5 and t7 xor not t6) xor t4 and t1 xor t5 and t6 xor t7 and t3);
|
||||
t0:= ((temp shr 7) or (temp shl 25)) + ((t0 shr 11) or (t0 shl 21)) + w[29] + $456F9FB4;
|
||||
|
||||
temp:= (t1 and (t3 and t4 and t6 xor not t5) xor t3 and t0 xor t4 and t5 xor t6 and t2);
|
||||
t7:= ((temp shr 7) or (temp shl 25)) + ((t7 shr 11) or (t7 shl 21)) + w[19] + $7D84A5C3;
|
||||
temp:= (t0 and (t2 and t3 and t5 xor not t4) xor t2 and t7 xor t3 and t4 xor t5 and t1);
|
||||
t6:= ((temp shr 7) or (temp shl 25)) + ((t6 shr 11) or (t6 shl 21)) + w[ 0] + $3B8B5EBE;
|
||||
temp:= (t7 and (t1 and t2 and t4 xor not t3) xor t1 and t6 xor t2 and t3 xor t4 and t0);
|
||||
t5:= ((temp shr 7) or (temp shl 25)) + ((t5 shr 11) or (t5 shl 21)) + w[12] + $E06F75D8;
|
||||
temp:= (t6 and (t0 and t1 and t3 xor not t2) xor t0 and t5 xor t1 and t2 xor t3 and t7);
|
||||
t4:= ((temp shr 7) or (temp shl 25)) + ((t4 shr 11) or (t4 shl 21)) + w[ 7] + $85C12073;
|
||||
temp:= (t5 and (t7 and t0 and t2 xor not t1) xor t7 and t4 xor t0 and t1 xor t2 and t6);
|
||||
t3:= ((temp shr 7) or (temp shl 25)) + ((t3 shr 11) or (t3 shl 21)) + w[13] + $401A449F;
|
||||
temp:= (t4 and (t6 and t7 and t1 xor not t0) xor t6 and t3 xor t7 and t0 xor t1 and t5);
|
||||
t2:= ((temp shr 7) or (temp shl 25)) + ((t2 shr 11) or (t2 shl 21)) + w[ 8] + $56C16AA6;
|
||||
temp:= (t3 and (t5 and t6 and t0 xor not t7) xor t5 and t2 xor t6 and t7 xor t0 and t4);
|
||||
t1:= ((temp shr 7) or (temp shl 25)) + ((t1 shr 11) or (t1 shl 21)) + w[31] + $4ED3AA62;
|
||||
temp:= (t2 and (t4 and t5 and t7 xor not t6) xor t4 and t1 xor t5 and t6 xor t7 and t3);
|
||||
t0:= ((temp shr 7) or (temp shl 25)) + ((t0 shr 11) or (t0 shl 21)) + w[10] + $363F7706;
|
||||
|
||||
temp:= (t1 and (t3 and t4 and t6 xor not t5) xor t3 and t0 xor t4 and t5 xor t6 and t2);
|
||||
t7:= ((temp shr 7) or (temp shl 25)) + ((t7 shr 11) or (t7 shl 21)) + w[ 5] + $1BFEDF72;
|
||||
temp:= (t0 and (t2 and t3 and t5 xor not t4) xor t2 and t7 xor t3 and t4 xor t5 and t1);
|
||||
t6:= ((temp shr 7) or (temp shl 25)) + ((t6 shr 11) or (t6 shl 21)) + w[ 9] + $429B023D;
|
||||
temp:= (t7 and (t1 and t2 and t4 xor not t3) xor t1 and t6 xor t2 and t3 xor t4 and t0);
|
||||
t5:= ((temp shr 7) or (temp shl 25)) + ((t5 shr 11) or (t5 shl 21)) + w[14] + $37D0D724;
|
||||
temp:= (t6 and (t0 and t1 and t3 xor not t2) xor t0 and t5 xor t1 and t2 xor t3 and t7);
|
||||
t4:= ((temp shr 7) or (temp shl 25)) + ((t4 shr 11) or (t4 shl 21)) + w[30] + $D00A1248;
|
||||
temp:= (t5 and (t7 and t0 and t2 xor not t1) xor t7 and t4 xor t0 and t1 xor t2 and t6);
|
||||
t3:= ((temp shr 7) or (temp shl 25)) + ((t3 shr 11) or (t3 shl 21)) + w[18] + $DB0FEAD3;
|
||||
temp:= (t4 and (t6 and t7 and t1 xor not t0) xor t6 and t3 xor t7 and t0 xor t1 and t5);
|
||||
t2:= ((temp shr 7) or (temp shl 25)) + ((t2 shr 11) or (t2 shl 21)) + w[ 6] + $49F1C09B;
|
||||
temp:= (t3 and (t5 and t6 and t0 xor not t7) xor t5 and t2 xor t6 and t7 xor t0 and t4);
|
||||
t1:= ((temp shr 7) or (temp shl 25)) + ((t1 shr 11) or (t1 shl 21)) + w[28] + $075372C9;
|
||||
temp:= (t2 and (t4 and t5 and t7 xor not t6) xor t4 and t1 xor t5 and t6 xor t7 and t3);
|
||||
t0:= ((temp shr 7) or (temp shl 25)) + ((t0 shr 11) or (t0 shl 21)) + w[24] + $80991B7B;
|
||||
|
||||
temp:= (t1 and (t3 and t4 and t6 xor not t5) xor t3 and t0 xor t4 and t5 xor t6 and t2);
|
||||
t7:= ((temp shr 7) or (temp shl 25)) + ((t7 shr 11) or (t7 shl 21)) + w[ 2] + $25D479D8;
|
||||
temp:= (t0 and (t2 and t3 and t5 xor not t4) xor t2 and t7 xor t3 and t4 xor t5 and t1);
|
||||
t6:= ((temp shr 7) or (temp shl 25)) + ((t6 shr 11) or (t6 shl 21)) + w[23] + $F6E8DEF7;
|
||||
temp:= (t7 and (t1 and t2 and t4 xor not t3) xor t1 and t6 xor t2 and t3 xor t4 and t0);
|
||||
t5:= ((temp shr 7) or (temp shl 25)) + ((t5 shr 11) or (t5 shl 21)) + w[16] + $E3FE501A;
|
||||
temp:= (t6 and (t0 and t1 and t3 xor not t2) xor t0 and t5 xor t1 and t2 xor t3 and t7);
|
||||
t4:= ((temp shr 7) or (temp shl 25)) + ((t4 shr 11) or (t4 shl 21)) + w[22] + $B6794C3B;
|
||||
temp:= (t5 and (t7 and t0 and t2 xor not t1) xor t7 and t4 xor t0 and t1 xor t2 and t6);
|
||||
t3:= ((temp shr 7) or (temp shl 25)) + ((t3 shr 11) or (t3 shl 21)) + w[ 4] + $976CE0BD;
|
||||
temp:= (t4 and (t6 and t7 and t1 xor not t0) xor t6 and t3 xor t7 and t0 xor t1 and t5);
|
||||
t2:= ((temp shr 7) or (temp shl 25)) + ((t2 shr 11) or (t2 shl 21)) + w[ 1] + $04C006BA;
|
||||
temp:= (t3 and (t5 and t6 and t0 xor not t7) xor t5 and t2 xor t6 and t7 xor t0 and t4);
|
||||
t1:= ((temp shr 7) or (temp shl 25)) + ((t1 shr 11) or (t1 shl 21)) + w[25] + $C1A94FB6;
|
||||
temp:= (t2 and (t4 and t5 and t7 xor not t6) xor t4 and t1 xor t5 and t6 xor t7 and t3);
|
||||
t0:= ((temp shr 7) or (temp shl 25)) + ((t0 shr 11) or (t0 shl 21)) + w[15] + $409F60C4;
|
||||
520
dcpcrypt/Hashes/DCPtiger.inc
Normal file
@@ -0,0 +1,520 @@
|
||||
const
|
||||
t1: array[0..255] of int64= (
|
||||
$02AAB17CF7E90C5E, $AC424B03E243A8EC,
|
||||
$72CD5BE30DD5FCD3, $6D019B93F6F97F3A,
|
||||
$CD9978FFD21F9193, $7573A1C9708029E2,
|
||||
$B164326B922A83C3, $46883EEE04915870,
|
||||
$EAACE3057103ECE6, $C54169B808A3535C,
|
||||
$4CE754918DDEC47C, $0AA2F4DFDC0DF40C,
|
||||
$10B76F18A74DBEFA, $C6CCB6235AD1AB6A,
|
||||
$13726121572FE2FF, $1A488C6F199D921E,
|
||||
$4BC9F9F4DA0007CA, $26F5E6F6E85241C7,
|
||||
$859079DBEA5947B6, $4F1885C5C99E8C92,
|
||||
$D78E761EA96F864B, $8E36428C52B5C17D,
|
||||
$69CF6827373063C1, $B607C93D9BB4C56E,
|
||||
$7D820E760E76B5EA, $645C9CC6F07FDC42,
|
||||
$BF38A078243342E0, $5F6B343C9D2E7D04,
|
||||
$F2C28AEB600B0EC6, $6C0ED85F7254BCAC,
|
||||
$71592281A4DB4FE5, $1967FA69CE0FED9F,
|
||||
$FD5293F8B96545DB, $C879E9D7F2A7600B,
|
||||
$860248920193194E, $A4F9533B2D9CC0B3,
|
||||
$9053836C15957613, $DB6DCF8AFC357BF1,
|
||||
$18BEEA7A7A370F57, $037117CA50B99066,
|
||||
$6AB30A9774424A35, $F4E92F02E325249B,
|
||||
$7739DB07061CCAE1, $D8F3B49CECA42A05,
|
||||
$BD56BE3F51382F73, $45FAED5843B0BB28,
|
||||
$1C813D5C11BF1F83, $8AF0E4B6D75FA169,
|
||||
$33EE18A487AD9999, $3C26E8EAB1C94410,
|
||||
$B510102BC0A822F9, $141EEF310CE6123B,
|
||||
$FC65B90059DDB154, $E0158640C5E0E607,
|
||||
$884E079826C3A3CF, $930D0D9523C535FD,
|
||||
$35638D754E9A2B00, $4085FCCF40469DD5,
|
||||
$C4B17AD28BE23A4C, $CAB2F0FC6A3E6A2E,
|
||||
$2860971A6B943FCD, $3DDE6EE212E30446,
|
||||
$6222F32AE01765AE, $5D550BB5478308FE,
|
||||
$A9EFA98DA0EDA22A, $C351A71686C40DA7,
|
||||
$1105586D9C867C84, $DCFFEE85FDA22853,
|
||||
$CCFBD0262C5EEF76, $BAF294CB8990D201,
|
||||
$E69464F52AFAD975, $94B013AFDF133E14,
|
||||
$06A7D1A32823C958, $6F95FE5130F61119,
|
||||
$D92AB34E462C06C0, $ED7BDE33887C71D2,
|
||||
$79746D6E6518393E, $5BA419385D713329,
|
||||
$7C1BA6B948A97564, $31987C197BFDAC67,
|
||||
$DE6C23C44B053D02, $581C49FED002D64D,
|
||||
$DD474D6338261571, $AA4546C3E473D062,
|
||||
$928FCE349455F860, $48161BBACAAB94D9,
|
||||
$63912430770E6F68, $6EC8A5E602C6641C,
|
||||
$87282515337DDD2B, $2CDA6B42034B701B,
|
||||
$B03D37C181CB096D, $E108438266C71C6F,
|
||||
$2B3180C7EB51B255, $DF92B82F96C08BBC,
|
||||
$5C68C8C0A632F3BA, $5504CC861C3D0556,
|
||||
$ABBFA4E55FB26B8F, $41848B0AB3BACEB4,
|
||||
$B334A273AA445D32, $BCA696F0A85AD881,
|
||||
$24F6EC65B528D56C, $0CE1512E90F4524A,
|
||||
$4E9DD79D5506D35A, $258905FAC6CE9779,
|
||||
$2019295B3E109B33, $F8A9478B73A054CC,
|
||||
$2924F2F934417EB0, $3993357D536D1BC4,
|
||||
$38A81AC21DB6FF8B, $47C4FBF17D6016BF,
|
||||
$1E0FAADD7667E3F5, $7ABCFF62938BEB96,
|
||||
$A78DAD948FC179C9, $8F1F98B72911E50D,
|
||||
$61E48EAE27121A91, $4D62F7AD31859808,
|
||||
$ECEBA345EF5CEAEB, $F5CEB25EBC9684CE,
|
||||
$F633E20CB7F76221, $A32CDF06AB8293E4,
|
||||
$985A202CA5EE2CA4, $CF0B8447CC8A8FB1,
|
||||
$9F765244979859A3, $A8D516B1A1240017,
|
||||
$0BD7BA3EBB5DC726, $E54BCA55B86ADB39,
|
||||
$1D7A3AFD6C478063, $519EC608E7669EDD,
|
||||
$0E5715A2D149AA23, $177D4571848FF194,
|
||||
$EEB55F3241014C22, $0F5E5CA13A6E2EC2,
|
||||
$8029927B75F5C361, $AD139FABC3D6E436,
|
||||
$0D5DF1A94CCF402F, $3E8BD948BEA5DFC8,
|
||||
$A5A0D357BD3FF77E, $A2D12E251F74F645,
|
||||
$66FD9E525E81A082, $2E0C90CE7F687A49,
|
||||
$C2E8BCBEBA973BC5, $000001BCE509745F,
|
||||
$423777BBE6DAB3D6, $D1661C7EAEF06EB5,
|
||||
$A1781F354DAACFD8, $2D11284A2B16AFFC,
|
||||
$F1FC4F67FA891D1F, $73ECC25DCB920ADA,
|
||||
$AE610C22C2A12651, $96E0A810D356B78A,
|
||||
$5A9A381F2FE7870F, $D5AD62EDE94E5530,
|
||||
$D225E5E8368D1427, $65977B70C7AF4631,
|
||||
$99F889B2DE39D74F, $233F30BF54E1D143,
|
||||
$9A9675D3D9A63C97, $5470554FF334F9A8,
|
||||
$166ACB744A4F5688, $70C74CAAB2E4AEAD,
|
||||
$F0D091646F294D12, $57B82A89684031D1,
|
||||
$EFD95A5A61BE0B6B, $2FBD12E969F2F29A,
|
||||
$9BD37013FEFF9FE8, $3F9B0404D6085A06,
|
||||
$4940C1F3166CFE15, $09542C4DCDF3DEFB,
|
||||
$B4C5218385CD5CE3, $C935B7DC4462A641,
|
||||
$3417F8A68ED3B63F, $B80959295B215B40,
|
||||
$F99CDAEF3B8C8572, $018C0614F8FCB95D,
|
||||
$1B14ACCD1A3ACDF3, $84D471F200BB732D,
|
||||
$C1A3110E95E8DA16, $430A7220BF1A82B8,
|
||||
$B77E090D39DF210E, $5EF4BD9F3CD05E9D,
|
||||
$9D4FF6DA7E57A444, $DA1D60E183D4A5F8,
|
||||
$B287C38417998E47, $FE3EDC121BB31886,
|
||||
$C7FE3CCC980CCBEF, $E46FB590189BFD03,
|
||||
$3732FD469A4C57DC, $7EF700A07CF1AD65,
|
||||
$59C64468A31D8859, $762FB0B4D45B61F6,
|
||||
$155BAED099047718, $68755E4C3D50BAA6,
|
||||
$E9214E7F22D8B4DF, $2ADDBF532EAC95F4,
|
||||
$32AE3909B4BD0109, $834DF537B08E3450,
|
||||
$FA209DA84220728D, $9E691D9B9EFE23F7,
|
||||
$0446D288C4AE8D7F, $7B4CC524E169785B,
|
||||
$21D87F0135CA1385, $CEBB400F137B8AA5,
|
||||
$272E2B66580796BE, $3612264125C2B0DE,
|
||||
$057702BDAD1EFBB2, $D4BABB8EACF84BE9,
|
||||
$91583139641BC67B, $8BDC2DE08036E024,
|
||||
$603C8156F49F68ED, $F7D236F7DBEF5111,
|
||||
$9727C4598AD21E80, $A08A0896670A5FD7,
|
||||
$CB4A8F4309EBA9CB, $81AF564B0F7036A1,
|
||||
$C0B99AA778199ABD, $959F1EC83FC8E952,
|
||||
$8C505077794A81B9, $3ACAAF8F056338F0,
|
||||
$07B43F50627A6778, $4A44AB49F5ECCC77,
|
||||
$3BC3D6E4B679EE98, $9CC0D4D1CF14108C,
|
||||
$4406C00B206BC8A0, $82A18854C8D72D89,
|
||||
$67E366B35C3C432C, $B923DD61102B37F2,
|
||||
$56AB2779D884271D, $BE83E1B0FF1525AF,
|
||||
$FB7C65D4217E49A9, $6BDBE0E76D48E7D4,
|
||||
$08DF828745D9179E, $22EA6A9ADD53BD34,
|
||||
$E36E141C5622200A, $7F805D1B8CB750EE,
|
||||
$AFE5C7A59F58E837, $E27F996A4FB1C23C,
|
||||
$D3867DFB0775F0D0, $D0E673DE6E88891A,
|
||||
$123AEB9EAFB86C25, $30F1D5D5C145B895,
|
||||
$BB434A2DEE7269E7, $78CB67ECF931FA38,
|
||||
$F33B0372323BBF9C, $52D66336FB279C74,
|
||||
$505F33AC0AFB4EAA, $E8A5CD99A2CCE187,
|
||||
$534974801E2D30BB, $8D2D5711D5876D90,
|
||||
$1F1A412891BC038E, $D6E2E71D82E56648,
|
||||
$74036C3A497732B7, $89B67ED96361F5AB,
|
||||
$FFED95D8F1EA02A2, $E72B3BD61464D43D,
|
||||
$A6300F170BDC4820, $EBC18760ED78A77A);
|
||||
|
||||
t2: array[0..255] of int64= (
|
||||
$E6A6BE5A05A12138, $B5A122A5B4F87C98,
|
||||
$563C6089140B6990, $4C46CB2E391F5DD5,
|
||||
$D932ADDBC9B79434, $08EA70E42015AFF5,
|
||||
$D765A6673E478CF1, $C4FB757EAB278D99,
|
||||
$DF11C6862D6E0692, $DDEB84F10D7F3B16,
|
||||
$6F2EF604A665EA04, $4A8E0F0FF0E0DFB3,
|
||||
$A5EDEEF83DBCBA51, $FC4F0A2A0EA4371E,
|
||||
$E83E1DA85CB38429, $DC8FF882BA1B1CE2,
|
||||
$CD45505E8353E80D, $18D19A00D4DB0717,
|
||||
$34A0CFEDA5F38101, $0BE77E518887CAF2,
|
||||
$1E341438B3C45136, $E05797F49089CCF9,
|
||||
$FFD23F9DF2591D14, $543DDA228595C5CD,
|
||||
$661F81FD99052A33, $8736E641DB0F7B76,
|
||||
$15227725418E5307, $E25F7F46162EB2FA,
|
||||
$48A8B2126C13D9FE, $AFDC541792E76EEA,
|
||||
$03D912BFC6D1898F, $31B1AAFA1B83F51B,
|
||||
$F1AC2796E42AB7D9, $40A3A7D7FCD2EBAC,
|
||||
$1056136D0AFBBCC5, $7889E1DD9A6D0C85,
|
||||
$D33525782A7974AA, $A7E25D09078AC09B,
|
||||
$BD4138B3EAC6EDD0, $920ABFBE71EB9E70,
|
||||
$A2A5D0F54FC2625C, $C054E36B0B1290A3,
|
||||
$F6DD59FF62FE932B, $3537354511A8AC7D,
|
||||
$CA845E9172FADCD4, $84F82B60329D20DC,
|
||||
$79C62CE1CD672F18, $8B09A2ADD124642C,
|
||||
$D0C1E96A19D9E726, $5A786A9B4BA9500C,
|
||||
$0E020336634C43F3, $C17B474AEB66D822,
|
||||
$6A731AE3EC9BAAC2, $8226667AE0840258,
|
||||
$67D4567691CAECA5, $1D94155C4875ADB5,
|
||||
$6D00FD985B813FDF, $51286EFCB774CD06,
|
||||
$5E8834471FA744AF, $F72CA0AEE761AE2E,
|
||||
$BE40E4CDAEE8E09A, $E9970BBB5118F665,
|
||||
$726E4BEB33DF1964, $703B000729199762,
|
||||
$4631D816F5EF30A7, $B880B5B51504A6BE,
|
||||
$641793C37ED84B6C, $7B21ED77F6E97D96,
|
||||
$776306312EF96B73, $AE528948E86FF3F4,
|
||||
$53DBD7F286A3F8F8, $16CADCE74CFC1063,
|
||||
$005C19BDFA52C6DD, $68868F5D64D46AD3,
|
||||
$3A9D512CCF1E186A, $367E62C2385660AE,
|
||||
$E359E7EA77DCB1D7, $526C0773749ABE6E,
|
||||
$735AE5F9D09F734B, $493FC7CC8A558BA8,
|
||||
$B0B9C1533041AB45, $321958BA470A59BD,
|
||||
$852DB00B5F46C393, $91209B2BD336B0E5,
|
||||
$6E604F7D659EF19F, $B99A8AE2782CCB24,
|
||||
$CCF52AB6C814C4C7, $4727D9AFBE11727B,
|
||||
$7E950D0C0121B34D, $756F435670AD471F,
|
||||
$F5ADD442615A6849, $4E87E09980B9957A,
|
||||
$2ACFA1DF50AEE355, $D898263AFD2FD556,
|
||||
$C8F4924DD80C8FD6, $CF99CA3D754A173A,
|
||||
$FE477BACAF91BF3C, $ED5371F6D690C12D,
|
||||
$831A5C285E687094, $C5D3C90A3708A0A4,
|
||||
$0F7F903717D06580, $19F9BB13B8FDF27F,
|
||||
$B1BD6F1B4D502843, $1C761BA38FFF4012,
|
||||
$0D1530C4E2E21F3B, $8943CE69A7372C8A,
|
||||
$E5184E11FEB5CE66, $618BDB80BD736621,
|
||||
$7D29BAD68B574D0B, $81BB613E25E6FE5B,
|
||||
$071C9C10BC07913F, $C7BEEB7909AC2D97,
|
||||
$C3E58D353BC5D757, $EB017892F38F61E8,
|
||||
$D4EFFB9C9B1CC21A, $99727D26F494F7AB,
|
||||
$A3E063A2956B3E03, $9D4A8B9A4AA09C30,
|
||||
$3F6AB7D500090FB4, $9CC0F2A057268AC0,
|
||||
$3DEE9D2DEDBF42D1, $330F49C87960A972,
|
||||
$C6B2720287421B41, $0AC59EC07C00369C,
|
||||
$EF4EAC49CB353425, $F450244EEF0129D8,
|
||||
$8ACC46E5CAF4DEB6, $2FFEAB63989263F7,
|
||||
$8F7CB9FE5D7A4578, $5BD8F7644E634635,
|
||||
$427A7315BF2DC900, $17D0C4AA2125261C,
|
||||
$3992486C93518E50, $B4CBFEE0A2D7D4C3,
|
||||
$7C75D6202C5DDD8D, $DBC295D8E35B6C61,
|
||||
$60B369D302032B19, $CE42685FDCE44132,
|
||||
$06F3DDB9DDF65610, $8EA4D21DB5E148F0,
|
||||
$20B0FCE62FCD496F, $2C1B912358B0EE31,
|
||||
$B28317B818F5A308, $A89C1E189CA6D2CF,
|
||||
$0C6B18576AAADBC8, $B65DEAA91299FAE3,
|
||||
$FB2B794B7F1027E7, $04E4317F443B5BEB,
|
||||
$4B852D325939D0A6, $D5AE6BEEFB207FFC,
|
||||
$309682B281C7D374, $BAE309A194C3B475,
|
||||
$8CC3F97B13B49F05, $98A9422FF8293967,
|
||||
$244B16B01076FF7C, $F8BF571C663D67EE,
|
||||
$1F0D6758EEE30DA1, $C9B611D97ADEB9B7,
|
||||
$B7AFD5887B6C57A2, $6290AE846B984FE1,
|
||||
$94DF4CDEACC1A5FD, $058A5BD1C5483AFF,
|
||||
$63166CC142BA3C37, $8DB8526EB2F76F40,
|
||||
$E10880036F0D6D4E, $9E0523C9971D311D,
|
||||
$45EC2824CC7CD691, $575B8359E62382C9,
|
||||
$FA9E400DC4889995, $D1823ECB45721568,
|
||||
$DAFD983B8206082F, $AA7D29082386A8CB,
|
||||
$269FCD4403B87588, $1B91F5F728BDD1E0,
|
||||
$E4669F39040201F6, $7A1D7C218CF04ADE,
|
||||
$65623C29D79CE5CE, $2368449096C00BB1,
|
||||
$AB9BF1879DA503BA, $BC23ECB1A458058E,
|
||||
$9A58DF01BB401ECC, $A070E868A85F143D,
|
||||
$4FF188307DF2239E, $14D565B41A641183,
|
||||
$EE13337452701602, $950E3DCF3F285E09,
|
||||
$59930254B9C80953, $3BF299408930DA6D,
|
||||
$A955943F53691387, $A15EDECAA9CB8784,
|
||||
$29142127352BE9A0, $76F0371FFF4E7AFB,
|
||||
$0239F450274F2228, $BB073AF01D5E868B,
|
||||
$BFC80571C10E96C1, $D267088568222E23,
|
||||
$9671A3D48E80B5B0, $55B5D38AE193BB81,
|
||||
$693AE2D0A18B04B8, $5C48B4ECADD5335F,
|
||||
$FD743B194916A1CA, $2577018134BE98C4,
|
||||
$E77987E83C54A4AD, $28E11014DA33E1B9,
|
||||
$270CC59E226AA213, $71495F756D1A5F60,
|
||||
$9BE853FB60AFEF77, $ADC786A7F7443DBF,
|
||||
$0904456173B29A82, $58BC7A66C232BD5E,
|
||||
$F306558C673AC8B2, $41F639C6B6C9772A,
|
||||
$216DEFE99FDA35DA, $11640CC71C7BE615,
|
||||
$93C43694565C5527, $EA038E6246777839,
|
||||
$F9ABF3CE5A3E2469, $741E768D0FD312D2,
|
||||
$0144B883CED652C6, $C20B5A5BA33F8552,
|
||||
$1AE69633C3435A9D, $97A28CA4088CFDEC,
|
||||
$8824A43C1E96F420, $37612FA66EEEA746,
|
||||
$6B4CB165F9CF0E5A, $43AA1C06A0ABFB4A,
|
||||
$7F4DC26FF162796B, $6CBACC8E54ED9B0F,
|
||||
$A6B7FFEFD2BB253E, $2E25BC95B0A29D4F,
|
||||
$86D6A58BDEF1388C, $DED74AC576B6F054,
|
||||
$8030BDBC2B45805D, $3C81AF70E94D9289,
|
||||
$3EFF6DDA9E3100DB, $B38DC39FDFCC8847,
|
||||
$123885528D17B87E, $F2DA0ED240B1B642,
|
||||
$44CEFADCD54BF9A9, $1312200E433C7EE6,
|
||||
$9FFCC84F3A78C748, $F0CD1F72248576BB,
|
||||
$EC6974053638CFE4, $2BA7B67C0CEC4E4C,
|
||||
$AC2F4DF3E5CE32ED, $CB33D14326EA4C11,
|
||||
$A4E9044CC77E58BC, $5F513293D934FCEF,
|
||||
$5DC9645506E55444, $50DE418F317DE40A,
|
||||
$388CB31A69DDE259, $2DB4A83455820A86,
|
||||
$9010A91E84711AE9, $4DF7F0B7B1498371,
|
||||
$D62A2EABC0977179, $22FAC097AA8D5C0E);
|
||||
|
||||
t3: array[0..255] of int64= (
|
||||
$F49FCC2FF1DAF39B, $487FD5C66FF29281,
|
||||
$E8A30667FCDCA83F, $2C9B4BE3D2FCCE63,
|
||||
$DA3FF74B93FBBBC2, $2FA165D2FE70BA66,
|
||||
$A103E279970E93D4, $BECDEC77B0E45E71,
|
||||
$CFB41E723985E497, $B70AAA025EF75017,
|
||||
$D42309F03840B8E0, $8EFC1AD035898579,
|
||||
$96C6920BE2B2ABC5, $66AF4163375A9172,
|
||||
$2174ABDCCA7127FB, $B33CCEA64A72FF41,
|
||||
$F04A4933083066A5, $8D970ACDD7289AF5,
|
||||
$8F96E8E031C8C25E, $F3FEC02276875D47,
|
||||
$EC7BF310056190DD, $F5ADB0AEBB0F1491,
|
||||
$9B50F8850FD58892, $4975488358B74DE8,
|
||||
$A3354FF691531C61, $0702BBE481D2C6EE,
|
||||
$89FB24057DEDED98, $AC3075138596E902,
|
||||
$1D2D3580172772ED, $EB738FC28E6BC30D,
|
||||
$5854EF8F63044326, $9E5C52325ADD3BBE,
|
||||
$90AA53CF325C4623, $C1D24D51349DD067,
|
||||
$2051CFEEA69EA624, $13220F0A862E7E4F,
|
||||
$CE39399404E04864, $D9C42CA47086FCB7,
|
||||
$685AD2238A03E7CC, $066484B2AB2FF1DB,
|
||||
$FE9D5D70EFBF79EC, $5B13B9DD9C481854,
|
||||
$15F0D475ED1509AD, $0BEBCD060EC79851,
|
||||
$D58C6791183AB7F8, $D1187C5052F3EEE4,
|
||||
$C95D1192E54E82FF, $86EEA14CB9AC6CA2,
|
||||
$3485BEB153677D5D, $DD191D781F8C492A,
|
||||
$F60866BAA784EBF9, $518F643BA2D08C74,
|
||||
$8852E956E1087C22, $A768CB8DC410AE8D,
|
||||
$38047726BFEC8E1A, $A67738B4CD3B45AA,
|
||||
$AD16691CEC0DDE19, $C6D4319380462E07,
|
||||
$C5A5876D0BA61938, $16B9FA1FA58FD840,
|
||||
$188AB1173CA74F18, $ABDA2F98C99C021F,
|
||||
$3E0580AB134AE816, $5F3B05B773645ABB,
|
||||
$2501A2BE5575F2F6, $1B2F74004E7E8BA9,
|
||||
$1CD7580371E8D953, $7F6ED89562764E30,
|
||||
$B15926FF596F003D, $9F65293DA8C5D6B9,
|
||||
$6ECEF04DD690F84C, $4782275FFF33AF88,
|
||||
$E41433083F820801, $FD0DFE409A1AF9B5,
|
||||
$4325A3342CDB396B, $8AE77E62B301B252,
|
||||
$C36F9E9F6655615A, $85455A2D92D32C09,
|
||||
$F2C7DEA949477485, $63CFB4C133A39EBA,
|
||||
$83B040CC6EBC5462, $3B9454C8FDB326B0,
|
||||
$56F56A9E87FFD78C, $2DC2940D99F42BC6,
|
||||
$98F7DF096B096E2D, $19A6E01E3AD852BF,
|
||||
$42A99CCBDBD4B40B, $A59998AF45E9C559,
|
||||
$366295E807D93186, $6B48181BFAA1F773,
|
||||
$1FEC57E2157A0A1D, $4667446AF6201AD5,
|
||||
$E615EBCACFB0F075, $B8F31F4F68290778,
|
||||
$22713ED6CE22D11E, $3057C1A72EC3C93B,
|
||||
$CB46ACC37C3F1F2F, $DBB893FD02AAF50E,
|
||||
$331FD92E600B9FCF, $A498F96148EA3AD6,
|
||||
$A8D8426E8B6A83EA, $A089B274B7735CDC,
|
||||
$87F6B3731E524A11, $118808E5CBC96749,
|
||||
$9906E4C7B19BD394, $AFED7F7E9B24A20C,
|
||||
$6509EADEEB3644A7, $6C1EF1D3E8EF0EDE,
|
||||
$B9C97D43E9798FB4, $A2F2D784740C28A3,
|
||||
$7B8496476197566F, $7A5BE3E6B65F069D,
|
||||
$F96330ED78BE6F10, $EEE60DE77A076A15,
|
||||
$2B4BEE4AA08B9BD0, $6A56A63EC7B8894E,
|
||||
$02121359BA34FEF4, $4CBF99F8283703FC,
|
||||
$398071350CAF30C8, $D0A77A89F017687A,
|
||||
$F1C1A9EB9E423569, $8C7976282DEE8199,
|
||||
$5D1737A5DD1F7ABD, $4F53433C09A9FA80,
|
||||
$FA8B0C53DF7CA1D9, $3FD9DCBC886CCB77,
|
||||
$C040917CA91B4720, $7DD00142F9D1DCDF,
|
||||
$8476FC1D4F387B58, $23F8E7C5F3316503,
|
||||
$032A2244E7E37339, $5C87A5D750F5A74B,
|
||||
$082B4CC43698992E, $DF917BECB858F63C,
|
||||
$3270B8FC5BF86DDA, $10AE72BB29B5DD76,
|
||||
$576AC94E7700362B, $1AD112DAC61EFB8F,
|
||||
$691BC30EC5FAA427, $FF246311CC327143,
|
||||
$3142368E30E53206, $71380E31E02CA396,
|
||||
$958D5C960AAD76F1, $F8D6F430C16DA536,
|
||||
$C8FFD13F1BE7E1D2, $7578AE66004DDBE1,
|
||||
$05833F01067BE646, $BB34B5AD3BFE586D,
|
||||
$095F34C9A12B97F0, $247AB64525D60CA8,
|
||||
$DCDBC6F3017477D1, $4A2E14D4DECAD24D,
|
||||
$BDB5E6D9BE0A1EEB, $2A7E70F7794301AB,
|
||||
$DEF42D8A270540FD, $01078EC0A34C22C1,
|
||||
$E5DE511AF4C16387, $7EBB3A52BD9A330A,
|
||||
$77697857AA7D6435, $004E831603AE4C32,
|
||||
$E7A21020AD78E312, $9D41A70C6AB420F2,
|
||||
$28E06C18EA1141E6, $D2B28CBD984F6B28,
|
||||
$26B75F6C446E9D83, $BA47568C4D418D7F,
|
||||
$D80BADBFE6183D8E, $0E206D7F5F166044,
|
||||
$E258A43911CBCA3E, $723A1746B21DC0BC,
|
||||
$C7CAA854F5D7CDD3, $7CAC32883D261D9C,
|
||||
$7690C26423BA942C, $17E55524478042B8,
|
||||
$E0BE477656A2389F, $4D289B5E67AB2DA0,
|
||||
$44862B9C8FBBFD31, $B47CC8049D141365,
|
||||
$822C1B362B91C793, $4EB14655FB13DFD8,
|
||||
$1ECBBA0714E2A97B, $6143459D5CDE5F14,
|
||||
$53A8FBF1D5F0AC89, $97EA04D81C5E5B00,
|
||||
$622181A8D4FDB3F3, $E9BCD341572A1208,
|
||||
$1411258643CCE58A, $9144C5FEA4C6E0A4,
|
||||
$0D33D06565CF620F, $54A48D489F219CA1,
|
||||
$C43E5EAC6D63C821, $A9728B3A72770DAF,
|
||||
$D7934E7B20DF87EF, $E35503B61A3E86E5,
|
||||
$CAE321FBC819D504, $129A50B3AC60BFA6,
|
||||
$CD5E68EA7E9FB6C3, $B01C90199483B1C7,
|
||||
$3DE93CD5C295376C, $AED52EDF2AB9AD13,
|
||||
$2E60F512C0A07884, $BC3D86A3E36210C9,
|
||||
$35269D9B163951CE, $0C7D6E2AD0CDB5FA,
|
||||
$59E86297D87F5733, $298EF221898DB0E7,
|
||||
$55000029D1A5AA7E, $8BC08AE1B5061B45,
|
||||
$C2C31C2B6C92703A, $94CC596BAF25EF42,
|
||||
$0A1D73DB22540456, $04B6A0F9D9C4179A,
|
||||
$EFFDAFA2AE3D3C60, $F7C8075BB49496C4,
|
||||
$9CC5C7141D1CD4E3, $78BD1638218E5534,
|
||||
$B2F11568F850246A, $EDFABCFA9502BC29,
|
||||
$796CE5F2DA23051B, $AAE128B0DC93537C,
|
||||
$3A493DA0EE4B29AE, $B5DF6B2C416895D7,
|
||||
$FCABBD25122D7F37, $70810B58105DC4B1,
|
||||
$E10FDD37F7882A90, $524DCAB5518A3F5C,
|
||||
$3C9E85878451255B, $4029828119BD34E2,
|
||||
$74A05B6F5D3CECCB, $B610021542E13ECA,
|
||||
$0FF979D12F59E2AC, $6037DA27E4F9CC50,
|
||||
$5E92975A0DF1847D, $D66DE190D3E623FE,
|
||||
$5032D6B87B568048, $9A36B7CE8235216E,
|
||||
$80272A7A24F64B4A, $93EFED8B8C6916F7,
|
||||
$37DDBFF44CCE1555, $4B95DB5D4B99BD25,
|
||||
$92D3FDA169812FC0, $FB1A4A9A90660BB6,
|
||||
$730C196946A4B9B2, $81E289AA7F49DA68,
|
||||
$64669A0F83B1A05F, $27B3FF7D9644F48B,
|
||||
$CC6B615C8DB675B3, $674F20B9BCEBBE95,
|
||||
$6F31238275655982, $5AE488713E45CF05,
|
||||
$BF619F9954C21157, $EABAC46040A8EAE9,
|
||||
$454C6FE9F2C0C1CD, $419CF6496412691C,
|
||||
$D3DC3BEF265B0F70, $6D0E60F5C3578A9E);
|
||||
|
||||
t4: array[0..255] of int64= (
|
||||
$5B0E608526323C55, $1A46C1A9FA1B59F5,
|
||||
$A9E245A17C4C8FFA, $65CA5159DB2955D7,
|
||||
$05DB0A76CE35AFC2, $81EAC77EA9113D45,
|
||||
$528EF88AB6AC0A0D, $A09EA253597BE3FF,
|
||||
$430DDFB3AC48CD56, $C4B3A67AF45CE46F,
|
||||
$4ECECFD8FBE2D05E, $3EF56F10B39935F0,
|
||||
$0B22D6829CD619C6, $17FD460A74DF2069,
|
||||
$6CF8CC8E8510ED40, $D6C824BF3A6ECAA7,
|
||||
$61243D581A817049, $048BACB6BBC163A2,
|
||||
$D9A38AC27D44CC32, $7FDDFF5BAAF410AB,
|
||||
$AD6D495AA804824B, $E1A6A74F2D8C9F94,
|
||||
$D4F7851235DEE8E3, $FD4B7F886540D893,
|
||||
$247C20042AA4BFDA, $096EA1C517D1327C,
|
||||
$D56966B4361A6685, $277DA5C31221057D,
|
||||
$94D59893A43ACFF7, $64F0C51CCDC02281,
|
||||
$3D33BCC4FF6189DB, $E005CB184CE66AF1,
|
||||
$FF5CCD1D1DB99BEA, $B0B854A7FE42980F,
|
||||
$7BD46A6A718D4B9F, $D10FA8CC22A5FD8C,
|
||||
$D31484952BE4BD31, $C7FA975FCB243847,
|
||||
$4886ED1E5846C407, $28CDDB791EB70B04,
|
||||
$C2B00BE2F573417F, $5C9590452180F877,
|
||||
$7A6BDDFFF370EB00, $CE509E38D6D9D6A4,
|
||||
$EBEB0F00647FA702, $1DCC06CF76606F06,
|
||||
$E4D9F28BA286FF0A, $D85A305DC918C262,
|
||||
$475B1D8732225F54, $2D4FB51668CCB5FE,
|
||||
$A679B9D9D72BBA20, $53841C0D912D43A5,
|
||||
$3B7EAA48BF12A4E8, $781E0E47F22F1DDF,
|
||||
$EFF20CE60AB50973, $20D261D19DFFB742,
|
||||
$16A12B03062A2E39, $1960EB2239650495,
|
||||
$251C16FED50EB8B8, $9AC0C330F826016E,
|
||||
$ED152665953E7671, $02D63194A6369570,
|
||||
$5074F08394B1C987, $70BA598C90B25CE1,
|
||||
$794A15810B9742F6, $0D5925E9FCAF8C6C,
|
||||
$3067716CD868744E, $910AB077E8D7731B,
|
||||
$6A61BBDB5AC42F61, $93513EFBF0851567,
|
||||
$F494724B9E83E9D5, $E887E1985C09648D,
|
||||
$34B1D3C675370CFD, $DC35E433BC0D255D,
|
||||
$D0AAB84234131BE0, $08042A50B48B7EAF,
|
||||
$9997C4EE44A3AB35, $829A7B49201799D0,
|
||||
$263B8307B7C54441, $752F95F4FD6A6CA6,
|
||||
$927217402C08C6E5, $2A8AB754A795D9EE,
|
||||
$A442F7552F72943D, $2C31334E19781208,
|
||||
$4FA98D7CEAEE6291, $55C3862F665DB309,
|
||||
$BD0610175D53B1F3, $46FE6CB840413F27,
|
||||
$3FE03792DF0CFA59, $CFE700372EB85E8F,
|
||||
$A7BE29E7ADBCE118, $E544EE5CDE8431DD,
|
||||
$8A781B1B41F1873E, $A5C94C78A0D2F0E7,
|
||||
$39412E2877B60728, $A1265EF3AFC9A62C,
|
||||
$BCC2770C6A2506C5, $3AB66DD5DCE1CE12,
|
||||
$E65499D04A675B37, $7D8F523481BFD216,
|
||||
$0F6F64FCEC15F389, $74EFBE618B5B13C8,
|
||||
$ACDC82B714273E1D, $DD40BFE003199D17,
|
||||
$37E99257E7E061F8, $FA52626904775AAA,
|
||||
$8BBBF63A463D56F9, $F0013F1543A26E64,
|
||||
$A8307E9F879EC898, $CC4C27A4150177CC,
|
||||
$1B432F2CCA1D3348, $DE1D1F8F9F6FA013,
|
||||
$606602A047A7DDD6, $D237AB64CC1CB2C7,
|
||||
$9B938E7225FCD1D3, $EC4E03708E0FF476,
|
||||
$FEB2FBDA3D03C12D, $AE0BCED2EE43889A,
|
||||
$22CB8923EBFB4F43, $69360D013CF7396D,
|
||||
$855E3602D2D4E022, $073805BAD01F784C,
|
||||
$33E17A133852F546, $DF4874058AC7B638,
|
||||
$BA92B29C678AA14A, $0CE89FC76CFAADCD,
|
||||
$5F9D4E0908339E34, $F1AFE9291F5923B9,
|
||||
$6E3480F60F4A265F, $EEBF3A2AB29B841C,
|
||||
$E21938A88F91B4AD, $57DFEFF845C6D3C3,
|
||||
$2F006B0BF62CAAF2, $62F479EF6F75EE78,
|
||||
$11A55AD41C8916A9, $F229D29084FED453,
|
||||
$42F1C27B16B000E6, $2B1F76749823C074,
|
||||
$4B76ECA3C2745360, $8C98F463B91691BD,
|
||||
$14BCC93CF1ADE66A, $8885213E6D458397,
|
||||
$8E177DF0274D4711, $B49B73B5503F2951,
|
||||
$10168168C3F96B6B, $0E3D963B63CAB0AE,
|
||||
$8DFC4B5655A1DB14, $F789F1356E14DE5C,
|
||||
$683E68AF4E51DAC1, $C9A84F9D8D4B0FD9,
|
||||
$3691E03F52A0F9D1, $5ED86E46E1878E80,
|
||||
$3C711A0E99D07150, $5A0865B20C4E9310,
|
||||
$56FBFC1FE4F0682E, $EA8D5DE3105EDF9B,
|
||||
$71ABFDB12379187A, $2EB99DE1BEE77B9C,
|
||||
$21ECC0EA33CF4523, $59A4D7521805C7A1,
|
||||
$3896F5EB56AE7C72, $AA638F3DB18F75DC,
|
||||
$9F39358DABE9808E, $B7DEFA91C00B72AC,
|
||||
$6B5541FD62492D92, $6DC6DEE8F92E4D5B,
|
||||
$353F57ABC4BEEA7E, $735769D6DA5690CE,
|
||||
$0A234AA642391484, $F6F9508028F80D9D,
|
||||
$B8E319A27AB3F215, $31AD9C1151341A4D,
|
||||
$773C22A57BEF5805, $45C7561A07968633,
|
||||
$F913DA9E249DBE36, $DA652D9B78A64C68,
|
||||
$4C27A97F3BC334EF, $76621220E66B17F4,
|
||||
$967743899ACD7D0B, $F3EE5BCAE0ED6782,
|
||||
$409F753600C879FC, $06D09A39B5926DB6,
|
||||
$6F83AEB0317AC588, $01E6CA4A86381F21,
|
||||
$66FF3462D19F3025, $72207C24DDFD3BFB,
|
||||
$4AF6B6D3E2ECE2EB, $9C994DBEC7EA08DE,
|
||||
$49ACE597B09A8BC4, $B38C4766CF0797BA,
|
||||
$131B9373C57C2A75, $B1822CCE61931E58,
|
||||
$9D7555B909BA1C0C, $127FAFDD937D11D2,
|
||||
$29DA3BADC66D92E4, $A2C1D57154C2ECBC,
|
||||
$58C5134D82F6FE24, $1C3AE3515B62274F,
|
||||
$E907C82E01CB8126, $F8ED091913E37FCB,
|
||||
$3249D8F9C80046C9, $80CF9BEDE388FB63,
|
||||
$1881539A116CF19E, $5103F3F76BD52457,
|
||||
$15B7E6F5AE47F7A8, $DBD7C6DED47E9CCF,
|
||||
$44E55C410228BB1A, $B647D4255EDB4E99,
|
||||
$5D11882BB8AAFC30, $F5098BBB29D3212A,
|
||||
$8FB5EA14E90296B3, $677B942157DD025A,
|
||||
$FB58E7C0A390ACB5, $89D3674C83BD4A01,
|
||||
$9E2DA4DF4BF3B93B, $FCC41E328CAB4829,
|
||||
$03F38C96BA582C52, $CAD1BDBD7FD85DB2,
|
||||
$BBB442C16082AE83, $B95FE86BA5DA9AB0,
|
||||
$B22E04673771A93F, $845358C9493152D8,
|
||||
$BE2A488697B4541E, $95A2DC2DD38E6966,
|
||||
$C02C11AC923C852B, $2388B1990DF2A87B,
|
||||
$7C8008FA1B4F37BE, $1F70D0C84D54E503,
|
||||
$5490ADEC7ECE57D4, $002B3C27D9063A3A,
|
||||
$7EAEA3848030A2BF, $C602326DED2003C0,
|
||||
$83A7287D69A94086, $C57A5FCB30F57A8A,
|
||||
$B56844E479EBE779, $A373B40F05DCBCE9,
|
||||
$D71A786E88570EE2, $879CBACDBDE8F6A0,
|
||||
$976AD1BCC164A32F, $AB21E25E9666D78B,
|
||||
$901063AAE5E5C33C, $9818B34448698D90,
|
||||
$E36487AE3E1E8ABB, $AFBDF931893BDCB4,
|
||||
$6345A0DC5FBBD519, $8628FE269B9465CA,
|
||||
$1E5D01603F9C51EC, $4DE44006A15049B7,
|
||||
$BF6C70E5F776CBB1, $411218F2EF552BED,
|
||||
$CB0C0708705A36A3, $E74D14754F986044,
|
||||
$CD56D9430EA8280E, $C12591D7535F5065,
|
||||
$C83223F1720AEF96, $C3A0396F7363A51F);
|
||||
503
dcpcrypt/Hashes/dcphaval.pas
Normal file
@@ -0,0 +1,503 @@
|
||||
{******************************************************************************}
|
||||
{* DCPcrypt v2.0 written by David Barton (crypto@cityinthesky.co.uk) **********}
|
||||
{******************************************************************************}
|
||||
{* A binary compatible implementation of Haval ********************************}
|
||||
{******************************************************************************}
|
||||
{* Copyright (c) 1999-2002 David Barton *}
|
||||
{* Permission is hereby granted, free of charge, to any person obtaining a *}
|
||||
{* copy of this software and associated documentation files (the "Software"), *}
|
||||
{* to deal in the Software without restriction, including without limitation *}
|
||||
{* the rights to use, copy, modify, merge, publish, distribute, sublicense, *}
|
||||
{* and/or sell copies of the Software, and to permit persons to whom the *}
|
||||
{* Software is furnished to do so, subject to the following conditions: *}
|
||||
{* *}
|
||||
{* The above copyright notice and this permission notice shall be included in *}
|
||||
{* all copies or substantial portions of the Software. *}
|
||||
{* *}
|
||||
{* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *}
|
||||
{* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *}
|
||||
{* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *}
|
||||
{* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *}
|
||||
{* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *}
|
||||
{* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *}
|
||||
{* DEALINGS IN THE SOFTWARE. *}
|
||||
{******************************************************************************}
|
||||
unit DCPhaval;
|
||||
|
||||
{$MODE Delphi}
|
||||
|
||||
interface
|
||||
uses
|
||||
Classes, Sysutils, DCPcrypt2, DCPconst;
|
||||
|
||||
type
|
||||
TDCP_haval= class(TDCP_hash)
|
||||
protected
|
||||
LenHi, LenLo: longword;
|
||||
Index: DWord;
|
||||
CurrentHash: array[0..7] of DWord;
|
||||
HashBuffer: array[0..127] of byte;
|
||||
procedure Compress;
|
||||
public
|
||||
class function GetId: integer; override;
|
||||
class function GetAlgorithm: string; override;
|
||||
class function GetHashSize: integer; override;
|
||||
class function SelfTest: boolean; override;
|
||||
procedure Init; override;
|
||||
procedure Burn; override;
|
||||
procedure Update(const Buffer; Size: longword); override;
|
||||
procedure Final(var Digest); override;
|
||||
end;
|
||||
|
||||
{ Choose how many passes (previous versions of DCPcrypt uses 5 passes) }
|
||||
{ ONLY UNCOMMENT ONE! }
|
||||
//{$DEFINE PASS3}
|
||||
//{$DEFINE PASS4}
|
||||
{$DEFINE PASS5}
|
||||
|
||||
{ Choose digest length (previous versions of DCPcrypt uses 256bits) }
|
||||
{ ONLY UNCOMMENT ONE! }
|
||||
//{$DEFINE DIGEST128}
|
||||
//{$DEFINE DIGEST160}
|
||||
//{$DEFINE DIGEST192}
|
||||
//{$DEFINE DIGEST224}
|
||||
{$DEFINE DIGEST256}
|
||||
|
||||
|
||||
{******************************************************************************}
|
||||
{******************************************************************************}
|
||||
implementation
|
||||
{$R-}{$Q-}
|
||||
|
||||
procedure TDCP_haval.Compress;
|
||||
var
|
||||
t7, t6, t5, t4, t3, t2, t1, t0: DWord;
|
||||
W: array[0..31] of DWord;
|
||||
Temp: dword;
|
||||
begin
|
||||
dcpFillChar(W, SizeOf(W), 0);
|
||||
t0:= CurrentHash[0];
|
||||
t1:= CurrentHash[1];
|
||||
t2:= CurrentHash[2];
|
||||
t3:= CurrentHash[3];
|
||||
t4:= CurrentHash[4];
|
||||
t5:= CurrentHash[5];
|
||||
t6:= CurrentHash[6];
|
||||
t7:= CurrentHash[7];
|
||||
Move(HashBuffer,W,Sizeof(W));
|
||||
|
||||
{$IFDEF PASS3}
|
||||
{$INCLUDE DCPhaval3.inc}
|
||||
{$ELSE}
|
||||
{$IFDEF PASS4}
|
||||
{$INCLUDE DCPhaval4.inc}
|
||||
{$ELSE}
|
||||
{$INCLUDE DCPhaval5.inc}
|
||||
{$ENDIF}
|
||||
{$ENDIF}
|
||||
|
||||
Inc(CurrentHash[0],t0);
|
||||
Inc(CurrentHash[1],t1);
|
||||
Inc(CurrentHash[2],t2);
|
||||
Inc(CurrentHash[3],t3);
|
||||
Inc(CurrentHash[4],t4);
|
||||
Inc(CurrentHash[5],t5);
|
||||
Inc(CurrentHash[6],t6);
|
||||
Inc(CurrentHash[7],t7);
|
||||
FillChar(W,Sizeof(W),0);
|
||||
Index:= 0;
|
||||
FillChar(HashBuffer,Sizeof(HashBuffer),0);
|
||||
end;
|
||||
|
||||
class function TDCP_haval.GetHashSize: integer;
|
||||
begin
|
||||
{$IFDEF DIGEST128}
|
||||
Result:= 128;
|
||||
{$ELSE}
|
||||
{$IFDEF DIGEST160}
|
||||
Result:= 160;
|
||||
{$ELSE}
|
||||
{$IFDEF DIGEST192}
|
||||
Result:= 192;
|
||||
{$ELSE}
|
||||
{$IFDEF DIGEST224}
|
||||
Result:= 224;
|
||||
{$ELSE}
|
||||
Result:= 256;
|
||||
{$ENDIF}
|
||||
{$ENDIF}
|
||||
{$ENDIF}
|
||||
{$ENDIF}
|
||||
end;
|
||||
|
||||
class function TDCP_haval.GetId: integer;
|
||||
begin
|
||||
Result:= DCP_haval;
|
||||
end;
|
||||
|
||||
class function TDCP_haval.GetAlgorithm: string;
|
||||
begin
|
||||
Result:= 'Haval (';
|
||||
{$IFDEF DIGEST128}
|
||||
Result:= Result+'128bit, ';
|
||||
{$ELSE}
|
||||
{$IFDEF DIGEST160}
|
||||
Result:= Result+'160bit, ';
|
||||
{$ELSE}
|
||||
{$IFDEF DIGEST192}
|
||||
Result:= Result+'192bit, ';
|
||||
{$ELSE}
|
||||
{$IFDEF DIGEST224}
|
||||
Result:= Result+'224bit, ';
|
||||
{$ELSE}
|
||||
Result:= Result+'256bit, ';
|
||||
{$ENDIF}
|
||||
{$ENDIF}
|
||||
{$ENDIF}
|
||||
{$ENDIF}
|
||||
{$IFDEF PASS3}
|
||||
Result:= Result+'3 passes)';
|
||||
{$ELSE}
|
||||
{$IFDEF PASS4}
|
||||
Result:= Result+'4 passes)';
|
||||
{$ELSE}
|
||||
Result:= Result+'5 passes)';
|
||||
{$ENDIF}
|
||||
{$ENDIF}
|
||||
end;
|
||||
|
||||
class function TDCP_haval.SelfTest: boolean;
|
||||
{$IFDEF PASS3}
|
||||
{$IFDEF DIGEST128}
|
||||
const
|
||||
Test1Out: array[0..15] of byte=
|
||||
($1B,$DC,$55,$6B,$29,$AD,$02,$EC,$09,$AF,$8C,$66,$47,$7F,$2A,$87);
|
||||
var
|
||||
TestHash: TDCP_haval;
|
||||
TestOut: array[0..15] of byte;
|
||||
begin
|
||||
TestHash:= TDCP_haval.Create(nil);
|
||||
TestHash.Init;
|
||||
TestHash.UpdateStr('');
|
||||
TestHash.Final(TestOut);
|
||||
Result:= CompareMem(@TestOut,@Test1Out,Sizeof(Test1Out));
|
||||
TestHash.Free;
|
||||
{$ELSE}
|
||||
{$IFDEF DIGEST160}
|
||||
const
|
||||
Test1Out: array[0..19] of byte=
|
||||
($5E,$16,$10,$FC,$ED,$1D,$3A,$DB,$0B,$B1,
|
||||
$8E,$92,$AC,$2B,$11,$F0,$BD,$99,$D8,$ED);
|
||||
var
|
||||
TestHash: TDCP_haval;
|
||||
TestOut: array[0..19] of byte;
|
||||
begin
|
||||
TestHash:= TDCP_haval.Create(nil);
|
||||
TestHash.Init;
|
||||
TestHash.UpdateStr('a');
|
||||
TestHash.Final(TestOut);
|
||||
Result:= CompareMem(@TestOut,@Test1Out,Sizeof(Test1Out));
|
||||
TestHash.Free;
|
||||
{$ELSE}
|
||||
begin
|
||||
Result:= true;
|
||||
{$ENDIF}
|
||||
{$ENDIF}
|
||||
{$ELSE}
|
||||
{$IFDEF PASS4}
|
||||
{$IFDEF DIGEST192}
|
||||
const
|
||||
Test1Out: array[0..23] of byte=
|
||||
($74,$AA,$31,$18,$2F,$F0,$9B,$CC,$E4,$53,$A7,$F7,
|
||||
$1B,$5A,$7C,$5E,$80,$87,$2F,$A9,$0C,$D9,$3A,$E4);
|
||||
var
|
||||
TestHash: TDCP_haval;
|
||||
TestOut: array[0..23] of byte;
|
||||
begin
|
||||
TestHash:= TDCP_haval.Create(nil);
|
||||
TestHash.Init;
|
||||
TestHash.UpdateStr('HAVAL');
|
||||
TestHash.Final(TestOut);
|
||||
Result:= CompareMem(@TestOut,@Test1Out,Sizeof(Test1Out));
|
||||
TestHash.Free;
|
||||
{$ELSE}
|
||||
{$IFDEF DIGEST224}
|
||||
const
|
||||
Test1Out: array[0..27] of byte=
|
||||
($14,$4C,$B2,$DE,$11,$F0,$5D,$F7,$C3,$56,$28,$2A,$3B,$48,
|
||||
$57,$96,$DA,$65,$3F,$6B,$70,$28,$68,$C7,$DC,$F4,$AE,$76);
|
||||
var
|
||||
TestHash: TDCP_haval;
|
||||
TestOut: array[0..27] of byte;
|
||||
begin
|
||||
TestHash:= TDCP_haval.Create(nil);
|
||||
TestHash.Init;
|
||||
TestHash.UpdateStr('0123456789');
|
||||
TestHash.Final(TestOut);
|
||||
Result:= CompareMem(@TestOut,@Test1Out,Sizeof(Test1Out));
|
||||
TestHash.Free;
|
||||
{$ELSE}
|
||||
begin
|
||||
Result:= true;
|
||||
{$ENDIF}
|
||||
{$ENDIF}
|
||||
{$ELSE}
|
||||
{$IFDEF DIGEST256}
|
||||
const
|
||||
Test1Out: array[0..31] of byte=
|
||||
($1A,$1D,$C8,$09,$9B,$DA,$A7,$F3,$5B,$4D,$A4,$E8,$05,$F1,$A2,$8F,
|
||||
$EE,$90,$9D,$8D,$EE,$92,$01,$98,$18,$5C,$BC,$AE,$D8,$A1,$0A,$8D);
|
||||
Test2Out: array[0..31] of byte=
|
||||
($C5,$64,$7F,$C6,$C1,$87,$7F,$FF,$96,$74,$2F,$27,$E9,$26,$6B,$68,
|
||||
$74,$89,$4F,$41,$A0,$8F,$59,$13,$03,$3D,$9D,$53,$2A,$ED,$DB,$39);
|
||||
var
|
||||
TestHash: TDCP_haval;
|
||||
TestOut: array[0..31] of byte;
|
||||
begin
|
||||
dcpFillChar(TestOut, SizeOf(TestOut), 0);
|
||||
TestHash:= TDCP_haval.Create(nil);
|
||||
TestHash.Init;
|
||||
TestHash.UpdateStr('abcdefghijklmnopqrstuvwxyz');
|
||||
TestHash.Final(TestOut);
|
||||
Result:= CompareMem(@TestOut,@Test1Out,Sizeof(Test1Out));
|
||||
TestHash.Init;
|
||||
TestHash.UpdateStr('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789');
|
||||
TestHash.Final(TestOut);
|
||||
Result:= CompareMem(@TestOut,@Test2Out,Sizeof(Test2Out)) and Result;
|
||||
TestHash.Free;
|
||||
{$ELSE}
|
||||
begin
|
||||
Result:= true;
|
||||
{$ENDIF}
|
||||
{$ENDIF}
|
||||
{$ENDIF}
|
||||
end;
|
||||
|
||||
procedure TDCP_haval.Init;
|
||||
begin
|
||||
Burn;
|
||||
CurrentHash[0]:= $243F6A88;
|
||||
CurrentHash[1]:= $85A308D3;
|
||||
CurrentHash[2]:= $13198A2E;
|
||||
CurrentHash[3]:= $03707344;
|
||||
CurrentHash[4]:= $A4093822;
|
||||
CurrentHash[5]:= $299F31D0;
|
||||
CurrentHash[6]:= $082EFA98;
|
||||
CurrentHash[7]:= $EC4E6C89;
|
||||
fInitialized:= true;
|
||||
end;
|
||||
|
||||
procedure TDCP_haval.Burn;
|
||||
begin
|
||||
LenHi:= 0; LenLo:= 0;
|
||||
Index:= 0;
|
||||
FillChar(HashBuffer,Sizeof(HashBuffer),0);
|
||||
FillChar(CurrentHash,Sizeof(CurrentHash),0);
|
||||
fInitialized:= false;
|
||||
end;
|
||||
|
||||
procedure TDCP_haval.Update(const Buffer; Size: longword);
|
||||
var
|
||||
PBuf: ^byte;
|
||||
begin
|
||||
if not fInitialized then
|
||||
raise EDCP_hash.Create('Hash not initialized');
|
||||
|
||||
Inc(LenHi,Size shr 29);
|
||||
Inc(LenLo,Size*8);
|
||||
if LenLo< (Size*8) then
|
||||
Inc(LenHi);
|
||||
|
||||
PBuf:= @Buffer;
|
||||
while Size> 0 do
|
||||
begin
|
||||
if (Sizeof(HashBuffer)-Index)<= DWord(Size) then
|
||||
begin
|
||||
Move(PBuf^,HashBuffer[Index],Sizeof(HashBuffer)-Index);
|
||||
Dec(Size,Sizeof(HashBuffer)-Index);
|
||||
Inc(PBuf,Sizeof(HashBuffer)-Index);
|
||||
Compress;
|
||||
end
|
||||
else
|
||||
begin
|
||||
Move(PBuf^,HashBuffer[Index],Size);
|
||||
Inc(Index,Size);
|
||||
Size:= 0;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TDCP_haval.Final(var Digest);
|
||||
{$IFNDEF DIGEST256}
|
||||
{$IFNDEF DIGEST224}
|
||||
var
|
||||
temp: dword;
|
||||
{$ENDIF}
|
||||
{$ENDIF}
|
||||
begin
|
||||
if not fInitialized then
|
||||
raise EDCP_hash.Create('Hash not initialized');
|
||||
HashBuffer[Index]:= $80;
|
||||
if Index>= 118 then
|
||||
Compress;
|
||||
{$IFDEF PASS3}
|
||||
{$IFDEF DIGEST128}
|
||||
HashBuffer[118]:= ((128 and 3) shl 6) or (3 shl 3) or 1;
|
||||
HashBuffer[119]:= (128 shr 2) and $FF;
|
||||
{$ELSE}
|
||||
{$IFDEF DIGEST160}
|
||||
HashBuffer[118]:= ((160 and 3) shl 6) or (3 shl 3) or 1;
|
||||
HashBuffer[119]:= (160 shr 2) and $FF;
|
||||
{$ELSE}
|
||||
{$IFDEF DIGEST192}
|
||||
HashBuffer[118]:= ((192 and 3) shl 6) or (3 shl 3) or 1;
|
||||
HashBuffer[119]:= (192 shr 2) and $FF;
|
||||
{$ELSE}
|
||||
{$IFDEF DIGEST224}
|
||||
HashBuffer[118]:= ((224 and 3) shl 6) or (3 shl 3) or 1;
|
||||
HashBuffer[119]:= (224 shr 2) and $FF;
|
||||
{$ELSE}
|
||||
HashBuffer[118]:= ((256 and 3) shl 6) or (3 shl 3) or 1;
|
||||
HashBuffer[119]:= (256 shr 2) and $FF;
|
||||
{$ENDIF}
|
||||
{$ENDIF}
|
||||
{$ENDIF}
|
||||
{$ENDIF}
|
||||
{$ELSE}
|
||||
{$IFDEF PASS4}
|
||||
{$IFDEF DIGEST128}
|
||||
HashBuffer[118]:= ((128 and 3) shl 6) or (4 shl 3) or 1;
|
||||
HashBuffer[119]:= (128 shr 2) and $FF;
|
||||
{$ELSE}
|
||||
{$IFDEF DIGEST160}
|
||||
HashBuffer[118]:= ((160 and 3) shl 6) or (4 shl 3) or 1;
|
||||
HashBuffer[119]:= (160 shr 2) and $FF;
|
||||
{$ELSE}
|
||||
{$IFDEF DIGEST192}
|
||||
HashBuffer[118]:= ((192 and 3) shl 6) or (4 shl 3) or 1;
|
||||
HashBuffer[119]:= (192 shr 2) and $FF;
|
||||
{$ELSE}
|
||||
{$IFDEF DIGEST224}
|
||||
HashBuffer[118]:= ((224 and 3) shl 6) or (4 shl 3) or 1;
|
||||
HashBuffer[119]:= (224 shr 2) and $FF;
|
||||
{$ELSE}
|
||||
HashBuffer[118]:= ((256 and 3) shl 6) or (4 shl 3) or 1;
|
||||
HashBuffer[119]:= (256 shr 2) and $FF;
|
||||
{$ENDIF}
|
||||
{$ENDIF}
|
||||
{$ENDIF}
|
||||
{$ENDIF}
|
||||
{$ELSE}
|
||||
{$IFDEF DIGEST128}
|
||||
HashBuffer[118]:= ((128 and 3) shl 6) or (5 shl 3) or 1;
|
||||
HashBuffer[119]:= (2128 shr 2) and $FF;
|
||||
{$ELSE}
|
||||
{$IFDEF DIGEST160}
|
||||
HashBuffer[118]:= ((160 and 3) shl 6) or (5 shl 3) or 1;
|
||||
HashBuffer[119]:= (160 shr 2) and $FF;
|
||||
{$ELSE}
|
||||
{$IFDEF DIGEST192}
|
||||
HashBuffer[118]:= ((192 and 3) shl 6) or (5 shl 3) or 1;
|
||||
HashBuffer[119]:= (192 shr 2) and $FF;
|
||||
{$ELSE}
|
||||
{$IFDEF DIGEST224}
|
||||
HashBuffer[118]:= ((224 and 3) shl 6) or (5 shl 3) or 1;
|
||||
HashBuffer[119]:= (224 shr 2) and $FF;
|
||||
{$ELSE}
|
||||
HashBuffer[118]:= ((256 and 3) shl 6) or (5 shl 3) or 1;
|
||||
HashBuffer[119]:= (256 shr 2) and $FF;
|
||||
{$ENDIF}
|
||||
{$ENDIF}
|
||||
{$ENDIF}
|
||||
{$ENDIF}
|
||||
{$ENDIF}
|
||||
{$ENDIF}
|
||||
PDWord(@HashBuffer[120])^:= LenLo;
|
||||
PDWord(@HashBuffer[124])^:= LenHi;
|
||||
Compress;
|
||||
{$IFDEF DIGEST128}
|
||||
temp:= (CurrentHash[7] and $000000FF) or
|
||||
(CurrentHash[6] and $FF000000) or
|
||||
(CurrentHash[5] and $00FF0000) or
|
||||
(CurrentHash[4] and $0000FF00);
|
||||
Inc(CurrentHash[0],(temp shr 8) or (temp shl 24));
|
||||
temp:= (CurrentHash[7] and $0000FF00) or
|
||||
(CurrentHash[6] and $000000FF) or
|
||||
(CurrentHash[5] and $FF000000) or
|
||||
(CurrentHash[4] and $00FF0000);
|
||||
Inc(CurrentHash[1],(temp shr 16) or (temp shl 16));
|
||||
temp:= (CurrentHash[7] and $00FF0000) or
|
||||
(CurrentHash[6] and $0000FF00) or
|
||||
(CurrentHash[5] and $000000FF) or
|
||||
(CurrentHash[4] and $FF000000);
|
||||
Inc(CurrentHash[2],(temp shr 24) or (temp shl 8));
|
||||
temp:= (CurrentHash[7] and $FF000000) or
|
||||
(CurrentHash[6] and $00FF0000) or
|
||||
(CurrentHash[5] and $0000FF00) or
|
||||
(CurrentHash[4] and $000000FF);
|
||||
Inc(CurrentHash[3],temp);
|
||||
Move(CurrentHash,Digest,128 div 8);
|
||||
{$ELSE}
|
||||
{$IFDEF DIGEST160}
|
||||
temp:= (CurrentHash[7] and $3F) or
|
||||
(CurrentHash[6] and ($7F shl 25)) or
|
||||
(CurrentHash[5] and ($3F shl 19));
|
||||
Inc(CurrentHash[0],(temp shr 19) or (temp shl 13));
|
||||
temp:= (CurrentHash[7] and ($3F shl 6)) or
|
||||
(CurrentHash[6] and $3F) or
|
||||
(CurrentHash[5] and ($7F shl 25));
|
||||
Inc(CurrentHash[1],(temp shr 25) or (temp shl 7));
|
||||
temp:= (CurrentHash[7] and ($7F shl 12)) or
|
||||
(CurrentHash[6] and ($3F shl 6)) or
|
||||
(CurrentHash[5] and $3F);
|
||||
Inc(CurrentHash[2],temp);
|
||||
temp:= (CurrentHash[7] and ($3F shl 19)) or
|
||||
(CurrentHash[6] and ($7F shl 12)) or
|
||||
(CurrentHash[5] and ($3F shl 6));
|
||||
Inc(CurrentHash[3],temp shr 6);
|
||||
temp:= (CurrentHash[7] and ($7F shl 25)) or
|
||||
(CurrentHash[6] and ($3F shl 19)) or
|
||||
(CurrentHash[5] and ($7F shl 12));
|
||||
Inc(CurrentHash[4],temp shr 12);
|
||||
Move(CurrentHash,Digest,160 div 8);
|
||||
{$ELSE}
|
||||
{$IFDEF DIGEST192}
|
||||
temp:= (CurrentHash[7] and $1F) or
|
||||
(CurrentHash[6] and ($3F shl 26));
|
||||
Inc(CurrentHash[0],(temp shr 26) or (temp shl 6));
|
||||
temp:= (CurrentHash[7] and ($1F shl 5)) or
|
||||
(CurrentHash[6] and $1F);
|
||||
Inc(CurrentHash[1],temp);
|
||||
temp:= (CurrentHash[7] and ($3F shl 10)) or
|
||||
(CurrentHash[6] and ($1F shl 5));
|
||||
Inc(CurrentHash[2],temp shr 5);
|
||||
temp:= (CurrentHash[7] and ($1F shl 16)) or
|
||||
(CurrentHash[6] and ($3F shl 10));
|
||||
Inc(CurrentHash[3],temp shr 10);
|
||||
temp:= (CurrentHash[7] and ($1F shl 21)) or
|
||||
(CurrentHash[6] and ($1F shl 16));
|
||||
Inc(CurrentHash[4],temp shr 16);
|
||||
temp:= (CurrentHash[7] and ($3F shl 26)) or
|
||||
(CurrentHash[6] and ($1F shl 21));
|
||||
Inc(CurrentHash[5],temp shr 21);
|
||||
Move(CurrentHash,Digest,192 div 8);
|
||||
{$ELSE}
|
||||
{$IFDEF DIGEST224}
|
||||
Inc(CurrentHash[0],(CurrentHash[7] shr 27) and $1F);
|
||||
Inc(CurrentHash[1],(CurrentHash[7] shr 22) and $1F);
|
||||
Inc(CurrentHash[2],(CurrentHash[7] shr 18) and $F);
|
||||
Inc(CurrentHash[3],(CurrentHash[7] shr 13) and $1F);
|
||||
Inc(CurrentHash[4],(CurrentHash[7] shr 9) and $F);
|
||||
Inc(CurrentHash[5],(CurrentHash[7] shr 4) and $1F);
|
||||
Inc(CurrentHash[6],CurrentHash[7] and $F);
|
||||
Move(CurrentHash,Digest,224 div 8);
|
||||
{$ELSE}
|
||||
Move(CurrentHash,Digest,256 div 8);
|
||||
{$ENDIF}
|
||||
{$ENDIF}
|
||||
{$ENDIF}
|
||||
{$ENDIF}
|
||||
Burn;
|
||||
end;
|
||||
|
||||
end.
|
||||
237
dcpcrypt/Hashes/dcpmd4.pas
Normal file
@@ -0,0 +1,237 @@
|
||||
{******************************************************************************}
|
||||
{* DCPcrypt v2.0 written by David Barton (crypto@cityinthesky.co.uk) **********}
|
||||
{******************************************************************************}
|
||||
{* A binary compatible implementation of MD4 **********************************}
|
||||
{******************************************************************************}
|
||||
{* Copyright (c) 1999-2002 David Barton *}
|
||||
{* Permission is hereby granted, free of charge, to any person obtaining a *}
|
||||
{* copy of this software and associated documentation files (the "Software"), *}
|
||||
{* to deal in the Software without restriction, including without limitation *}
|
||||
{* the rights to use, copy, modify, merge, publish, distribute, sublicense, *}
|
||||
{* and/or sell copies of the Software, and to permit persons to whom the *}
|
||||
{* Software is furnished to do so, subject to the following conditions: *}
|
||||
{* *}
|
||||
{* The above copyright notice and this permission notice shall be included in *}
|
||||
{* all copies or substantial portions of the Software. *}
|
||||
{* *}
|
||||
{* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *}
|
||||
{* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *}
|
||||
{* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *}
|
||||
{* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *}
|
||||
{* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *}
|
||||
{* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *}
|
||||
{* DEALINGS IN THE SOFTWARE. *}
|
||||
{******************************************************************************}
|
||||
unit DCPmd4;
|
||||
|
||||
{$MODE Delphi}
|
||||
|
||||
interface
|
||||
uses
|
||||
Classes, Sysutils, DCPcrypt2, DCPconst;
|
||||
|
||||
type
|
||||
TDCP_md4= class(TDCP_hash)
|
||||
protected
|
||||
LenHi, LenLo: longword;
|
||||
Index: DWord;
|
||||
CurrentHash: array[0..3] of DWord;
|
||||
HashBuffer: array[0..63] of byte;
|
||||
procedure Compress;
|
||||
public
|
||||
class function GetId: integer; override;
|
||||
class function GetAlgorithm: string; override;
|
||||
class function GetHashSize: integer; override;
|
||||
class function SelfTest: boolean; override;
|
||||
procedure Init; override;
|
||||
procedure Burn; override;
|
||||
procedure Update(const Buffer; Size: longword); override;
|
||||
procedure Final(var Digest); override;
|
||||
end;
|
||||
|
||||
|
||||
|
||||
{******************************************************************************}
|
||||
{******************************************************************************}
|
||||
implementation
|
||||
{$R-}{$Q-}
|
||||
|
||||
function LRot32(a, b: longword): longword;
|
||||
begin
|
||||
Result:= (a shl b) or (a shr (32-b));
|
||||
end;
|
||||
|
||||
procedure TDCP_md4.Compress;
|
||||
var
|
||||
Data: array[0..15] of dword;
|
||||
A, B, C, D: dword;
|
||||
begin
|
||||
dcpFillChar(Data, SizeOf(Data), 0);
|
||||
Move(HashBuffer,Data,Sizeof(Data));
|
||||
A:= CurrentHash[0];
|
||||
B:= CurrentHash[1];
|
||||
C:= CurrentHash[2];
|
||||
D:= CurrentHash[3];
|
||||
|
||||
A:= LRot32(A + (D xor (B and (C xor D))) + Data[ 0],3);
|
||||
D:= LRot32(D + (C xor (A and (B xor C))) + Data[ 1],7);
|
||||
C:= LRot32(C + (B xor (D and (A xor B))) + Data[ 2],11);
|
||||
B:= LRot32(B + (A xor (C and (D xor A))) + Data[ 3],19);
|
||||
A:= LRot32(A + (D xor (B and (C xor D))) + Data[ 4],3);
|
||||
D:= LRot32(D + (C xor (A and (B xor C))) + Data[ 5],7);
|
||||
C:= LRot32(C + (B xor (D and (A xor B))) + Data[ 6],11);
|
||||
B:= LRot32(B + (A xor (C and (D xor A))) + Data[ 7],19);
|
||||
A:= LRot32(A + (D xor (B and (C xor D))) + Data[ 8],3);
|
||||
D:= LRot32(D + (C xor (A and (B xor C))) + Data[ 9],7);
|
||||
C:= LRot32(C + (B xor (D and (A xor B))) + Data[10],11);
|
||||
B:= LRot32(B + (A xor (C and (D xor A))) + Data[11],19);
|
||||
A:= LRot32(A + (D xor (B and (C xor D))) + Data[12],3);
|
||||
D:= LRot32(D + (C xor (A and (B xor C))) + Data[13],7);
|
||||
C:= LRot32(C + (B xor (D and (A xor B))) + Data[14],11);
|
||||
B:= LRot32(B + (A xor (C and (D xor A))) + Data[15],19);
|
||||
|
||||
A:= LRot32(A + ((B and C) or (B and D) or (C and D)) + Data[ 0] + $5a827999,3);
|
||||
D:= LRot32(D + ((A and B) or (A and C) or (B and C)) + Data[ 4] + $5a827999,5);
|
||||
C:= LRot32(C + ((D and A) or (D and B) or (A and B)) + Data[ 8] + $5a827999,9);
|
||||
B:= LRot32(B + ((C and D) or (C and A) or (D and A)) + Data[12] + $5a827999,13);
|
||||
A:= LRot32(A + ((B and C) or (B and D) or (C and D)) + Data[ 1] + $5a827999,3);
|
||||
D:= LRot32(D + ((A and B) or (A and C) or (B and C)) + Data[ 5] + $5a827999,5);
|
||||
C:= LRot32(C + ((D and A) or (D and B) or (A and B)) + Data[ 9] + $5a827999,9);
|
||||
B:= LRot32(B + ((C and D) or (C and A) or (D and A)) + Data[13] + $5a827999,13);
|
||||
A:= LRot32(A + ((B and C) or (B and D) or (C and D)) + Data[ 2] + $5a827999,3);
|
||||
D:= LRot32(D + ((A and B) or (A and C) or (B and C)) + Data[ 6] + $5a827999,5);
|
||||
C:= LRot32(C + ((D and A) or (D and B) or (A and B)) + Data[10] + $5a827999,9);
|
||||
B:= LRot32(B + ((C and D) or (C and A) or (D and A)) + Data[14] + $5a827999,13);
|
||||
A:= LRot32(A + ((B and C) or (B and D) or (C and D)) + Data[ 3] + $5a827999,3);
|
||||
D:= LRot32(D + ((A and B) or (A and C) or (B and C)) + Data[ 7] + $5a827999,5);
|
||||
C:= LRot32(C + ((D and A) or (D and B) or (A and B)) + Data[11] + $5a827999,9);
|
||||
B:= LRot32(B + ((C and D) or (C and A) or (D and A)) + Data[15] + $5a827999,13);
|
||||
|
||||
A:= LRot32(A + (B xor C xor D) + Data[ 0] + $6ed9eba1,3);
|
||||
D:= LRot32(D + (A xor B xor C) + Data[ 8] + $6ed9eba1,9);
|
||||
C:= LRot32(C + (D xor A xor B) + Data[ 4] + $6ed9eba1,11);
|
||||
B:= LRot32(B + (C xor D xor A) + Data[12] + $6ed9eba1,15);
|
||||
A:= LRot32(A + (B xor C xor D) + Data[ 2] + $6ed9eba1,3);
|
||||
D:= LRot32(D + (A xor B xor C) + Data[10] + $6ed9eba1,9);
|
||||
C:= LRot32(C + (D xor A xor B) + Data[ 6] + $6ed9eba1,11);
|
||||
B:= LRot32(B + (C xor D xor A) + Data[14] + $6ed9eba1,15);
|
||||
A:= LRot32(A + (B xor C xor D) + Data[ 1] + $6ed9eba1,3);
|
||||
D:= LRot32(D + (A xor B xor C) + Data[ 9] + $6ed9eba1,9);
|
||||
C:= LRot32(C + (D xor A xor B) + Data[ 5] + $6ed9eba1,11);
|
||||
B:= LRot32(B + (C xor D xor A) + Data[13] + $6ed9eba1,15);
|
||||
A:= LRot32(A + (B xor C xor D) + Data[ 3] + $6ed9eba1,3);
|
||||
D:= LRot32(D + (A xor B xor C) + Data[11] + $6ed9eba1,9);
|
||||
C:= LRot32(C + (D xor A xor B) + Data[ 7] + $6ed9eba1,11);
|
||||
B:= LRot32(B + (C xor D xor A) + Data[15] + $6ed9eba1,15);
|
||||
|
||||
Inc(CurrentHash[0],A);
|
||||
Inc(CurrentHash[1],B);
|
||||
Inc(CurrentHash[2],C);
|
||||
Inc(CurrentHash[3],D);
|
||||
Index:= 0;
|
||||
FillChar(HashBuffer,Sizeof(HashBuffer),0);
|
||||
end;
|
||||
|
||||
class function TDCP_md4.GetHashSize: integer;
|
||||
begin
|
||||
Result:= 128;
|
||||
end;
|
||||
|
||||
class function TDCP_md4.GetId: integer;
|
||||
begin
|
||||
Result:= DCP_md4;
|
||||
end;
|
||||
|
||||
class function TDCP_md4.GetAlgorithm: string;
|
||||
begin
|
||||
Result:= 'MD4';
|
||||
end;
|
||||
|
||||
class function TDCP_md4.SelfTest: boolean;
|
||||
const
|
||||
Test1Out: array[0..15] of byte=
|
||||
($a4,$48,$01,$7a,$af,$21,$d8,$52,$5f,$c1,$0a,$e8,$7a,$a6,$72,$9d);
|
||||
Test2Out: array[0..15] of byte=
|
||||
($d7,$9e,$1c,$30,$8a,$a5,$bb,$cd,$ee,$a8,$ed,$63,$df,$41,$2d,$a9);
|
||||
var
|
||||
TestHash: TDCP_md4;
|
||||
TestOut: array[0..19] of byte;
|
||||
begin
|
||||
dcpFillChar(TestOut, SizeOf(TestOut), 0);
|
||||
TestHash:= TDCP_md4.Create(nil);
|
||||
TestHash.Init;
|
||||
TestHash.UpdateStr('abc');
|
||||
TestHash.Final(TestOut);
|
||||
Result:= CompareMem(@TestOut,@Test1Out,Sizeof(Test1Out));
|
||||
TestHash.Init;
|
||||
TestHash.UpdateStr('abcdefghijklmnopqrstuvwxyz');
|
||||
TestHash.Final(TestOut);
|
||||
Result:= CompareMem(@TestOut,@Test2Out,Sizeof(Test2Out)) and Result;
|
||||
TestHash.Free;
|
||||
end;
|
||||
|
||||
procedure TDCP_md4.Init;
|
||||
begin
|
||||
Burn;
|
||||
CurrentHash[0]:= $67452301;
|
||||
CurrentHash[1]:= $efcdab89;
|
||||
CurrentHash[2]:= $98badcfe;
|
||||
CurrentHash[3]:= $10325476;
|
||||
fInitialized:= true;
|
||||
end;
|
||||
|
||||
procedure TDCP_md4.Burn;
|
||||
begin
|
||||
LenHi:= 0; LenLo:= 0;
|
||||
Index:= 0;
|
||||
FillChar(HashBuffer,Sizeof(HashBuffer),0);
|
||||
FillChar(CurrentHash,Sizeof(CurrentHash),0);
|
||||
fInitialized:= false;
|
||||
end;
|
||||
|
||||
procedure TDCP_md4.Update(const Buffer; Size: longword);
|
||||
var
|
||||
PBuf: ^byte;
|
||||
begin
|
||||
if not fInitialized then
|
||||
raise EDCP_hash.Create('Hash not initialized');
|
||||
|
||||
Inc(LenHi,Size shr 29);
|
||||
Inc(LenLo,Size*8);
|
||||
if LenLo< (Size*8) then
|
||||
Inc(LenHi);
|
||||
|
||||
PBuf:= @Buffer;
|
||||
while Size> 0 do
|
||||
begin
|
||||
if (Sizeof(HashBuffer)-Index)<= DWord(Size) then
|
||||
begin
|
||||
Move(PBuf^,HashBuffer[Index],Sizeof(HashBuffer)-Index);
|
||||
Dec(Size,Sizeof(HashBuffer)-Index);
|
||||
Inc(PBuf,Sizeof(HashBuffer)-Index);
|
||||
Compress;
|
||||
end
|
||||
else
|
||||
begin
|
||||
Move(PBuf^,HashBuffer[Index],Size);
|
||||
Inc(Index,Size);
|
||||
Size:= 0;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TDCP_md4.Final(var Digest);
|
||||
begin
|
||||
if not fInitialized then
|
||||
raise EDCP_hash.Create('Hash not initialized');
|
||||
HashBuffer[Index]:= $80;
|
||||
if Index>= 56 then
|
||||
Compress;
|
||||
PDWord(@HashBuffer[56])^:= LenLo;
|
||||
PDWord(@HashBuffer[60])^:= LenHi;
|
||||
Compress;
|
||||
Move(CurrentHash,Digest,Sizeof(CurrentHash));
|
||||
Burn;
|
||||
end;
|
||||
|
||||
end.
|
||||
254
dcpcrypt/Hashes/dcpmd5.pas
Normal file
@@ -0,0 +1,254 @@
|
||||
{******************************************************************************}
|
||||
{* DCPcrypt v2.0 written by David Barton (crypto@cityinthesky.co.uk) **********}
|
||||
{******************************************************************************}
|
||||
{* A binary compatible implementation of MD5 **********************************}
|
||||
{******************************************************************************}
|
||||
{* Copyright (c) 1999-2002 David Barton *}
|
||||
{* Permission is hereby granted, free of charge, to any person obtaining a *}
|
||||
{* copy of this software and associated documentation files (the "Software"), *}
|
||||
{* to deal in the Software without restriction, including without limitation *}
|
||||
{* the rights to use, copy, modify, merge, publish, distribute, sublicense, *}
|
||||
{* and/or sell copies of the Software, and to permit persons to whom the *}
|
||||
{* Software is furnished to do so, subject to the following conditions: *}
|
||||
{* *}
|
||||
{* The above copyright notice and this permission notice shall be included in *}
|
||||
{* all copies or substantial portions of the Software. *}
|
||||
{* *}
|
||||
{* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *}
|
||||
{* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *}
|
||||
{* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *}
|
||||
{* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *}
|
||||
{* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *}
|
||||
{* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *}
|
||||
{* DEALINGS IN THE SOFTWARE. *}
|
||||
{******************************************************************************}
|
||||
unit DCPmd5;
|
||||
|
||||
{$MODE Delphi}
|
||||
|
||||
interface
|
||||
uses
|
||||
Classes, Sysutils, DCPcrypt2, DCPconst;
|
||||
|
||||
type
|
||||
TDCP_md5= class(TDCP_hash)
|
||||
protected
|
||||
LenHi, LenLo: longword;
|
||||
Index: DWord;
|
||||
CurrentHash: array[0..3] of DWord;
|
||||
HashBuffer: array[0..63] of byte;
|
||||
procedure Compress;
|
||||
public
|
||||
class function GetId: integer; override;
|
||||
class function GetAlgorithm: string; override;
|
||||
class function GetHashSize: integer; override;
|
||||
class function SelfTest: boolean; override;
|
||||
procedure Init; override;
|
||||
procedure Burn; override;
|
||||
procedure Update(const Buffer; Size: longword); override;
|
||||
procedure Final(var Digest); override;
|
||||
end;
|
||||
|
||||
|
||||
|
||||
{******************************************************************************}
|
||||
{******************************************************************************}
|
||||
implementation
|
||||
{$R-}{$Q-}
|
||||
|
||||
function LRot32(a, b: longword): longword;
|
||||
begin
|
||||
Result:= (a shl b) or (a shr (32-b));
|
||||
end;
|
||||
|
||||
procedure TDCP_md5.Compress;
|
||||
var
|
||||
Data: array[0..15] of dword;
|
||||
A, B, C, D: dword;
|
||||
begin
|
||||
dcpFillChar(Data, SizeOf(Data), 0);
|
||||
Move(HashBuffer,Data,Sizeof(Data));
|
||||
A:= CurrentHash[0];
|
||||
B:= CurrentHash[1];
|
||||
C:= CurrentHash[2];
|
||||
D:= CurrentHash[3];
|
||||
|
||||
A:= B + LRot32(A + (D xor (B and (C xor D))) + Data[ 0] + $d76aa478,7);
|
||||
D:= A + LRot32(D + (C xor (A and (B xor C))) + Data[ 1] + $e8c7b756,12);
|
||||
C:= D + LRot32(C + (B xor (D and (A xor B))) + Data[ 2] + $242070db,17);
|
||||
B:= C + LRot32(B + (A xor (C and (D xor A))) + Data[ 3] + $c1bdceee,22);
|
||||
A:= B + LRot32(A + (D xor (B and (C xor D))) + Data[ 4] + $f57c0faf,7);
|
||||
D:= A + LRot32(D + (C xor (A and (B xor C))) + Data[ 5] + $4787c62a,12);
|
||||
C:= D + LRot32(C + (B xor (D and (A xor B))) + Data[ 6] + $a8304613,17);
|
||||
B:= C + LRot32(B + (A xor (C and (D xor A))) + Data[ 7] + $fd469501,22);
|
||||
A:= B + LRot32(A + (D xor (B and (C xor D))) + Data[ 8] + $698098d8,7);
|
||||
D:= A + LRot32(D + (C xor (A and (B xor C))) + Data[ 9] + $8b44f7af,12);
|
||||
C:= D + LRot32(C + (B xor (D and (A xor B))) + Data[10] + $ffff5bb1,17);
|
||||
B:= C + LRot32(B + (A xor (C and (D xor A))) + Data[11] + $895cd7be,22);
|
||||
A:= B + LRot32(A + (D xor (B and (C xor D))) + Data[12] + $6b901122,7);
|
||||
D:= A + LRot32(D + (C xor (A and (B xor C))) + Data[13] + $fd987193,12);
|
||||
C:= D + LRot32(C + (B xor (D and (A xor B))) + Data[14] + $a679438e,17);
|
||||
B:= C + LRot32(B + (A xor (C and (D xor A))) + Data[15] + $49b40821,22);
|
||||
|
||||
A:= B + LRot32(A + (C xor (D and (B xor C))) + Data[ 1] + $f61e2562,5);
|
||||
D:= A + LRot32(D + (B xor (C and (A xor B))) + Data[ 6] + $c040b340,9);
|
||||
C:= D + LRot32(C + (A xor (B and (D xor A))) + Data[11] + $265e5a51,14);
|
||||
B:= C + LRot32(B + (D xor (A and (C xor D))) + Data[ 0] + $e9b6c7aa,20);
|
||||
A:= B + LRot32(A + (C xor (D and (B xor C))) + Data[ 5] + $d62f105d,5);
|
||||
D:= A + LRot32(D + (B xor (C and (A xor B))) + Data[10] + $02441453,9);
|
||||
C:= D + LRot32(C + (A xor (B and (D xor A))) + Data[15] + $d8a1e681,14);
|
||||
B:= C + LRot32(B + (D xor (A and (C xor D))) + Data[ 4] + $e7d3fbc8,20);
|
||||
A:= B + LRot32(A + (C xor (D and (B xor C))) + Data[ 9] + $21e1cde6,5);
|
||||
D:= A + LRot32(D + (B xor (C and (A xor B))) + Data[14] + $c33707d6,9);
|
||||
C:= D + LRot32(C + (A xor (B and (D xor A))) + Data[ 3] + $f4d50d87,14);
|
||||
B:= C + LRot32(B + (D xor (A and (C xor D))) + Data[ 8] + $455a14ed,20);
|
||||
A:= B + LRot32(A + (C xor (D and (B xor C))) + Data[13] + $a9e3e905,5);
|
||||
D:= A + LRot32(D + (B xor (C and (A xor B))) + Data[ 2] + $fcefa3f8,9);
|
||||
C:= D + LRot32(C + (A xor (B and (D xor A))) + Data[ 7] + $676f02d9,14);
|
||||
B:= C + LRot32(B + (D xor (A and (C xor D))) + Data[12] + $8d2a4c8a,20);
|
||||
|
||||
A:= B + LRot32(A + (B xor C xor D) + Data[ 5] + $fffa3942,4);
|
||||
D:= A + LRot32(D + (A xor B xor C) + Data[ 8] + $8771f681,11);
|
||||
C:= D + LRot32(C + (D xor A xor B) + Data[11] + $6d9d6122,16);
|
||||
B:= C + LRot32(B + (C xor D xor A) + Data[14] + $fde5380c,23);
|
||||
A:= B + LRot32(A + (B xor C xor D) + Data[ 1] + $a4beea44,4);
|
||||
D:= A + LRot32(D + (A xor B xor C) + Data[ 4] + $4bdecfa9,11);
|
||||
C:= D + LRot32(C + (D xor A xor B) + Data[ 7] + $f6bb4b60,16);
|
||||
B:= C + LRot32(B + (C xor D xor A) + Data[10] + $bebfbc70,23);
|
||||
A:= B + LRot32(A + (B xor C xor D) + Data[13] + $289b7ec6,4);
|
||||
D:= A + LRot32(D + (A xor B xor C) + Data[ 0] + $eaa127fa,11);
|
||||
C:= D + LRot32(C + (D xor A xor B) + Data[ 3] + $d4ef3085,16);
|
||||
B:= C + LRot32(B + (C xor D xor A) + Data[ 6] + $04881d05,23);
|
||||
A:= B + LRot32(A + (B xor C xor D) + Data[ 9] + $d9d4d039,4);
|
||||
D:= A + LRot32(D + (A xor B xor C) + Data[12] + $e6db99e5,11);
|
||||
C:= D + LRot32(C + (D xor A xor B) + Data[15] + $1fa27cf8,16);
|
||||
B:= C + LRot32(B + (C xor D xor A) + Data[ 2] + $c4ac5665,23);
|
||||
|
||||
A:= B + LRot32(A + (C xor (B or (not D))) + Data[ 0] + $f4292244,6);
|
||||
D:= A + LRot32(D + (B xor (A or (not C))) + Data[ 7] + $432aff97,10);
|
||||
C:= D + LRot32(C + (A xor (D or (not B))) + Data[14] + $ab9423a7,15);
|
||||
B:= C + LRot32(B + (D xor (C or (not A))) + Data[ 5] + $fc93a039,21);
|
||||
A:= B + LRot32(A + (C xor (B or (not D))) + Data[12] + $655b59c3,6);
|
||||
D:= A + LRot32(D + (B xor (A or (not C))) + Data[ 3] + $8f0ccc92,10);
|
||||
C:= D + LRot32(C + (A xor (D or (not B))) + Data[10] + $ffeff47d,15);
|
||||
B:= C + LRot32(B + (D xor (C or (not A))) + Data[ 1] + $85845dd1,21);
|
||||
A:= B + LRot32(A + (C xor (B or (not D))) + Data[ 8] + $6fa87e4f,6);
|
||||
D:= A + LRot32(D + (B xor (A or (not C))) + Data[15] + $fe2ce6e0,10);
|
||||
C:= D + LRot32(C + (A xor (D or (not B))) + Data[ 6] + $a3014314,15);
|
||||
B:= C + LRot32(B + (D xor (C or (not A))) + Data[13] + $4e0811a1,21);
|
||||
A:= B + LRot32(A + (C xor (B or (not D))) + Data[ 4] + $f7537e82,6);
|
||||
D:= A + LRot32(D + (B xor (A or (not C))) + Data[11] + $bd3af235,10);
|
||||
C:= D + LRot32(C + (A xor (D or (not B))) + Data[ 2] + $2ad7d2bb,15);
|
||||
B:= C + LRot32(B + (D xor (C or (not A))) + Data[ 9] + $eb86d391,21);
|
||||
|
||||
Inc(CurrentHash[0],A);
|
||||
Inc(CurrentHash[1],B);
|
||||
Inc(CurrentHash[2],C);
|
||||
Inc(CurrentHash[3],D);
|
||||
Index:= 0;
|
||||
FillChar(HashBuffer,Sizeof(HashBuffer),0);
|
||||
end;
|
||||
|
||||
class function TDCP_md5.GetHashSize: integer;
|
||||
begin
|
||||
Result:= 128;
|
||||
end;
|
||||
|
||||
class function TDCP_md5.GetId: integer;
|
||||
begin
|
||||
Result:= DCP_md5;
|
||||
end;
|
||||
|
||||
class function TDCP_md5.GetAlgorithm: string;
|
||||
begin
|
||||
Result:= 'MD5';
|
||||
end;
|
||||
|
||||
class function TDCP_md5.SelfTest: boolean;
|
||||
const
|
||||
Test1Out: array[0..15] of byte=
|
||||
($90,$01,$50,$98,$3c,$d2,$4f,$b0,$d6,$96,$3f,$7d,$28,$e1,$7f,$72);
|
||||
Test2Out: array[0..15] of byte=
|
||||
($c3,$fc,$d3,$d7,$61,$92,$e4,$00,$7d,$fb,$49,$6c,$ca,$67,$e1,$3b);
|
||||
var
|
||||
TestHash: TDCP_md5;
|
||||
TestOut: array[0..19] of byte;
|
||||
begin
|
||||
dcpFillChar(TestOut, SizeOf(TestOut), 0);
|
||||
TestHash:= TDCP_md5.Create(nil);
|
||||
TestHash.Init;
|
||||
TestHash.UpdateStr('abc');
|
||||
TestHash.Final(TestOut);
|
||||
Result:= CompareMem(@TestOut,@Test1Out,Sizeof(Test1Out));
|
||||
TestHash.Init;
|
||||
TestHash.UpdateStr('abcdefghijklmnopqrstuvwxyz');
|
||||
TestHash.Final(TestOut);
|
||||
Result:= CompareMem(@TestOut,@Test2Out,Sizeof(Test2Out)) and Result;
|
||||
TestHash.Free;
|
||||
end;
|
||||
|
||||
procedure TDCP_md5.Init;
|
||||
begin
|
||||
Burn;
|
||||
CurrentHash[0]:= $67452301;
|
||||
CurrentHash[1]:= $efcdab89;
|
||||
CurrentHash[2]:= $98badcfe;
|
||||
CurrentHash[3]:= $10325476;
|
||||
fInitialized:= true;
|
||||
end;
|
||||
|
||||
procedure TDCP_md5.Burn;
|
||||
begin
|
||||
LenHi:= 0; LenLo:= 0;
|
||||
Index:= 0;
|
||||
FillChar(HashBuffer,Sizeof(HashBuffer),0);
|
||||
FillChar(CurrentHash,Sizeof(CurrentHash),0);
|
||||
fInitialized:= false;
|
||||
end;
|
||||
|
||||
procedure TDCP_md5.Update(const Buffer; Size: longword);
|
||||
var
|
||||
PBuf: ^byte;
|
||||
begin
|
||||
if not fInitialized then
|
||||
raise EDCP_hash.Create('Hash not initialized');
|
||||
|
||||
Inc(LenHi,Size shr 29);
|
||||
Inc(LenLo,Size*8);
|
||||
if LenLo< (Size*8) then
|
||||
Inc(LenHi);
|
||||
|
||||
PBuf:= @Buffer;
|
||||
while Size> 0 do
|
||||
begin
|
||||
if (Sizeof(HashBuffer)-Index)<= DWord(Size) then
|
||||
begin
|
||||
Move(PBuf^,HashBuffer[Index],Sizeof(HashBuffer)-Index);
|
||||
Dec(Size,Sizeof(HashBuffer)-Index);
|
||||
Inc(PBuf,Sizeof(HashBuffer)-Index);
|
||||
Compress;
|
||||
end
|
||||
else
|
||||
begin
|
||||
Move(PBuf^,HashBuffer[Index],Size);
|
||||
Inc(Index,Size);
|
||||
Size:= 0;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TDCP_md5.Final(var Digest);
|
||||
begin
|
||||
if not fInitialized then
|
||||
raise EDCP_hash.Create('Hash not initialized');
|
||||
HashBuffer[Index]:= $80;
|
||||
if Index>= 56 then
|
||||
Compress;
|
||||
PDWord(@HashBuffer[56])^:= LenLo;
|
||||
PDWord(@HashBuffer[60])^:= LenHi;
|
||||
Compress;
|
||||
Move(CurrentHash,Digest,Sizeof(CurrentHash));
|
||||
Burn;
|
||||
end;
|
||||
|
||||
end.
|
||||
321
dcpcrypt/Hashes/dcpripemd128.pas
Normal file
@@ -0,0 +1,321 @@
|
||||
{******************************************************************************}
|
||||
{* DCPcrypt v2.0 written by David Barton (crypto@cityinthesky.co.uk) **********}
|
||||
{******************************************************************************}
|
||||
{* A binary compatible implementation of RipeMD-128 ***************************}
|
||||
{******************************************************************************}
|
||||
{* Copyright (c) 2002 David Barton *}
|
||||
{* Permission is hereby granted, free of charge, to any person obtaining a *}
|
||||
{* copy of this software and associated documentation files (the "Software"), *}
|
||||
{* to deal in the Software without restriction, including without limitation *}
|
||||
{* the rights to use, copy, modify, merge, publish, distribute, sublicense, *}
|
||||
{* and/or sell copies of the Software, and to permit persons to whom the *}
|
||||
{* Software is furnished to do so, subject to the following conditions: *}
|
||||
{* *}
|
||||
{* The above copyright notice and this permission notice shall be included in *}
|
||||
{* all copies or substantial portions of the Software. *}
|
||||
{* *}
|
||||
{* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *}
|
||||
{* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *}
|
||||
{* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *}
|
||||
{* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *}
|
||||
{* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *}
|
||||
{* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *}
|
||||
{* DEALINGS IN THE SOFTWARE. *}
|
||||
{******************************************************************************}
|
||||
unit DCPripemd128;
|
||||
|
||||
{$MODE Delphi}
|
||||
|
||||
interface
|
||||
uses
|
||||
Classes, Sysutils, DCPcrypt2, DCPconst;
|
||||
|
||||
type
|
||||
TDCP_ripemd128= class(TDCP_hash)
|
||||
protected
|
||||
LenHi, LenLo: longword;
|
||||
Index: DWord;
|
||||
CurrentHash: array[0..3] of DWord;
|
||||
HashBuffer: array[0..63] of byte;
|
||||
procedure Compress;
|
||||
public
|
||||
class function GetId: integer; override;
|
||||
class function GetAlgorithm: string; override;
|
||||
class function GetHashSize: integer; override;
|
||||
class function SelfTest: boolean; override;
|
||||
procedure Init; override;
|
||||
procedure Burn; override;
|
||||
procedure Update(const Buffer; Size: longword); override;
|
||||
procedure Final(var Digest); override;
|
||||
end;
|
||||
|
||||
|
||||
|
||||
{******************************************************************************}
|
||||
{******************************************************************************}
|
||||
implementation
|
||||
{$R-}{$Q-}
|
||||
|
||||
procedure TDCP_ripemd128.Compress;
|
||||
var
|
||||
X: array[0..15] of DWord;
|
||||
a, aa, b, bb, c, cc, d, dd, t: dword;
|
||||
begin
|
||||
dcpFillChar(X, SizeOf(X), 0);
|
||||
Move(HashBuffer,X,Sizeof(X));
|
||||
a:= CurrentHash[0]; aa:= a;
|
||||
b:= CurrentHash[1]; bb:= b;
|
||||
c:= CurrentHash[2]; cc:= c;
|
||||
d:= CurrentHash[3]; dd:= d;
|
||||
|
||||
t:= a + (b xor c xor d) + X[ 0]; a:= (t shl 11) or (t shr (32-11));
|
||||
t:= d + (a xor b xor c) + X[ 1]; d:= (t shl 14) or (t shr (32-14));
|
||||
t:= c + (d xor a xor b) + X[ 2]; c:= (t shl 15) or (t shr (32-15));
|
||||
t:= b + (c xor d xor a) + X[ 3]; b:= (t shl 12) or (t shr (32-12));
|
||||
t:= a + (b xor c xor d) + X[ 4]; a:= (t shl 5) or (t shr (32-5));
|
||||
t:= d + (a xor b xor c) + X[ 5]; d:= (t shl 8) or (t shr (32-8));
|
||||
t:= c + (d xor a xor b) + X[ 6]; c:= (t shl 7) or (t shr (32-7));
|
||||
t:= b + (c xor d xor a) + X[ 7]; b:= (t shl 9) or (t shr (32-9));
|
||||
t:= a + (b xor c xor d) + X[ 8]; a:= (t shl 11) or (t shr (32-11));
|
||||
t:= d + (a xor b xor c) + X[ 9]; d:= (t shl 13) or (t shr (32-13));
|
||||
t:= c + (d xor a xor b) + X[10]; c:= (t shl 14) or (t shr (32-14));
|
||||
t:= b + (c xor d xor a) + X[11]; b:= (t shl 15) or (t shr (32-15));
|
||||
t:= a + (b xor c xor d) + X[12]; a:= (t shl 6) or (t shr (32-6));
|
||||
t:= d + (a xor b xor c) + X[13]; d:= (t shl 7) or (t shr (32-7));
|
||||
t:= c + (d xor a xor b) + X[14]; c:= (t shl 9) or (t shr (32-9));
|
||||
t:= b + (c xor d xor a) + X[15]; b:= (t shl 8) or (t shr (32-8));
|
||||
|
||||
t:= a + ((b and c) or (not b and d)) + X[ 7]+$5A827999; a:= (t shl 7) or (t shr (32-7));
|
||||
t:= d + ((a and b) or (not a and c)) + X[ 4]+$5A827999; d:= (t shl 6) or (t shr (32-6));
|
||||
t:= c + ((d and a) or (not d and b)) + X[13]+$5A827999; c:= (t shl 8) or (t shr (32-8));
|
||||
t:= b + ((c and d) or (not c and a)) + X[ 1]+$5A827999; b:= (t shl 13) or (t shr (32-13));
|
||||
t:= a + ((b and c) or (not b and d)) + X[10]+$5A827999; a:= (t shl 11) or (t shr (32-11));
|
||||
t:= d + ((a and b) or (not a and c)) + X[ 6]+$5A827999; d:= (t shl 9) or (t shr (32-9));
|
||||
t:= c + ((d and a) or (not d and b)) + X[15]+$5A827999; c:= (t shl 7) or (t shr (32-7));
|
||||
t:= b + ((c and d) or (not c and a)) + X[ 3]+$5A827999; b:= (t shl 15) or (t shr (32-15));
|
||||
t:= a + ((b and c) or (not b and d)) + X[12]+$5A827999; a:= (t shl 7) or (t shr (32-7));
|
||||
t:= d + ((a and b) or (not a and c)) + X[ 0]+$5A827999; d:= (t shl 12) or (t shr (32-12));
|
||||
t:= c + ((d and a) or (not d and b)) + X[ 9]+$5A827999; c:= (t shl 15) or (t shr (32-15));
|
||||
t:= b + ((c and d) or (not c and a)) + X[ 5]+$5A827999; b:= (t shl 9) or (t shr (32-9));
|
||||
t:= a + ((b and c) or (not b and d)) + X[ 2]+$5A827999; a:= (t shl 11) or (t shr (32-11));
|
||||
t:= d + ((a and b) or (not a and c)) + X[14]+$5A827999; d:= (t shl 7) or (t shr (32-7));
|
||||
t:= c + ((d and a) or (not d and b)) + X[11]+$5A827999; c:= (t shl 13) or (t shr (32-13));
|
||||
t:= b + ((c and d) or (not c and a)) + X[ 8]+$5A827999; b:= (t shl 12) or (t shr (32-12));
|
||||
|
||||
t:= a + ((b or not c) xor d) + X[ 3]+$6ED9EBA1; a:= (t shl 11) or (t shr (32-11));
|
||||
t:= d + ((a or not b) xor c) + X[10]+$6ED9EBA1; d:= (t shl 13) or (t shr (32-13));
|
||||
t:= c + ((d or not a) xor b) + X[14]+$6ED9EBA1; c:= (t shl 6) or (t shr (32-6));
|
||||
t:= b + ((c or not d) xor a) + X[ 4]+$6ED9EBA1; b:= (t shl 7) or (t shr (32-7));
|
||||
t:= a + ((b or not c) xor d) + X[ 9]+$6ED9EBA1; a:= (t shl 14) or (t shr (32-14));
|
||||
t:= d + ((a or not b) xor c) + X[15]+$6ED9EBA1; d:= (t shl 9) or (t shr (32-9));
|
||||
t:= c + ((d or not a) xor b) + X[ 8]+$6ED9EBA1; c:= (t shl 13) or (t shr (32-13));
|
||||
t:= b + ((c or not d) xor a) + X[ 1]+$6ED9EBA1; b:= (t shl 15) or (t shr (32-15));
|
||||
t:= a + ((b or not c) xor d) + X[ 2]+$6ED9EBA1; a:= (t shl 14) or (t shr (32-14));
|
||||
t:= d + ((a or not b) xor c) + X[ 7]+$6ED9EBA1; d:= (t shl 8) or (t shr (32-8));
|
||||
t:= c + ((d or not a) xor b) + X[ 0]+$6ED9EBA1; c:= (t shl 13) or (t shr (32-13));
|
||||
t:= b + ((c or not d) xor a) + X[ 6]+$6ED9EBA1; b:= (t shl 6) or (t shr (32-6));
|
||||
t:= a + ((b or not c) xor d) + X[13]+$6ED9EBA1; a:= (t shl 5) or (t shr (32-5));
|
||||
t:= d + ((a or not b) xor c) + X[11]+$6ED9EBA1; d:= (t shl 12) or (t shr (32-12));
|
||||
t:= c + ((d or not a) xor b) + X[ 5]+$6ED9EBA1; c:= (t shl 7) or (t shr (32-7));
|
||||
t:= b + ((c or not d) xor a) + X[12]+$6ED9EBA1; b:= (t shl 5) or (t shr (32-5));
|
||||
|
||||
t:= a + ((b and d) or (c and not d)) + X[ 1]+$8F1BBCDC; a:= (t shl 11) or (t shr (32-11));
|
||||
t:= d + ((a and c) or (b and not c)) + X[ 9]+$8F1BBCDC; d:= (t shl 12) or (t shr (32-12));
|
||||
t:= c + ((d and b) or (a and not b)) + X[11]+$8F1BBCDC; c:= (t shl 14) or (t shr (32-14));
|
||||
t:= b + ((c and a) or (d and not a)) + X[10]+$8F1BBCDC; b:= (t shl 15) or (t shr (32-15));
|
||||
t:= a + ((b and d) or (c and not d)) + X[ 0]+$8F1BBCDC; a:= (t shl 14) or (t shr (32-14));
|
||||
t:= d + ((a and c) or (b and not c)) + X[ 8]+$8F1BBCDC; d:= (t shl 15) or (t shr (32-15));
|
||||
t:= c + ((d and b) or (a and not b)) + X[12]+$8F1BBCDC; c:= (t shl 9) or (t shr (32-9));
|
||||
t:= b + ((c and a) or (d and not a)) + X[ 4]+$8F1BBCDC; b:= (t shl 8) or (t shr (32-8));
|
||||
t:= a + ((b and d) or (c and not d)) + X[13]+$8F1BBCDC; a:= (t shl 9) or (t shr (32-9));
|
||||
t:= d + ((a and c) or (b and not c)) + X[ 3]+$8F1BBCDC; d:= (t shl 14) or (t shr (32-14));
|
||||
t:= c + ((d and b) or (a and not b)) + X[ 7]+$8F1BBCDC; c:= (t shl 5) or (t shr (32-5));
|
||||
t:= b + ((c and a) or (d and not a)) + X[15]+$8F1BBCDC; b:= (t shl 6) or (t shr (32-6));
|
||||
t:= a + ((b and d) or (c and not d)) + X[14]+$8F1BBCDC; a:= (t shl 8) or (t shr (32-8));
|
||||
t:= d + ((a and c) or (b and not c)) + X[ 5]+$8F1BBCDC; d:= (t shl 6) or (t shr (32-6));
|
||||
t:= c + ((d and b) or (a and not b)) + X[ 6]+$8F1BBCDC; c:= (t shl 5) or (t shr (32-5));
|
||||
t:= b + ((c and a) or (d and not a)) + X[ 2]+$8F1BBCDC; b:= (t shl 12) or (t shr (32-12));
|
||||
|
||||
t:= aa + ((bb and dd) or (cc and not dd)) + X[ 5]+$50A28BE6; aa:= (t shl 8) or (t shr (32-8));
|
||||
t:= dd + ((aa and cc) or (bb and not cc)) + X[14]+$50A28BE6; dd:= (t shl 9) or (t shr (32-9));
|
||||
t:= cc + ((dd and bb) or (aa and not bb)) + X[ 7]+$50A28BE6; cc:= (t shl 9) or (t shr (32-9));
|
||||
t:= bb + ((cc and aa) or (dd and not aa)) + X[ 0]+$50A28BE6; bb:= (t shl 11) or (t shr (32-11));
|
||||
t:= aa + ((bb and dd) or (cc and not dd)) + X[ 9]+$50A28BE6; aa:= (t shl 13) or (t shr (32-13));
|
||||
t:= dd + ((aa and cc) or (bb and not cc)) + X[ 2]+$50A28BE6; dd:= (t shl 15) or (t shr (32-15));
|
||||
t:= cc + ((dd and bb) or (aa and not bb)) + X[11]+$50A28BE6; cc:= (t shl 15) or (t shr (32-15));
|
||||
t:= bb + ((cc and aa) or (dd and not aa)) + X[ 4]+$50A28BE6; bb:= (t shl 5) or (t shr (32-5));
|
||||
t:= aa + ((bb and dd) or (cc and not dd)) + X[13]+$50A28BE6; aa:= (t shl 7) or (t shr (32-7));
|
||||
t:= dd + ((aa and cc) or (bb and not cc)) + X[ 6]+$50A28BE6; dd:= (t shl 7) or (t shr (32-7));
|
||||
t:= cc + ((dd and bb) or (aa and not bb)) + X[15]+$50A28BE6; cc:= (t shl 8) or (t shr (32-8));
|
||||
t:= bb + ((cc and aa) or (dd and not aa)) + X[ 8]+$50A28BE6; bb:= (t shl 11) or (t shr (32-11));
|
||||
t:= aa + ((bb and dd) or (cc and not dd)) + X[ 1]+$50A28BE6; aa:= (t shl 14) or (t shr (32-14));
|
||||
t:= dd + ((aa and cc) or (bb and not cc)) + X[10]+$50A28BE6; dd:= (t shl 14) or (t shr (32-14));
|
||||
t:= cc + ((dd and bb) or (aa and not bb)) + X[ 3]+$50A28BE6; cc:= (t shl 12) or (t shr (32-12));
|
||||
t:= bb + ((cc and aa) or (dd and not aa)) + X[12]+$50A28BE6; bb:= (t shl 6) or (t shr (32-6));
|
||||
|
||||
t:= aa + ((bb or not cc) xor dd) + X[ 6]+$5C4DD124; aa:= (t shl 9) or (t shr (32-9));
|
||||
t:= dd + ((aa or not bb) xor cc) + X[11]+$5C4DD124; dd:= (t shl 13) or (t shr (32-13));
|
||||
t:= cc + ((dd or not aa) xor bb) + X[ 3]+$5C4DD124; cc:= (t shl 15) or (t shr (32-15));
|
||||
t:= bb + ((cc or not dd) xor aa) + X[ 7]+$5C4DD124; bb:= (t shl 7) or (t shr (32-7));
|
||||
t:= aa + ((bb or not cc) xor dd) + X[ 0]+$5C4DD124; aa:= (t shl 12) or (t shr (32-12));
|
||||
t:= dd + ((aa or not bb) xor cc) + X[13]+$5C4DD124; dd:= (t shl 8) or (t shr (32-8));
|
||||
t:= cc + ((dd or not aa) xor bb) + X[ 5]+$5C4DD124; cc:= (t shl 9) or (t shr (32-9));
|
||||
t:= bb + ((cc or not dd) xor aa) + X[10]+$5C4DD124; bb:= (t shl 11) or (t shr (32-11));
|
||||
t:= aa + ((bb or not cc) xor dd) + X[14]+$5C4DD124; aa:= (t shl 7) or (t shr (32-7));
|
||||
t:= dd + ((aa or not bb) xor cc) + X[15]+$5C4DD124; dd:= (t shl 7) or (t shr (32-7));
|
||||
t:= cc + ((dd or not aa) xor bb) + X[ 8]+$5C4DD124; cc:= (t shl 12) or (t shr (32-12));
|
||||
t:= bb + ((cc or not dd) xor aa) + X[12]+$5C4DD124; bb:= (t shl 7) or (t shr (32-7));
|
||||
t:= aa + ((bb or not cc) xor dd) + X[ 4]+$5C4DD124; aa:= (t shl 6) or (t shr (32-6));
|
||||
t:= dd + ((aa or not bb) xor cc) + X[ 9]+$5C4DD124; dd:= (t shl 15) or (t shr (32-15));
|
||||
t:= cc + ((dd or not aa) xor bb) + X[ 1]+$5C4DD124; cc:= (t shl 13) or (t shr (32-13));
|
||||
t:= bb + ((cc or not dd) xor aa) + X[ 2]+$5C4DD124; bb:= (t shl 11) or (t shr (32-11));
|
||||
|
||||
t:= aa + ((bb and cc) or (not bb and dd)) + X[15]+$6D703EF3; aa:= (t shl 9) or (t shr (32-9));
|
||||
t:= dd + ((aa and bb) or (not aa and cc)) + X[ 5]+$6D703EF3; dd:= (t shl 7) or (t shr (32-7));
|
||||
t:= cc + ((dd and aa) or (not dd and bb)) + X[ 1]+$6D703EF3; cc:= (t shl 15) or (t shr (32-15));
|
||||
t:= bb + ((cc and dd) or (not cc and aa)) + X[ 3]+$6D703EF3; bb:= (t shl 11) or (t shr (32-11));
|
||||
t:= aa + ((bb and cc) or (not bb and dd)) + X[ 7]+$6D703EF3; aa:= (t shl 8) or (t shr (32-8));
|
||||
t:= dd + ((aa and bb) or (not aa and cc)) + X[14]+$6D703EF3; dd:= (t shl 6) or (t shr (32-6));
|
||||
t:= cc + ((dd and aa) or (not dd and bb)) + X[ 6]+$6D703EF3; cc:= (t shl 6) or (t shr (32-6));
|
||||
t:= bb + ((cc and dd) or (not cc and aa)) + X[ 9]+$6D703EF3; bb:= (t shl 14) or (t shr (32-14));
|
||||
t:= aa + ((bb and cc) or (not bb and dd)) + X[11]+$6D703EF3; aa:= (t shl 12) or (t shr (32-12));
|
||||
t:= dd + ((aa and bb) or (not aa and cc)) + X[ 8]+$6D703EF3; dd:= (t shl 13) or (t shr (32-13));
|
||||
t:= cc + ((dd and aa) or (not dd and bb)) + X[12]+$6D703EF3; cc:= (t shl 5) or (t shr (32-5));
|
||||
t:= bb + ((cc and dd) or (not cc and aa)) + X[ 2]+$6D703EF3; bb:= (t shl 14) or (t shr (32-14));
|
||||
t:= aa + ((bb and cc) or (not bb and dd)) + X[10]+$6D703EF3; aa:= (t shl 13) or (t shr (32-13));
|
||||
t:= dd + ((aa and bb) or (not aa and cc)) + X[ 0]+$6D703EF3; dd:= (t shl 13) or (t shr (32-13));
|
||||
t:= cc + ((dd and aa) or (not dd and bb)) + X[ 4]+$6D703EF3; cc:= (t shl 7) or (t shr (32-7));
|
||||
t:= bb + ((cc and dd) or (not cc and aa)) + X[13]+$6D703EF3; bb:= (t shl 5) or (t shr (32-5));
|
||||
|
||||
t:= aa + (bb xor cc xor dd) + X[ 8]; aa:= (t shl 15) or (t shr (32-15));
|
||||
t:= dd + (aa xor bb xor cc) + X[ 6]; dd:= (t shl 5) or (t shr (32-5));
|
||||
t:= cc + (dd xor aa xor bb) + X[ 4]; cc:= (t shl 8) or (t shr (32-8));
|
||||
t:= bb + (cc xor dd xor aa) + X[ 1]; bb:= (t shl 11) or (t shr (32-11));
|
||||
t:= aa + (bb xor cc xor dd) + X[ 3]; aa:= (t shl 14) or (t shr (32-14));
|
||||
t:= dd + (aa xor bb xor cc) + X[11]; dd:= (t shl 14) or (t shr (32-14));
|
||||
t:= cc + (dd xor aa xor bb) + X[15]; cc:= (t shl 6) or (t shr (32-6));
|
||||
t:= bb + (cc xor dd xor aa) + X[ 0]; bb:= (t shl 14) or (t shr (32-14));
|
||||
t:= aa + (bb xor cc xor dd) + X[ 5]; aa:= (t shl 6) or (t shr (32-6));
|
||||
t:= dd + (aa xor bb xor cc) + X[12]; dd:= (t shl 9) or (t shr (32-9));
|
||||
t:= cc + (dd xor aa xor bb) + X[ 2]; cc:= (t shl 12) or (t shr (32-12));
|
||||
t:= bb + (cc xor dd xor aa) + X[13]; bb:= (t shl 9) or (t shr (32-9));
|
||||
t:= aa + (bb xor cc xor dd) + X[ 9]; aa:= (t shl 12) or (t shr (32-12));
|
||||
t:= dd + (aa xor bb xor cc) + X[ 7]; dd:= (t shl 5) or (t shr (32-5));
|
||||
t:= cc + (dd xor aa xor bb) + X[10]; cc:= (t shl 15) or (t shr (32-15));
|
||||
t:= bb + (cc xor dd xor aa) + X[14]; bb:= (t shl 8) or (t shr (32-8));
|
||||
|
||||
Inc(dd,c + CurrentHash[1]);
|
||||
CurrentHash[1]:= CurrentHash[2] + d + aa;
|
||||
CurrentHash[2]:= CurrentHash[3] + a + bb;
|
||||
CurrentHash[3]:= CurrentHash[0] + b + cc;
|
||||
CurrentHash[0]:= dd;
|
||||
|
||||
FillChar(X,Sizeof(X),0);
|
||||
Index:= 0;
|
||||
FillChar(HashBuffer,Sizeof(HashBuffer),0);
|
||||
end;
|
||||
|
||||
class function TDCP_ripemd128.GetHashSize: integer;
|
||||
begin
|
||||
Result:= 128;
|
||||
end;
|
||||
|
||||
class function TDCP_ripemd128.GetId: integer;
|
||||
begin
|
||||
Result:= DCP_ripemd128;
|
||||
end;
|
||||
|
||||
class function TDCP_ripemd128.GetAlgorithm: string;
|
||||
begin
|
||||
Result:= 'RipeMD-128';
|
||||
end;
|
||||
|
||||
class function TDCP_ripemd128.SelfTest: boolean;
|
||||
const
|
||||
Test1Out: array[0..15] of byte=
|
||||
($86,$be,$7a,$fa,$33,$9d,$0f,$c7,$cf,$c7,$85,$e7,$2f,$57,$8d,$33);
|
||||
Test2Out: array[0..15] of byte=
|
||||
($fd,$2a,$a6,$07,$f7,$1d,$c8,$f5,$10,$71,$49,$22,$b3,$71,$83,$4e);
|
||||
var
|
||||
TestHash: TDCP_ripemd128;
|
||||
TestOut: array[0..15] of byte;
|
||||
begin
|
||||
dcpFillChar(TestOut, SizeOf(TestOut), 0);
|
||||
TestHash:= TDCP_ripemd128.Create(nil);
|
||||
TestHash.Init;
|
||||
TestHash.UpdateStr('a');
|
||||
TestHash.Final(TestOut);
|
||||
Result:= CompareMem(@TestOut,@Test1Out,Sizeof(Test1Out));
|
||||
TestHash.Init;
|
||||
TestHash.UpdateStr('abcdefghijklmnopqrstuvwxyz');
|
||||
TestHash.Final(TestOut);
|
||||
Result:= CompareMem(@TestOut,@Test2Out,Sizeof(Test2Out)) and Result;
|
||||
TestHash.Free;
|
||||
end;
|
||||
|
||||
procedure TDCP_ripemd128.Init;
|
||||
begin
|
||||
Burn;
|
||||
CurrentHash[0]:= $67452301;
|
||||
CurrentHash[1]:= $efcdab89;
|
||||
CurrentHash[2]:= $98badcfe;
|
||||
CurrentHash[3]:= $10325476;
|
||||
fInitialized:= true;
|
||||
end;
|
||||
|
||||
procedure TDCP_ripemd128.Burn;
|
||||
begin
|
||||
LenHi:= 0; LenLo:= 0;
|
||||
Index:= 0;
|
||||
FillChar(HashBuffer,Sizeof(HashBuffer),0);
|
||||
FillChar(CurrentHash,Sizeof(CurrentHash),0);
|
||||
fInitialized:= false;
|
||||
end;
|
||||
|
||||
procedure TDCP_ripemd128.Update(const Buffer; Size: longword);
|
||||
var
|
||||
PBuf: ^byte;
|
||||
begin
|
||||
if not fInitialized then
|
||||
raise EDCP_hash.Create('Hash not initialized');
|
||||
|
||||
Inc(LenHi,Size shr 29);
|
||||
Inc(LenLo,Size*8);
|
||||
if LenLo< (Size*8) then
|
||||
Inc(LenHi);
|
||||
|
||||
PBuf:= @Buffer;
|
||||
while Size> 0 do
|
||||
begin
|
||||
if (Sizeof(HashBuffer)-Index)<= DWord(Size) then
|
||||
begin
|
||||
Move(PBuf^,HashBuffer[Index],Sizeof(HashBuffer)-Index);
|
||||
Dec(Size,Sizeof(HashBuffer)-Index);
|
||||
Inc(PBuf,Sizeof(HashBuffer)-Index);
|
||||
Compress;
|
||||
end
|
||||
else
|
||||
begin
|
||||
Move(PBuf^,HashBuffer[Index],Size);
|
||||
Inc(Index,Size);
|
||||
Size:= 0;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TDCP_ripemd128.Final(var Digest);
|
||||
begin
|
||||
if not fInitialized then
|
||||
raise EDCP_hash.Create('Hash not initialized');
|
||||
HashBuffer[Index]:= $80;
|
||||
if Index>= 56 then
|
||||
Compress;
|
||||
PDWord(@HashBuffer[56])^:= LenLo;
|
||||
PDWord(@HashBuffer[60])^:= LenHi;
|
||||
Compress;
|
||||
Move(CurrentHash,Digest,Sizeof(CurrentHash));
|
||||
Burn;
|
||||
end;
|
||||
|
||||
|
||||
end.
|
||||
682
dcpcrypt/Hashes/dcpripemd160.pas
Normal file
@@ -0,0 +1,682 @@
|
||||
{******************************************************************************}
|
||||
{* DCPcrypt v2.0 written by David Barton (crypto@cityinthesky.co.uk) **********}
|
||||
{******************************************************************************}
|
||||
{* A binary compatible implementation of RipeMD-160 ***************************}
|
||||
{******************************************************************************}
|
||||
{* Copyright (c) 1999-2002 David Barton *}
|
||||
{* Permission is hereby granted, free of charge, to any person obtaining a *}
|
||||
{* copy of this software and associated documentation files (the "Software"), *}
|
||||
{* to deal in the Software without restriction, including without limitation *}
|
||||
{* the rights to use, copy, modify, merge, publish, distribute, sublicense, *}
|
||||
{* and/or sell copies of the Software, and to permit persons to whom the *}
|
||||
{* Software is furnished to do so, subject to the following conditions: *}
|
||||
{* *}
|
||||
{* The above copyright notice and this permission notice shall be included in *}
|
||||
{* all copies or substantial portions of the Software. *}
|
||||
{* *}
|
||||
{* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *}
|
||||
{* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *}
|
||||
{* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *}
|
||||
{* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *}
|
||||
{* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *}
|
||||
{* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *}
|
||||
{* DEALINGS IN THE SOFTWARE. *}
|
||||
{******************************************************************************}
|
||||
unit DCPripemd160;
|
||||
|
||||
{$MODE Delphi}
|
||||
|
||||
interface
|
||||
uses
|
||||
Classes, Sysutils, DCPcrypt2, DCPconst;
|
||||
|
||||
type
|
||||
TDCP_ripemd160= class(TDCP_hash)
|
||||
protected
|
||||
LenHi, LenLo: longword;
|
||||
Index: DWord;
|
||||
CurrentHash: array[0..4] of DWord;
|
||||
HashBuffer: array[0..63] of byte;
|
||||
procedure Compress;
|
||||
public
|
||||
class function GetId: integer; override;
|
||||
class function GetAlgorithm: string; override;
|
||||
class function GetHashSize: integer; override;
|
||||
class function SelfTest: boolean; override;
|
||||
procedure Init; override;
|
||||
procedure Burn; override;
|
||||
procedure Update(const Buffer; Size: longword); override;
|
||||
procedure Final(var Digest); override;
|
||||
end;
|
||||
|
||||
|
||||
|
||||
{******************************************************************************}
|
||||
{******************************************************************************}
|
||||
implementation
|
||||
{$R-}{$Q-}
|
||||
|
||||
procedure TDCP_ripemd160.Compress;
|
||||
var
|
||||
aa, bb, cc, dd, ee, aaa, bbb, ccc, ddd, eee: DWord;
|
||||
X: array[0..15] of DWord;
|
||||
begin
|
||||
dcpFillChar(X, SizeOf(X), 0);
|
||||
Move(HashBuffer,X,Sizeof(X));
|
||||
aa:= CurrentHash[0];
|
||||
aaa:= CurrentHash[0];
|
||||
bb:= CurrentHash[1];
|
||||
bbb:= CurrentHash[1];
|
||||
cc:= CurrentHash[2];
|
||||
ccc:= CurrentHash[2];
|
||||
dd:= CurrentHash[3];
|
||||
ddd:= CurrentHash[3];
|
||||
ee:= CurrentHash[4];
|
||||
eee:= CurrentHash[4];
|
||||
|
||||
aa:= aa + (bb xor cc xor dd) + X[ 0];
|
||||
aa:= ((aa shl 11) or (aa shr (32-11))) + ee;
|
||||
cc:= ((cc shl 10) or (cc shr (32-10)));
|
||||
ee:= ee + (aa xor bb xor cc) + X[ 1];
|
||||
ee:= ((ee shl 14) or (ee shr (32-14))) + dd;
|
||||
bb:= ((bb shl 10) or (bb shr (32-10)));
|
||||
dd:= dd + (ee xor aa xor bb) + X[ 2];
|
||||
dd:= ((dd shl 15) or (dd shr (32-15))) + cc;
|
||||
aa:= ((aa shl 10) or (aa shr (32-10)));
|
||||
cc:= cc + (dd xor ee xor aa) + X[ 3];
|
||||
cc:= ((cc shl 12) or (cc shr (32-12))) + bb;
|
||||
ee:= ((ee shl 10) or (ee shr (32-10)));
|
||||
bb:= bb + (cc xor dd xor ee) + X[ 4];
|
||||
bb:= ((bb shl 5) or (bb shr (32-5))) + aa;
|
||||
dd:= ((dd shl 10) or (dd shr (32-10)));
|
||||
aa:= aa + (bb xor cc xor dd) + X[ 5];
|
||||
aa:= ((aa shl 8) or (aa shr (32-8))) + ee;
|
||||
cc:= ((cc shl 10) or (cc shr (32-10)));
|
||||
ee:= ee + (aa xor bb xor cc) + X[ 6];
|
||||
ee:= ((ee shl 7) or (ee shr (32-7))) + dd;
|
||||
bb:= ((bb shl 10) or (bb shr (32-10)));
|
||||
dd:= dd + (ee xor aa xor bb) + X[ 7];
|
||||
dd:= ((dd shl 9) or (dd shr (32-9))) + cc;
|
||||
aa:= ((aa shl 10) or (aa shr (32-10)));
|
||||
cc:= cc + (dd xor ee xor aa) + X[ 8];
|
||||
cc:= ((cc shl 11) or (cc shr (32-11))) + bb;
|
||||
ee:= ((ee shl 10) or (ee shr (32-10)));
|
||||
bb:= bb + (cc xor dd xor ee) + X[ 9];
|
||||
bb:= ((bb shl 13) or (bb shr (32-13))) + aa;
|
||||
dd:= ((dd shl 10) or (dd shr (32-10)));
|
||||
aa:= aa + (bb xor cc xor dd) + X[10];
|
||||
aa:= ((aa shl 14) or (aa shr (32-14))) + ee;
|
||||
cc:= ((cc shl 10) or (cc shr (32-10)));
|
||||
ee:= ee + (aa xor bb xor cc) + X[11];
|
||||
ee:= ((ee shl 15) or (ee shr (32-15))) + dd;
|
||||
bb:= ((bb shl 10) or (bb shr (32-10)));
|
||||
dd:= dd + (ee xor aa xor bb) + X[12];
|
||||
dd:= ((dd shl 6) or (dd shr (32-6))) + cc;
|
||||
aa:= ((aa shl 10) or (aa shr (32-10)));
|
||||
cc:= cc + (dd xor ee xor aa) + X[13];
|
||||
cc:= ((cc shl 7) or (cc shr (32-7))) + bb;
|
||||
ee:= ((ee shl 10) or (ee shr (32-10)));
|
||||
bb:= bb + (cc xor dd xor ee) + X[14];
|
||||
bb:= ((bb shl 9) or (bb shr (32-9))) + aa;
|
||||
dd:= ((dd shl 10) or (dd shr (32-10)));
|
||||
aa:= aa + (bb xor cc xor dd) + X[15];
|
||||
aa:= ((aa shl 8) or (aa shr (32-8))) + ee;
|
||||
cc:= ((cc shl 10) or (cc shr (32-10)));
|
||||
|
||||
ee:= ee + ((aa and bb) or ((not aa) and cc)) + X[ 7] + $5a827999;
|
||||
ee:= ((ee shl 7) or (ee shr (32-7))) + dd;
|
||||
bb:= ((bb shl 10) or (bb shr (32-10)));
|
||||
dd:= dd + ((ee and aa) or ((not ee) and bb)) + X[ 4] + $5a827999;
|
||||
dd:= ((dd shl 6) or (dd shr (32-6))) + cc;
|
||||
aa:= ((aa shl 10) or (aa shr (32-10)));
|
||||
cc:= cc + ((dd and ee) or ((not dd) and aa)) + X[13] + $5a827999;
|
||||
cc:= ((cc shl 8) or (cc shr (32-8))) + bb;
|
||||
ee:= ((ee shl 10) or (ee shr (32-10)));
|
||||
bb:= bb + ((cc and dd) or ((not cc) and ee)) + X[ 1] + $5a827999;
|
||||
bb:= ((bb shl 13) or (bb shr (32-13))) + aa;
|
||||
dd:= ((dd shl 10) or (dd shr (32-10)));
|
||||
aa:= aa + ((bb and cc) or ((not bb) and dd)) + X[10] + $5a827999;
|
||||
aa:= ((aa shl 11) or (aa shr (32-11))) + ee;
|
||||
cc:= ((cc shl 10) or (cc shr (32-10)));
|
||||
ee:= ee + ((aa and bb) or ((not aa) and cc)) + X[ 6] + $5a827999;
|
||||
ee:= ((ee shl 9) or (ee shr (32-9))) + dd;
|
||||
bb:= ((bb shl 10) or (bb shr (32-10)));
|
||||
dd:= dd + ((ee and aa) or ((not ee) and bb)) + X[15] + $5a827999;
|
||||
dd:= ((dd shl 7) or (dd shr (32-7))) + cc;
|
||||
aa:= ((aa shl 10) or (aa shr (32-10)));
|
||||
cc:= cc + ((dd and ee) or ((not dd) and aa)) + X[ 3] + $5a827999;
|
||||
cc:= ((cc shl 15) or (cc shr (32-15))) + bb;
|
||||
ee:= ((ee shl 10) or (ee shr (32-10)));
|
||||
bb:= bb + ((cc and dd) or ((not cc) and ee)) + X[12] + $5a827999;
|
||||
bb:= ((bb shl 7) or (bb shr (32-7))) + aa;
|
||||
dd:= ((dd shl 10) or (dd shr (32-10)));
|
||||
aa:= aa + ((bb and cc) or ((not bb) and dd)) + X[ 0] + $5a827999;
|
||||
aa:= ((aa shl 12) or (aa shr (32-12))) + ee;
|
||||
cc:= ((cc shl 10) or (cc shr (32-10)));
|
||||
ee:= ee + ((aa and bb) or ((not aa) and cc)) + X[ 9] + $5a827999;
|
||||
ee:= ((ee shl 15) or (ee shr (32-15))) + dd;
|
||||
bb:= ((bb shl 10) or (bb shr (32-10)));
|
||||
dd:= dd + ((ee and aa) or ((not ee) and bb)) + X[ 5] + $5a827999;
|
||||
dd:= ((dd shl 9) or (dd shr (32-9))) + cc;
|
||||
aa:= ((aa shl 10) or (aa shr (32-10)));
|
||||
cc:= cc + ((dd and ee) or ((not dd) and aa)) + X[ 2] + $5a827999;
|
||||
cc:= ((cc shl 11) or (cc shr (32-11))) + bb;
|
||||
ee:= ((ee shl 10) or (ee shr (32-10)));
|
||||
bb:= bb + ((cc and dd) or ((not cc) and ee)) + X[14] + $5a827999;
|
||||
bb:= ((bb shl 7) or (bb shr (32-7))) + aa;
|
||||
dd:= ((dd shl 10) or (dd shr (32-10)));
|
||||
aa:= aa + ((bb and cc) or ((not bb) and dd)) + X[11] + $5a827999;
|
||||
aa:= ((aa shl 13) or (aa shr (32-13))) + ee;
|
||||
cc:= ((cc shl 10) or (cc shr (32-10)));
|
||||
ee:= ee + ((aa and bb) or ((not aa) and cc)) + X[ 8] + $5a827999;
|
||||
ee:= ((ee shl 12) or (ee shr (32-12))) + dd;
|
||||
bb:= ((bb shl 10) or (bb shr (32-10)));
|
||||
|
||||
dd:= dd + ((ee or (not aa)) xor bb) + X[ 3] + $6ed9eba1;
|
||||
dd:= ((dd shl 11) or (dd shr (32-11))) + cc;
|
||||
aa:= ((aa shl 10) or (aa shr (32-10)));
|
||||
cc:= cc + ((dd or (not ee)) xor aa) + X[10] + $6ed9eba1;
|
||||
cc:= ((cc shl 13) or (cc shr (32-13))) + bb;
|
||||
ee:= ((ee shl 10) or (ee shr (32-10)));
|
||||
bb:= bb + ((cc or (not dd)) xor ee) + X[14] + $6ed9eba1;
|
||||
bb:= ((bb shl 6) or (bb shr (32-6))) + aa;
|
||||
dd:= ((dd shl 10) or (dd shr (32-10)));
|
||||
aa:= aa + ((bb or (not cc)) xor dd) + X[ 4] + $6ed9eba1;
|
||||
aa:= ((aa shl 7) or (aa shr (32-7))) + ee;
|
||||
cc:= ((cc shl 10) or (cc shr (32-10)));
|
||||
ee:= ee + ((aa or (not bb)) xor cc) + X[ 9] + $6ed9eba1;
|
||||
ee:= ((ee shl 14) or (ee shr (32-14))) + dd;
|
||||
bb:= ((bb shl 10) or (bb shr (32-10)));
|
||||
dd:= dd + ((ee or (not aa)) xor bb) + X[15] + $6ed9eba1;
|
||||
dd:= ((dd shl 9) or (dd shr (32-9))) + cc;
|
||||
aa:= ((aa shl 10) or (aa shr (32-10)));
|
||||
cc:= cc + ((dd or (not ee)) xor aa) + X[ 8] + $6ed9eba1;
|
||||
cc:= ((cc shl 13) or (cc shr (32-13))) + bb;
|
||||
ee:= ((ee shl 10) or (ee shr (32-10)));
|
||||
bb:= bb + ((cc or (not dd)) xor ee) + X[ 1] + $6ed9eba1;
|
||||
bb:= ((bb shl 15) or (bb shr (32-15))) + aa;
|
||||
dd:= ((dd shl 10) or (dd shr (32-10)));
|
||||
aa:= aa + ((bb or (not cc)) xor dd) + X[ 2] + $6ed9eba1;
|
||||
aa:= ((aa shl 14) or (aa shr (32-14))) + ee;
|
||||
cc:= ((cc shl 10) or (cc shr (32-10)));
|
||||
ee:= ee + ((aa or (not bb)) xor cc) + X[ 7] + $6ed9eba1;
|
||||
ee:= ((ee shl 8) or (ee shr (32-8))) + dd;
|
||||
bb:= ((bb shl 10) or (bb shr (32-10)));
|
||||
dd:= dd + ((ee or (not aa)) xor bb) + X[ 0] + $6ed9eba1;
|
||||
dd:= ((dd shl 13) or (dd shr (32-13))) + cc;
|
||||
aa:= ((aa shl 10) or (aa shr (32-10)));
|
||||
cc:= cc + ((dd or (not ee)) xor aa) + X[ 6] + $6ed9eba1;
|
||||
cc:= ((cc shl 6) or (cc shr (32-6))) + bb;
|
||||
ee:= ((ee shl 10) or (ee shr (32-10)));
|
||||
bb:= bb + ((cc or (not dd)) xor ee) + X[13] + $6ed9eba1;
|
||||
bb:= ((bb shl 5) or (bb shr (32-5))) + aa;
|
||||
dd:= ((dd shl 10) or (dd shr (32-10)));
|
||||
aa:= aa + ((bb or (not cc)) xor dd) + X[11] + $6ed9eba1;
|
||||
aa:= ((aa shl 12) or (aa shr (32-12))) + ee;
|
||||
cc:= ((cc shl 10) or (cc shr (32-10)));
|
||||
ee:= ee + ((aa or (not bb)) xor cc) + X[ 5] + $6ed9eba1;
|
||||
ee:= ((ee shl 7) or (ee shr (32-7))) + dd;
|
||||
bb:= ((bb shl 10) or (bb shr (32-10)));
|
||||
dd:= dd + ((ee or (not aa)) xor bb) + X[12] + $6ed9eba1;
|
||||
dd:= ((dd shl 5) or (dd shr (32-5))) + cc;
|
||||
aa:= ((aa shl 10) or (aa shr (32-10)));
|
||||
|
||||
cc:= cc + ((dd and aa) or (ee and (not aa))) + X[ 1] + $8f1bbcdc;
|
||||
cc:= ((cc shl 11) or (cc shr (32-11))) + bb;
|
||||
ee:= ((ee shl 10) or (ee shr (32-10)));
|
||||
bb:= bb + ((cc and ee) or (dd and (not ee))) + X[ 9] + $8f1bbcdc;
|
||||
bb:= ((bb shl 12) or (bb shr (32-12))) + aa;
|
||||
dd:= ((dd shl 10) or (dd shr (32-10)));
|
||||
aa:= aa + ((bb and dd) or (cc and (not dd))) + X[11] + $8f1bbcdc;
|
||||
aa:= ((aa shl 14) or (aa shr (32-14))) + ee;
|
||||
cc:= ((cc shl 10) or (cc shr (32-10)));
|
||||
ee:= ee + ((aa and cc) or (bb and (not cc))) + X[10] + $8f1bbcdc;
|
||||
ee:= ((ee shl 15) or (ee shr (32-15))) + dd;
|
||||
bb:= ((bb shl 10) or (bb shr (32-10)));
|
||||
dd:= dd + ((ee and bb) or (aa and (not bb))) + X[ 0] + $8f1bbcdc;
|
||||
dd:= ((dd shl 14) or (dd shr (32-14))) + cc;
|
||||
aa:= ((aa shl 10) or (aa shr (32-10)));
|
||||
cc:= cc + ((dd and aa) or (ee and (not aa))) + X[ 8] + $8f1bbcdc;
|
||||
cc:= ((cc shl 15) or (cc shr (32-15))) + bb;
|
||||
ee:= ((ee shl 10) or (ee shr (32-10)));
|
||||
bb:= bb + ((cc and ee) or (dd and (not ee))) + X[12] + $8f1bbcdc;
|
||||
bb:= ((bb shl 9) or (bb shr (32-9))) + aa;
|
||||
dd:= ((dd shl 10) or (dd shr (32-10)));
|
||||
aa:= aa + ((bb and dd) or (cc and (not dd))) + X[ 4] + $8f1bbcdc;
|
||||
aa:= ((aa shl 8) or (aa shr (32-8))) + ee;
|
||||
cc:= ((cc shl 10) or (cc shr (32-10)));
|
||||
ee:= ee + ((aa and cc) or (bb and (not cc))) + X[13] + $8f1bbcdc;
|
||||
ee:= ((ee shl 9) or (ee shr (32-9))) + dd;
|
||||
bb:= ((bb shl 10) or (bb shr (32-10)));
|
||||
dd:= dd + ((ee and bb) or (aa and (not bb))) + X[ 3] + $8f1bbcdc;
|
||||
dd:= ((dd shl 14) or (dd shr (32-14))) + cc;
|
||||
aa:= ((aa shl 10) or (aa shr (32-10)));
|
||||
cc:= cc + ((dd and aa) or (ee and (not aa))) + X[ 7] + $8f1bbcdc;
|
||||
cc:= ((cc shl 5) or (cc shr (32-5))) + bb;
|
||||
ee:= ((ee shl 10) or (ee shr (32-10)));
|
||||
bb:= bb + ((cc and ee) or (dd and (not ee))) + X[15] + $8f1bbcdc;
|
||||
bb:= ((bb shl 6) or (bb shr (32-6))) + aa;
|
||||
dd:= ((dd shl 10) or (dd shr (32-10)));
|
||||
aa:= aa + ((bb and dd) or (cc and (not dd))) + X[14] + $8f1bbcdc;
|
||||
aa:= ((aa shl 8) or (aa shr (32-8))) + ee;
|
||||
cc:= ((cc shl 10) or (cc shr (32-10)));
|
||||
ee:= ee + ((aa and cc) or (bb and (not cc))) + X[ 5] + $8f1bbcdc;
|
||||
ee:= ((ee shl 6) or (ee shr (32-6))) + dd;
|
||||
bb:= ((bb shl 10) or (bb shr (32-10)));
|
||||
dd:= dd + ((ee and bb) or (aa and (not bb))) + X[ 6] + $8f1bbcdc;
|
||||
dd:= ((dd shl 5) or (dd shr (32-5))) + cc;
|
||||
aa:= ((aa shl 10) or (aa shr (32-10)));
|
||||
cc:= cc + ((dd and aa) or (ee and (not aa))) + X[ 2] + $8f1bbcdc;
|
||||
cc:= ((cc shl 12) or (cc shr (32-12))) + bb;
|
||||
ee:= ((ee shl 10) or (ee shr (32-10)));
|
||||
|
||||
bb:= bb + (cc xor (dd or (not ee))) + X[ 4] + $a953fd4e;
|
||||
bb:= ((bb shl 9) or (bb shr (32-9))) + aa;
|
||||
dd:= ((dd shl 10) or (dd shr (32-10)));
|
||||
aa:= aa + (bb xor (cc or (not dd))) + X[ 0] + $a953fd4e;
|
||||
aa:= ((aa shl 15) or (aa shr (32-15))) + ee;
|
||||
cc:= ((cc shl 10) or (cc shr (32-10)));
|
||||
ee:= ee + (aa xor (bb or (not cc))) + X[ 5] + $a953fd4e;
|
||||
ee:= ((ee shl 5) or (ee shr (32-5))) + dd;
|
||||
bb:= ((bb shl 10) or (bb shr (32-10)));
|
||||
dd:= dd + (ee xor (aa or (not bb))) + X[ 9] + $a953fd4e;
|
||||
dd:= ((dd shl 11) or (dd shr (32-11))) + cc;
|
||||
aa:= ((aa shl 10) or (aa shr (32-10)));
|
||||
cc:= cc + (dd xor (ee or (not aa))) + X[ 7] + $a953fd4e;
|
||||
cc:= ((cc shl 6) or (cc shr (32-6))) + bb;
|
||||
ee:= ((ee shl 10) or (ee shr (32-10)));
|
||||
bb:= bb + (cc xor (dd or (not ee))) + X[12] + $a953fd4e;
|
||||
bb:= ((bb shl 8) or (bb shr (32-8))) + aa;
|
||||
dd:= ((dd shl 10) or (dd shr (32-10)));
|
||||
aa:= aa + (bb xor (cc or (not dd))) + X[ 2] + $a953fd4e;
|
||||
aa:= ((aa shl 13) or (aa shr (32-13))) + ee;
|
||||
cc:= ((cc shl 10) or (cc shr (32-10)));
|
||||
ee:= ee + (aa xor (bb or (not cc))) + X[10] + $a953fd4e;
|
||||
ee:= ((ee shl 12) or (ee shr (32-12))) + dd;
|
||||
bb:= ((bb shl 10) or (bb shr (32-10)));
|
||||
dd:= dd + (ee xor (aa or (not bb))) + X[14] + $a953fd4e;
|
||||
dd:= ((dd shl 5) or (dd shr (32-5))) + cc;
|
||||
aa:= ((aa shl 10) or (aa shr (32-10)));
|
||||
cc:= cc + (dd xor (ee or (not aa))) + X[ 1] + $a953fd4e;
|
||||
cc:= ((cc shl 12) or (cc shr (32-12))) + bb;
|
||||
ee:= ((ee shl 10) or (ee shr (32-10)));
|
||||
bb:= bb + (cc xor (dd or (not ee))) + X[ 3] + $a953fd4e;
|
||||
bb:= ((bb shl 13) or (bb shr (32-13))) + aa;
|
||||
dd:= ((dd shl 10) or (dd shr (32-10)));
|
||||
aa:= aa + (bb xor (cc or (not dd))) + X[ 8] + $a953fd4e;
|
||||
aa:= ((aa shl 14) or (aa shr (32-14))) + ee;
|
||||
cc:= ((cc shl 10) or (cc shr (32-10)));
|
||||
ee:= ee + (aa xor (bb or (not cc))) + X[11] + $a953fd4e;
|
||||
ee:= ((ee shl 11) or (ee shr (32-11))) + dd;
|
||||
bb:= ((bb shl 10) or (bb shr (32-10)));
|
||||
dd:= dd + (ee xor (aa or (not bb))) + X[ 6] + $a953fd4e;
|
||||
dd:= ((dd shl 8) or (dd shr (32-8))) + cc;
|
||||
aa:= ((aa shl 10) or (aa shr (32-10)));
|
||||
cc:= cc + (dd xor (ee or (not aa))) + X[15] + $a953fd4e;
|
||||
cc:= ((cc shl 5) or (cc shr (32-5))) + bb;
|
||||
ee:= ((ee shl 10) or (ee shr (32-10)));
|
||||
bb:= bb + (cc xor (dd or (not ee))) + X[13] + $a953fd4e;
|
||||
bb:= ((bb shl 6) or (bb shr (32-6))) + aa;
|
||||
dd:= ((dd shl 10) or (dd shr (32-10)));
|
||||
|
||||
aaa:= aaa + (bbb xor (ccc or (not ddd))) + X[ 5] + $50a28be6;
|
||||
aaa:= ((aaa shl 8) or (aaa shr (32-8))) + eee;
|
||||
ccc:= ((ccc shl 10) or (ccc shr (32-10)));
|
||||
eee:= eee + (aaa xor (bbb or (not ccc))) + X[14] + $50a28be6;
|
||||
eee:= ((eee shl 9) or (eee shr (32-9))) + ddd;
|
||||
bbb:= ((bbb shl 10) or (bbb shr (32-10)));
|
||||
ddd:= ddd + (eee xor (aaa or (not bbb))) + X[ 7] + $50a28be6;
|
||||
ddd:= ((ddd shl 9) or (ddd shr (32-9))) + ccc;
|
||||
aaa:= ((aaa shl 10) or (aaa shr (32-10)));
|
||||
ccc:= ccc + (ddd xor (eee or (not aaa))) + X[ 0] + $50a28be6;
|
||||
ccc:= ((ccc shl 11) or (ccc shr (32-11))) + bbb;
|
||||
eee:= ((eee shl 10) or (eee shr (32-10)));
|
||||
bbb:= bbb + (ccc xor (ddd or (not eee))) + X[ 9] + $50a28be6;
|
||||
bbb:= ((bbb shl 13) or (bbb shr (32-13))) + aaa;
|
||||
ddd:= ((ddd shl 10) or (ddd shr (32-10)));
|
||||
aaa:= aaa + (bbb xor (ccc or (not ddd))) + X[ 2] + $50a28be6;
|
||||
aaa:= ((aaa shl 15) or (aaa shr (32-15))) + eee;
|
||||
ccc:= ((ccc shl 10) or (ccc shr (32-10)));
|
||||
eee:= eee + (aaa xor (bbb or (not ccc))) + X[11] + $50a28be6;
|
||||
eee:= ((eee shl 15) or (eee shr (32-15))) + ddd;
|
||||
bbb:= ((bbb shl 10) or (bbb shr (32-10)));
|
||||
ddd:= ddd + (eee xor (aaa or (not bbb))) + X[ 4] + $50a28be6;
|
||||
ddd:= ((ddd shl 5) or (ddd shr (32-5))) + ccc;
|
||||
aaa:= ((aaa shl 10) or (aaa shr (32-10)));
|
||||
ccc:= ccc + (ddd xor (eee or (not aaa))) + X[13] + $50a28be6;
|
||||
ccc:= ((ccc shl 7) or (ccc shr (32-7))) + bbb;
|
||||
eee:= ((eee shl 10) or (eee shr (32-10)));
|
||||
bbb:= bbb + (ccc xor (ddd or (not eee))) + X[ 6] + $50a28be6;
|
||||
bbb:= ((bbb shl 7) or (bbb shr (32-7))) + aaa;
|
||||
ddd:= ((ddd shl 10) or (ddd shr (32-10)));
|
||||
aaa:= aaa + (bbb xor (ccc or (not ddd))) + X[15] + $50a28be6;
|
||||
aaa:= ((aaa shl 8) or (aaa shr (32-8))) + eee;
|
||||
ccc:= ((ccc shl 10) or (ccc shr (32-10)));
|
||||
eee:= eee + (aaa xor (bbb or (not ccc))) + X[ 8] + $50a28be6;
|
||||
eee:= ((eee shl 11) or (eee shr (32-11))) + ddd;
|
||||
bbb:= ((bbb shl 10) or (bbb shr (32-10)));
|
||||
ddd:= ddd + (eee xor (aaa or (not bbb))) + X[ 1] + $50a28be6;
|
||||
ddd:= ((ddd shl 14) or (ddd shr (32-14))) + ccc;
|
||||
aaa:= ((aaa shl 10) or (aaa shr (32-10)));
|
||||
ccc:= ccc + (ddd xor (eee or (not aaa))) + X[10] + $50a28be6;
|
||||
ccc:= ((ccc shl 14) or (ccc shr (32-14))) + bbb;
|
||||
eee:= ((eee shl 10) or (eee shr (32-10)));
|
||||
bbb:= bbb + (ccc xor (ddd or (not eee))) + X[ 3] + $50a28be6;
|
||||
bbb:= ((bbb shl 12) or (bbb shr (32-12))) + aaa;
|
||||
ddd:= ((ddd shl 10) or (ddd shr (32-10)));
|
||||
aaa:= aaa + (bbb xor (ccc or (not ddd))) + X[12] + $50a28be6;
|
||||
aaa:= ((aaa shl 6) or (aaa shr (32-6))) + eee;
|
||||
ccc:= ((ccc shl 10) or (ccc shr (32-10)));
|
||||
|
||||
eee:= eee + ((aaa and ccc) or (bbb and (not ccc))) + X[ 6] + $5c4dd124;
|
||||
eee:= ((eee shl 9) or (eee shr (32-9))) + ddd;
|
||||
bbb:= ((bbb shl 10) or (bbb shr (32-10)));
|
||||
ddd:= ddd + ((eee and bbb) or (aaa and (not bbb))) + X[11] + $5c4dd124;
|
||||
ddd:= ((ddd shl 13) or (ddd shr (32-13))) + ccc;
|
||||
aaa:= ((aaa shl 10) or (aaa shr (32-10)));
|
||||
ccc:= ccc + ((ddd and aaa) or (eee and (not aaa))) + X[ 3] + $5c4dd124;
|
||||
ccc:= ((ccc shl 15) or (ccc shr (32-15))) + bbb;
|
||||
eee:= ((eee shl 10) or (eee shr (32-10)));
|
||||
bbb:= bbb + ((ccc and eee) or (ddd and (not eee))) + X[ 7] + $5c4dd124;
|
||||
bbb:= ((bbb shl 7) or (bbb shr (32-7))) + aaa;
|
||||
ddd:= ((ddd shl 10) or (ddd shr (32-10)));
|
||||
aaa:= aaa + ((bbb and ddd) or (ccc and (not ddd))) + X[ 0] + $5c4dd124;
|
||||
aaa:= ((aaa shl 12) or (aaa shr (32-12))) + eee;
|
||||
ccc:= ((ccc shl 10) or (ccc shr (32-10)));
|
||||
eee:= eee + ((aaa and ccc) or (bbb and (not ccc))) + X[13] + $5c4dd124;
|
||||
eee:= ((eee shl 8) or (eee shr (32-8))) + ddd;
|
||||
bbb:= ((bbb shl 10) or (bbb shr (32-10)));
|
||||
ddd:= ddd + ((eee and bbb) or (aaa and (not bbb))) + X[ 5] + $5c4dd124;
|
||||
ddd:= ((ddd shl 9) or (ddd shr (32-9))) + ccc;
|
||||
aaa:= ((aaa shl 10) or (aaa shr (32-10)));
|
||||
ccc:= ccc + ((ddd and aaa) or (eee and (not aaa))) + X[10] + $5c4dd124;
|
||||
ccc:= ((ccc shl 11) or (ccc shr (32-11))) + bbb;
|
||||
eee:= ((eee shl 10) or (eee shr (32-10)));
|
||||
bbb:= bbb + ((ccc and eee) or (ddd and (not eee))) + X[14] + $5c4dd124;
|
||||
bbb:= ((bbb shl 7) or (bbb shr (32-7))) + aaa;
|
||||
ddd:= ((ddd shl 10) or (ddd shr (32-10)));
|
||||
aaa:= aaa + ((bbb and ddd) or (ccc and (not ddd))) + X[15] + $5c4dd124;
|
||||
aaa:= ((aaa shl 7) or (aaa shr (32-7))) + eee;
|
||||
ccc:= ((ccc shl 10) or (ccc shr (32-10)));
|
||||
eee:= eee + ((aaa and ccc) or (bbb and (not ccc))) + X[ 8] + $5c4dd124;
|
||||
eee:= ((eee shl 12) or (eee shr (32-12))) + ddd;
|
||||
bbb:= ((bbb shl 10) or (bbb shr (32-10)));
|
||||
ddd:= ddd + ((eee and bbb) or (aaa and (not bbb))) + X[12] + $5c4dd124;
|
||||
ddd:= ((ddd shl 7) or (ddd shr (32-7))) + ccc;
|
||||
aaa:= ((aaa shl 10) or (aaa shr (32-10)));
|
||||
ccc:= ccc + ((ddd and aaa) or (eee and (not aaa))) + X[ 4] + $5c4dd124;
|
||||
ccc:= ((ccc shl 6) or (ccc shr (32-6))) + bbb;
|
||||
eee:= ((eee shl 10) or (eee shr (32-10)));
|
||||
bbb:= bbb + ((ccc and eee) or (ddd and (not eee))) + X[ 9] + $5c4dd124;
|
||||
bbb:= ((bbb shl 15) or (bbb shr (32-15))) + aaa;
|
||||
ddd:= ((ddd shl 10) or (ddd shr (32-10)));
|
||||
aaa:= aaa + ((bbb and ddd) or (ccc and (not ddd))) + X[ 1] + $5c4dd124;
|
||||
aaa:= ((aaa shl 13) or (aaa shr (32-13))) + eee;
|
||||
ccc:= ((ccc shl 10) or (ccc shr (32-10)));
|
||||
eee:= eee + ((aaa and ccc) or (bbb and (not ccc))) + X[ 2] + $5c4dd124;
|
||||
eee:= ((eee shl 11) or (eee shr (32-11))) + ddd;
|
||||
bbb:= ((bbb shl 10) or (bbb shr (32-10)));
|
||||
|
||||
ddd:= ddd + ((eee or (not aaa)) xor bbb) + X[15] + $6d703ef3;
|
||||
ddd:= ((ddd shl 9) or (ddd shr (32-9))) + ccc;
|
||||
aaa:= ((aaa shl 10) or (aaa shr (32-10)));
|
||||
ccc:= ccc + ((ddd or (not eee)) xor aaa) + X[ 5] + $6d703ef3;
|
||||
ccc:= ((ccc shl 7) or (ccc shr (32-7))) + bbb;
|
||||
eee:= ((eee shl 10) or (eee shr (32-10)));
|
||||
bbb:= bbb + ((ccc or (not ddd)) xor eee) + X[ 1] + $6d703ef3;
|
||||
bbb:= ((bbb shl 15) or (bbb shr (32-15))) + aaa;
|
||||
ddd:= ((ddd shl 10) or (ddd shr (32-10)));
|
||||
aaa:= aaa + ((bbb or (not ccc)) xor ddd) + X[ 3] + $6d703ef3;
|
||||
aaa:= ((aaa shl 11) or (aaa shr (32-11))) + eee;
|
||||
ccc:= ((ccc shl 10) or (ccc shr (32-10)));
|
||||
eee:= eee + ((aaa or (not bbb)) xor ccc) + X[ 7] + $6d703ef3;
|
||||
eee:= ((eee shl 8) or (eee shr (32-8))) + ddd;
|
||||
bbb:= ((bbb shl 10) or (bbb shr (32-10)));
|
||||
ddd:= ddd + ((eee or (not aaa)) xor bbb) + X[14] + $6d703ef3;
|
||||
ddd:= ((ddd shl 6) or (ddd shr (32-6))) + ccc;
|
||||
aaa:= ((aaa shl 10) or (aaa shr (32-10)));
|
||||
ccc:= ccc + ((ddd or (not eee)) xor aaa) + X[ 6] + $6d703ef3;
|
||||
ccc:= ((ccc shl 6) or (ccc shr (32-6))) + bbb;
|
||||
eee:= ((eee shl 10) or (eee shr (32-10)));
|
||||
bbb:= bbb + ((ccc or (not ddd)) xor eee) + X[ 9] + $6d703ef3;
|
||||
bbb:= ((bbb shl 14) or (bbb shr (32-14))) + aaa;
|
||||
ddd:= ((ddd shl 10) or (ddd shr (32-10)));
|
||||
aaa:= aaa + ((bbb or (not ccc)) xor ddd) + X[11] + $6d703ef3;
|
||||
aaa:= ((aaa shl 12) or (aaa shr (32-12))) + eee;
|
||||
ccc:= ((ccc shl 10) or (ccc shr (32-10)));
|
||||
eee:= eee + ((aaa or (not bbb)) xor ccc) + X[ 8] + $6d703ef3;
|
||||
eee:= ((eee shl 13) or (eee shr (32-13))) + ddd;
|
||||
bbb:= ((bbb shl 10) or (bbb shr (32-10)));
|
||||
ddd:= ddd + ((eee or (not aaa)) xor bbb) + X[12] + $6d703ef3;
|
||||
ddd:= ((ddd shl 5) or (ddd shr (32-5))) + ccc;
|
||||
aaa:= ((aaa shl 10) or (aaa shr (32-10)));
|
||||
ccc:= ccc + ((ddd or (not eee)) xor aaa) + X[ 2] + $6d703ef3;
|
||||
ccc:= ((ccc shl 14) or (ccc shr (32-14))) + bbb;
|
||||
eee:= ((eee shl 10) or (eee shr (32-10)));
|
||||
bbb:= bbb + ((ccc or (not ddd)) xor eee) + X[10] + $6d703ef3;
|
||||
bbb:= ((bbb shl 13) or (bbb shr (32-13))) + aaa;
|
||||
ddd:= ((ddd shl 10) or (ddd shr (32-10)));
|
||||
aaa:= aaa + ((bbb or (not ccc)) xor ddd) + X[ 0] + $6d703ef3;
|
||||
aaa:= ((aaa shl 13) or (aaa shr (32-13))) + eee;
|
||||
ccc:= ((ccc shl 10) or (ccc shr (32-10)));
|
||||
eee:= eee + ((aaa or (not bbb)) xor ccc) + X[ 4] + $6d703ef3;
|
||||
eee:= ((eee shl 7) or (eee shr (32-7))) + ddd;
|
||||
bbb:= ((bbb shl 10) or (bbb shr (32-10)));
|
||||
ddd:= ddd + ((eee or (not aaa)) xor bbb) + X[13] + $6d703ef3;
|
||||
ddd:= ((ddd shl 5) or (ddd shr (32-5))) + ccc;
|
||||
aaa:= ((aaa shl 10) or (aaa shr (32-10)));
|
||||
|
||||
ccc:= ccc + ((ddd and eee) or ((not ddd) and aaa)) + X[ 8] + $7a6d76e9;
|
||||
ccc:= ((ccc shl 15) or (ccc shr (32-15))) + bbb;
|
||||
eee:= ((eee shl 10) or (eee shr (32-10)));
|
||||
bbb:= bbb + ((ccc and ddd) or ((not ccc) and eee)) + X[ 6] + $7a6d76e9;
|
||||
bbb:= ((bbb shl 5) or (bbb shr (32-5))) + aaa;
|
||||
ddd:= ((ddd shl 10) or (ddd shr (32-10)));
|
||||
aaa:= aaa + ((bbb and ccc) or ((not bbb) and ddd)) + X[ 4] + $7a6d76e9;
|
||||
aaa:= ((aaa shl 8) or (aaa shr (32-8))) + eee;
|
||||
ccc:= ((ccc shl 10) or (ccc shr (32-10)));
|
||||
eee:= eee + ((aaa and bbb) or ((not aaa) and ccc)) + X[ 1] + $7a6d76e9;
|
||||
eee:= ((eee shl 11) or (eee shr (32-11))) + ddd;
|
||||
bbb:= ((bbb shl 10) or (bbb shr (32-10)));
|
||||
ddd:= ddd + ((eee and aaa) or ((not eee) and bbb)) + X[ 3] + $7a6d76e9;
|
||||
ddd:= ((ddd shl 14) or (ddd shr (32-14))) + ccc;
|
||||
aaa:= ((aaa shl 10) or (aaa shr (32-10)));
|
||||
ccc:= ccc + ((ddd and eee) or ((not ddd) and aaa)) + X[11] + $7a6d76e9;
|
||||
ccc:= ((ccc shl 14) or (ccc shr (32-14))) + bbb;
|
||||
eee:= ((eee shl 10) or (eee shr (32-10)));
|
||||
bbb:= bbb + ((ccc and ddd) or ((not ccc) and eee)) + X[15] + $7a6d76e9;
|
||||
bbb:= ((bbb shl 6) or (bbb shr (32-6))) + aaa;
|
||||
ddd:= ((ddd shl 10) or (ddd shr (32-10)));
|
||||
aaa:= aaa + ((bbb and ccc) or ((not bbb) and ddd)) + X[ 0] + $7a6d76e9;
|
||||
aaa:= ((aaa shl 14) or (aaa shr (32-14))) + eee;
|
||||
ccc:= ((ccc shl 10) or (ccc shr (32-10)));
|
||||
eee:= eee + ((aaa and bbb) or ((not aaa) and ccc)) + X[ 5] + $7a6d76e9;
|
||||
eee:= ((eee shl 6) or (eee shr (32-6))) + ddd;
|
||||
bbb:= ((bbb shl 10) or (bbb shr (32-10)));
|
||||
ddd:= ddd + ((eee and aaa) or ((not eee) and bbb)) + X[12] + $7a6d76e9;
|
||||
ddd:= ((ddd shl 9) or (ddd shr (32-9))) + ccc;
|
||||
aaa:= ((aaa shl 10) or (aaa shr (32-10)));
|
||||
ccc:= ccc + ((ddd and eee) or ((not ddd) and aaa)) + X[ 2] + $7a6d76e9;
|
||||
ccc:= ((ccc shl 12) or (ccc shr (32-12))) + bbb;
|
||||
eee:= ((eee shl 10) or (eee shr (32-10)));
|
||||
bbb:= bbb + ((ccc and ddd) or ((not ccc) and eee)) + X[13] + $7a6d76e9;
|
||||
bbb:= ((bbb shl 9) or (bbb shr (32-9))) + aaa;
|
||||
ddd:= ((ddd shl 10) or (ddd shr (32-10)));
|
||||
aaa:= aaa + ((bbb and ccc) or ((not bbb) and ddd)) + X[ 9] + $7a6d76e9;
|
||||
aaa:= ((aaa shl 12) or (aaa shr (32-12))) + eee;
|
||||
ccc:= ((ccc shl 10) or (ccc shr (32-10)));
|
||||
eee:= eee + ((aaa and bbb) or ((not aaa) and ccc)) + X[ 7] + $7a6d76e9;
|
||||
eee:= ((eee shl 5) or (eee shr (32-5))) + ddd;
|
||||
bbb:= ((bbb shl 10) or (bbb shr (32-10)));
|
||||
ddd:= ddd + ((eee and aaa) or ((not eee) and bbb)) + X[10] + $7a6d76e9;
|
||||
ddd:= ((ddd shl 15) or (ddd shr (32-15))) + ccc;
|
||||
aaa:= ((aaa shl 10) or (aaa shr (32-10)));
|
||||
ccc:= ccc + ((ddd and eee) or ((not ddd) and aaa)) + X[14] + $7a6d76e9;
|
||||
ccc:= ((ccc shl 8) or (ccc shr (32-8))) + bbb;
|
||||
eee:= ((eee shl 10) or (eee shr (32-10)));
|
||||
|
||||
bbb:= bbb + (ccc xor ddd xor eee) + X[12];
|
||||
bbb:= ((bbb shl 8) or (bbb shr (32-8))) + aaa;
|
||||
ddd:= ((ddd shl 10) or (ddd shr (32-10)));
|
||||
aaa:= aaa + (bbb xor ccc xor ddd) + X[15];
|
||||
aaa:= ((aaa shl 5) or (aaa shr (32-5))) + eee;
|
||||
ccc:= ((ccc shl 10) or (ccc shr (32-10)));
|
||||
eee:= eee + (aaa xor bbb xor ccc) + X[10];
|
||||
eee:= ((eee shl 12) or (eee shr (32-12))) + ddd;
|
||||
bbb:= ((bbb shl 10) or (bbb shr (32-10)));
|
||||
ddd:= ddd + (eee xor aaa xor bbb) + X[ 4];
|
||||
ddd:= ((ddd shl 9) or (ddd shr (32-9))) + ccc;
|
||||
aaa:= ((aaa shl 10) or (aaa shr (32-10)));
|
||||
ccc:= ccc + (ddd xor eee xor aaa) + X[ 1];
|
||||
ccc:= ((ccc shl 12) or (ccc shr (32-12))) + bbb;
|
||||
eee:= ((eee shl 10) or (eee shr (32-10)));
|
||||
bbb:= bbb + (ccc xor ddd xor eee) + X[ 5];
|
||||
bbb:= ((bbb shl 5) or (bbb shr (32-5))) + aaa;
|
||||
ddd:= ((ddd shl 10) or (ddd shr (32-10)));
|
||||
aaa:= aaa + (bbb xor ccc xor ddd) + X[ 8];
|
||||
aaa:= ((aaa shl 14) or (aaa shr (32-14))) + eee;
|
||||
ccc:= ((ccc shl 10) or (ccc shr (32-10)));
|
||||
eee:= eee + (aaa xor bbb xor ccc) + X[ 7];
|
||||
eee:= ((eee shl 6) or (eee shr (32-6))) + ddd;
|
||||
bbb:= ((bbb shl 10) or (bbb shr (32-10)));
|
||||
ddd:= ddd + (eee xor aaa xor bbb) + X[ 6];
|
||||
ddd:= ((ddd shl 8) or (ddd shr (32-8))) + ccc;
|
||||
aaa:= ((aaa shl 10) or (aaa shr (32-10)));
|
||||
ccc:= ccc + (ddd xor eee xor aaa) + X[ 2];
|
||||
ccc:= ((ccc shl 13) or (ccc shr (32-13))) + bbb;
|
||||
eee:= ((eee shl 10) or (eee shr (32-10)));
|
||||
bbb:= bbb + (ccc xor ddd xor eee) + X[13];
|
||||
bbb:= ((bbb shl 6) or (bbb shr (32-6))) + aaa;
|
||||
ddd:= ((ddd shl 10) or (ddd shr (32-10)));
|
||||
aaa:= aaa + (bbb xor ccc xor ddd) + X[14];
|
||||
aaa:= ((aaa shl 5) or (aaa shr (32-5))) + eee;
|
||||
ccc:= ((ccc shl 10) or (ccc shr (32-10)));
|
||||
eee:= eee + (aaa xor bbb xor ccc) + X[ 0];
|
||||
eee:= ((eee shl 15) or (eee shr (32-15))) + ddd;
|
||||
bbb:= ((bbb shl 10) or (bbb shr (32-10)));
|
||||
ddd:= ddd + (eee xor aaa xor bbb) + X[ 3];
|
||||
ddd:= ((ddd shl 13) or (ddd shr (32-13))) + ccc;
|
||||
aaa:= ((aaa shl 10) or (aaa shr (32-10)));
|
||||
ccc:= ccc + (ddd xor eee xor aaa) + X[ 9];
|
||||
ccc:= ((ccc shl 11) or (ccc shr (32-11))) + bbb;
|
||||
eee:= ((eee shl 10) or (eee shr (32-10)));
|
||||
bbb:= bbb + (ccc xor ddd xor eee) + X[11];
|
||||
bbb:= ((bbb shl 11) or (bbb shr (32-11))) + aaa;
|
||||
ddd:= ((ddd shl 10) or (ddd shr (32-10)));
|
||||
|
||||
ddd:= ddd + cc + CurrentHash[1];
|
||||
CurrentHash[1]:= CurrentHash[2] + dd + eee;
|
||||
CurrentHash[2]:= CurrentHash[3] + ee + aaa;
|
||||
CurrentHash[3]:= CurrentHash[4] + aa + bbb;
|
||||
CurrentHash[4]:= CurrentHash[0] + bb + ccc;
|
||||
CurrentHash[0]:= ddd;
|
||||
FillChar(X,Sizeof(X),0);
|
||||
Index:= 0;
|
||||
FillChar(HashBuffer,Sizeof(HashBuffer),0);
|
||||
end;
|
||||
|
||||
class function TDCP_ripemd160.GetHashSize: integer;
|
||||
begin
|
||||
Result:= 160;
|
||||
end;
|
||||
|
||||
class function TDCP_ripemd160.GetId: integer;
|
||||
begin
|
||||
Result:= DCP_ripemd160;
|
||||
end;
|
||||
|
||||
class function TDCP_ripemd160.GetAlgorithm: string;
|
||||
begin
|
||||
Result:= 'RipeMD-160';
|
||||
end;
|
||||
|
||||
class function TDCP_ripemd160.SelfTest: boolean;
|
||||
const
|
||||
Test1Out: array[0..19] of byte=
|
||||
($0B,$DC,$9D,$2D,$25,$6B,$3E,$E9,$DA,$AE,$34,$7B,$E6,$F4,$DC,$83,$5A,$46,$7F,$FE);
|
||||
Test2Out: array[0..19] of byte=
|
||||
($F7,$1C,$27,$10,$9C,$69,$2C,$1B,$56,$BB,$DC,$EB,$5B,$9D,$28,$65,$B3,$70,$8D,$BC);
|
||||
var
|
||||
TestHash: TDCP_ripemd160;
|
||||
TestOut: array[0..19] of byte;
|
||||
begin
|
||||
dcpFillChar(TestOut, SizeOf(TestOut), 0);
|
||||
TestHash:= TDCP_ripemd160.Create(nil);
|
||||
TestHash.Init;
|
||||
TestHash.UpdateStr('a');
|
||||
TestHash.Final(TestOut);
|
||||
Result:= CompareMem(@TestOut,@Test1Out,Sizeof(Test1Out));
|
||||
TestHash.Init;
|
||||
TestHash.UpdateStr('abcdefghijklmnopqrstuvwxyz');
|
||||
TestHash.Final(TestOut);
|
||||
Result:= CompareMem(@TestOut,@Test2Out,Sizeof(Test2Out)) and Result;
|
||||
TestHash.Free;
|
||||
end;
|
||||
|
||||
procedure TDCP_ripemd160.Init;
|
||||
begin
|
||||
Burn;
|
||||
CurrentHash[0]:= $67452301;
|
||||
CurrentHash[1]:= $efcdab89;
|
||||
CurrentHash[2]:= $98badcfe;
|
||||
CurrentHash[3]:= $10325476;
|
||||
CurrentHash[4]:= $c3d2e1f0;
|
||||
fInitialized:= true;
|
||||
end;
|
||||
|
||||
procedure TDCP_ripemd160.Burn;
|
||||
begin
|
||||
LenHi:= 0; LenLo:= 0;
|
||||
Index:= 0;
|
||||
FillChar(HashBuffer,Sizeof(HashBuffer),0);
|
||||
FillChar(CurrentHash,Sizeof(CurrentHash),0);
|
||||
fInitialized:= false;
|
||||
end;
|
||||
|
||||
procedure TDCP_ripemd160.Update(const Buffer; Size: longword);
|
||||
var
|
||||
PBuf: ^byte;
|
||||
begin
|
||||
if not fInitialized then
|
||||
raise EDCP_hash.Create('Hash not initialized');
|
||||
|
||||
Inc(LenHi,Size shr 29);
|
||||
Inc(LenLo,Size*8);
|
||||
if LenLo< (Size*8) then
|
||||
Inc(LenHi);
|
||||
|
||||
PBuf:= @Buffer;
|
||||
while Size> 0 do
|
||||
begin
|
||||
if (Sizeof(HashBuffer)-Index)<= DWord(Size) then
|
||||
begin
|
||||
Move(PBuf^,HashBuffer[Index],Sizeof(HashBuffer)-Index);
|
||||
Dec(Size,Sizeof(HashBuffer)-Index);
|
||||
Inc(PBuf,Sizeof(HashBuffer)-Index);
|
||||
Compress;
|
||||
end
|
||||
else
|
||||
begin
|
||||
Move(PBuf^,HashBuffer[Index],Size);
|
||||
Inc(Index,Size);
|
||||
Size:= 0;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TDCP_ripemd160.Final(var Digest);
|
||||
begin
|
||||
if not fInitialized then
|
||||
raise EDCP_hash.Create('Hash not initialized');
|
||||
HashBuffer[Index]:= $80;
|
||||
if Index>= 56 then
|
||||
Compress;
|
||||
PDWord(@HashBuffer[56])^:= LenLo;
|
||||
PDWord(@HashBuffer[60])^:= LenHi;
|
||||
Compress;
|
||||
Move(CurrentHash,Digest,Sizeof(CurrentHash));
|
||||
Burn;
|
||||
end;
|
||||
|
||||
|
||||
end.
|
||||
182
dcpcrypt/Hashes/dcpsfv.pas
Normal file
@@ -0,0 +1,182 @@
|
||||
{******************************************************************************}
|
||||
{* DCPcrypt v2.0 written by David Barton (crypto@cityinthesky.co.uk) **********}
|
||||
{******************************************************************************}
|
||||
{* A binary compatible (with Total Commander) implementation of SFV *}
|
||||
{******************************************************************************}
|
||||
{* Copyright (C) 2011 Alexander Koblov (alexx2000@mail.ru) *}
|
||||
{* Permission is hereby granted, free of charge, to any person obtaining a *}
|
||||
{* copy of this software and associated documentation files (the "Software"), *}
|
||||
{* to deal in the Software without restriction, including without limitation *}
|
||||
{* the rights to use, copy, modify, merge, publish, distribute, sublicense, *}
|
||||
{* and/or sell copies of the Software, and to permit persons to whom the *}
|
||||
{* Software is furnished to do so, subject to the following conditions: *}
|
||||
{* *}
|
||||
{* The above copyright notice and this permission notice shall be included in *}
|
||||
{* all copies or substantial portions of the Software. *}
|
||||
{* *}
|
||||
{* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *}
|
||||
{* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *}
|
||||
{* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *}
|
||||
{* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *}
|
||||
{* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *}
|
||||
{* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *}
|
||||
{* DEALINGS IN THE SOFTWARE. *}
|
||||
{******************************************************************************}
|
||||
unit DCPsfv;
|
||||
|
||||
{$mode objfpc}{$h+}
|
||||
|
||||
interface
|
||||
uses
|
||||
Classes, Sysutils, DCPcrypt2, DCPconst;
|
||||
|
||||
type
|
||||
TDCP_sfv = class(TDCP_hash)
|
||||
protected
|
||||
CurrentHash: LongWord;
|
||||
public
|
||||
class function GetId: integer; override;
|
||||
class function GetAlgorithm: string; override;
|
||||
class function GetHashSize: integer; override;
|
||||
class function SelfTest: boolean; override;
|
||||
procedure Init; override;
|
||||
procedure Burn; override;
|
||||
procedure Update(const Buffer; Size: longword); override;
|
||||
procedure Final(var Digest); override;
|
||||
end;
|
||||
|
||||
|
||||
|
||||
{******************************************************************************}
|
||||
{******************************************************************************}
|
||||
implementation
|
||||
{$R-}{$Q-}
|
||||
|
||||
const
|
||||
sfv_table : array[Byte] of cardinal = (
|
||||
$00000000, $77073096, $ee0e612c, $990951ba, $076dc419,
|
||||
$706af48f, $e963a535, $9e6495a3, $0edb8832, $79dcb8a4,
|
||||
$e0d5e91e, $97d2d988, $09b64c2b, $7eb17cbd, $e7b82d07,
|
||||
$90bf1d91, $1db71064, $6ab020f2, $f3b97148, $84be41de,
|
||||
$1adad47d, $6ddde4eb, $f4d4b551, $83d385c7, $136c9856,
|
||||
$646ba8c0, $fd62f97a, $8a65c9ec, $14015c4f, $63066cd9,
|
||||
$fa0f3d63, $8d080df5, $3b6e20c8, $4c69105e, $d56041e4,
|
||||
$a2677172, $3c03e4d1, $4b04d447, $d20d85fd, $a50ab56b,
|
||||
$35b5a8fa, $42b2986c, $dbbbc9d6, $acbcf940, $32d86ce3,
|
||||
$45df5c75, $dcd60dcf, $abd13d59, $26d930ac, $51de003a,
|
||||
$c8d75180, $bfd06116, $21b4f4b5, $56b3c423, $cfba9599,
|
||||
$b8bda50f, $2802b89e, $5f058808, $c60cd9b2, $b10be924,
|
||||
$2f6f7c87, $58684c11, $c1611dab, $b6662d3d, $76dc4190,
|
||||
$01db7106, $98d220bc, $efd5102a, $71b18589, $06b6b51f,
|
||||
$9fbfe4a5, $e8b8d433, $7807c9a2, $0f00f934, $9609a88e,
|
||||
$e10e9818, $7f6a0dbb, $086d3d2d, $91646c97, $e6635c01,
|
||||
$6b6b51f4, $1c6c6162, $856530d8, $f262004e, $6c0695ed,
|
||||
$1b01a57b, $8208f4c1, $f50fc457, $65b0d9c6, $12b7e950,
|
||||
$8bbeb8ea, $fcb9887c, $62dd1ddf, $15da2d49, $8cd37cf3,
|
||||
$fbd44c65, $4db26158, $3ab551ce, $a3bc0074, $d4bb30e2,
|
||||
$4adfa541, $3dd895d7, $a4d1c46d, $d3d6f4fb, $4369e96a,
|
||||
$346ed9fc, $ad678846, $da60b8d0, $44042d73, $33031de5,
|
||||
$aa0a4c5f, $dd0d7cc9, $5005713c, $270241aa, $be0b1010,
|
||||
$c90c2086, $5768b525, $206f85b3, $b966d409, $ce61e49f,
|
||||
$5edef90e, $29d9c998, $b0d09822, $c7d7a8b4, $59b33d17,
|
||||
$2eb40d81, $b7bd5c3b, $c0ba6cad, $edb88320, $9abfb3b6,
|
||||
$03b6e20c, $74b1d29a, $ead54739, $9dd277af, $04db2615,
|
||||
$73dc1683, $e3630b12, $94643b84, $0d6d6a3e, $7a6a5aa8,
|
||||
$e40ecf0b, $9309ff9d, $0a00ae27, $7d079eb1, $f00f9344,
|
||||
$8708a3d2, $1e01f268, $6906c2fe, $f762575d, $806567cb,
|
||||
$196c3671, $6e6b06e7, $fed41b76, $89d32be0, $10da7a5a,
|
||||
$67dd4acc, $f9b9df6f, $8ebeeff9, $17b7be43, $60b08ed5,
|
||||
$d6d6a3e8, $a1d1937e, $38d8c2c4, $4fdff252, $d1bb67f1,
|
||||
$a6bc5767, $3fb506dd, $48b2364b, $d80d2bda, $af0a1b4c,
|
||||
$36034af6, $41047a60, $df60efc3, $a867df55, $316e8eef,
|
||||
$4669be79, $cb61b38c, $bc66831a, $256fd2a0, $5268e236,
|
||||
$cc0c7795, $bb0b4703, $220216b9, $5505262f, $c5ba3bbe,
|
||||
$b2bd0b28, $2bb45a92, $5cb36a04, $c2d7ffa7, $b5d0cf31,
|
||||
$2cd99e8b, $5bdeae1d, $9b64c2b0, $ec63f226, $756aa39c,
|
||||
$026d930a, $9c0906a9, $eb0e363f, $72076785, $05005713,
|
||||
$95bf4a82, $e2b87a14, $7bb12bae, $0cb61b38, $92d28e9b,
|
||||
$e5d5be0d, $7cdcefb7, $0bdbdf21, $86d3d2d4, $f1d4e242,
|
||||
$68ddb3f8, $1fda836e, $81be16cd, $f6b9265b, $6fb077e1,
|
||||
$18b74777, $88085ae6, $ff0f6a70, $66063bca, $11010b5c,
|
||||
$8f659eff, $f862ae69, $616bffd3, $166ccf45, $a00ae278,
|
||||
$d70dd2ee, $4e048354, $3903b3c2, $a7672661, $d06016f7,
|
||||
$4969474d, $3e6e77db, $aed16a4a, $d9d65adc, $40df0b66,
|
||||
$37d83bf0, $a9bcae53, $debb9ec5, $47b2cf7f, $30b5ffe9,
|
||||
$bdbdf21c, $cabac28a, $53b39330, $24b4a3a6, $bad03605,
|
||||
$cdd70693, $54de5729, $23d967bf, $b3667a2e, $c4614ab8,
|
||||
$5d681b02, $2a6f2b94, $b40bbe37, $c30c8ea1, $5a05df1b,
|
||||
$2d02ef8d);
|
||||
|
||||
class function TDCP_sfv.GetHashSize: integer;
|
||||
begin
|
||||
Result:= 32;
|
||||
end;
|
||||
|
||||
class function TDCP_sfv.GetId: integer;
|
||||
begin
|
||||
Result:= DCP_sfv;
|
||||
end;
|
||||
|
||||
class function TDCP_sfv.GetAlgorithm: string;
|
||||
begin
|
||||
Result:= 'SFV';
|
||||
end;
|
||||
|
||||
class function TDCP_sfv.SelfTest: boolean;
|
||||
const
|
||||
Test1Out: array[0..3] of byte=($35,$24,$41,$C2);
|
||||
Test2Out: array[0..3] of byte=($4C,$27,$50,$BD);
|
||||
var
|
||||
TestHash: TDCP_sfv;
|
||||
TestOut: array[0..3] of byte;
|
||||
begin
|
||||
dcpFillChar(TestOut, SizeOf(TestOut), 0);
|
||||
TestHash:= TDCP_sfv.Create(nil);
|
||||
TestHash.Init;
|
||||
TestHash.UpdateStr('abc');
|
||||
TestHash.Final(TestOut);
|
||||
Result:= CompareMem(@TestOut,@Test1Out,Sizeof(Test1Out));
|
||||
TestHash.Init;
|
||||
TestHash.UpdateStr('abcdefghijklmnopqrstuvwxyz');
|
||||
TestHash.Final(TestOut);
|
||||
Result:= CompareMem(@TestOut,@Test2Out,Sizeof(Test2Out)) and Result;
|
||||
TestHash.Free;
|
||||
end;
|
||||
|
||||
procedure TDCP_sfv.Init;
|
||||
begin
|
||||
Burn;
|
||||
CurrentHash:= $FFFFFFFF;
|
||||
fInitialized:= true;
|
||||
end;
|
||||
|
||||
procedure TDCP_sfv.Burn;
|
||||
begin
|
||||
CurrentHash:= 0;
|
||||
fInitialized:= false;
|
||||
end;
|
||||
|
||||
procedure TDCP_sfv.Update(const Buffer; Size: longword);
|
||||
var
|
||||
I: LongWord;
|
||||
Bytes: PByte;
|
||||
begin
|
||||
Bytes:= @Buffer;
|
||||
for I:= 0 to Size - 1 do
|
||||
begin
|
||||
CurrentHash:= ((CurrentHash shr 8) and $00FFFFFF) xor
|
||||
(sfv_table[(CurrentHash xor Bytes[I]) and $000000FF]);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TDCP_sfv.Final(var Digest);
|
||||
begin
|
||||
if not fInitialized then
|
||||
raise EDCP_hash.Create('Hash not initialized');
|
||||
CurrentHash:= not CurrentHash;
|
||||
CurrentHash:= SwapEndian(CurrentHash);
|
||||
Move(CurrentHash,Digest,Sizeof(CurrentHash));
|
||||
Burn;
|
||||
end;
|
||||
|
||||
end.
|
||||
278
dcpcrypt/Hashes/dcpsha1.pas
Normal file
@@ -0,0 +1,278 @@
|
||||
{******************************************************************************}
|
||||
{* DCPcrypt v2.0 written by David Barton (crypto@cityinthesky.co.uk) **********}
|
||||
{******************************************************************************}
|
||||
{* A binary compatible implementation of SHA1 *********************************}
|
||||
{******************************************************************************}
|
||||
{* Copyright (c) 1999-2002 David Barton *}
|
||||
{* Permission is hereby granted, free of charge, to any person obtaining a *}
|
||||
{* copy of this software and associated documentation files (the "Software"), *}
|
||||
{* to deal in the Software without restriction, including without limitation *}
|
||||
{* the rights to use, copy, modify, merge, publish, distribute, sublicense, *}
|
||||
{* and/or sell copies of the Software, and to permit persons to whom the *}
|
||||
{* Software is furnished to do so, subject to the following conditions: *}
|
||||
{* *}
|
||||
{* The above copyright notice and this permission notice shall be included in *}
|
||||
{* all copies or substantial portions of the Software. *}
|
||||
{* *}
|
||||
{* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *}
|
||||
{* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *}
|
||||
{* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *}
|
||||
{* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *}
|
||||
{* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *}
|
||||
{* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *}
|
||||
{* DEALINGS IN THE SOFTWARE. *}
|
||||
{******************************************************************************}
|
||||
unit DCPsha1;
|
||||
|
||||
{$MODE Delphi}
|
||||
|
||||
interface
|
||||
uses
|
||||
Classes, Sysutils, DCPcrypt2, DCPconst;
|
||||
|
||||
type
|
||||
TDCP_sha1= class(TDCP_hash)
|
||||
protected
|
||||
LenHi, LenLo: longword;
|
||||
Index: DWord;
|
||||
CurrentHash: array[0..4] of DWord;
|
||||
HashBuffer: array[0..63] of byte;
|
||||
procedure Compress;
|
||||
public
|
||||
class function GetId: integer; override;
|
||||
class function GetAlgorithm: string; override;
|
||||
class function GetHashSize: integer; override;
|
||||
class function SelfTest: boolean; override;
|
||||
procedure Init; override;
|
||||
procedure Final(var Digest); override;
|
||||
procedure Burn; override;
|
||||
procedure Update(const Buffer; Size: longword); override;
|
||||
end;
|
||||
|
||||
{******************************************************************************}
|
||||
{******************************************************************************}
|
||||
implementation
|
||||
{$R-}{$Q-}
|
||||
|
||||
function SwapDWord(a: dword): dword;
|
||||
begin
|
||||
Result:= ((a and $FF) shl 24) or ((a and $FF00) shl 8) or ((a and $FF0000) shr 8) or ((a and $FF000000) shr 24);
|
||||
end;
|
||||
|
||||
procedure TDCP_sha1.Compress;
|
||||
var
|
||||
A, B, C, D, E: DWord;
|
||||
W: array[0..79] of DWord;
|
||||
i: longword;
|
||||
begin
|
||||
Index:= 0;
|
||||
dcpFillChar(W, SizeOf(W), 0);
|
||||
Move(HashBuffer,W,Sizeof(HashBuffer));
|
||||
for i:= 0 to 15 do
|
||||
W[i]:= SwapDWord(W[i]);
|
||||
for i:= 16 to 79 do
|
||||
W[i]:= ((W[i-3] xor W[i-8] xor W[i-14] xor W[i-16]) shl 1) or ((W[i-3] xor W[i-8] xor W[i-14] xor W[i-16]) shr 31);
|
||||
A:= CurrentHash[0]; B:= CurrentHash[1]; C:= CurrentHash[2]; D:= CurrentHash[3]; E:= CurrentHash[4];
|
||||
|
||||
Inc(E,((A shl 5) or (A shr 27)) + (D xor (B and (C xor D))) + $5A827999 + W[ 0]); B:= (B shl 30) or (B shr 2);
|
||||
Inc(D,((E shl 5) or (E shr 27)) + (C xor (A and (B xor C))) + $5A827999 + W[ 1]); A:= (A shl 30) or (A shr 2);
|
||||
Inc(C,((D shl 5) or (D shr 27)) + (B xor (E and (A xor B))) + $5A827999 + W[ 2]); E:= (E shl 30) or (E shr 2);
|
||||
Inc(B,((C shl 5) or (C shr 27)) + (A xor (D and (E xor A))) + $5A827999 + W[ 3]); D:= (D shl 30) or (D shr 2);
|
||||
Inc(A,((B shl 5) or (B shr 27)) + (E xor (C and (D xor E))) + $5A827999 + W[ 4]); C:= (C shl 30) or (C shr 2);
|
||||
Inc(E,((A shl 5) or (A shr 27)) + (D xor (B and (C xor D))) + $5A827999 + W[ 5]); B:= (B shl 30) or (B shr 2);
|
||||
Inc(D,((E shl 5) or (E shr 27)) + (C xor (A and (B xor C))) + $5A827999 + W[ 6]); A:= (A shl 30) or (A shr 2);
|
||||
Inc(C,((D shl 5) or (D shr 27)) + (B xor (E and (A xor B))) + $5A827999 + W[ 7]); E:= (E shl 30) or (E shr 2);
|
||||
Inc(B,((C shl 5) or (C shr 27)) + (A xor (D and (E xor A))) + $5A827999 + W[ 8]); D:= (D shl 30) or (D shr 2);
|
||||
Inc(A,((B shl 5) or (B shr 27)) + (E xor (C and (D xor E))) + $5A827999 + W[ 9]); C:= (C shl 30) or (C shr 2);
|
||||
Inc(E,((A shl 5) or (A shr 27)) + (D xor (B and (C xor D))) + $5A827999 + W[10]); B:= (B shl 30) or (B shr 2);
|
||||
Inc(D,((E shl 5) or (E shr 27)) + (C xor (A and (B xor C))) + $5A827999 + W[11]); A:= (A shl 30) or (A shr 2);
|
||||
Inc(C,((D shl 5) or (D shr 27)) + (B xor (E and (A xor B))) + $5A827999 + W[12]); E:= (E shl 30) or (E shr 2);
|
||||
Inc(B,((C shl 5) or (C shr 27)) + (A xor (D and (E xor A))) + $5A827999 + W[13]); D:= (D shl 30) or (D shr 2);
|
||||
Inc(A,((B shl 5) or (B shr 27)) + (E xor (C and (D xor E))) + $5A827999 + W[14]); C:= (C shl 30) or (C shr 2);
|
||||
Inc(E,((A shl 5) or (A shr 27)) + (D xor (B and (C xor D))) + $5A827999 + W[15]); B:= (B shl 30) or (B shr 2);
|
||||
Inc(D,((E shl 5) or (E shr 27)) + (C xor (A and (B xor C))) + $5A827999 + W[16]); A:= (A shl 30) or (A shr 2);
|
||||
Inc(C,((D shl 5) or (D shr 27)) + (B xor (E and (A xor B))) + $5A827999 + W[17]); E:= (E shl 30) or (E shr 2);
|
||||
Inc(B,((C shl 5) or (C shr 27)) + (A xor (D and (E xor A))) + $5A827999 + W[18]); D:= (D shl 30) or (D shr 2);
|
||||
Inc(A,((B shl 5) or (B shr 27)) + (E xor (C and (D xor E))) + $5A827999 + W[19]); C:= (C shl 30) or (C shr 2);
|
||||
|
||||
Inc(E,((A shl 5) or (A shr 27)) + (B xor C xor D) + $6ED9EBA1 + W[20]); B:= (B shl 30) or (B shr 2);
|
||||
Inc(D,((E shl 5) or (E shr 27)) + (A xor B xor C) + $6ED9EBA1 + W[21]); A:= (A shl 30) or (A shr 2);
|
||||
Inc(C,((D shl 5) or (D shr 27)) + (E xor A xor B) + $6ED9EBA1 + W[22]); E:= (E shl 30) or (E shr 2);
|
||||
Inc(B,((C shl 5) or (C shr 27)) + (D xor E xor A) + $6ED9EBA1 + W[23]); D:= (D shl 30) or (D shr 2);
|
||||
Inc(A,((B shl 5) or (B shr 27)) + (C xor D xor E) + $6ED9EBA1 + W[24]); C:= (C shl 30) or (C shr 2);
|
||||
Inc(E,((A shl 5) or (A shr 27)) + (B xor C xor D) + $6ED9EBA1 + W[25]); B:= (B shl 30) or (B shr 2);
|
||||
Inc(D,((E shl 5) or (E shr 27)) + (A xor B xor C) + $6ED9EBA1 + W[26]); A:= (A shl 30) or (A shr 2);
|
||||
Inc(C,((D shl 5) or (D shr 27)) + (E xor A xor B) + $6ED9EBA1 + W[27]); E:= (E shl 30) or (E shr 2);
|
||||
Inc(B,((C shl 5) or (C shr 27)) + (D xor E xor A) + $6ED9EBA1 + W[28]); D:= (D shl 30) or (D shr 2);
|
||||
Inc(A,((B shl 5) or (B shr 27)) + (C xor D xor E) + $6ED9EBA1 + W[29]); C:= (C shl 30) or (C shr 2);
|
||||
Inc(E,((A shl 5) or (A shr 27)) + (B xor C xor D) + $6ED9EBA1 + W[30]); B:= (B shl 30) or (B shr 2);
|
||||
Inc(D,((E shl 5) or (E shr 27)) + (A xor B xor C) + $6ED9EBA1 + W[31]); A:= (A shl 30) or (A shr 2);
|
||||
Inc(C,((D shl 5) or (D shr 27)) + (E xor A xor B) + $6ED9EBA1 + W[32]); E:= (E shl 30) or (E shr 2);
|
||||
Inc(B,((C shl 5) or (C shr 27)) + (D xor E xor A) + $6ED9EBA1 + W[33]); D:= (D shl 30) or (D shr 2);
|
||||
Inc(A,((B shl 5) or (B shr 27)) + (C xor D xor E) + $6ED9EBA1 + W[34]); C:= (C shl 30) or (C shr 2);
|
||||
Inc(E,((A shl 5) or (A shr 27)) + (B xor C xor D) + $6ED9EBA1 + W[35]); B:= (B shl 30) or (B shr 2);
|
||||
Inc(D,((E shl 5) or (E shr 27)) + (A xor B xor C) + $6ED9EBA1 + W[36]); A:= (A shl 30) or (A shr 2);
|
||||
Inc(C,((D shl 5) or (D shr 27)) + (E xor A xor B) + $6ED9EBA1 + W[37]); E:= (E shl 30) or (E shr 2);
|
||||
Inc(B,((C shl 5) or (C shr 27)) + (D xor E xor A) + $6ED9EBA1 + W[38]); D:= (D shl 30) or (D shr 2);
|
||||
Inc(A,((B shl 5) or (B shr 27)) + (C xor D xor E) + $6ED9EBA1 + W[39]); C:= (C shl 30) or (C shr 2);
|
||||
|
||||
Inc(E,((A shl 5) or (A shr 27)) + ((B and C) or (D and (B or C))) + $8F1BBCDC + W[40]); B:= (B shl 30) or (B shr 2);
|
||||
Inc(D,((E shl 5) or (E shr 27)) + ((A and B) or (C and (A or B))) + $8F1BBCDC + W[41]); A:= (A shl 30) or (A shr 2);
|
||||
Inc(C,((D shl 5) or (D shr 27)) + ((E and A) or (B and (E or A))) + $8F1BBCDC + W[42]); E:= (E shl 30) or (E shr 2);
|
||||
Inc(B,((C shl 5) or (C shr 27)) + ((D and E) or (A and (D or E))) + $8F1BBCDC + W[43]); D:= (D shl 30) or (D shr 2);
|
||||
Inc(A,((B shl 5) or (B shr 27)) + ((C and D) or (E and (C or D))) + $8F1BBCDC + W[44]); C:= (C shl 30) or (C shr 2);
|
||||
Inc(E,((A shl 5) or (A shr 27)) + ((B and C) or (D and (B or C))) + $8F1BBCDC + W[45]); B:= (B shl 30) or (B shr 2);
|
||||
Inc(D,((E shl 5) or (E shr 27)) + ((A and B) or (C and (A or B))) + $8F1BBCDC + W[46]); A:= (A shl 30) or (A shr 2);
|
||||
Inc(C,((D shl 5) or (D shr 27)) + ((E and A) or (B and (E or A))) + $8F1BBCDC + W[47]); E:= (E shl 30) or (E shr 2);
|
||||
Inc(B,((C shl 5) or (C shr 27)) + ((D and E) or (A and (D or E))) + $8F1BBCDC + W[48]); D:= (D shl 30) or (D shr 2);
|
||||
Inc(A,((B shl 5) or (B shr 27)) + ((C and D) or (E and (C or D))) + $8F1BBCDC + W[49]); C:= (C shl 30) or (C shr 2);
|
||||
Inc(E,((A shl 5) or (A shr 27)) + ((B and C) or (D and (B or C))) + $8F1BBCDC + W[50]); B:= (B shl 30) or (B shr 2);
|
||||
Inc(D,((E shl 5) or (E shr 27)) + ((A and B) or (C and (A or B))) + $8F1BBCDC + W[51]); A:= (A shl 30) or (A shr 2);
|
||||
Inc(C,((D shl 5) or (D shr 27)) + ((E and A) or (B and (E or A))) + $8F1BBCDC + W[52]); E:= (E shl 30) or (E shr 2);
|
||||
Inc(B,((C shl 5) or (C shr 27)) + ((D and E) or (A and (D or E))) + $8F1BBCDC + W[53]); D:= (D shl 30) or (D shr 2);
|
||||
Inc(A,((B shl 5) or (B shr 27)) + ((C and D) or (E and (C or D))) + $8F1BBCDC + W[54]); C:= (C shl 30) or (C shr 2);
|
||||
Inc(E,((A shl 5) or (A shr 27)) + ((B and C) or (D and (B or C))) + $8F1BBCDC + W[55]); B:= (B shl 30) or (B shr 2);
|
||||
Inc(D,((E shl 5) or (E shr 27)) + ((A and B) or (C and (A or B))) + $8F1BBCDC + W[56]); A:= (A shl 30) or (A shr 2);
|
||||
Inc(C,((D shl 5) or (D shr 27)) + ((E and A) or (B and (E or A))) + $8F1BBCDC + W[57]); E:= (E shl 30) or (E shr 2);
|
||||
Inc(B,((C shl 5) or (C shr 27)) + ((D and E) or (A and (D or E))) + $8F1BBCDC + W[58]); D:= (D shl 30) or (D shr 2);
|
||||
Inc(A,((B shl 5) or (B shr 27)) + ((C and D) or (E and (C or D))) + $8F1BBCDC + W[59]); C:= (C shl 30) or (C shr 2);
|
||||
|
||||
Inc(E,((A shl 5) or (A shr 27)) + (B xor C xor D) + $CA62C1D6 + W[60]); B:= (B shl 30) or (B shr 2);
|
||||
Inc(D,((E shl 5) or (E shr 27)) + (A xor B xor C) + $CA62C1D6 + W[61]); A:= (A shl 30) or (A shr 2);
|
||||
Inc(C,((D shl 5) or (D shr 27)) + (E xor A xor B) + $CA62C1D6 + W[62]); E:= (E shl 30) or (E shr 2);
|
||||
Inc(B,((C shl 5) or (C shr 27)) + (D xor E xor A) + $CA62C1D6 + W[63]); D:= (D shl 30) or (D shr 2);
|
||||
Inc(A,((B shl 5) or (B shr 27)) + (C xor D xor E) + $CA62C1D6 + W[64]); C:= (C shl 30) or (C shr 2);
|
||||
Inc(E,((A shl 5) or (A shr 27)) + (B xor C xor D) + $CA62C1D6 + W[65]); B:= (B shl 30) or (B shr 2);
|
||||
Inc(D,((E shl 5) or (E shr 27)) + (A xor B xor C) + $CA62C1D6 + W[66]); A:= (A shl 30) or (A shr 2);
|
||||
Inc(C,((D shl 5) or (D shr 27)) + (E xor A xor B) + $CA62C1D6 + W[67]); E:= (E shl 30) or (E shr 2);
|
||||
Inc(B,((C shl 5) or (C shr 27)) + (D xor E xor A) + $CA62C1D6 + W[68]); D:= (D shl 30) or (D shr 2);
|
||||
Inc(A,((B shl 5) or (B shr 27)) + (C xor D xor E) + $CA62C1D6 + W[69]); C:= (C shl 30) or (C shr 2);
|
||||
Inc(E,((A shl 5) or (A shr 27)) + (B xor C xor D) + $CA62C1D6 + W[70]); B:= (B shl 30) or (B shr 2);
|
||||
Inc(D,((E shl 5) or (E shr 27)) + (A xor B xor C) + $CA62C1D6 + W[71]); A:= (A shl 30) or (A shr 2);
|
||||
Inc(C,((D shl 5) or (D shr 27)) + (E xor A xor B) + $CA62C1D6 + W[72]); E:= (E shl 30) or (E shr 2);
|
||||
Inc(B,((C shl 5) or (C shr 27)) + (D xor E xor A) + $CA62C1D6 + W[73]); D:= (D shl 30) or (D shr 2);
|
||||
Inc(A,((B shl 5) or (B shr 27)) + (C xor D xor E) + $CA62C1D6 + W[74]); C:= (C shl 30) or (C shr 2);
|
||||
Inc(E,((A shl 5) or (A shr 27)) + (B xor C xor D) + $CA62C1D6 + W[75]); B:= (B shl 30) or (B shr 2);
|
||||
Inc(D,((E shl 5) or (E shr 27)) + (A xor B xor C) + $CA62C1D6 + W[76]); A:= (A shl 30) or (A shr 2);
|
||||
Inc(C,((D shl 5) or (D shr 27)) + (E xor A xor B) + $CA62C1D6 + W[77]); E:= (E shl 30) or (E shr 2);
|
||||
Inc(B,((C shl 5) or (C shr 27)) + (D xor E xor A) + $CA62C1D6 + W[78]); D:= (D shl 30) or (D shr 2);
|
||||
Inc(A,((B shl 5) or (B shr 27)) + (C xor D xor E) + $CA62C1D6 + W[79]); C:= (C shl 30) or (C shr 2);
|
||||
|
||||
CurrentHash[0]:= CurrentHash[0] + A;
|
||||
CurrentHash[1]:= CurrentHash[1] + B;
|
||||
CurrentHash[2]:= CurrentHash[2] + C;
|
||||
CurrentHash[3]:= CurrentHash[3] + D;
|
||||
CurrentHash[4]:= CurrentHash[4] + E;
|
||||
FillChar(W,Sizeof(W),0);
|
||||
FillChar(HashBuffer,Sizeof(HashBuffer),0);
|
||||
end;
|
||||
|
||||
class function TDCP_sha1.GetAlgorithm: string;
|
||||
begin
|
||||
Result:= 'SHA1';
|
||||
end;
|
||||
|
||||
class function TDCP_sha1.GetId: integer;
|
||||
begin
|
||||
Result:= DCP_sha1;
|
||||
end;
|
||||
|
||||
class function TDCP_sha1.GetHashSize: integer;
|
||||
begin
|
||||
Result:= 160;
|
||||
end;
|
||||
|
||||
class function TDCP_sha1.SelfTest: boolean;
|
||||
const
|
||||
Test1Out: array[0..19] of byte=
|
||||
($A9,$99,$3E,$36,$47,$06,$81,$6A,$BA,$3E,$25,$71,$78,$50,$C2,$6C,$9C,$D0,$D8,$9D);
|
||||
Test2Out: array[0..19] of byte=
|
||||
($84,$98,$3E,$44,$1C,$3B,$D2,$6E,$BA,$AE,$4A,$A1,$F9,$51,$29,$E5,$E5,$46,$70,$F1);
|
||||
var
|
||||
TestHash: TDCP_sha1;
|
||||
TestOut: array[0..19] of byte;
|
||||
begin
|
||||
dcpFillChar(TestOut, SizeOf(TestOut), 0);
|
||||
TestHash:= TDCP_sha1.Create(nil);
|
||||
TestHash.Init;
|
||||
TestHash.UpdateStr('abc');
|
||||
TestHash.Final(TestOut);
|
||||
Result:= boolean(CompareMem(@TestOut,@Test1Out,Sizeof(Test1Out)));
|
||||
TestHash.Init;
|
||||
TestHash.UpdateStr('abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq');
|
||||
TestHash.Final(TestOut);
|
||||
Result:= boolean(CompareMem(@TestOut,@Test2Out,Sizeof(Test2Out))) and Result;
|
||||
TestHash.Free;
|
||||
end;
|
||||
|
||||
procedure TDCP_sha1.Init;
|
||||
begin
|
||||
Burn;
|
||||
CurrentHash[0]:= $67452301;
|
||||
CurrentHash[1]:= $EFCDAB89;
|
||||
CurrentHash[2]:= $98BADCFE;
|
||||
CurrentHash[3]:= $10325476;
|
||||
CurrentHash[4]:= $C3D2E1F0;
|
||||
fInitialized:= true;
|
||||
end;
|
||||
|
||||
procedure TDCP_sha1.Burn;
|
||||
begin
|
||||
LenHi:= 0; LenLo:= 0;
|
||||
Index:= 0;
|
||||
FillChar(HashBuffer,Sizeof(HashBuffer),0);
|
||||
FillChar(CurrentHash,Sizeof(CurrentHash),0);
|
||||
fInitialized:= false;
|
||||
end;
|
||||
|
||||
procedure TDCP_sha1.Update(const Buffer; Size: longword);
|
||||
var
|
||||
PBuf: ^byte;
|
||||
begin
|
||||
if not fInitialized then
|
||||
raise EDCP_hash.Create('Hash not initialized');
|
||||
|
||||
Inc(LenHi,Size shr 29);
|
||||
Inc(LenLo,Size*8);
|
||||
if LenLo< (Size*8) then
|
||||
Inc(LenHi);
|
||||
|
||||
PBuf:= @Buffer;
|
||||
while Size> 0 do
|
||||
begin
|
||||
if (Sizeof(HashBuffer)-Index)<= DWord(Size) then
|
||||
begin
|
||||
Move(PBuf^,HashBuffer[Index],Sizeof(HashBuffer)-Index);
|
||||
Dec(Size,Sizeof(HashBuffer)-Index);
|
||||
Inc(PBuf,Sizeof(HashBuffer)-Index);
|
||||
Compress;
|
||||
end
|
||||
else
|
||||
begin
|
||||
Move(PBuf^,HashBuffer[Index],Size);
|
||||
Inc(Index,Size);
|
||||
Size:= 0;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TDCP_sha1.Final(var Digest);
|
||||
begin
|
||||
if not fInitialized then
|
||||
raise EDCP_hash.Create('Hash not initialized');
|
||||
HashBuffer[Index]:= $80;
|
||||
if Index>= 56 then
|
||||
Compress;
|
||||
PDWord(@HashBuffer[56])^:= SwapDWord(LenHi);
|
||||
PDWord(@HashBuffer[60])^:= SwapDWord(LenLo);
|
||||
Compress;
|
||||
CurrentHash[0]:= SwapDWord(CurrentHash[0]);
|
||||
CurrentHash[1]:= SwapDWord(CurrentHash[1]);
|
||||
CurrentHash[2]:= SwapDWord(CurrentHash[2]);
|
||||
CurrentHash[3]:= SwapDWord(CurrentHash[3]);
|
||||
CurrentHash[4]:= SwapDWord(CurrentHash[4]);
|
||||
Move(CurrentHash,Digest,Sizeof(CurrentHash));
|
||||
Burn;
|
||||
end;
|
||||
|
||||
end.
|
||||
284
dcpcrypt/Hashes/dcpsha256.pas
Normal file
@@ -0,0 +1,284 @@
|
||||
{******************************************************************************}
|
||||
{* DCPcrypt v2.0 written by David Barton (crypto@cityinthesky.co.uk) **********}
|
||||
{******************************************************************************}
|
||||
{* A binary compatible implementation of SHA256 *******************************}
|
||||
{******************************************************************************}
|
||||
{* Copyright (c) 1999-2002 David Barton *}
|
||||
{* Permission is hereby granted, free of charge, to any person obtaining a *}
|
||||
{* copy of this software and associated documentation files (the "Software"), *}
|
||||
{* to deal in the Software without restriction, including without limitation *}
|
||||
{* the rights to use, copy, modify, merge, publish, distribute, sublicense, *}
|
||||
{* and/or sell copies of the Software, and to permit persons to whom the *}
|
||||
{* Software is furnished to do so, subject to the following conditions: *}
|
||||
{* *}
|
||||
{* The above copyright notice and this permission notice shall be included in *}
|
||||
{* all copies or substantial portions of the Software. *}
|
||||
{* *}
|
||||
{* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *}
|
||||
{* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *}
|
||||
{* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *}
|
||||
{* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *}
|
||||
{* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *}
|
||||
{* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *}
|
||||
{* DEALINGS IN THE SOFTWARE. *}
|
||||
{******************************************************************************}
|
||||
unit DCPsha256;
|
||||
|
||||
{$MODE Delphi}
|
||||
|
||||
interface
|
||||
uses
|
||||
Classes, Sysutils, DCPcrypt2, DCPconst;
|
||||
|
||||
type
|
||||
TDCP_sha256= class(TDCP_hash)
|
||||
protected
|
||||
LenHi, LenLo: longword;
|
||||
Index: DWord;
|
||||
CurrentHash: array[0..7] of DWord;
|
||||
HashBuffer: array[0..63] of byte;
|
||||
procedure Compress;
|
||||
public
|
||||
class function GetId: integer; override;
|
||||
class function GetAlgorithm: string; override;
|
||||
class function GetHashSize: integer; override;
|
||||
class function SelfTest: boolean; override;
|
||||
procedure Init; override;
|
||||
procedure Final(var Digest); override;
|
||||
procedure Burn; override;
|
||||
procedure Update(const Buffer; Size: longword); override;
|
||||
end;
|
||||
|
||||
{******************************************************************************}
|
||||
{******************************************************************************}
|
||||
implementation
|
||||
{$R-}{$Q-}
|
||||
|
||||
function SwapDWord(a: dword): dword;
|
||||
begin
|
||||
Result:= ((a and $FF) shl 24) or ((a and $FF00) shl 8) or ((a and $FF0000) shr 8) or ((a and $FF000000) shr 24);
|
||||
end;
|
||||
|
||||
procedure TDCP_sha256.Compress;
|
||||
var
|
||||
a, b, c, d, e, f, g, h, t1, t2: DWord;
|
||||
W: array[0..63] of DWord;
|
||||
i: longword;
|
||||
begin
|
||||
Index:= 0;
|
||||
dcpFillChar(W, SizeOf(W), 0);
|
||||
a:= CurrentHash[0]; b:= CurrentHash[1]; c:= CurrentHash[2]; d:= CurrentHash[3];
|
||||
e:= CurrentHash[4]; f:= CurrentHash[5]; g:= CurrentHash[6]; h:= CurrentHash[7];
|
||||
Move(HashBuffer,W,Sizeof(HashBuffer));
|
||||
for i:= 0 to 15 do
|
||||
W[i]:= SwapDWord(W[i]);
|
||||
for i:= 16 to 63 do
|
||||
W[i]:= (((W[i-2] shr 17) or (W[i-2] shl 15)) xor ((W[i-2] shr 19) or (W[i-2] shl 13)) xor
|
||||
(W[i-2] shr 10)) + W[i-7] + (((W[i-15] shr 7) or (W[i-15] shl 25)) xor
|
||||
((W[i-15] shr 18) or (W[i-15] shl 14)) xor (W[i-15] shr 3)) + W[i-16];
|
||||
{
|
||||
Non-optimised version
|
||||
for i:= 0 to 63 do
|
||||
begin
|
||||
t1:= h + (((e shr 6) or (e shl 26)) xor ((e shr 11) or (e shl 21)) xor ((e shr 25) or (e shl 7))) +
|
||||
((e and f) xor (not e and g)) + K[i] + W[i];
|
||||
t2:= (((a shr 2) or (a shl 30)) xor ((a shr 13) or (a shl 19)) xor ((a shr 22) xor (a shl 10))) +
|
||||
((a and b) xor (a and c) xor (b and c));
|
||||
h:= g; g:= f; f:= e; e:= d + t1; d:= c; c:= b; b:= a; a:= t1 + t2;
|
||||
end;
|
||||
}
|
||||
|
||||
t1:= h + (((e shr 6) or (e shl 26)) xor ((e shr 11) or (e shl 21)) xor ((e shr 25) or (e shl 7))) + ((e and f) xor (not e and g)) + $428a2f98 + W[0]; t2:= (((a shr 2) or (a shl 30)) xor ((a shr 13) or (a shl 19)) xor ((a shr 22) xor (a shl 10))) + ((a and b) xor (a and c) xor (b and c)); h:= t1 + t2; d:= d + t1;
|
||||
t1:= g + (((d shr 6) or (d shl 26)) xor ((d shr 11) or (d shl 21)) xor ((d shr 25) or (d shl 7))) + ((d and e) xor (not d and f)) + $71374491 + W[1]; t2:= (((h shr 2) or (h shl 30)) xor ((h shr 13) or (h shl 19)) xor ((h shr 22) xor (h shl 10))) + ((h and a) xor (h and b) xor (a and b)); g:= t1 + t2; c:= c + t1;
|
||||
t1:= f + (((c shr 6) or (c shl 26)) xor ((c shr 11) or (c shl 21)) xor ((c shr 25) or (c shl 7))) + ((c and d) xor (not c and e)) + $b5c0fbcf + W[2]; t2:= (((g shr 2) or (g shl 30)) xor ((g shr 13) or (g shl 19)) xor ((g shr 22) xor (g shl 10))) + ((g and h) xor (g and a) xor (h and a)); f:= t1 + t2; b:= b + t1;
|
||||
t1:= e + (((b shr 6) or (b shl 26)) xor ((b shr 11) or (b shl 21)) xor ((b shr 25) or (b shl 7))) + ((b and c) xor (not b and d)) + $e9b5dba5 + W[3]; t2:= (((f shr 2) or (f shl 30)) xor ((f shr 13) or (f shl 19)) xor ((f shr 22) xor (f shl 10))) + ((f and g) xor (f and h) xor (g and h)); e:= t1 + t2; a:= a + t1;
|
||||
t1:= d + (((a shr 6) or (a shl 26)) xor ((a shr 11) or (a shl 21)) xor ((a shr 25) or (a shl 7))) + ((a and b) xor (not a and c)) + $3956c25b + W[4]; t2:= (((e shr 2) or (e shl 30)) xor ((e shr 13) or (e shl 19)) xor ((e shr 22) xor (e shl 10))) + ((e and f) xor (e and g) xor (f and g)); d:= t1 + t2; h:= h + t1;
|
||||
t1:= c + (((h shr 6) or (h shl 26)) xor ((h shr 11) or (h shl 21)) xor ((h shr 25) or (h shl 7))) + ((h and a) xor (not h and b)) + $59f111f1 + W[5]; t2:= (((d shr 2) or (d shl 30)) xor ((d shr 13) or (d shl 19)) xor ((d shr 22) xor (d shl 10))) + ((d and e) xor (d and f) xor (e and f)); c:= t1 + t2; g:= g + t1;
|
||||
t1:= b + (((g shr 6) or (g shl 26)) xor ((g shr 11) or (g shl 21)) xor ((g shr 25) or (g shl 7))) + ((g and h) xor (not g and a)) + $923f82a4 + W[6]; t2:= (((c shr 2) or (c shl 30)) xor ((c shr 13) or (c shl 19)) xor ((c shr 22) xor (c shl 10))) + ((c and d) xor (c and e) xor (d and e)); b:= t1 + t2; f:= f + t1;
|
||||
t1:= a + (((f shr 6) or (f shl 26)) xor ((f shr 11) or (f shl 21)) xor ((f shr 25) or (f shl 7))) + ((f and g) xor (not f and h)) + $ab1c5ed5 + W[7]; t2:= (((b shr 2) or (b shl 30)) xor ((b shr 13) or (b shl 19)) xor ((b shr 22) xor (b shl 10))) + ((b and c) xor (b and d) xor (c and d)); a:= t1 + t2; e:= e + t1;
|
||||
t1:= h + (((e shr 6) or (e shl 26)) xor ((e shr 11) or (e shl 21)) xor ((e shr 25) or (e shl 7))) + ((e and f) xor (not e and g)) + $d807aa98 + W[8]; t2:= (((a shr 2) or (a shl 30)) xor ((a shr 13) or (a shl 19)) xor ((a shr 22) xor (a shl 10))) + ((a and b) xor (a and c) xor (b and c)); h:= t1 + t2; d:= d + t1;
|
||||
t1:= g + (((d shr 6) or (d shl 26)) xor ((d shr 11) or (d shl 21)) xor ((d shr 25) or (d shl 7))) + ((d and e) xor (not d and f)) + $12835b01 + W[9]; t2:= (((h shr 2) or (h shl 30)) xor ((h shr 13) or (h shl 19)) xor ((h shr 22) xor (h shl 10))) + ((h and a) xor (h and b) xor (a and b)); g:= t1 + t2; c:= c + t1;
|
||||
t1:= f + (((c shr 6) or (c shl 26)) xor ((c shr 11) or (c shl 21)) xor ((c shr 25) or (c shl 7))) + ((c and d) xor (not c and e)) + $243185be + W[10]; t2:= (((g shr 2) or (g shl 30)) xor ((g shr 13) or (g shl 19)) xor ((g shr 22) xor (g shl 10))) + ((g and h) xor (g and a) xor (h and a)); f:= t1 + t2; b:= b + t1;
|
||||
t1:= e + (((b shr 6) or (b shl 26)) xor ((b shr 11) or (b shl 21)) xor ((b shr 25) or (b shl 7))) + ((b and c) xor (not b and d)) + $550c7dc3 + W[11]; t2:= (((f shr 2) or (f shl 30)) xor ((f shr 13) or (f shl 19)) xor ((f shr 22) xor (f shl 10))) + ((f and g) xor (f and h) xor (g and h)); e:= t1 + t2; a:= a + t1;
|
||||
t1:= d + (((a shr 6) or (a shl 26)) xor ((a shr 11) or (a shl 21)) xor ((a shr 25) or (a shl 7))) + ((a and b) xor (not a and c)) + $72be5d74 + W[12]; t2:= (((e shr 2) or (e shl 30)) xor ((e shr 13) or (e shl 19)) xor ((e shr 22) xor (e shl 10))) + ((e and f) xor (e and g) xor (f and g)); d:= t1 + t2; h:= h + t1;
|
||||
t1:= c + (((h shr 6) or (h shl 26)) xor ((h shr 11) or (h shl 21)) xor ((h shr 25) or (h shl 7))) + ((h and a) xor (not h and b)) + $80deb1fe + W[13]; t2:= (((d shr 2) or (d shl 30)) xor ((d shr 13) or (d shl 19)) xor ((d shr 22) xor (d shl 10))) + ((d and e) xor (d and f) xor (e and f)); c:= t1 + t2; g:= g + t1;
|
||||
t1:= b + (((g shr 6) or (g shl 26)) xor ((g shr 11) or (g shl 21)) xor ((g shr 25) or (g shl 7))) + ((g and h) xor (not g and a)) + $9bdc06a7 + W[14]; t2:= (((c shr 2) or (c shl 30)) xor ((c shr 13) or (c shl 19)) xor ((c shr 22) xor (c shl 10))) + ((c and d) xor (c and e) xor (d and e)); b:= t1 + t2; f:= f + t1;
|
||||
t1:= a + (((f shr 6) or (f shl 26)) xor ((f shr 11) or (f shl 21)) xor ((f shr 25) or (f shl 7))) + ((f and g) xor (not f and h)) + $c19bf174 + W[15]; t2:= (((b shr 2) or (b shl 30)) xor ((b shr 13) or (b shl 19)) xor ((b shr 22) xor (b shl 10))) + ((b and c) xor (b and d) xor (c and d)); a:= t1 + t2; e:= e + t1;
|
||||
t1:= h + (((e shr 6) or (e shl 26)) xor ((e shr 11) or (e shl 21)) xor ((e shr 25) or (e shl 7))) + ((e and f) xor (not e and g)) + $e49b69c1 + W[16]; t2:= (((a shr 2) or (a shl 30)) xor ((a shr 13) or (a shl 19)) xor ((a shr 22) xor (a shl 10))) + ((a and b) xor (a and c) xor (b and c)); h:= t1 + t2; d:= d + t1;
|
||||
t1:= g + (((d shr 6) or (d shl 26)) xor ((d shr 11) or (d shl 21)) xor ((d shr 25) or (d shl 7))) + ((d and e) xor (not d and f)) + $efbe4786 + W[17]; t2:= (((h shr 2) or (h shl 30)) xor ((h shr 13) or (h shl 19)) xor ((h shr 22) xor (h shl 10))) + ((h and a) xor (h and b) xor (a and b)); g:= t1 + t2; c:= c + t1;
|
||||
t1:= f + (((c shr 6) or (c shl 26)) xor ((c shr 11) or (c shl 21)) xor ((c shr 25) or (c shl 7))) + ((c and d) xor (not c and e)) + $0fc19dc6 + W[18]; t2:= (((g shr 2) or (g shl 30)) xor ((g shr 13) or (g shl 19)) xor ((g shr 22) xor (g shl 10))) + ((g and h) xor (g and a) xor (h and a)); f:= t1 + t2; b:= b + t1;
|
||||
t1:= e + (((b shr 6) or (b shl 26)) xor ((b shr 11) or (b shl 21)) xor ((b shr 25) or (b shl 7))) + ((b and c) xor (not b and d)) + $240ca1cc + W[19]; t2:= (((f shr 2) or (f shl 30)) xor ((f shr 13) or (f shl 19)) xor ((f shr 22) xor (f shl 10))) + ((f and g) xor (f and h) xor (g and h)); e:= t1 + t2; a:= a + t1;
|
||||
t1:= d + (((a shr 6) or (a shl 26)) xor ((a shr 11) or (a shl 21)) xor ((a shr 25) or (a shl 7))) + ((a and b) xor (not a and c)) + $2de92c6f + W[20]; t2:= (((e shr 2) or (e shl 30)) xor ((e shr 13) or (e shl 19)) xor ((e shr 22) xor (e shl 10))) + ((e and f) xor (e and g) xor (f and g)); d:= t1 + t2; h:= h + t1;
|
||||
t1:= c + (((h shr 6) or (h shl 26)) xor ((h shr 11) or (h shl 21)) xor ((h shr 25) or (h shl 7))) + ((h and a) xor (not h and b)) + $4a7484aa + W[21]; t2:= (((d shr 2) or (d shl 30)) xor ((d shr 13) or (d shl 19)) xor ((d shr 22) xor (d shl 10))) + ((d and e) xor (d and f) xor (e and f)); c:= t1 + t2; g:= g + t1;
|
||||
t1:= b + (((g shr 6) or (g shl 26)) xor ((g shr 11) or (g shl 21)) xor ((g shr 25) or (g shl 7))) + ((g and h) xor (not g and a)) + $5cb0a9dc + W[22]; t2:= (((c shr 2) or (c shl 30)) xor ((c shr 13) or (c shl 19)) xor ((c shr 22) xor (c shl 10))) + ((c and d) xor (c and e) xor (d and e)); b:= t1 + t2; f:= f + t1;
|
||||
t1:= a + (((f shr 6) or (f shl 26)) xor ((f shr 11) or (f shl 21)) xor ((f shr 25) or (f shl 7))) + ((f and g) xor (not f and h)) + $76f988da + W[23]; t2:= (((b shr 2) or (b shl 30)) xor ((b shr 13) or (b shl 19)) xor ((b shr 22) xor (b shl 10))) + ((b and c) xor (b and d) xor (c and d)); a:= t1 + t2; e:= e + t1;
|
||||
t1:= h + (((e shr 6) or (e shl 26)) xor ((e shr 11) or (e shl 21)) xor ((e shr 25) or (e shl 7))) + ((e and f) xor (not e and g)) + $983e5152 + W[24]; t2:= (((a shr 2) or (a shl 30)) xor ((a shr 13) or (a shl 19)) xor ((a shr 22) xor (a shl 10))) + ((a and b) xor (a and c) xor (b and c)); h:= t1 + t2; d:= d + t1;
|
||||
t1:= g + (((d shr 6) or (d shl 26)) xor ((d shr 11) or (d shl 21)) xor ((d shr 25) or (d shl 7))) + ((d and e) xor (not d and f)) + $a831c66d + W[25]; t2:= (((h shr 2) or (h shl 30)) xor ((h shr 13) or (h shl 19)) xor ((h shr 22) xor (h shl 10))) + ((h and a) xor (h and b) xor (a and b)); g:= t1 + t2; c:= c + t1;
|
||||
t1:= f + (((c shr 6) or (c shl 26)) xor ((c shr 11) or (c shl 21)) xor ((c shr 25) or (c shl 7))) + ((c and d) xor (not c and e)) + $b00327c8 + W[26]; t2:= (((g shr 2) or (g shl 30)) xor ((g shr 13) or (g shl 19)) xor ((g shr 22) xor (g shl 10))) + ((g and h) xor (g and a) xor (h and a)); f:= t1 + t2; b:= b + t1;
|
||||
t1:= e + (((b shr 6) or (b shl 26)) xor ((b shr 11) or (b shl 21)) xor ((b shr 25) or (b shl 7))) + ((b and c) xor (not b and d)) + $bf597fc7 + W[27]; t2:= (((f shr 2) or (f shl 30)) xor ((f shr 13) or (f shl 19)) xor ((f shr 22) xor (f shl 10))) + ((f and g) xor (f and h) xor (g and h)); e:= t1 + t2; a:= a + t1;
|
||||
t1:= d + (((a shr 6) or (a shl 26)) xor ((a shr 11) or (a shl 21)) xor ((a shr 25) or (a shl 7))) + ((a and b) xor (not a and c)) + $c6e00bf3 + W[28]; t2:= (((e shr 2) or (e shl 30)) xor ((e shr 13) or (e shl 19)) xor ((e shr 22) xor (e shl 10))) + ((e and f) xor (e and g) xor (f and g)); d:= t1 + t2; h:= h + t1;
|
||||
t1:= c + (((h shr 6) or (h shl 26)) xor ((h shr 11) or (h shl 21)) xor ((h shr 25) or (h shl 7))) + ((h and a) xor (not h and b)) + $d5a79147 + W[29]; t2:= (((d shr 2) or (d shl 30)) xor ((d shr 13) or (d shl 19)) xor ((d shr 22) xor (d shl 10))) + ((d and e) xor (d and f) xor (e and f)); c:= t1 + t2; g:= g + t1;
|
||||
t1:= b + (((g shr 6) or (g shl 26)) xor ((g shr 11) or (g shl 21)) xor ((g shr 25) or (g shl 7))) + ((g and h) xor (not g and a)) + $06ca6351 + W[30]; t2:= (((c shr 2) or (c shl 30)) xor ((c shr 13) or (c shl 19)) xor ((c shr 22) xor (c shl 10))) + ((c and d) xor (c and e) xor (d and e)); b:= t1 + t2; f:= f + t1;
|
||||
t1:= a + (((f shr 6) or (f shl 26)) xor ((f shr 11) or (f shl 21)) xor ((f shr 25) or (f shl 7))) + ((f and g) xor (not f and h)) + $14292967 + W[31]; t2:= (((b shr 2) or (b shl 30)) xor ((b shr 13) or (b shl 19)) xor ((b shr 22) xor (b shl 10))) + ((b and c) xor (b and d) xor (c and d)); a:= t1 + t2; e:= e + t1;
|
||||
t1:= h + (((e shr 6) or (e shl 26)) xor ((e shr 11) or (e shl 21)) xor ((e shr 25) or (e shl 7))) + ((e and f) xor (not e and g)) + $27b70a85 + W[32]; t2:= (((a shr 2) or (a shl 30)) xor ((a shr 13) or (a shl 19)) xor ((a shr 22) xor (a shl 10))) + ((a and b) xor (a and c) xor (b and c)); h:= t1 + t2; d:= d + t1;
|
||||
t1:= g + (((d shr 6) or (d shl 26)) xor ((d shr 11) or (d shl 21)) xor ((d shr 25) or (d shl 7))) + ((d and e) xor (not d and f)) + $2e1b2138 + W[33]; t2:= (((h shr 2) or (h shl 30)) xor ((h shr 13) or (h shl 19)) xor ((h shr 22) xor (h shl 10))) + ((h and a) xor (h and b) xor (a and b)); g:= t1 + t2; c:= c + t1;
|
||||
t1:= f + (((c shr 6) or (c shl 26)) xor ((c shr 11) or (c shl 21)) xor ((c shr 25) or (c shl 7))) + ((c and d) xor (not c and e)) + $4d2c6dfc + W[34]; t2:= (((g shr 2) or (g shl 30)) xor ((g shr 13) or (g shl 19)) xor ((g shr 22) xor (g shl 10))) + ((g and h) xor (g and a) xor (h and a)); f:= t1 + t2; b:= b + t1;
|
||||
t1:= e + (((b shr 6) or (b shl 26)) xor ((b shr 11) or (b shl 21)) xor ((b shr 25) or (b shl 7))) + ((b and c) xor (not b and d)) + $53380d13 + W[35]; t2:= (((f shr 2) or (f shl 30)) xor ((f shr 13) or (f shl 19)) xor ((f shr 22) xor (f shl 10))) + ((f and g) xor (f and h) xor (g and h)); e:= t1 + t2; a:= a + t1;
|
||||
t1:= d + (((a shr 6) or (a shl 26)) xor ((a shr 11) or (a shl 21)) xor ((a shr 25) or (a shl 7))) + ((a and b) xor (not a and c)) + $650a7354 + W[36]; t2:= (((e shr 2) or (e shl 30)) xor ((e shr 13) or (e shl 19)) xor ((e shr 22) xor (e shl 10))) + ((e and f) xor (e and g) xor (f and g)); d:= t1 + t2; h:= h + t1;
|
||||
t1:= c + (((h shr 6) or (h shl 26)) xor ((h shr 11) or (h shl 21)) xor ((h shr 25) or (h shl 7))) + ((h and a) xor (not h and b)) + $766a0abb + W[37]; t2:= (((d shr 2) or (d shl 30)) xor ((d shr 13) or (d shl 19)) xor ((d shr 22) xor (d shl 10))) + ((d and e) xor (d and f) xor (e and f)); c:= t1 + t2; g:= g + t1;
|
||||
t1:= b + (((g shr 6) or (g shl 26)) xor ((g shr 11) or (g shl 21)) xor ((g shr 25) or (g shl 7))) + ((g and h) xor (not g and a)) + $81c2c92e + W[38]; t2:= (((c shr 2) or (c shl 30)) xor ((c shr 13) or (c shl 19)) xor ((c shr 22) xor (c shl 10))) + ((c and d) xor (c and e) xor (d and e)); b:= t1 + t2; f:= f + t1;
|
||||
t1:= a + (((f shr 6) or (f shl 26)) xor ((f shr 11) or (f shl 21)) xor ((f shr 25) or (f shl 7))) + ((f and g) xor (not f and h)) + $92722c85 + W[39]; t2:= (((b shr 2) or (b shl 30)) xor ((b shr 13) or (b shl 19)) xor ((b shr 22) xor (b shl 10))) + ((b and c) xor (b and d) xor (c and d)); a:= t1 + t2; e:= e + t1;
|
||||
t1:= h + (((e shr 6) or (e shl 26)) xor ((e shr 11) or (e shl 21)) xor ((e shr 25) or (e shl 7))) + ((e and f) xor (not e and g)) + $a2bfe8a1 + W[40]; t2:= (((a shr 2) or (a shl 30)) xor ((a shr 13) or (a shl 19)) xor ((a shr 22) xor (a shl 10))) + ((a and b) xor (a and c) xor (b and c)); h:= t1 + t2; d:= d + t1;
|
||||
t1:= g + (((d shr 6) or (d shl 26)) xor ((d shr 11) or (d shl 21)) xor ((d shr 25) or (d shl 7))) + ((d and e) xor (not d and f)) + $a81a664b + W[41]; t2:= (((h shr 2) or (h shl 30)) xor ((h shr 13) or (h shl 19)) xor ((h shr 22) xor (h shl 10))) + ((h and a) xor (h and b) xor (a and b)); g:= t1 + t2; c:= c + t1;
|
||||
t1:= f + (((c shr 6) or (c shl 26)) xor ((c shr 11) or (c shl 21)) xor ((c shr 25) or (c shl 7))) + ((c and d) xor (not c and e)) + $c24b8b70 + W[42]; t2:= (((g shr 2) or (g shl 30)) xor ((g shr 13) or (g shl 19)) xor ((g shr 22) xor (g shl 10))) + ((g and h) xor (g and a) xor (h and a)); f:= t1 + t2; b:= b + t1;
|
||||
t1:= e + (((b shr 6) or (b shl 26)) xor ((b shr 11) or (b shl 21)) xor ((b shr 25) or (b shl 7))) + ((b and c) xor (not b and d)) + $c76c51a3 + W[43]; t2:= (((f shr 2) or (f shl 30)) xor ((f shr 13) or (f shl 19)) xor ((f shr 22) xor (f shl 10))) + ((f and g) xor (f and h) xor (g and h)); e:= t1 + t2; a:= a + t1;
|
||||
t1:= d + (((a shr 6) or (a shl 26)) xor ((a shr 11) or (a shl 21)) xor ((a shr 25) or (a shl 7))) + ((a and b) xor (not a and c)) + $d192e819 + W[44]; t2:= (((e shr 2) or (e shl 30)) xor ((e shr 13) or (e shl 19)) xor ((e shr 22) xor (e shl 10))) + ((e and f) xor (e and g) xor (f and g)); d:= t1 + t2; h:= h + t1;
|
||||
t1:= c + (((h shr 6) or (h shl 26)) xor ((h shr 11) or (h shl 21)) xor ((h shr 25) or (h shl 7))) + ((h and a) xor (not h and b)) + $d6990624 + W[45]; t2:= (((d shr 2) or (d shl 30)) xor ((d shr 13) or (d shl 19)) xor ((d shr 22) xor (d shl 10))) + ((d and e) xor (d and f) xor (e and f)); c:= t1 + t2; g:= g + t1;
|
||||
t1:= b + (((g shr 6) or (g shl 26)) xor ((g shr 11) or (g shl 21)) xor ((g shr 25) or (g shl 7))) + ((g and h) xor (not g and a)) + $f40e3585 + W[46]; t2:= (((c shr 2) or (c shl 30)) xor ((c shr 13) or (c shl 19)) xor ((c shr 22) xor (c shl 10))) + ((c and d) xor (c and e) xor (d and e)); b:= t1 + t2; f:= f + t1;
|
||||
t1:= a + (((f shr 6) or (f shl 26)) xor ((f shr 11) or (f shl 21)) xor ((f shr 25) or (f shl 7))) + ((f and g) xor (not f and h)) + $106aa070 + W[47]; t2:= (((b shr 2) or (b shl 30)) xor ((b shr 13) or (b shl 19)) xor ((b shr 22) xor (b shl 10))) + ((b and c) xor (b and d) xor (c and d)); a:= t1 + t2; e:= e + t1;
|
||||
t1:= h + (((e shr 6) or (e shl 26)) xor ((e shr 11) or (e shl 21)) xor ((e shr 25) or (e shl 7))) + ((e and f) xor (not e and g)) + $19a4c116 + W[48]; t2:= (((a shr 2) or (a shl 30)) xor ((a shr 13) or (a shl 19)) xor ((a shr 22) xor (a shl 10))) + ((a and b) xor (a and c) xor (b and c)); h:= t1 + t2; d:= d + t1;
|
||||
t1:= g + (((d shr 6) or (d shl 26)) xor ((d shr 11) or (d shl 21)) xor ((d shr 25) or (d shl 7))) + ((d and e) xor (not d and f)) + $1e376c08 + W[49]; t2:= (((h shr 2) or (h shl 30)) xor ((h shr 13) or (h shl 19)) xor ((h shr 22) xor (h shl 10))) + ((h and a) xor (h and b) xor (a and b)); g:= t1 + t2; c:= c + t1;
|
||||
t1:= f + (((c shr 6) or (c shl 26)) xor ((c shr 11) or (c shl 21)) xor ((c shr 25) or (c shl 7))) + ((c and d) xor (not c and e)) + $2748774c + W[50]; t2:= (((g shr 2) or (g shl 30)) xor ((g shr 13) or (g shl 19)) xor ((g shr 22) xor (g shl 10))) + ((g and h) xor (g and a) xor (h and a)); f:= t1 + t2; b:= b + t1;
|
||||
t1:= e + (((b shr 6) or (b shl 26)) xor ((b shr 11) or (b shl 21)) xor ((b shr 25) or (b shl 7))) + ((b and c) xor (not b and d)) + $34b0bcb5 + W[51]; t2:= (((f shr 2) or (f shl 30)) xor ((f shr 13) or (f shl 19)) xor ((f shr 22) xor (f shl 10))) + ((f and g) xor (f and h) xor (g and h)); e:= t1 + t2; a:= a + t1;
|
||||
t1:= d + (((a shr 6) or (a shl 26)) xor ((a shr 11) or (a shl 21)) xor ((a shr 25) or (a shl 7))) + ((a and b) xor (not a and c)) + $391c0cb3 + W[52]; t2:= (((e shr 2) or (e shl 30)) xor ((e shr 13) or (e shl 19)) xor ((e shr 22) xor (e shl 10))) + ((e and f) xor (e and g) xor (f and g)); d:= t1 + t2; h:= h + t1;
|
||||
t1:= c + (((h shr 6) or (h shl 26)) xor ((h shr 11) or (h shl 21)) xor ((h shr 25) or (h shl 7))) + ((h and a) xor (not h and b)) + $4ed8aa4a + W[53]; t2:= (((d shr 2) or (d shl 30)) xor ((d shr 13) or (d shl 19)) xor ((d shr 22) xor (d shl 10))) + ((d and e) xor (d and f) xor (e and f)); c:= t1 + t2; g:= g + t1;
|
||||
t1:= b + (((g shr 6) or (g shl 26)) xor ((g shr 11) or (g shl 21)) xor ((g shr 25) or (g shl 7))) + ((g and h) xor (not g and a)) + $5b9cca4f + W[54]; t2:= (((c shr 2) or (c shl 30)) xor ((c shr 13) or (c shl 19)) xor ((c shr 22) xor (c shl 10))) + ((c and d) xor (c and e) xor (d and e)); b:= t1 + t2; f:= f + t1;
|
||||
t1:= a + (((f shr 6) or (f shl 26)) xor ((f shr 11) or (f shl 21)) xor ((f shr 25) or (f shl 7))) + ((f and g) xor (not f and h)) + $682e6ff3 + W[55]; t2:= (((b shr 2) or (b shl 30)) xor ((b shr 13) or (b shl 19)) xor ((b shr 22) xor (b shl 10))) + ((b and c) xor (b and d) xor (c and d)); a:= t1 + t2; e:= e + t1;
|
||||
t1:= h + (((e shr 6) or (e shl 26)) xor ((e shr 11) or (e shl 21)) xor ((e shr 25) or (e shl 7))) + ((e and f) xor (not e and g)) + $748f82ee + W[56]; t2:= (((a shr 2) or (a shl 30)) xor ((a shr 13) or (a shl 19)) xor ((a shr 22) xor (a shl 10))) + ((a and b) xor (a and c) xor (b and c)); h:= t1 + t2; d:= d + t1;
|
||||
t1:= g + (((d shr 6) or (d shl 26)) xor ((d shr 11) or (d shl 21)) xor ((d shr 25) or (d shl 7))) + ((d and e) xor (not d and f)) + $78a5636f + W[57]; t2:= (((h shr 2) or (h shl 30)) xor ((h shr 13) or (h shl 19)) xor ((h shr 22) xor (h shl 10))) + ((h and a) xor (h and b) xor (a and b)); g:= t1 + t2; c:= c + t1;
|
||||
t1:= f + (((c shr 6) or (c shl 26)) xor ((c shr 11) or (c shl 21)) xor ((c shr 25) or (c shl 7))) + ((c and d) xor (not c and e)) + $84c87814 + W[58]; t2:= (((g shr 2) or (g shl 30)) xor ((g shr 13) or (g shl 19)) xor ((g shr 22) xor (g shl 10))) + ((g and h) xor (g and a) xor (h and a)); f:= t1 + t2; b:= b + t1;
|
||||
t1:= e + (((b shr 6) or (b shl 26)) xor ((b shr 11) or (b shl 21)) xor ((b shr 25) or (b shl 7))) + ((b and c) xor (not b and d)) + $8cc70208 + W[59]; t2:= (((f shr 2) or (f shl 30)) xor ((f shr 13) or (f shl 19)) xor ((f shr 22) xor (f shl 10))) + ((f and g) xor (f and h) xor (g and h)); e:= t1 + t2; a:= a + t1;
|
||||
t1:= d + (((a shr 6) or (a shl 26)) xor ((a shr 11) or (a shl 21)) xor ((a shr 25) or (a shl 7))) + ((a and b) xor (not a and c)) + $90befffa + W[60]; t2:= (((e shr 2) or (e shl 30)) xor ((e shr 13) or (e shl 19)) xor ((e shr 22) xor (e shl 10))) + ((e and f) xor (e and g) xor (f and g)); d:= t1 + t2; h:= h + t1;
|
||||
t1:= c + (((h shr 6) or (h shl 26)) xor ((h shr 11) or (h shl 21)) xor ((h shr 25) or (h shl 7))) + ((h and a) xor (not h and b)) + $a4506ceb + W[61]; t2:= (((d shr 2) or (d shl 30)) xor ((d shr 13) or (d shl 19)) xor ((d shr 22) xor (d shl 10))) + ((d and e) xor (d and f) xor (e and f)); c:= t1 + t2; g:= g + t1;
|
||||
t1:= b + (((g shr 6) or (g shl 26)) xor ((g shr 11) or (g shl 21)) xor ((g shr 25) or (g shl 7))) + ((g and h) xor (not g and a)) + $bef9a3f7 + W[62]; t2:= (((c shr 2) or (c shl 30)) xor ((c shr 13) or (c shl 19)) xor ((c shr 22) xor (c shl 10))) + ((c and d) xor (c and e) xor (d and e)); b:= t1 + t2; f:= f + t1;
|
||||
t1:= a + (((f shr 6) or (f shl 26)) xor ((f shr 11) or (f shl 21)) xor ((f shr 25) or (f shl 7))) + ((f and g) xor (not f and h)) + $c67178f2 + W[63]; t2:= (((b shr 2) or (b shl 30)) xor ((b shr 13) or (b shl 19)) xor ((b shr 22) xor (b shl 10))) + ((b and c) xor (b and d) xor (c and d)); a:= t1 + t2; e:= e + t1;
|
||||
|
||||
CurrentHash[0]:= CurrentHash[0] + a;
|
||||
CurrentHash[1]:= CurrentHash[1] + b;
|
||||
CurrentHash[2]:= CurrentHash[2] + c;
|
||||
CurrentHash[3]:= CurrentHash[3] + d;
|
||||
CurrentHash[4]:= CurrentHash[4] + e;
|
||||
CurrentHash[5]:= CurrentHash[5] + f;
|
||||
CurrentHash[6]:= CurrentHash[6] + g;
|
||||
CurrentHash[7]:= CurrentHash[7] + h;
|
||||
FillChar(W,Sizeof(W),0);
|
||||
FillChar(HashBuffer,Sizeof(HashBuffer),0);
|
||||
end;
|
||||
|
||||
class function TDCP_sha256.GetAlgorithm: string;
|
||||
begin
|
||||
Result:= 'SHA256';
|
||||
end;
|
||||
|
||||
class function TDCP_sha256.GetId: integer;
|
||||
begin
|
||||
Result:= DCP_sha256;
|
||||
end;
|
||||
|
||||
class function TDCP_sha256.GetHashSize: integer;
|
||||
begin
|
||||
Result:= 256;
|
||||
end;
|
||||
|
||||
class function TDCP_sha256.SelfTest: boolean;
|
||||
const
|
||||
Test1Out: array[0..31] of byte=
|
||||
($ba,$78,$16,$bf,$8f,$01,$cf,$ea,$41,$41,$40,$de,$5d,$ae,$22,$23,
|
||||
$b0,$03,$61,$a3,$96,$17,$7a,$9c,$b4,$10,$ff,$61,$f2,$00,$15,$ad);
|
||||
Test2Out: array[0..31] of byte=
|
||||
($24,$8d,$6a,$61,$d2,$06,$38,$b8,$e5,$c0,$26,$93,$0c,$3e,$60,$39,
|
||||
$a3,$3c,$e4,$59,$64,$ff,$21,$67,$f6,$ec,$ed,$d4,$19,$db,$06,$c1);
|
||||
var
|
||||
TestHash: TDCP_sha256;
|
||||
TestOut: array[0..31] of byte;
|
||||
begin
|
||||
dcpFillChar(TestOut, SizeOf(TestOut), 0);
|
||||
TestHash:= TDCP_sha256.Create(nil);
|
||||
TestHash.Init;
|
||||
TestHash.UpdateStr('abc');
|
||||
TestHash.Final(TestOut);
|
||||
Result:= boolean(CompareMem(@TestOut,@Test1Out,Sizeof(Test1Out)));
|
||||
TestHash.Init;
|
||||
TestHash.UpdateStr('abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq');
|
||||
TestHash.Final(TestOut);
|
||||
Result:= boolean(CompareMem(@TestOut,@Test2Out,Sizeof(Test2Out))) and Result;
|
||||
TestHash.Free;
|
||||
end;
|
||||
|
||||
procedure TDCP_sha256.Init;
|
||||
begin
|
||||
Burn;
|
||||
CurrentHash[0]:= $6a09e667;
|
||||
CurrentHash[1]:= $bb67ae85;
|
||||
CurrentHash[2]:= $3c6ef372;
|
||||
CurrentHash[3]:= $a54ff53a;
|
||||
CurrentHash[4]:= $510e527f;
|
||||
CurrentHash[5]:= $9b05688c;
|
||||
CurrentHash[6]:= $1f83d9ab;
|
||||
CurrentHash[7]:= $5be0cd19;
|
||||
fInitialized:= true;
|
||||
end;
|
||||
|
||||
procedure TDCP_sha256.Burn;
|
||||
begin
|
||||
LenHi:= 0; LenLo:= 0;
|
||||
Index:= 0;
|
||||
FillChar(HashBuffer,Sizeof(HashBuffer),0);
|
||||
FillChar(CurrentHash,Sizeof(CurrentHash),0);
|
||||
fInitialized:= false;
|
||||
end;
|
||||
|
||||
procedure TDCP_sha256.Update(const Buffer; Size: longword);
|
||||
var
|
||||
PBuf: ^byte;
|
||||
begin
|
||||
if not fInitialized then
|
||||
raise EDCP_hash.Create('Hash not initialized');
|
||||
|
||||
Inc(LenHi,Size shr 29);
|
||||
Inc(LenLo,Size*8);
|
||||
if LenLo< (Size*8) then
|
||||
Inc(LenHi);
|
||||
|
||||
PBuf:= @Buffer;
|
||||
while Size> 0 do
|
||||
begin
|
||||
if (Sizeof(HashBuffer)-Index)<= DWord(Size) then
|
||||
begin
|
||||
Move(PBuf^,HashBuffer[Index],Sizeof(HashBuffer)-Index);
|
||||
Dec(Size,Sizeof(HashBuffer)-Index);
|
||||
Inc(PBuf,Sizeof(HashBuffer)-Index);
|
||||
Compress;
|
||||
end
|
||||
else
|
||||
begin
|
||||
Move(PBuf^,HashBuffer[Index],Size);
|
||||
Inc(Index,Size);
|
||||
Size:= 0;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TDCP_sha256.Final(var Digest);
|
||||
begin
|
||||
if not fInitialized then
|
||||
raise EDCP_hash.Create('Hash not initialized');
|
||||
HashBuffer[Index]:= $80;
|
||||
if Index>= 56 then
|
||||
Compress;
|
||||
PDWord(@HashBuffer[56])^:= SwapDWord(LenHi);
|
||||
PDWord(@HashBuffer[60])^:= SwapDWord(LenLo);
|
||||
Compress;
|
||||
CurrentHash[0]:= SwapDWord(CurrentHash[0]);
|
||||
CurrentHash[1]:= SwapDWord(CurrentHash[1]);
|
||||
CurrentHash[2]:= SwapDWord(CurrentHash[2]);
|
||||
CurrentHash[3]:= SwapDWord(CurrentHash[3]);
|
||||
CurrentHash[4]:= SwapDWord(CurrentHash[4]);
|
||||
CurrentHash[5]:= SwapDWord(CurrentHash[5]);
|
||||
CurrentHash[6]:= SwapDWord(CurrentHash[6]);
|
||||
CurrentHash[7]:= SwapDWord(CurrentHash[7]);
|
||||
Move(CurrentHash,Digest,Sizeof(CurrentHash));
|
||||
Burn;
|
||||
end;
|
||||
|
||||
end.
|
||||
397
dcpcrypt/Hashes/dcpsha512.pas
Normal file
@@ -0,0 +1,397 @@
|
||||
{******************************************************************************}
|
||||
{* DCPcrypt v2.0 written by David Barton (crypto@cityinthesky.co.uk) **********}
|
||||
{******************************************************************************}
|
||||
{* A binary compatible implementation of SHA512 *******************************}
|
||||
{******************************************************************************}
|
||||
{* Copyright (c) 1999-2002 David Barton *}
|
||||
{* Permission is hereby granted, free of charge, to any person obtaining a *}
|
||||
{* copy of this software and associated documentation files (the "Software"), *}
|
||||
{* to deal in the Software without restriction, including without limitation *}
|
||||
{* the rights to use, copy, modify, merge, publish, distribute, sublicense, *}
|
||||
{* and/or sell copies of the Software, and to permit persons to whom the *}
|
||||
{* Software is furnished to do so, subject to the following conditions: *}
|
||||
{* *}
|
||||
{* The above copyright notice and this permission notice shall be included in *}
|
||||
{* all copies or substantial portions of the Software. *}
|
||||
{* *}
|
||||
{* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *}
|
||||
{* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *}
|
||||
{* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *}
|
||||
{* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *}
|
||||
{* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *}
|
||||
{* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *}
|
||||
{* DEALINGS IN THE SOFTWARE. *}
|
||||
{******************************************************************************}
|
||||
unit DCPsha512;
|
||||
|
||||
{$MODE Delphi}
|
||||
|
||||
interface
|
||||
uses
|
||||
Classes, Sysutils, DCPcrypt2, DCPconst;
|
||||
|
||||
type
|
||||
TDCP_sha512base= class(TDCP_hash)
|
||||
protected
|
||||
LenHi, LenLo: int64;
|
||||
Index: DWord;
|
||||
CurrentHash: array[0..7] of int64;
|
||||
HashBuffer: array[0..127] of byte;
|
||||
procedure Compress;
|
||||
public
|
||||
procedure Update(const Buffer; Size: longword); override;
|
||||
procedure Burn; override;
|
||||
end;
|
||||
|
||||
TDCP_sha384= class(TDCP_sha512base)
|
||||
public
|
||||
class function GetId: integer; override;
|
||||
class function GetAlgorithm: string; override;
|
||||
class function GetHashSize: integer; override;
|
||||
class function SelfTest: boolean; override;
|
||||
procedure Init; override;
|
||||
procedure Final(var Digest); override;
|
||||
end;
|
||||
|
||||
TDCP_sha512= class(TDCP_sha512base)
|
||||
public
|
||||
class function GetId: integer; override;
|
||||
class function GetAlgorithm: string; override;
|
||||
class function GetHashSize: integer; override;
|
||||
class function SelfTest: boolean; override;
|
||||
procedure Init; override;
|
||||
procedure Final(var Digest); override;
|
||||
end;
|
||||
|
||||
{******************************************************************************}
|
||||
{******************************************************************************}
|
||||
implementation
|
||||
{$R-}{$Q-}
|
||||
|
||||
function SwapDWord(a: int64): int64;
|
||||
begin
|
||||
Result:= ((a and $FF) shl 56) or ((a and $FF00) shl 40) or ((a and $FF0000) shl 24) or ((a and $FF000000) shl 8) or
|
||||
((a and $FF00000000) shr 8) or ((a and $FF0000000000) shr 24) or ((a and $FF000000000000) shr 40) or ((a and $FF00000000000000) shr 56);
|
||||
end;
|
||||
|
||||
procedure TDCP_sha512base.Compress;
|
||||
var
|
||||
a, b, c, d, e, f, g, h, t1, t2: int64;
|
||||
W: array[0..79] of int64;
|
||||
i: longword;
|
||||
begin
|
||||
Index:= 0;
|
||||
dcpFillChar(W, SizeOf(W), 0);
|
||||
a:= CurrentHash[0]; b:= CurrentHash[1]; c:= CurrentHash[2]; d:= CurrentHash[3];
|
||||
e:= CurrentHash[4]; f:= CurrentHash[5]; g:= CurrentHash[6]; h:= CurrentHash[7];
|
||||
Move(HashBuffer,W,Sizeof(HashBuffer));
|
||||
for i:= 0 to 15 do
|
||||
W[i]:= SwapDWord(W[i]);
|
||||
for i:= 16 to 79 do
|
||||
W[i]:= (((W[i-2] shr 19) or (W[i-2] shl 45)) xor ((W[i-2] shr 61) or (W[i-2] shl 3)) xor
|
||||
(W[i-2] shr 6)) + W[i-7] + (((W[i-15] shr 1) or (W[i-15] shl 63)) xor ((W[i-15] shr 8) or
|
||||
(W[i-15] shl 56)) xor (W[i-15] shr 7)) + W[i-16];
|
||||
|
||||
{
|
||||
Non-optimised version
|
||||
for i:= 0 to 79 do
|
||||
begin
|
||||
t1:= h + (((e shr 14) or (e shl 50)) xor ((e shr 18) or (e shl 46)) xor ((e shr 41) or (e shl 23))) +
|
||||
((e and f) xor (not e and g)) + K[i] + W[i];
|
||||
t2:= (((a shr 28) or (a shl 36)) xor ((a shr 34) or (a shl 30)) xor ((a shr 39) or (a shl 25))) +
|
||||
((a and b) xor (a and c) xor (b and c));
|
||||
h:= g; g:= f; f:= e; e:= d + t1; d:= c; c:= b; b:= a; a:= t1 + t2;
|
||||
end;
|
||||
}
|
||||
|
||||
t1:= h + (((e shr 14) or (e shl 50)) xor ((e shr 18) or (e shl 46)) xor ((e shr 41) or (e shl 23))) + ((e and f) xor (not e and g)) + $428a2f98d728ae22 + W[0]; t2:= (((a shr 28) or (a shl 36)) xor ((a shr 34) or (a shl 30)) xor ((a shr 39) or (a shl 25))) + ((a and b) xor (a and c) xor (b and c)); d:= d + t1; h:= t1 + t2;
|
||||
t1:= g + (((d shr 14) or (d shl 50)) xor ((d shr 18) or (d shl 46)) xor ((d shr 41) or (d shl 23))) + ((d and e) xor (not d and f)) + $7137449123ef65cd + W[1]; t2:= (((h shr 28) or (h shl 36)) xor ((h shr 34) or (h shl 30)) xor ((h shr 39) or (h shl 25))) + ((h and a) xor (h and b) xor (a and b)); c:= c + t1; g:= t1 + t2;
|
||||
t1:= f + (((c shr 14) or (c shl 50)) xor ((c shr 18) or (c shl 46)) xor ((c shr 41) or (c shl 23))) + ((c and d) xor (not c and e)) + $b5c0fbcfec4d3b2f + W[2]; t2:= (((g shr 28) or (g shl 36)) xor ((g shr 34) or (g shl 30)) xor ((g shr 39) or (g shl 25))) + ((g and h) xor (g and a) xor (h and a)); b:= b + t1; f:= t1 + t2;
|
||||
t1:= e + (((b shr 14) or (b shl 50)) xor ((b shr 18) or (b shl 46)) xor ((b shr 41) or (b shl 23))) + ((b and c) xor (not b and d)) + $e9b5dba58189dbbc + W[3]; t2:= (((f shr 28) or (f shl 36)) xor ((f shr 34) or (f shl 30)) xor ((f shr 39) or (f shl 25))) + ((f and g) xor (f and h) xor (g and h)); a:= a + t1; e:= t1 + t2;
|
||||
t1:= d + (((a shr 14) or (a shl 50)) xor ((a shr 18) or (a shl 46)) xor ((a shr 41) or (a shl 23))) + ((a and b) xor (not a and c)) + $3956c25bf348b538 + W[4]; t2:= (((e shr 28) or (e shl 36)) xor ((e shr 34) or (e shl 30)) xor ((e shr 39) or (e shl 25))) + ((e and f) xor (e and g) xor (f and g)); h:= h + t1; d:= t1 + t2;
|
||||
t1:= c + (((h shr 14) or (h shl 50)) xor ((h shr 18) or (h shl 46)) xor ((h shr 41) or (h shl 23))) + ((h and a) xor (not h and b)) + $59f111f1b605d019 + W[5]; t2:= (((d shr 28) or (d shl 36)) xor ((d shr 34) or (d shl 30)) xor ((d shr 39) or (d shl 25))) + ((d and e) xor (d and f) xor (e and f)); g:= g + t1; c:= t1 + t2;
|
||||
t1:= b + (((g shr 14) or (g shl 50)) xor ((g shr 18) or (g shl 46)) xor ((g shr 41) or (g shl 23))) + ((g and h) xor (not g and a)) + $923f82a4af194f9b + W[6]; t2:= (((c shr 28) or (c shl 36)) xor ((c shr 34) or (c shl 30)) xor ((c shr 39) or (c shl 25))) + ((c and d) xor (c and e) xor (d and e)); f:= f + t1; b:= t1 + t2;
|
||||
t1:= a + (((f shr 14) or (f shl 50)) xor ((f shr 18) or (f shl 46)) xor ((f shr 41) or (f shl 23))) + ((f and g) xor (not f and h)) + $ab1c5ed5da6d8118 + W[7]; t2:= (((b shr 28) or (b shl 36)) xor ((b shr 34) or (b shl 30)) xor ((b shr 39) or (b shl 25))) + ((b and c) xor (b and d) xor (c and d)); e:= e + t1; a:= t1 + t2;
|
||||
t1:= h + (((e shr 14) or (e shl 50)) xor ((e shr 18) or (e shl 46)) xor ((e shr 41) or (e shl 23))) + ((e and f) xor (not e and g)) + $d807aa98a3030242 + W[8]; t2:= (((a shr 28) or (a shl 36)) xor ((a shr 34) or (a shl 30)) xor ((a shr 39) or (a shl 25))) + ((a and b) xor (a and c) xor (b and c)); d:= d + t1; h:= t1 + t2;
|
||||
t1:= g + (((d shr 14) or (d shl 50)) xor ((d shr 18) or (d shl 46)) xor ((d shr 41) or (d shl 23))) + ((d and e) xor (not d and f)) + $12835b0145706fbe + W[9]; t2:= (((h shr 28) or (h shl 36)) xor ((h shr 34) or (h shl 30)) xor ((h shr 39) or (h shl 25))) + ((h and a) xor (h and b) xor (a and b)); c:= c + t1; g:= t1 + t2;
|
||||
t1:= f + (((c shr 14) or (c shl 50)) xor ((c shr 18) or (c shl 46)) xor ((c shr 41) or (c shl 23))) + ((c and d) xor (not c and e)) + $243185be4ee4b28c + W[10]; t2:= (((g shr 28) or (g shl 36)) xor ((g shr 34) or (g shl 30)) xor ((g shr 39) or (g shl 25))) + ((g and h) xor (g and a) xor (h and a)); b:= b + t1; f:= t1 + t2;
|
||||
t1:= e + (((b shr 14) or (b shl 50)) xor ((b shr 18) or (b shl 46)) xor ((b shr 41) or (b shl 23))) + ((b and c) xor (not b and d)) + $550c7dc3d5ffb4e2 + W[11]; t2:= (((f shr 28) or (f shl 36)) xor ((f shr 34) or (f shl 30)) xor ((f shr 39) or (f shl 25))) + ((f and g) xor (f and h) xor (g and h)); a:= a + t1; e:= t1 + t2;
|
||||
t1:= d + (((a shr 14) or (a shl 50)) xor ((a shr 18) or (a shl 46)) xor ((a shr 41) or (a shl 23))) + ((a and b) xor (not a and c)) + $72be5d74f27b896f + W[12]; t2:= (((e shr 28) or (e shl 36)) xor ((e shr 34) or (e shl 30)) xor ((e shr 39) or (e shl 25))) + ((e and f) xor (e and g) xor (f and g)); h:= h + t1; d:= t1 + t2;
|
||||
t1:= c + (((h shr 14) or (h shl 50)) xor ((h shr 18) or (h shl 46)) xor ((h shr 41) or (h shl 23))) + ((h and a) xor (not h and b)) + $80deb1fe3b1696b1 + W[13]; t2:= (((d shr 28) or (d shl 36)) xor ((d shr 34) or (d shl 30)) xor ((d shr 39) or (d shl 25))) + ((d and e) xor (d and f) xor (e and f)); g:= g + t1; c:= t1 + t2;
|
||||
t1:= b + (((g shr 14) or (g shl 50)) xor ((g shr 18) or (g shl 46)) xor ((g shr 41) or (g shl 23))) + ((g and h) xor (not g and a)) + $9bdc06a725c71235 + W[14]; t2:= (((c shr 28) or (c shl 36)) xor ((c shr 34) or (c shl 30)) xor ((c shr 39) or (c shl 25))) + ((c and d) xor (c and e) xor (d and e)); f:= f + t1; b:= t1 + t2;
|
||||
t1:= a + (((f shr 14) or (f shl 50)) xor ((f shr 18) or (f shl 46)) xor ((f shr 41) or (f shl 23))) + ((f and g) xor (not f and h)) + $c19bf174cf692694 + W[15]; t2:= (((b shr 28) or (b shl 36)) xor ((b shr 34) or (b shl 30)) xor ((b shr 39) or (b shl 25))) + ((b and c) xor (b and d) xor (c and d)); e:= e + t1; a:= t1 + t2;
|
||||
t1:= h + (((e shr 14) or (e shl 50)) xor ((e shr 18) or (e shl 46)) xor ((e shr 41) or (e shl 23))) + ((e and f) xor (not e and g)) + $e49b69c19ef14ad2 + W[16]; t2:= (((a shr 28) or (a shl 36)) xor ((a shr 34) or (a shl 30)) xor ((a shr 39) or (a shl 25))) + ((a and b) xor (a and c) xor (b and c)); d:= d + t1; h:= t1 + t2;
|
||||
t1:= g + (((d shr 14) or (d shl 50)) xor ((d shr 18) or (d shl 46)) xor ((d shr 41) or (d shl 23))) + ((d and e) xor (not d and f)) + $efbe4786384f25e3 + W[17]; t2:= (((h shr 28) or (h shl 36)) xor ((h shr 34) or (h shl 30)) xor ((h shr 39) or (h shl 25))) + ((h and a) xor (h and b) xor (a and b)); c:= c + t1; g:= t1 + t2;
|
||||
t1:= f + (((c shr 14) or (c shl 50)) xor ((c shr 18) or (c shl 46)) xor ((c shr 41) or (c shl 23))) + ((c and d) xor (not c and e)) + $0fc19dc68b8cd5b5 + W[18]; t2:= (((g shr 28) or (g shl 36)) xor ((g shr 34) or (g shl 30)) xor ((g shr 39) or (g shl 25))) + ((g and h) xor (g and a) xor (h and a)); b:= b + t1; f:= t1 + t2;
|
||||
t1:= e + (((b shr 14) or (b shl 50)) xor ((b shr 18) or (b shl 46)) xor ((b shr 41) or (b shl 23))) + ((b and c) xor (not b and d)) + $240ca1cc77ac9c65 + W[19]; t2:= (((f shr 28) or (f shl 36)) xor ((f shr 34) or (f shl 30)) xor ((f shr 39) or (f shl 25))) + ((f and g) xor (f and h) xor (g and h)); a:= a + t1; e:= t1 + t2;
|
||||
t1:= d + (((a shr 14) or (a shl 50)) xor ((a shr 18) or (a shl 46)) xor ((a shr 41) or (a shl 23))) + ((a and b) xor (not a and c)) + $2de92c6f592b0275 + W[20]; t2:= (((e shr 28) or (e shl 36)) xor ((e shr 34) or (e shl 30)) xor ((e shr 39) or (e shl 25))) + ((e and f) xor (e and g) xor (f and g)); h:= h + t1; d:= t1 + t2;
|
||||
t1:= c + (((h shr 14) or (h shl 50)) xor ((h shr 18) or (h shl 46)) xor ((h shr 41) or (h shl 23))) + ((h and a) xor (not h and b)) + $4a7484aa6ea6e483 + W[21]; t2:= (((d shr 28) or (d shl 36)) xor ((d shr 34) or (d shl 30)) xor ((d shr 39) or (d shl 25))) + ((d and e) xor (d and f) xor (e and f)); g:= g + t1; c:= t1 + t2;
|
||||
t1:= b + (((g shr 14) or (g shl 50)) xor ((g shr 18) or (g shl 46)) xor ((g shr 41) or (g shl 23))) + ((g and h) xor (not g and a)) + $5cb0a9dcbd41fbd4 + W[22]; t2:= (((c shr 28) or (c shl 36)) xor ((c shr 34) or (c shl 30)) xor ((c shr 39) or (c shl 25))) + ((c and d) xor (c and e) xor (d and e)); f:= f + t1; b:= t1 + t2;
|
||||
t1:= a + (((f shr 14) or (f shl 50)) xor ((f shr 18) or (f shl 46)) xor ((f shr 41) or (f shl 23))) + ((f and g) xor (not f and h)) + $76f988da831153b5 + W[23]; t2:= (((b shr 28) or (b shl 36)) xor ((b shr 34) or (b shl 30)) xor ((b shr 39) or (b shl 25))) + ((b and c) xor (b and d) xor (c and d)); e:= e + t1; a:= t1 + t2;
|
||||
t1:= h + (((e shr 14) or (e shl 50)) xor ((e shr 18) or (e shl 46)) xor ((e shr 41) or (e shl 23))) + ((e and f) xor (not e and g)) + $983e5152ee66dfab + W[24]; t2:= (((a shr 28) or (a shl 36)) xor ((a shr 34) or (a shl 30)) xor ((a shr 39) or (a shl 25))) + ((a and b) xor (a and c) xor (b and c)); d:= d + t1; h:= t1 + t2;
|
||||
t1:= g + (((d shr 14) or (d shl 50)) xor ((d shr 18) or (d shl 46)) xor ((d shr 41) or (d shl 23))) + ((d and e) xor (not d and f)) + $a831c66d2db43210 + W[25]; t2:= (((h shr 28) or (h shl 36)) xor ((h shr 34) or (h shl 30)) xor ((h shr 39) or (h shl 25))) + ((h and a) xor (h and b) xor (a and b)); c:= c + t1; g:= t1 + t2;
|
||||
t1:= f + (((c shr 14) or (c shl 50)) xor ((c shr 18) or (c shl 46)) xor ((c shr 41) or (c shl 23))) + ((c and d) xor (not c and e)) + $b00327c898fb213f + W[26]; t2:= (((g shr 28) or (g shl 36)) xor ((g shr 34) or (g shl 30)) xor ((g shr 39) or (g shl 25))) + ((g and h) xor (g and a) xor (h and a)); b:= b + t1; f:= t1 + t2;
|
||||
t1:= e + (((b shr 14) or (b shl 50)) xor ((b shr 18) or (b shl 46)) xor ((b shr 41) or (b shl 23))) + ((b and c) xor (not b and d)) + $bf597fc7beef0ee4 + W[27]; t2:= (((f shr 28) or (f shl 36)) xor ((f shr 34) or (f shl 30)) xor ((f shr 39) or (f shl 25))) + ((f and g) xor (f and h) xor (g and h)); a:= a + t1; e:= t1 + t2;
|
||||
t1:= d + (((a shr 14) or (a shl 50)) xor ((a shr 18) or (a shl 46)) xor ((a shr 41) or (a shl 23))) + ((a and b) xor (not a and c)) + $c6e00bf33da88fc2 + W[28]; t2:= (((e shr 28) or (e shl 36)) xor ((e shr 34) or (e shl 30)) xor ((e shr 39) or (e shl 25))) + ((e and f) xor (e and g) xor (f and g)); h:= h + t1; d:= t1 + t2;
|
||||
t1:= c + (((h shr 14) or (h shl 50)) xor ((h shr 18) or (h shl 46)) xor ((h shr 41) or (h shl 23))) + ((h and a) xor (not h and b)) + $d5a79147930aa725 + W[29]; t2:= (((d shr 28) or (d shl 36)) xor ((d shr 34) or (d shl 30)) xor ((d shr 39) or (d shl 25))) + ((d and e) xor (d and f) xor (e and f)); g:= g + t1; c:= t1 + t2;
|
||||
t1:= b + (((g shr 14) or (g shl 50)) xor ((g shr 18) or (g shl 46)) xor ((g shr 41) or (g shl 23))) + ((g and h) xor (not g and a)) + $06ca6351e003826f + W[30]; t2:= (((c shr 28) or (c shl 36)) xor ((c shr 34) or (c shl 30)) xor ((c shr 39) or (c shl 25))) + ((c and d) xor (c and e) xor (d and e)); f:= f + t1; b:= t1 + t2;
|
||||
t1:= a + (((f shr 14) or (f shl 50)) xor ((f shr 18) or (f shl 46)) xor ((f shr 41) or (f shl 23))) + ((f and g) xor (not f and h)) + $142929670a0e6e70 + W[31]; t2:= (((b shr 28) or (b shl 36)) xor ((b shr 34) or (b shl 30)) xor ((b shr 39) or (b shl 25))) + ((b and c) xor (b and d) xor (c and d)); e:= e + t1; a:= t1 + t2;
|
||||
t1:= h + (((e shr 14) or (e shl 50)) xor ((e shr 18) or (e shl 46)) xor ((e shr 41) or (e shl 23))) + ((e and f) xor (not e and g)) + $27b70a8546d22ffc + W[32]; t2:= (((a shr 28) or (a shl 36)) xor ((a shr 34) or (a shl 30)) xor ((a shr 39) or (a shl 25))) + ((a and b) xor (a and c) xor (b and c)); d:= d + t1; h:= t1 + t2;
|
||||
t1:= g + (((d shr 14) or (d shl 50)) xor ((d shr 18) or (d shl 46)) xor ((d shr 41) or (d shl 23))) + ((d and e) xor (not d and f)) + $2e1b21385c26c926 + W[33]; t2:= (((h shr 28) or (h shl 36)) xor ((h shr 34) or (h shl 30)) xor ((h shr 39) or (h shl 25))) + ((h and a) xor (h and b) xor (a and b)); c:= c + t1; g:= t1 + t2;
|
||||
t1:= f + (((c shr 14) or (c shl 50)) xor ((c shr 18) or (c shl 46)) xor ((c shr 41) or (c shl 23))) + ((c and d) xor (not c and e)) + $4d2c6dfc5ac42aed + W[34]; t2:= (((g shr 28) or (g shl 36)) xor ((g shr 34) or (g shl 30)) xor ((g shr 39) or (g shl 25))) + ((g and h) xor (g and a) xor (h and a)); b:= b + t1; f:= t1 + t2;
|
||||
t1:= e + (((b shr 14) or (b shl 50)) xor ((b shr 18) or (b shl 46)) xor ((b shr 41) or (b shl 23))) + ((b and c) xor (not b and d)) + $53380d139d95b3df + W[35]; t2:= (((f shr 28) or (f shl 36)) xor ((f shr 34) or (f shl 30)) xor ((f shr 39) or (f shl 25))) + ((f and g) xor (f and h) xor (g and h)); a:= a + t1; e:= t1 + t2;
|
||||
t1:= d + (((a shr 14) or (a shl 50)) xor ((a shr 18) or (a shl 46)) xor ((a shr 41) or (a shl 23))) + ((a and b) xor (not a and c)) + $650a73548baf63de + W[36]; t2:= (((e shr 28) or (e shl 36)) xor ((e shr 34) or (e shl 30)) xor ((e shr 39) or (e shl 25))) + ((e and f) xor (e and g) xor (f and g)); h:= h + t1; d:= t1 + t2;
|
||||
t1:= c + (((h shr 14) or (h shl 50)) xor ((h shr 18) or (h shl 46)) xor ((h shr 41) or (h shl 23))) + ((h and a) xor (not h and b)) + $766a0abb3c77b2a8 + W[37]; t2:= (((d shr 28) or (d shl 36)) xor ((d shr 34) or (d shl 30)) xor ((d shr 39) or (d shl 25))) + ((d and e) xor (d and f) xor (e and f)); g:= g + t1; c:= t1 + t2;
|
||||
t1:= b + (((g shr 14) or (g shl 50)) xor ((g shr 18) or (g shl 46)) xor ((g shr 41) or (g shl 23))) + ((g and h) xor (not g and a)) + $81c2c92e47edaee6 + W[38]; t2:= (((c shr 28) or (c shl 36)) xor ((c shr 34) or (c shl 30)) xor ((c shr 39) or (c shl 25))) + ((c and d) xor (c and e) xor (d and e)); f:= f + t1; b:= t1 + t2;
|
||||
t1:= a + (((f shr 14) or (f shl 50)) xor ((f shr 18) or (f shl 46)) xor ((f shr 41) or (f shl 23))) + ((f and g) xor (not f and h)) + $92722c851482353b + W[39]; t2:= (((b shr 28) or (b shl 36)) xor ((b shr 34) or (b shl 30)) xor ((b shr 39) or (b shl 25))) + ((b and c) xor (b and d) xor (c and d)); e:= e + t1; a:= t1 + t2;
|
||||
t1:= h + (((e shr 14) or (e shl 50)) xor ((e shr 18) or (e shl 46)) xor ((e shr 41) or (e shl 23))) + ((e and f) xor (not e and g)) + $a2bfe8a14cf10364 + W[40]; t2:= (((a shr 28) or (a shl 36)) xor ((a shr 34) or (a shl 30)) xor ((a shr 39) or (a shl 25))) + ((a and b) xor (a and c) xor (b and c)); d:= d + t1; h:= t1 + t2;
|
||||
t1:= g + (((d shr 14) or (d shl 50)) xor ((d shr 18) or (d shl 46)) xor ((d shr 41) or (d shl 23))) + ((d and e) xor (not d and f)) + $a81a664bbc423001 + W[41]; t2:= (((h shr 28) or (h shl 36)) xor ((h shr 34) or (h shl 30)) xor ((h shr 39) or (h shl 25))) + ((h and a) xor (h and b) xor (a and b)); c:= c + t1; g:= t1 + t2;
|
||||
t1:= f + (((c shr 14) or (c shl 50)) xor ((c shr 18) or (c shl 46)) xor ((c shr 41) or (c shl 23))) + ((c and d) xor (not c and e)) + $c24b8b70d0f89791 + W[42]; t2:= (((g shr 28) or (g shl 36)) xor ((g shr 34) or (g shl 30)) xor ((g shr 39) or (g shl 25))) + ((g and h) xor (g and a) xor (h and a)); b:= b + t1; f:= t1 + t2;
|
||||
t1:= e + (((b shr 14) or (b shl 50)) xor ((b shr 18) or (b shl 46)) xor ((b shr 41) or (b shl 23))) + ((b and c) xor (not b and d)) + $c76c51a30654be30 + W[43]; t2:= (((f shr 28) or (f shl 36)) xor ((f shr 34) or (f shl 30)) xor ((f shr 39) or (f shl 25))) + ((f and g) xor (f and h) xor (g and h)); a:= a + t1; e:= t1 + t2;
|
||||
t1:= d + (((a shr 14) or (a shl 50)) xor ((a shr 18) or (a shl 46)) xor ((a shr 41) or (a shl 23))) + ((a and b) xor (not a and c)) + $d192e819d6ef5218 + W[44]; t2:= (((e shr 28) or (e shl 36)) xor ((e shr 34) or (e shl 30)) xor ((e shr 39) or (e shl 25))) + ((e and f) xor (e and g) xor (f and g)); h:= h + t1; d:= t1 + t2;
|
||||
t1:= c + (((h shr 14) or (h shl 50)) xor ((h shr 18) or (h shl 46)) xor ((h shr 41) or (h shl 23))) + ((h and a) xor (not h and b)) + $d69906245565a910 + W[45]; t2:= (((d shr 28) or (d shl 36)) xor ((d shr 34) or (d shl 30)) xor ((d shr 39) or (d shl 25))) + ((d and e) xor (d and f) xor (e and f)); g:= g + t1; c:= t1 + t2;
|
||||
t1:= b + (((g shr 14) or (g shl 50)) xor ((g shr 18) or (g shl 46)) xor ((g shr 41) or (g shl 23))) + ((g and h) xor (not g and a)) + $f40e35855771202a + W[46]; t2:= (((c shr 28) or (c shl 36)) xor ((c shr 34) or (c shl 30)) xor ((c shr 39) or (c shl 25))) + ((c and d) xor (c and e) xor (d and e)); f:= f + t1; b:= t1 + t2;
|
||||
t1:= a + (((f shr 14) or (f shl 50)) xor ((f shr 18) or (f shl 46)) xor ((f shr 41) or (f shl 23))) + ((f and g) xor (not f and h)) + $106aa07032bbd1b8 + W[47]; t2:= (((b shr 28) or (b shl 36)) xor ((b shr 34) or (b shl 30)) xor ((b shr 39) or (b shl 25))) + ((b and c) xor (b and d) xor (c and d)); e:= e + t1; a:= t1 + t2;
|
||||
t1:= h + (((e shr 14) or (e shl 50)) xor ((e shr 18) or (e shl 46)) xor ((e shr 41) or (e shl 23))) + ((e and f) xor (not e and g)) + $19a4c116b8d2d0c8 + W[48]; t2:= (((a shr 28) or (a shl 36)) xor ((a shr 34) or (a shl 30)) xor ((a shr 39) or (a shl 25))) + ((a and b) xor (a and c) xor (b and c)); d:= d + t1; h:= t1 + t2;
|
||||
t1:= g + (((d shr 14) or (d shl 50)) xor ((d shr 18) or (d shl 46)) xor ((d shr 41) or (d shl 23))) + ((d and e) xor (not d and f)) + $1e376c085141ab53 + W[49]; t2:= (((h shr 28) or (h shl 36)) xor ((h shr 34) or (h shl 30)) xor ((h shr 39) or (h shl 25))) + ((h and a) xor (h and b) xor (a and b)); c:= c + t1; g:= t1 + t2;
|
||||
t1:= f + (((c shr 14) or (c shl 50)) xor ((c shr 18) or (c shl 46)) xor ((c shr 41) or (c shl 23))) + ((c and d) xor (not c and e)) + $2748774cdf8eeb99 + W[50]; t2:= (((g shr 28) or (g shl 36)) xor ((g shr 34) or (g shl 30)) xor ((g shr 39) or (g shl 25))) + ((g and h) xor (g and a) xor (h and a)); b:= b + t1; f:= t1 + t2;
|
||||
t1:= e + (((b shr 14) or (b shl 50)) xor ((b shr 18) or (b shl 46)) xor ((b shr 41) or (b shl 23))) + ((b and c) xor (not b and d)) + $34b0bcb5e19b48a8 + W[51]; t2:= (((f shr 28) or (f shl 36)) xor ((f shr 34) or (f shl 30)) xor ((f shr 39) or (f shl 25))) + ((f and g) xor (f and h) xor (g and h)); a:= a + t1; e:= t1 + t2;
|
||||
t1:= d + (((a shr 14) or (a shl 50)) xor ((a shr 18) or (a shl 46)) xor ((a shr 41) or (a shl 23))) + ((a and b) xor (not a and c)) + $391c0cb3c5c95a63 + W[52]; t2:= (((e shr 28) or (e shl 36)) xor ((e shr 34) or (e shl 30)) xor ((e shr 39) or (e shl 25))) + ((e and f) xor (e and g) xor (f and g)); h:= h + t1; d:= t1 + t2;
|
||||
t1:= c + (((h shr 14) or (h shl 50)) xor ((h shr 18) or (h shl 46)) xor ((h shr 41) or (h shl 23))) + ((h and a) xor (not h and b)) + $4ed8aa4ae3418acb + W[53]; t2:= (((d shr 28) or (d shl 36)) xor ((d shr 34) or (d shl 30)) xor ((d shr 39) or (d shl 25))) + ((d and e) xor (d and f) xor (e and f)); g:= g + t1; c:= t1 + t2;
|
||||
t1:= b + (((g shr 14) or (g shl 50)) xor ((g shr 18) or (g shl 46)) xor ((g shr 41) or (g shl 23))) + ((g and h) xor (not g and a)) + $5b9cca4f7763e373 + W[54]; t2:= (((c shr 28) or (c shl 36)) xor ((c shr 34) or (c shl 30)) xor ((c shr 39) or (c shl 25))) + ((c and d) xor (c and e) xor (d and e)); f:= f + t1; b:= t1 + t2;
|
||||
t1:= a + (((f shr 14) or (f shl 50)) xor ((f shr 18) or (f shl 46)) xor ((f shr 41) or (f shl 23))) + ((f and g) xor (not f and h)) + $682e6ff3d6b2b8a3 + W[55]; t2:= (((b shr 28) or (b shl 36)) xor ((b shr 34) or (b shl 30)) xor ((b shr 39) or (b shl 25))) + ((b and c) xor (b and d) xor (c and d)); e:= e + t1; a:= t1 + t2;
|
||||
t1:= h + (((e shr 14) or (e shl 50)) xor ((e shr 18) or (e shl 46)) xor ((e shr 41) or (e shl 23))) + ((e and f) xor (not e and g)) + $748f82ee5defb2fc + W[56]; t2:= (((a shr 28) or (a shl 36)) xor ((a shr 34) or (a shl 30)) xor ((a shr 39) or (a shl 25))) + ((a and b) xor (a and c) xor (b and c)); d:= d + t1; h:= t1 + t2;
|
||||
t1:= g + (((d shr 14) or (d shl 50)) xor ((d shr 18) or (d shl 46)) xor ((d shr 41) or (d shl 23))) + ((d and e) xor (not d and f)) + $78a5636f43172f60 + W[57]; t2:= (((h shr 28) or (h shl 36)) xor ((h shr 34) or (h shl 30)) xor ((h shr 39) or (h shl 25))) + ((h and a) xor (h and b) xor (a and b)); c:= c + t1; g:= t1 + t2;
|
||||
t1:= f + (((c shr 14) or (c shl 50)) xor ((c shr 18) or (c shl 46)) xor ((c shr 41) or (c shl 23))) + ((c and d) xor (not c and e)) + $84c87814a1f0ab72 + W[58]; t2:= (((g shr 28) or (g shl 36)) xor ((g shr 34) or (g shl 30)) xor ((g shr 39) or (g shl 25))) + ((g and h) xor (g and a) xor (h and a)); b:= b + t1; f:= t1 + t2;
|
||||
t1:= e + (((b shr 14) or (b shl 50)) xor ((b shr 18) or (b shl 46)) xor ((b shr 41) or (b shl 23))) + ((b and c) xor (not b and d)) + $8cc702081a6439ec + W[59]; t2:= (((f shr 28) or (f shl 36)) xor ((f shr 34) or (f shl 30)) xor ((f shr 39) or (f shl 25))) + ((f and g) xor (f and h) xor (g and h)); a:= a + t1; e:= t1 + t2;
|
||||
t1:= d + (((a shr 14) or (a shl 50)) xor ((a shr 18) or (a shl 46)) xor ((a shr 41) or (a shl 23))) + ((a and b) xor (not a and c)) + $90befffa23631e28 + W[60]; t2:= (((e shr 28) or (e shl 36)) xor ((e shr 34) or (e shl 30)) xor ((e shr 39) or (e shl 25))) + ((e and f) xor (e and g) xor (f and g)); h:= h + t1; d:= t1 + t2;
|
||||
t1:= c + (((h shr 14) or (h shl 50)) xor ((h shr 18) or (h shl 46)) xor ((h shr 41) or (h shl 23))) + ((h and a) xor (not h and b)) + $a4506cebde82bde9 + W[61]; t2:= (((d shr 28) or (d shl 36)) xor ((d shr 34) or (d shl 30)) xor ((d shr 39) or (d shl 25))) + ((d and e) xor (d and f) xor (e and f)); g:= g + t1; c:= t1 + t2;
|
||||
t1:= b + (((g shr 14) or (g shl 50)) xor ((g shr 18) or (g shl 46)) xor ((g shr 41) or (g shl 23))) + ((g and h) xor (not g and a)) + $bef9a3f7b2c67915 + W[62]; t2:= (((c shr 28) or (c shl 36)) xor ((c shr 34) or (c shl 30)) xor ((c shr 39) or (c shl 25))) + ((c and d) xor (c and e) xor (d and e)); f:= f + t1; b:= t1 + t2;
|
||||
t1:= a + (((f shr 14) or (f shl 50)) xor ((f shr 18) or (f shl 46)) xor ((f shr 41) or (f shl 23))) + ((f and g) xor (not f and h)) + $c67178f2e372532b + W[63]; t2:= (((b shr 28) or (b shl 36)) xor ((b shr 34) or (b shl 30)) xor ((b shr 39) or (b shl 25))) + ((b and c) xor (b and d) xor (c and d)); e:= e + t1; a:= t1 + t2;
|
||||
t1:= h + (((e shr 14) or (e shl 50)) xor ((e shr 18) or (e shl 46)) xor ((e shr 41) or (e shl 23))) + ((e and f) xor (not e and g)) + $ca273eceea26619c + W[64]; t2:= (((a shr 28) or (a shl 36)) xor ((a shr 34) or (a shl 30)) xor ((a shr 39) or (a shl 25))) + ((a and b) xor (a and c) xor (b and c)); d:= d + t1; h:= t1 + t2;
|
||||
t1:= g + (((d shr 14) or (d shl 50)) xor ((d shr 18) or (d shl 46)) xor ((d shr 41) or (d shl 23))) + ((d and e) xor (not d and f)) + $d186b8c721c0c207 + W[65]; t2:= (((h shr 28) or (h shl 36)) xor ((h shr 34) or (h shl 30)) xor ((h shr 39) or (h shl 25))) + ((h and a) xor (h and b) xor (a and b)); c:= c + t1; g:= t1 + t2;
|
||||
t1:= f + (((c shr 14) or (c shl 50)) xor ((c shr 18) or (c shl 46)) xor ((c shr 41) or (c shl 23))) + ((c and d) xor (not c and e)) + $eada7dd6cde0eb1e + W[66]; t2:= (((g shr 28) or (g shl 36)) xor ((g shr 34) or (g shl 30)) xor ((g shr 39) or (g shl 25))) + ((g and h) xor (g and a) xor (h and a)); b:= b + t1; f:= t1 + t2;
|
||||
t1:= e + (((b shr 14) or (b shl 50)) xor ((b shr 18) or (b shl 46)) xor ((b shr 41) or (b shl 23))) + ((b and c) xor (not b and d)) + $f57d4f7fee6ed178 + W[67]; t2:= (((f shr 28) or (f shl 36)) xor ((f shr 34) or (f shl 30)) xor ((f shr 39) or (f shl 25))) + ((f and g) xor (f and h) xor (g and h)); a:= a + t1; e:= t1 + t2;
|
||||
t1:= d + (((a shr 14) or (a shl 50)) xor ((a shr 18) or (a shl 46)) xor ((a shr 41) or (a shl 23))) + ((a and b) xor (not a and c)) + $06f067aa72176fba + W[68]; t2:= (((e shr 28) or (e shl 36)) xor ((e shr 34) or (e shl 30)) xor ((e shr 39) or (e shl 25))) + ((e and f) xor (e and g) xor (f and g)); h:= h + t1; d:= t1 + t2;
|
||||
t1:= c + (((h shr 14) or (h shl 50)) xor ((h shr 18) or (h shl 46)) xor ((h shr 41) or (h shl 23))) + ((h and a) xor (not h and b)) + $0a637dc5a2c898a6 + W[69]; t2:= (((d shr 28) or (d shl 36)) xor ((d shr 34) or (d shl 30)) xor ((d shr 39) or (d shl 25))) + ((d and e) xor (d and f) xor (e and f)); g:= g + t1; c:= t1 + t2;
|
||||
t1:= b + (((g shr 14) or (g shl 50)) xor ((g shr 18) or (g shl 46)) xor ((g shr 41) or (g shl 23))) + ((g and h) xor (not g and a)) + $113f9804bef90dae + W[70]; t2:= (((c shr 28) or (c shl 36)) xor ((c shr 34) or (c shl 30)) xor ((c shr 39) or (c shl 25))) + ((c and d) xor (c and e) xor (d and e)); f:= f + t1; b:= t1 + t2;
|
||||
t1:= a + (((f shr 14) or (f shl 50)) xor ((f shr 18) or (f shl 46)) xor ((f shr 41) or (f shl 23))) + ((f and g) xor (not f and h)) + $1b710b35131c471b + W[71]; t2:= (((b shr 28) or (b shl 36)) xor ((b shr 34) or (b shl 30)) xor ((b shr 39) or (b shl 25))) + ((b and c) xor (b and d) xor (c and d)); e:= e + t1; a:= t1 + t2;
|
||||
t1:= h + (((e shr 14) or (e shl 50)) xor ((e shr 18) or (e shl 46)) xor ((e shr 41) or (e shl 23))) + ((e and f) xor (not e and g)) + $28db77f523047d84 + W[72]; t2:= (((a shr 28) or (a shl 36)) xor ((a shr 34) or (a shl 30)) xor ((a shr 39) or (a shl 25))) + ((a and b) xor (a and c) xor (b and c)); d:= d + t1; h:= t1 + t2;
|
||||
t1:= g + (((d shr 14) or (d shl 50)) xor ((d shr 18) or (d shl 46)) xor ((d shr 41) or (d shl 23))) + ((d and e) xor (not d and f)) + $32caab7b40c72493 + W[73]; t2:= (((h shr 28) or (h shl 36)) xor ((h shr 34) or (h shl 30)) xor ((h shr 39) or (h shl 25))) + ((h and a) xor (h and b) xor (a and b)); c:= c + t1; g:= t1 + t2;
|
||||
t1:= f + (((c shr 14) or (c shl 50)) xor ((c shr 18) or (c shl 46)) xor ((c shr 41) or (c shl 23))) + ((c and d) xor (not c and e)) + $3c9ebe0a15c9bebc + W[74]; t2:= (((g shr 28) or (g shl 36)) xor ((g shr 34) or (g shl 30)) xor ((g shr 39) or (g shl 25))) + ((g and h) xor (g and a) xor (h and a)); b:= b + t1; f:= t1 + t2;
|
||||
t1:= e + (((b shr 14) or (b shl 50)) xor ((b shr 18) or (b shl 46)) xor ((b shr 41) or (b shl 23))) + ((b and c) xor (not b and d)) + $431d67c49c100d4c + W[75]; t2:= (((f shr 28) or (f shl 36)) xor ((f shr 34) or (f shl 30)) xor ((f shr 39) or (f shl 25))) + ((f and g) xor (f and h) xor (g and h)); a:= a + t1; e:= t1 + t2;
|
||||
t1:= d + (((a shr 14) or (a shl 50)) xor ((a shr 18) or (a shl 46)) xor ((a shr 41) or (a shl 23))) + ((a and b) xor (not a and c)) + $4cc5d4becb3e42b6 + W[76]; t2:= (((e shr 28) or (e shl 36)) xor ((e shr 34) or (e shl 30)) xor ((e shr 39) or (e shl 25))) + ((e and f) xor (e and g) xor (f and g)); h:= h + t1; d:= t1 + t2;
|
||||
t1:= c + (((h shr 14) or (h shl 50)) xor ((h shr 18) or (h shl 46)) xor ((h shr 41) or (h shl 23))) + ((h and a) xor (not h and b)) + $597f299cfc657e2a + W[77]; t2:= (((d shr 28) or (d shl 36)) xor ((d shr 34) or (d shl 30)) xor ((d shr 39) or (d shl 25))) + ((d and e) xor (d and f) xor (e and f)); g:= g + t1; c:= t1 + t2;
|
||||
t1:= b + (((g shr 14) or (g shl 50)) xor ((g shr 18) or (g shl 46)) xor ((g shr 41) or (g shl 23))) + ((g and h) xor (not g and a)) + $5fcb6fab3ad6faec + W[78]; t2:= (((c shr 28) or (c shl 36)) xor ((c shr 34) or (c shl 30)) xor ((c shr 39) or (c shl 25))) + ((c and d) xor (c and e) xor (d and e)); f:= f + t1; b:= t1 + t2;
|
||||
t1:= a + (((f shr 14) or (f shl 50)) xor ((f shr 18) or (f shl 46)) xor ((f shr 41) or (f shl 23))) + ((f and g) xor (not f and h)) + $6c44198c4a475817 + W[79]; t2:= (((b shr 28) or (b shl 36)) xor ((b shr 34) or (b shl 30)) xor ((b shr 39) or (b shl 25))) + ((b and c) xor (b and d) xor (c and d)); e:= e + t1; a:= t1 + t2;
|
||||
|
||||
CurrentHash[0]:= CurrentHash[0] + a;
|
||||
CurrentHash[1]:= CurrentHash[1] + b;
|
||||
CurrentHash[2]:= CurrentHash[2] + c;
|
||||
CurrentHash[3]:= CurrentHash[3] + d;
|
||||
CurrentHash[4]:= CurrentHash[4] + e;
|
||||
CurrentHash[5]:= CurrentHash[5] + f;
|
||||
CurrentHash[6]:= CurrentHash[6] + g;
|
||||
CurrentHash[7]:= CurrentHash[7] + h;
|
||||
FillChar(W,Sizeof(W),0);
|
||||
FillChar(HashBuffer,Sizeof(HashBuffer),0);
|
||||
end;
|
||||
|
||||
procedure TDCP_sha512base.Burn;
|
||||
begin
|
||||
LenHi:= 0; LenLo:= 0;
|
||||
Index:= 0;
|
||||
FillChar(HashBuffer,Sizeof(HashBuffer),0);
|
||||
FillChar(CurrentHash,Sizeof(CurrentHash),0);
|
||||
fInitialized:= false;
|
||||
end;
|
||||
|
||||
procedure TDCP_sha512base.Update(const Buffer; Size: longword);
|
||||
var
|
||||
PBuf: ^byte;
|
||||
begin
|
||||
if not fInitialized then
|
||||
raise EDCP_hash.Create('Hash not initialized');
|
||||
|
||||
Inc(LenLo,Size*8);
|
||||
if LenLo< (Size*8) then
|
||||
Inc(LenHi);
|
||||
|
||||
PBuf:= @Buffer;
|
||||
while Size> 0 do
|
||||
begin
|
||||
if (Sizeof(HashBuffer)-Index)<= DWord(Size) then
|
||||
begin
|
||||
Move(PBuf^,HashBuffer[Index],Sizeof(HashBuffer)-Index);
|
||||
Dec(Size,Sizeof(HashBuffer)-Index);
|
||||
Inc(PBuf,Sizeof(HashBuffer)-Index);
|
||||
Compress;
|
||||
end
|
||||
else
|
||||
begin
|
||||
Move(PBuf^,HashBuffer[Index],Size);
|
||||
Inc(Index,Size);
|
||||
Size:= 0;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
{******************************************************************************}
|
||||
class function TDCP_sha384.GetAlgorithm: string;
|
||||
begin
|
||||
Result:= 'SHA384';
|
||||
end;
|
||||
|
||||
class function TDCP_sha384.GetId: integer;
|
||||
begin
|
||||
Result:= DCP_sha384;
|
||||
end;
|
||||
|
||||
class function TDCP_sha384.GetHashSize: integer;
|
||||
begin
|
||||
Result:= 384;
|
||||
end;
|
||||
|
||||
class function TDCP_sha384.SelfTest: boolean;
|
||||
const
|
||||
Test1Out: array[0..47] of byte=
|
||||
($cb,$00,$75,$3f,$45,$a3,$5e,$8b,$b5,$a0,$3d,$69,$9a,$c6,$50,$07,
|
||||
$27,$2c,$32,$ab,$0e,$de,$d1,$63,$1a,$8b,$60,$5a,$43,$ff,$5b,$ed,
|
||||
$80,$86,$07,$2b,$a1,$e7,$cc,$23,$58,$ba,$ec,$a1,$34,$c8,$25,$a7);
|
||||
Test2Out: array[0..47] of byte=
|
||||
($09,$33,$0c,$33,$f7,$11,$47,$e8,$3d,$19,$2f,$c7,$82,$cd,$1b,$47,
|
||||
$53,$11,$1b,$17,$3b,$3b,$05,$d2,$2f,$a0,$80,$86,$e3,$b0,$f7,$12,
|
||||
$fc,$c7,$c7,$1a,$55,$7e,$2d,$b9,$66,$c3,$e9,$fa,$91,$74,$60,$39);
|
||||
var
|
||||
TestHash: TDCP_sha384;
|
||||
TestOut: array[0..47] of byte;
|
||||
begin
|
||||
dcpFillChar(TestOut, SizeOf(TestOut), 0);
|
||||
TestHash:= TDCP_sha384.Create(nil);
|
||||
TestHash.Init;
|
||||
TestHash.UpdateStr('abc');
|
||||
TestHash.Final(TestOut);
|
||||
Result:= boolean(CompareMem(@TestOut,@Test1Out,Sizeof(Test1Out)));
|
||||
TestHash.Init;
|
||||
TestHash.UpdateStr('abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu');
|
||||
TestHash.Final(TestOut);
|
||||
Result:= boolean(CompareMem(@TestOut,@Test2Out,Sizeof(Test2Out))) and Result;
|
||||
TestHash.Free;
|
||||
end;
|
||||
|
||||
procedure TDCP_sha384.Init;
|
||||
begin
|
||||
Burn;
|
||||
CurrentHash[0]:= $cbbb9d5dc1059ed8;
|
||||
CurrentHash[1]:= $629a292a367cd507;
|
||||
CurrentHash[2]:= $9159015a3070dd17;
|
||||
CurrentHash[3]:= $152fecd8f70e5939;
|
||||
CurrentHash[4]:= $67332667ffc00b31;
|
||||
CurrentHash[5]:= $8eb44a8768581511;
|
||||
CurrentHash[6]:= $db0c2e0d64f98fa7;
|
||||
CurrentHash[7]:= $47b5481dbefa4fa4;
|
||||
fInitialized:= true;
|
||||
end;
|
||||
|
||||
procedure TDCP_sha384.Final(var Digest);
|
||||
begin
|
||||
if not fInitialized then
|
||||
raise EDCP_hash.Create('Hash not initialized');
|
||||
HashBuffer[Index]:= $80;
|
||||
if Index>= 112 then
|
||||
Compress;
|
||||
Pint64(@HashBuffer[112])^:= SwapDWord(LenHi);
|
||||
Pint64(@HashBuffer[120])^:= SwapDWord(LenLo);
|
||||
Compress;
|
||||
CurrentHash[0]:= SwapDWord(CurrentHash[0]);
|
||||
CurrentHash[1]:= SwapDWord(CurrentHash[1]);
|
||||
CurrentHash[2]:= SwapDWord(CurrentHash[2]);
|
||||
CurrentHash[3]:= SwapDWord(CurrentHash[3]);
|
||||
CurrentHash[4]:= SwapDWord(CurrentHash[4]);
|
||||
CurrentHash[5]:= SwapDWord(CurrentHash[5]);
|
||||
Move(CurrentHash,Digest,384 div 8);
|
||||
Burn;
|
||||
end;
|
||||
|
||||
{******************************************************************************}
|
||||
class function TDCP_sha512.GetAlgorithm: string;
|
||||
begin
|
||||
Result:= 'SHA512';
|
||||
end;
|
||||
|
||||
class function TDCP_sha512.GetId: integer;
|
||||
begin
|
||||
Result:= DCP_sha512;
|
||||
end;
|
||||
|
||||
class function TDCP_sha512.GetHashSize: integer;
|
||||
begin
|
||||
Result:= 512;
|
||||
end;
|
||||
|
||||
class function TDCP_sha512.SelfTest: boolean;
|
||||
const
|
||||
Test1Out: array[0..63] of byte=
|
||||
($dd,$af,$35,$a1,$93,$61,$7a,$ba,$cc,$41,$73,$49,$ae,$20,$41,$31,
|
||||
$12,$e6,$fa,$4e,$89,$a9,$7e,$a2,$0a,$9e,$ee,$e6,$4b,$55,$d3,$9a,
|
||||
$21,$92,$99,$2a,$27,$4f,$c1,$a8,$36,$ba,$3c,$23,$a3,$fe,$eb,$bd,
|
||||
$45,$4d,$44,$23,$64,$3c,$e8,$0e,$2a,$9a,$c9,$4f,$a5,$4c,$a4,$9f);
|
||||
Test2Out: array[0..63] of byte=
|
||||
($8e,$95,$9b,$75,$da,$e3,$13,$da,$8c,$f4,$f7,$28,$14,$fc,$14,$3f,
|
||||
$8f,$77,$79,$c6,$eb,$9f,$7f,$a1,$72,$99,$ae,$ad,$b6,$88,$90,$18,
|
||||
$50,$1d,$28,$9e,$49,$00,$f7,$e4,$33,$1b,$99,$de,$c4,$b5,$43,$3a,
|
||||
$c7,$d3,$29,$ee,$b6,$dd,$26,$54,$5e,$96,$e5,$5b,$87,$4b,$e9,$09);
|
||||
var
|
||||
TestHash: TDCP_sha512;
|
||||
TestOut: array[0..63] of byte;
|
||||
begin
|
||||
dcpFillChar(TestOut, SizeOf(TestOut), 0);
|
||||
TestHash:= TDCP_sha512.Create(nil);
|
||||
TestHash.Init;
|
||||
TestHash.UpdateStr('abc');
|
||||
TestHash.Final(TestOut);
|
||||
Result:= boolean(CompareMem(@TestOut,@Test1Out,Sizeof(Test1Out)));
|
||||
TestHash.Init;
|
||||
TestHash.UpdateStr('abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu');
|
||||
TestHash.Final(TestOut);
|
||||
Result:= boolean(CompareMem(@TestOut,@Test2Out,Sizeof(Test2Out))) and Result;
|
||||
TestHash.Free;
|
||||
end;
|
||||
|
||||
procedure TDCP_sha512.Init;
|
||||
begin
|
||||
Burn;
|
||||
CurrentHash[0]:= $6a09e667f3bcc908;
|
||||
CurrentHash[1]:= $bb67ae8584caa73b;
|
||||
CurrentHash[2]:= $3c6ef372fe94f82b;
|
||||
CurrentHash[3]:= $a54ff53a5f1d36f1;
|
||||
CurrentHash[4]:= $510e527fade682d1;
|
||||
CurrentHash[5]:= $9b05688c2b3e6c1f;
|
||||
CurrentHash[6]:= $1f83d9abfb41bd6b;
|
||||
CurrentHash[7]:= $5be0cd19137e2179;
|
||||
fInitialized:= true;
|
||||
end;
|
||||
|
||||
procedure TDCP_sha512.Final(var Digest);
|
||||
begin
|
||||
if not fInitialized then
|
||||
raise EDCP_hash.Create('Hash not initialized');
|
||||
HashBuffer[Index]:= $80;
|
||||
if Index>= 112 then
|
||||
Compress;
|
||||
Pint64(@HashBuffer[112])^:= SwapDWord(LenHi);
|
||||
Pint64(@HashBuffer[120])^:= SwapDWord(LenLo);
|
||||
Compress;
|
||||
CurrentHash[0]:= SwapDWord(CurrentHash[0]);
|
||||
CurrentHash[1]:= SwapDWord(CurrentHash[1]);
|
||||
CurrentHash[2]:= SwapDWord(CurrentHash[2]);
|
||||
CurrentHash[3]:= SwapDWord(CurrentHash[3]);
|
||||
CurrentHash[4]:= SwapDWord(CurrentHash[4]);
|
||||
CurrentHash[5]:= SwapDWord(CurrentHash[5]);
|
||||
CurrentHash[6]:= SwapDWord(CurrentHash[6]);
|
||||
CurrentHash[7]:= SwapDWord(CurrentHash[7]);
|
||||
Move(CurrentHash,Digest,Sizeof(CurrentHash));
|
||||
Burn;
|
||||
end;
|
||||
|
||||
end.
|
||||
304
dcpcrypt/Hashes/dcptiger.pas
Normal file
@@ -0,0 +1,304 @@
|
||||
{******************************************************************************}
|
||||
{* DCPcrypt v2.0 written by David Barton (crypto@cityinthesky.co.uk) **********}
|
||||
{******************************************************************************}
|
||||
{* A binary compatible implementation of Tiger ********************************}
|
||||
{******************************************************************************}
|
||||
{* Copyright (c) 2002 David Barton *}
|
||||
{* Permission is hereby granted, free of charge, to any person obtaining a *}
|
||||
{* copy of this software and associated documentation files (the "Software"), *}
|
||||
{* to deal in the Software without restriction, including without limitation *}
|
||||
{* the rights to use, copy, modify, merge, publish, distribute, sublicense, *}
|
||||
{* and/or sell copies of the Software, and to permit persons to whom the *}
|
||||
{* Software is furnished to do so, subject to the following conditions: *}
|
||||
{* *}
|
||||
{* The above copyright notice and this permission notice shall be included in *}
|
||||
{* all copies or substantial portions of the Software. *}
|
||||
{* *}
|
||||
{* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *}
|
||||
{* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *}
|
||||
{* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *}
|
||||
{* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *}
|
||||
{* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *}
|
||||
{* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *}
|
||||
{* DEALINGS IN THE SOFTWARE. *}
|
||||
{******************************************************************************}
|
||||
unit DCPtiger;
|
||||
|
||||
{$MODE Delphi}
|
||||
|
||||
interface
|
||||
uses
|
||||
Classes, Sysutils, DCPcrypt2, DCPconst;
|
||||
|
||||
type
|
||||
TDCP_tiger= class(TDCP_hash)
|
||||
protected
|
||||
Len: int64;
|
||||
Index: DWord;
|
||||
CurrentHash: array[0..2] of int64;
|
||||
HashBuffer: array[0..63] of byte;
|
||||
procedure Compress;
|
||||
public
|
||||
class function GetId: integer; override;
|
||||
class function GetAlgorithm: string; override;
|
||||
class function GetHashSize: integer; override;
|
||||
class function SelfTest: boolean; override;
|
||||
procedure Init; override;
|
||||
procedure Burn; override;
|
||||
procedure Update(const Buffer; Size: longword); override;
|
||||
procedure Final(var Digest); override;
|
||||
end;
|
||||
|
||||
{******************************************************************************}
|
||||
{******************************************************************************}
|
||||
implementation
|
||||
{$R-}{$Q-}
|
||||
|
||||
{$INCLUDE DCPtiger.inc}
|
||||
|
||||
procedure TDCP_tiger.Compress;
|
||||
var
|
||||
a, b, c, aa, bb, cc: int64;
|
||||
x: array[0..7] of int64;
|
||||
begin
|
||||
dcpFillChar(x, SizeOf(x), 0);
|
||||
a:= CurrentHash[0]; aa:= a;
|
||||
b:= CurrentHash[1]; bb:= b;
|
||||
c:= CurrentHash[2]; cc:= c;
|
||||
|
||||
Move(HashBuffer,x,Sizeof(x));
|
||||
|
||||
c:= c xor x[0];
|
||||
a:= a - (t1[c and $FF] xor t2[(c shr 16) and $FF] xor t3[(c shr 32) and $FF] xor t4[(c shr 48) and $FF]);
|
||||
b:= b + (t4[(c shr 8) and $FF] xor t3[(c shr 24) and $FF] xor t2[(c shr 40) and $FF] xor t1[(c shr 56) and $FF]);
|
||||
b:= b * 5;
|
||||
a:= a xor x[1];
|
||||
b:= b - (t1[a and $FF] xor t2[(a shr 16) and $FF] xor t3[(a shr 32) and $FF] xor t4[(a shr 48) and $FF]);
|
||||
c:= c + (t4[(a shr 8) and $FF] xor t3[(a shr 24) and $FF] xor t2[(a shr 40) and $FF] xor t1[(a shr 56) and $FF]);
|
||||
c:= c * 5;
|
||||
b:= b xor x[2];
|
||||
c:= c - (t1[b and $FF] xor t2[(b shr 16) and $FF] xor t3[(b shr 32) and $FF] xor t4[(b shr 48) and $FF]);
|
||||
a:= a + (t4[(b shr 8) and $FF] xor t3[(b shr 24) and $FF] xor t2[(b shr 40) and $FF] xor t1[(b shr 56) and $FF]);
|
||||
a:= a * 5;
|
||||
c:= c xor x[3];
|
||||
a:= a - (t1[c and $FF] xor t2[(c shr 16) and $FF] xor t3[(c shr 32) and $FF] xor t4[(c shr 48) and $FF]);
|
||||
b:= b + (t4[(c shr 8) and $FF] xor t3[(c shr 24) and $FF] xor t2[(c shr 40) and $FF] xor t1[(c shr 56) and $FF]);
|
||||
b:= b * 5;
|
||||
a:= a xor x[4];
|
||||
b:= b - (t1[a and $FF] xor t2[(a shr 16) and $FF] xor t3[(a shr 32) and $FF] xor t4[(a shr 48) and $FF]);
|
||||
c:= c + (t4[(a shr 8) and $FF] xor t3[(a shr 24) and $FF] xor t2[(a shr 40) and $FF] xor t1[(a shr 56) and $FF]);
|
||||
c:= c * 5;
|
||||
b:= b xor x[5];
|
||||
c:= c - (t1[b and $FF] xor t2[(b shr 16) and $FF] xor t3[(b shr 32) and $FF] xor t4[(b shr 48) and $FF]);
|
||||
a:= a + (t4[(b shr 8) and $FF] xor t3[(b shr 24) and $FF] xor t2[(b shr 40) and $FF] xor t1[(b shr 56) and $FF]);
|
||||
a:= a * 5;
|
||||
c:= c xor x[6];
|
||||
a:= a - (t1[c and $FF] xor t2[(c shr 16) and $FF] xor t3[(c shr 32) and $FF] xor t4[(c shr 48) and $FF]);
|
||||
b:= b + (t4[(c shr 8) and $FF] xor t3[(c shr 24) and $FF] xor t2[(c shr 40) and $FF] xor t1[(c shr 56) and $FF]);
|
||||
b:= b * 5;
|
||||
a:= a xor x[7];
|
||||
b:= b - (t1[a and $FF] xor t2[(a shr 16) and $FF] xor t3[(a shr 32) and $FF] xor t4[(a shr 48) and $FF]);
|
||||
c:= c + (t4[(a shr 8) and $FF] xor t3[(a shr 24) and $FF] xor t2[(a shr 40) and $FF] xor t1[(a shr 56) and $FF]);
|
||||
c:= c * 5;
|
||||
x[0]:= x[0] - (x[7] xor $A5A5A5A5A5A5A5A5);
|
||||
x[1]:= x[1] xor x[0];
|
||||
x[2]:= x[2] + x[1];
|
||||
x[3]:= x[3] - (x[2] xor ((not x[1]) shl 19));
|
||||
x[4]:= x[4] xor x[3];
|
||||
x[5]:= x[5] + x[4];
|
||||
x[6]:= x[6] - (x[5] xor ((not x[4]) shr 23));
|
||||
x[7]:= x[7] xor x[6];
|
||||
x[0]:= x[0] + x[7];
|
||||
x[1]:= x[1] - (x[0] xor ((not x[7]) shl 19));
|
||||
x[2]:= x[2] xor x[1];
|
||||
x[3]:= x[3] + x[2];
|
||||
x[4]:= x[4] - (x[3] xor ((not x[2]) shr 23));
|
||||
x[5]:= x[5] xor x[4];
|
||||
x[6]:= x[6] + x[5];
|
||||
x[7]:= x[7] - (x[6] xor $0123456789ABCDEF);
|
||||
b:= b xor x[0];
|
||||
c:= c - (t1[b and $FF] xor t2[(b shr 16) and $FF] xor t3[(b shr 32) and $FF] xor t4[(b shr 48) and $FF]);
|
||||
a:= a + (t4[(b shr 8) and $FF] xor t3[(b shr 24) and $FF] xor t2[(b shr 40) and $FF] xor t1[(b shr 56) and $FF]);
|
||||
a:= a * 7;
|
||||
c:= c xor x[1];
|
||||
a:= a - (t1[c and $FF] xor t2[(c shr 16) and $FF] xor t3[(c shr 32) and $FF] xor t4[(c shr 48) and $FF]);
|
||||
b:= b + (t4[(c shr 8) and $FF] xor t3[(c shr 24) and $FF] xor t2[(c shr 40) and $FF] xor t1[(c shr 56) and $FF]);
|
||||
b:= b * 7;
|
||||
a:= a xor x[2];
|
||||
b:= b - (t1[a and $FF] xor t2[(a shr 16) and $FF] xor t3[(a shr 32) and $FF] xor t4[(a shr 48) and $FF]);
|
||||
c:= c + (t4[(a shr 8) and $FF] xor t3[(a shr 24) and $FF] xor t2[(a shr 40) and $FF] xor t1[(a shr 56) and $FF]);
|
||||
c:= c * 7;
|
||||
b:= b xor x[3];
|
||||
c:= c - (t1[b and $FF] xor t2[(b shr 16) and $FF] xor t3[(b shr 32) and $FF] xor t4[(b shr 48) and $FF]);
|
||||
a:= a + (t4[(b shr 8) and $FF] xor t3[(b shr 24) and $FF] xor t2[(b shr 40) and $FF] xor t1[(b shr 56) and $FF]);
|
||||
a:= a * 7;
|
||||
c:= c xor x[4];
|
||||
a:= a - (t1[c and $FF] xor t2[(c shr 16) and $FF] xor t3[(c shr 32) and $FF] xor t4[(c shr 48) and $FF]);
|
||||
b:= b + (t4[(c shr 8) and $FF] xor t3[(c shr 24) and $FF] xor t2[(c shr 40) and $FF] xor t1[(c shr 56) and $FF]);
|
||||
b:= b * 7;
|
||||
a:= a xor x[5];
|
||||
b:= b - (t1[a and $FF] xor t2[(a shr 16) and $FF] xor t3[(a shr 32) and $FF] xor t4[(a shr 48) and $FF]);
|
||||
c:= c + (t4[(a shr 8) and $FF] xor t3[(a shr 24) and $FF] xor t2[(a shr 40) and $FF] xor t1[(a shr 56) and $FF]);
|
||||
c:= c * 7;
|
||||
b:= b xor x[6];
|
||||
c:= c - (t1[b and $FF] xor t2[(b shr 16) and $FF] xor t3[(b shr 32) and $FF] xor t4[(b shr 48) and $FF]);
|
||||
a:= a + (t4[(b shr 8) and $FF] xor t3[(b shr 24) and $FF] xor t2[(b shr 40) and $FF] xor t1[(b shr 56) and $FF]);
|
||||
a:= a * 7;
|
||||
c:= c xor x[7];
|
||||
a:= a - (t1[c and $FF] xor t2[(c shr 16) and $FF] xor t3[(c shr 32) and $FF] xor t4[(c shr 48) and $FF]);
|
||||
b:= b + (t4[(c shr 8) and $FF] xor t3[(c shr 24) and $FF] xor t2[(c shr 40) and $FF] xor t1[(c shr 56) and $FF]);
|
||||
b:= b * 7;
|
||||
x[0]:= x[0] - (x[7] xor $A5A5A5A5A5A5A5A5);
|
||||
x[1]:= x[1] xor x[0];
|
||||
x[2]:= x[2] + x[1];
|
||||
x[3]:= x[3] - (x[2] xor ((not x[1]) shl 19));
|
||||
x[4]:= x[4] xor x[3];
|
||||
x[5]:= x[5] + x[4];
|
||||
x[6]:= x[6] - (x[5] xor ((not x[4]) shr 23));
|
||||
x[7]:= x[7] xor x[6];
|
||||
x[0]:= x[0] + x[7];
|
||||
x[1]:= x[1] - (x[0] xor ((not x[7]) shl 19));
|
||||
x[2]:= x[2] xor x[1];
|
||||
x[3]:= x[3] + x[2];
|
||||
x[4]:= x[4] - (x[3] xor ((not x[2]) shr 23));
|
||||
x[5]:= x[5] xor x[4];
|
||||
x[6]:= x[6] + x[5];
|
||||
x[7]:= x[7] - (x[6] xor $0123456789ABCDEF);
|
||||
a:= a xor x[0];
|
||||
b:= b - (t1[a and $FF] xor t2[(a shr 16) and $FF] xor t3[(a shr 32) and $FF] xor t4[(a shr 48) and $FF]);
|
||||
c:= c + (t4[(a shr 8) and $FF] xor t3[(a shr 24) and $FF] xor t2[(a shr 40) and $FF] xor t1[(a shr 56) and $FF]);
|
||||
c:= c * 9;
|
||||
b:= b xor x[1];
|
||||
c:= c - (t1[b and $FF] xor t2[(b shr 16) and $FF] xor t3[(b shr 32) and $FF] xor t4[(b shr 48) and $FF]);
|
||||
a:= a + (t4[(b shr 8) and $FF] xor t3[(b shr 24) and $FF] xor t2[(b shr 40) and $FF] xor t1[(b shr 56) and $FF]);
|
||||
a:= a * 9;
|
||||
c:= c xor x[2];
|
||||
a:= a - (t1[c and $FF] xor t2[(c shr 16) and $FF] xor t3[(c shr 32) and $FF] xor t4[(c shr 48) and $FF]);
|
||||
b:= b + (t4[(c shr 8) and $FF] xor t3[(c shr 24) and $FF] xor t2[(c shr 40) and $FF] xor t1[(c shr 56) and $FF]);
|
||||
b:= b * 9;
|
||||
a:= a xor x[3];
|
||||
b:= b - (t1[a and $FF] xor t2[(a shr 16) and $FF] xor t3[(a shr 32) and $FF] xor t4[(a shr 48) and $FF]);
|
||||
c:= c + (t4[(a shr 8) and $FF] xor t3[(a shr 24) and $FF] xor t2[(a shr 40) and $FF] xor t1[(a shr 56) and $FF]);
|
||||
c:= c * 9;
|
||||
b:= b xor x[4];
|
||||
c:= c - (t1[b and $FF] xor t2[(b shr 16) and $FF] xor t3[(b shr 32) and $FF] xor t4[(b shr 48) and $FF]);
|
||||
a:= a + (t4[(b shr 8) and $FF] xor t3[(b shr 24) and $FF] xor t2[(b shr 40) and $FF] xor t1[(b shr 56) and $FF]);
|
||||
a:= a * 9;
|
||||
c:= c xor x[5];
|
||||
a:= a - (t1[c and $FF] xor t2[(c shr 16) and $FF] xor t3[(c shr 32) and $FF] xor t4[(c shr 48) and $FF]);
|
||||
b:= b + (t4[(c shr 8) and $FF] xor t3[(c shr 24) and $FF] xor t2[(c shr 40) and $FF] xor t1[(c shr 56) and $FF]);
|
||||
b:= b * 9;
|
||||
a:= a xor x[6];
|
||||
b:= b - (t1[a and $FF] xor t2[(a shr 16) and $FF] xor t3[(a shr 32) and $FF] xor t4[(a shr 48) and $FF]);
|
||||
c:= c + (t4[(a shr 8) and $FF] xor t3[(a shr 24) and $FF] xor t2[(a shr 40) and $FF] xor t1[(a shr 56) and $FF]);
|
||||
c:= c * 9;
|
||||
b:= b xor x[7];
|
||||
c:= c - (t1[b and $FF] xor t2[(b shr 16) and $FF] xor t3[(b shr 32) and $FF] xor t4[(b shr 48) and $FF]);
|
||||
a:= a + (t4[(b shr 8) and $FF] xor t3[(b shr 24) and $FF] xor t2[(b shr 40) and $FF] xor t1[(b shr 56) and $FF]);
|
||||
a:= a * 9;
|
||||
|
||||
CurrentHash[0]:= a xor aa;
|
||||
CurrentHash[1]:= b - bb;
|
||||
CurrentHash[2]:= c + cc;
|
||||
Index:= 0;
|
||||
FillChar(HashBuffer,Sizeof(HashBuffer),0);
|
||||
end;
|
||||
|
||||
class function TDCP_tiger.GetHashSize: integer;
|
||||
begin
|
||||
Result:= 192;
|
||||
end;
|
||||
|
||||
class function TDCP_tiger.GetId: integer;
|
||||
begin
|
||||
Result:= DCP_tiger;
|
||||
end;
|
||||
|
||||
class function TDCP_tiger.GetAlgorithm: string;
|
||||
begin
|
||||
Result:= 'Tiger';
|
||||
end;
|
||||
|
||||
class function TDCP_tiger.SelfTest: boolean;
|
||||
const
|
||||
Test1Out: array[0..2] of int64=
|
||||
($87FB2A9083851CF7,$470D2CF810E6DF9E,$B586445034A5A386);
|
||||
Test2Out: array[0..2] of int64=
|
||||
($0C410A042968868A,$1671DA5A3FD29A72,$5EC1E457D3CDB303);
|
||||
var
|
||||
TestHash: TDCP_tiger;
|
||||
TestOut: array[0..2] of int64;
|
||||
begin
|
||||
dcpFillChar(TestOut, SizeOf(TestOut), 0);
|
||||
TestHash:= TDCP_tiger.Create(nil);
|
||||
TestHash.Init;
|
||||
TestHash.UpdateStr('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-');
|
||||
TestHash.Final(TestOut);
|
||||
Result:= CompareMem(@TestOut,@Test1Out,Sizeof(Test1Out));
|
||||
TestHash.Init;
|
||||
TestHash.UpdateStr('Tiger - A Fast New Hash Function, by Ross Anderson and Eli Biham');
|
||||
TestHash.Final(TestOut);
|
||||
Result:= CompareMem(@TestOut,@Test2Out,Sizeof(Test2Out)) and Result;
|
||||
TestHash.Free;
|
||||
end;
|
||||
|
||||
procedure TDCP_tiger.Init;
|
||||
begin
|
||||
Burn;
|
||||
fInitialized:= true;
|
||||
CurrentHash[0]:= $0123456789ABCDEF;
|
||||
CurrentHash[1]:= $FEDCBA9876543210;
|
||||
CurrentHash[2]:= $F096A5B4C3B2E187;
|
||||
end;
|
||||
|
||||
procedure TDCP_tiger.Burn;
|
||||
begin
|
||||
Len:= 0;
|
||||
Index:= 0;
|
||||
FillChar(HashBuffer,Sizeof(HashBuffer),0);
|
||||
FillChar(CurrentHash,Sizeof(CurrentHash),0);
|
||||
fInitialized:= false;
|
||||
end;
|
||||
|
||||
procedure TDCP_tiger.Update(const Buffer; Size: longword);
|
||||
var
|
||||
PBuf: ^byte;
|
||||
begin
|
||||
if not fInitialized then
|
||||
raise EDCP_hash.Create('Hash not initialized');
|
||||
|
||||
Inc(Len,Size*8);
|
||||
|
||||
PBuf:= @Buffer;
|
||||
while Size> 0 do
|
||||
begin
|
||||
if (Sizeof(HashBuffer)-Index)<= DWord(Size) then
|
||||
begin
|
||||
Move(PBuf^,HashBuffer[Index],Sizeof(HashBuffer)-Index);
|
||||
Dec(Size,Sizeof(HashBuffer)-Index);
|
||||
Inc(PBuf,Sizeof(HashBuffer)-Index);
|
||||
Compress;
|
||||
end
|
||||
else
|
||||
begin
|
||||
Move(PBuf^,HashBuffer[Index],Size);
|
||||
Inc(Index,Size);
|
||||
Size:= 0;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TDCP_tiger.Final(var Digest);
|
||||
begin
|
||||
if not fInitialized then
|
||||
raise EDCP_hash.Create('Hash not initialized');
|
||||
HashBuffer[Index]:= $01;
|
||||
if Index>= 56 then
|
||||
Compress;
|
||||
Pint64(@HashBuffer[56])^:= Len;
|
||||
Compress;
|
||||
Move(CurrentHash,Digest,Sizeof(CurrentHash));
|
||||
Burn;
|
||||
end;
|
||||
|
||||
end.
|
||||
130
dcpcrypt/Readme.txt
Normal file
@@ -0,0 +1,130 @@
|
||||
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
|
||||
= DCPcrypt Cryptographic Component Library v2 Beta 3 =
|
||||
= Copyright (c) 1999-2003 David Barton =
|
||||
= http://www.cityinthesky.co.uk/ =
|
||||
= crypto@cityinthesky.co.uk =
|
||||
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
|
||||
|
||||
|
||||
Introduction:
|
||||
|
||||
DCPcrypt is a collection of cryptographic components for the Borland
|
||||
Delphi(tm), C++ Builder(tm) and Kylix(tm) programming languages. The
|
||||
supported versions are Delphi 4, 5, 6, 7, 2005, C++ Builder (3?), 4,
|
||||
5, (6?) and Kylix 1 (untested), 2 and 3 (untested).
|
||||
|
||||
Thanks to Manuel C. for the modifications to make DCPcrypt work under
|
||||
Delphi 2005!
|
||||
|
||||
The idea behind DCPcrypt is that it should be possible to "drop in"
|
||||
any algorithm implementation to replace another with minimum or no
|
||||
code changes. To aid in this goal all cryptographic components are
|
||||
descended from one of several base classes, TDCP_cipher for encryption
|
||||
algorithms and TDCP_hash for message digest algorithms.
|
||||
|
||||
DCPcrypt is open source software (released under the MIT license) and
|
||||
as such there is no charge for inclusion in other software. However, I
|
||||
am currently a student and if you are making money from my software I
|
||||
would really appreciate a donation of some sort, whether financial or
|
||||
a license for the software you develop (or if anyone wants to sponsor
|
||||
a Mathematical Modelling (Masters) student for their final year...).
|
||||
Please note THIS IS NOT COMPULSORY IN ANY WAY. See
|
||||
http://www.cityinthesky.co.uk/cryptography.html for details on
|
||||
financial donations.
|
||||
|
||||
This software is OSI Certified Open Source Software.
|
||||
OSI Certified is a certification mark of the Open Source Initiative.
|
||||
|
||||
If you maintain a website then a link to my page at
|
||||
http://www.cityinthesky.co.uk/ would be great!
|
||||
|
||||
|
||||
|
||||
What's New:
|
||||
|
||||
Changes since DCPcrypt v2 Beta 2 include
|
||||
|
||||
* Corrected C++ Builder compilation problem.
|
||||
|
||||
|
||||
Changes since DCPcrypt v2 Beta 1 include
|
||||
|
||||
* Renamed source code files for hashes and ciphers to DCPxxx.pas
|
||||
|
||||
* Change the format of Cipher.InitStr so that the hash algorithm
|
||||
used to generate the key is explicitly specified. In order to
|
||||
get the same functionality as before, use TDCP_sha1.
|
||||
e.g. Cipher.InitStr('Hello World',TDCP_sha1);
|
||||
|
||||
* Block ciphers are now inherited from an intermediate component
|
||||
that implements the block size specific chaining mode encryption
|
||||
routines.
|
||||
|
||||
* Remove the internal component registration, it was more hassle
|
||||
than it was worth. If there is a demand for this to be put back
|
||||
then I might...
|
||||
|
||||
* Added the full range of operation modes for Haval. By changing
|
||||
the defines at the top of DCPhaval.pas you can specify the
|
||||
number of passes and the output hash size.
|
||||
|
||||
* Added the Tiger hash algorithm (192bit digest).
|
||||
|
||||
* Changed the name of the file containing TDCP_ripemd160 for
|
||||
consistency to DCPripemd160 from DCPrmd160.
|
||||
|
||||
* GOST no longer appears on the component palette pending verifying
|
||||
what the actual standard is (the code is still included however).
|
||||
|
||||
* Added the RipeMD-128 hash algorithm (128bit digest).
|
||||
|
||||
* Added the Serpent block cipher (AES finalist).
|
||||
|
||||
* Added the SHA-256,384,512 hash algorithms (256, 384, 512bit digest
|
||||
respectively).
|
||||
|
||||
* Added CTR chaining mode to all block ciphers.
|
||||
|
||||
|
||||
|
||||
Installation:
|
||||
|
||||
Delphi: Open the appropriate package, DCPdelphiX.dpk where X is
|
||||
your version of Delphi (either 4, 5 or 6). Then press the
|
||||
install button.
|
||||
|
||||
C++ Builder: Create a new design time package and add all the .pas
|
||||
files from the DCPcrypt2.zip archive including all those
|
||||
in the Ciphers and Hashes subdirectories. Then press the
|
||||
install button.
|
||||
|
||||
Kylix: Open the DCPkylix.dpk package and then press the install
|
||||
button (note: Kylix 1 users may need to create a new
|
||||
package as with C++ Builder as this is a Kylix 2 package).
|
||||
|
||||
You may need to add the directory containing DCPcrypt (and the Ciphers
|
||||
and Hashes subdirectories) to your library search path (found under
|
||||
Environment Options).
|
||||
|
||||
Once installed you will find two extra pages of components on your
|
||||
component palette, namely DCPciphers and DCPhashes. You can now place
|
||||
these components onto the form of your application to start using the
|
||||
algorithms.
|
||||
|
||||
|
||||
|
||||
Usage:
|
||||
|
||||
See the main html documentation in the Docs subdirectory.
|
||||
|
||||
|
||||
|
||||
Contact:
|
||||
|
||||
I appreciate knowing what DCPcrypt is being used for and also if you
|
||||
have any queries or bug reports please email me at crypto@cityinthesky.co.uk.
|
||||
|
||||
|
||||
|
||||
DCPcrypt is copyrighted (c) 1999-2003 David Barton.
|
||||
All trademarks are property of their respective owners.
|
||||
18
dcpcrypt/dcp.pas
Normal file
@@ -0,0 +1,18 @@
|
||||
{ This file was automatically created by Lazarus. do not edit!
|
||||
This source is only used to compile and install the package.
|
||||
}
|
||||
|
||||
unit dcp;
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
DCPbase64, DCPblockciphers, DCPconst, DCPcrypt2, DCPblowfish, DCPcast128,
|
||||
DCPcast256, DCPdes, DCPgost, DCPice, DCPidea, DCPmars, DCPmisty1, DCPrc2,
|
||||
DCPrc4, DCPrc5, DCPrc6, DCPrijndael, DCPserpent, DCPtea, DCPtwofish,
|
||||
DCPhaval, DCPmd4, DCPmd5, DCPripemd128, DCPripemd160, DCPsha1, DCPsha256,
|
||||
DCPsha512, DCPtiger;
|
||||
|
||||
implementation
|
||||
|
||||
end.
|
||||
139
dcpcrypt/dcpbase64.pas
Normal file
@@ -0,0 +1,139 @@
|
||||
{******************************************************************************}
|
||||
{* DCPcrypt v2.0 written by David Barton (crypto@cityinthesky.co.uk) **********}
|
||||
{******************************************************************************}
|
||||
{* A Base64 encoding/decoding unit ********************************************}
|
||||
{******************************************************************************}
|
||||
{* Copyright (c) 1999-2002 David Barton *}
|
||||
{* Permission is hereby granted, free of charge, to any person obtaining a *}
|
||||
{* copy of this software and associated documentation files (the "Software"), *}
|
||||
{* to deal in the Software without restriction, including without limitation *}
|
||||
{* the rights to use, copy, modify, merge, publish, distribute, sublicense, *}
|
||||
{* and/or sell copies of the Software, and to permit persons to whom the *}
|
||||
{* Software is furnished to do so, subject to the following conditions: *}
|
||||
{* *}
|
||||
{* The above copyright notice and this permission notice shall be included in *}
|
||||
{* all copies or substantial portions of the Software. *}
|
||||
{* *}
|
||||
{* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *}
|
||||
{* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *}
|
||||
{* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *}
|
||||
{* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *}
|
||||
{* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *}
|
||||
{* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *}
|
||||
{* DEALINGS IN THE SOFTWARE. *}
|
||||
{******************************************************************************}
|
||||
unit DCPbase64;
|
||||
|
||||
interface
|
||||
uses
|
||||
Sysutils;
|
||||
|
||||
function Base64EncodeStr(const Value: string): string;
|
||||
{ Encode a string into Base64 format }
|
||||
function Base64DecodeStr(const Value: string): string;
|
||||
{ Decode a Base64 format string }
|
||||
function Base64Encode(pInput: pointer; pOutput: pointer; Size: longint): longint;
|
||||
{ Encode a lump of raw data (output is (4/3) times bigger than input) }
|
||||
function Base64Decode(pInput: pointer; pOutput: pointer; Size: longint): longint;
|
||||
{ Decode a lump of raw data }
|
||||
|
||||
|
||||
{******************************************************************************}
|
||||
{******************************************************************************}
|
||||
implementation
|
||||
{$Q-}{$R-}
|
||||
|
||||
const
|
||||
B64: array[0..63] of byte= (65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,
|
||||
81,82,83,84,85,86,87,88,89,90,97,98,99,100,101,102,103,104,105,106,107,108,
|
||||
109,110,111,112,113,114,115,116,117,118,119,120,121,122,48,49,50,51,52,53,
|
||||
54,55,56,57,43,47);
|
||||
|
||||
function Base64Encode(pInput: pointer; pOutput: pointer; Size: longint): longint;
|
||||
var
|
||||
i, iptr, optr: integer;
|
||||
Input, Output: PByteArray;
|
||||
begin
|
||||
Input:= PByteArray(pInput); Output:= PByteArray(pOutput);
|
||||
iptr:= 0; optr:= 0;
|
||||
for i:= 1 to (Size div 3) do
|
||||
begin
|
||||
Output^[optr+0]:= B64[Input^[iptr] shr 2];
|
||||
Output^[optr+1]:= B64[((Input^[iptr] and 3) shl 4) + (Input^[iptr+1] shr 4)];
|
||||
Output^[optr+2]:= B64[((Input^[iptr+1] and 15) shl 2) + (Input^[iptr+2] shr 6)];
|
||||
Output^[optr+3]:= B64[Input^[iptr+2] and 63];
|
||||
Inc(optr,4); Inc(iptr,3);
|
||||
end;
|
||||
case (Size mod 3) of
|
||||
1: begin
|
||||
Output^[optr+0]:= B64[Input^[iptr] shr 2];
|
||||
Output^[optr+1]:= B64[(Input^[iptr] and 3) shl 4];
|
||||
Output^[optr+2]:= byte('=');
|
||||
Output^[optr+3]:= byte('=');
|
||||
end;
|
||||
2: begin
|
||||
Output^[optr+0]:= B64[Input^[iptr] shr 2];
|
||||
Output^[optr+1]:= B64[((Input^[iptr] and 3) shl 4) + (Input^[iptr+1] shr 4)];
|
||||
Output^[optr+2]:= B64[(Input^[iptr+1] and 15) shl 2];
|
||||
Output^[optr+3]:= byte('=');
|
||||
end;
|
||||
end;
|
||||
Result:= ((Size+2) div 3) * 4;
|
||||
end;
|
||||
|
||||
function Base64EncodeStr(const Value: string): string;
|
||||
begin
|
||||
SetLength(Result,((Length(Value)+2) div 3) * 4);
|
||||
Base64Encode(@Value[1],@Result[1],Length(Value));
|
||||
end;
|
||||
|
||||
function Base64Decode(pInput: pointer; pOutput: pointer; Size: longint): longint;
|
||||
var
|
||||
i, j, iptr, optr: integer;
|
||||
Temp: array[0..3] of byte;
|
||||
Input, Output: PByteArray;
|
||||
begin
|
||||
Input:= PByteArray(pInput); Output:= PByteArray(pOutput);
|
||||
iptr:= 0; optr:= 0;
|
||||
Result:= 0;
|
||||
for i:= 1 to (Size div 4) do
|
||||
begin
|
||||
for j:= 0 to 3 do
|
||||
begin
|
||||
case Input^[iptr] of
|
||||
65..90 : Temp[j]:= Input^[iptr] - Ord('A');
|
||||
97..122: Temp[j]:= Input^[iptr] - Ord('a') + 26;
|
||||
48..57 : Temp[j]:= Input^[iptr] - Ord('0') + 52;
|
||||
43 : Temp[j]:= 62;
|
||||
47 : Temp[j]:= 63;
|
||||
61 : Temp[j]:= $FF;
|
||||
end;
|
||||
Inc(iptr);
|
||||
end;
|
||||
Output^[optr]:= (Temp[0] shl 2) or (Temp[1] shr 4);
|
||||
Result:= optr+1;
|
||||
if (Temp[2]<> $FF) and (Temp[3]= $FF) then
|
||||
begin
|
||||
Output^[optr+1]:= (Temp[1] shl 4) or (Temp[2] shr 2);
|
||||
Result:= optr+2;
|
||||
Inc(optr)
|
||||
end
|
||||
else if (Temp[2]<> $FF) then
|
||||
begin
|
||||
Output^[optr+1]:= (Temp[1] shl 4) or (Temp[2] shr 2);
|
||||
Output^[optr+2]:= (Temp[2] shl 6) or Temp[3];
|
||||
Result:= optr+3;
|
||||
Inc(optr,2);
|
||||
end;
|
||||
Inc(optr);
|
||||
end;
|
||||
end;
|
||||
|
||||
function Base64DecodeStr(const Value: string): string;
|
||||
begin
|
||||
SetLength(Result,(Length(Value) div 4) * 3);
|
||||
SetLength(Result,Base64Decode(@Value[1],@Result[1],Length(Value)));
|
||||
end;
|
||||
|
||||
|
||||
end.
|
||||
788
dcpcrypt/dcpblockciphers.pas
Normal file
@@ -0,0 +1,788 @@
|
||||
{******************************************************************************}
|
||||
{* DCPcrypt v2.0 written by David Barton (crypto@cityinthesky.co.uk) **********}
|
||||
{******************************************************************************}
|
||||
{* Block cipher component definitions *****************************************}
|
||||
{******************************************************************************}
|
||||
{* Copyright (c) 1999-2002 David Barton *}
|
||||
{* Permission is hereby granted, free of charge, to any person obtaining a *}
|
||||
{* copy of this software and associated documentation files (the "Software"), *}
|
||||
{* to deal in the Software without restriction, including without limitation *}
|
||||
{* the rights to use, copy, modify, merge, publish, distribute, sublicense, *}
|
||||
{* and/or sell copies of the Software, and to permit persons to whom the *}
|
||||
{* Software is furnished to do so, subject to the following conditions: *}
|
||||
{* *}
|
||||
{* The above copyright notice and this permission notice shall be included in *}
|
||||
{* all copies or substantial portions of the Software. *}
|
||||
{* *}
|
||||
{* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *}
|
||||
{* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *}
|
||||
{* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *}
|
||||
{* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *}
|
||||
{* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *}
|
||||
{* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *}
|
||||
{* DEALINGS IN THE SOFTWARE. *}
|
||||
{******************************************************************************}
|
||||
unit DCPblockciphers;
|
||||
|
||||
{$MODE Delphi}
|
||||
|
||||
interface
|
||||
uses
|
||||
Classes, Sysutils, DCPcrypt2;
|
||||
|
||||
{******************************************************************************}
|
||||
{ Base type definition for 64 bit block ciphers }
|
||||
type
|
||||
TDCP_blockcipher64= class(TDCP_blockcipher)
|
||||
private
|
||||
IV, CV: array[0..7] of byte;
|
||||
|
||||
procedure IncCounter;
|
||||
public
|
||||
class function GetBlockSize: integer; override;
|
||||
{ Get the block size of the cipher (in bits) }
|
||||
|
||||
procedure Reset; override;
|
||||
{ Reset any stored chaining information }
|
||||
procedure Burn; override;
|
||||
{ Clear all stored key information and chaining information }
|
||||
procedure SetIV(const Value); override;
|
||||
{ Sets the IV to Value and performs a reset }
|
||||
procedure GetIV(var Value); override;
|
||||
{ Returns the current chaining information, not the actual IV }
|
||||
procedure Init(const Key; Size: longword; InitVector: pointer); override;
|
||||
{ Do key setup based on the data in Key, size is in bits }
|
||||
|
||||
procedure EncryptCBC(const Indata; var Outdata; Size: longword); override;
|
||||
{ Encrypt size bytes of data using the CBC method of encryption }
|
||||
procedure DecryptCBC(const Indata; var Outdata; Size: longword); override;
|
||||
{ Decrypt size bytes of data using the CBC method of decryption }
|
||||
procedure EncryptCFB8bit(const Indata; var Outdata; Size: longword); override;
|
||||
{ Encrypt size bytes of data using the CFB (8 bit) method of encryption }
|
||||
procedure DecryptCFB8bit(const Indata; var Outdata; Size: longword); override;
|
||||
{ Decrypt size bytes of data using the CFB (8 bit) method of decryption }
|
||||
procedure EncryptCFBblock(const Indata; var Outdata; Size: longword); override;
|
||||
{ Encrypt size bytes of data using the CFB (block) method of encryption }
|
||||
procedure DecryptCFBblock(const Indata; var Outdata; Size: longword); override;
|
||||
{ Decrypt size bytes of data using the CFB (block) method of decryption }
|
||||
procedure EncryptOFB(const Indata; var Outdata; Size: longword); override;
|
||||
{ Encrypt size bytes of data using the OFB method of encryption }
|
||||
procedure DecryptOFB(const Indata; var Outdata; Size: longword); override;
|
||||
{ Decrypt size bytes of data using the OFB method of decryption }
|
||||
procedure EncryptCTR(const Indata; var Outdata; Size: longword); override;
|
||||
{ Encrypt size bytes of data using the CTR method of encryption }
|
||||
procedure DecryptCTR(const Indata; var Outdata; Size: longword); override;
|
||||
{ Decrypt size bytes of data using the CTR method of decryption }
|
||||
end;
|
||||
|
||||
{******************************************************************************}
|
||||
{ Base type definition for 128 bit block ciphers }
|
||||
type
|
||||
TDCP_blockcipher128= class(TDCP_blockcipher)
|
||||
private
|
||||
IV, CV: array[0..15] of byte;
|
||||
|
||||
procedure IncCounter;
|
||||
public
|
||||
class function GetBlockSize: integer; override;
|
||||
{ Get the block size of the cipher (in bits) }
|
||||
|
||||
procedure Reset; override;
|
||||
{ Reset any stored chaining information }
|
||||
procedure Burn; override;
|
||||
{ Clear all stored key information and chaining information }
|
||||
procedure SetIV(const Value); override;
|
||||
{ Sets the IV to Value and performs a reset }
|
||||
procedure GetIV(var Value); override;
|
||||
{ Returns the current chaining information, not the actual IV }
|
||||
procedure Init(const Key; Size: longword; InitVector: pointer); override;
|
||||
{ Do key setup based on the data in Key, size is in bits }
|
||||
|
||||
procedure EncryptCBC(const Indata; var Outdata; Size: longword); override;
|
||||
{ Encrypt size bytes of data using the CBC method of encryption }
|
||||
procedure DecryptCBC(const Indata; var Outdata; Size: longword); override;
|
||||
{ Decrypt size bytes of data using the CBC method of decryption }
|
||||
procedure EncryptCFB8bit(const Indata; var Outdata; Size: longword); override;
|
||||
{ Encrypt size bytes of data using the CFB (8 bit) method of encryption }
|
||||
procedure DecryptCFB8bit(const Indata; var Outdata; Size: longword); override;
|
||||
{ Decrypt size bytes of data using the CFB (8 bit) method of decryption }
|
||||
procedure EncryptCFBblock(const Indata; var Outdata; Size: longword); override;
|
||||
{ Encrypt size bytes of data using the CFB (block) method of encryption }
|
||||
procedure DecryptCFBblock(const Indata; var Outdata; Size: longword); override;
|
||||
{ Decrypt size bytes of data using the CFB (block) method of decryption }
|
||||
procedure EncryptOFB(const Indata; var Outdata; Size: longword); override;
|
||||
{ Encrypt size bytes of data using the OFB method of encryption }
|
||||
procedure DecryptOFB(const Indata; var Outdata; Size: longword); override;
|
||||
{ Decrypt size bytes of data using the OFB method of decryption }
|
||||
procedure EncryptCTR(const Indata; var Outdata; Size: longword); override;
|
||||
{ Encrypt size bytes of data using the CTR method of encryption }
|
||||
procedure DecryptCTR(const Indata; var Outdata; Size: longword); override;
|
||||
{ Decrypt size bytes of data using the CTR method of decryption }
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
|
||||
{** TDCP_blockcipher64 ********************************************************}
|
||||
|
||||
procedure TDCP_blockcipher64.IncCounter;
|
||||
var
|
||||
i: integer;
|
||||
begin
|
||||
Inc(CV[7]);
|
||||
i:= 7;
|
||||
while (i> 0) and (CV[i] = 0) do
|
||||
begin
|
||||
Inc(CV[i-1]);
|
||||
Dec(i);
|
||||
end;
|
||||
end;
|
||||
|
||||
class function TDCP_blockcipher64.GetBlockSize: integer;
|
||||
begin
|
||||
Result:= 64;
|
||||
end;
|
||||
|
||||
procedure TDCP_blockcipher64.Init(const Key; Size: longword; InitVector: pointer);
|
||||
begin
|
||||
inherited Init(Key,Size,InitVector);
|
||||
InitKey(Key,Size);
|
||||
if InitVector= nil then
|
||||
begin
|
||||
FillChar(IV,8,{$IFDEF DCP1COMPAT}$FF{$ELSE}0{$ENDIF});
|
||||
EncryptECB(IV,IV);
|
||||
Reset;
|
||||
end
|
||||
else
|
||||
begin
|
||||
Move(InitVector^,IV,8);
|
||||
Reset;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TDCP_blockcipher64.SetIV(const Value);
|
||||
begin
|
||||
if not fInitialized then
|
||||
raise EDCP_blockcipher.Create('Cipher not initialized');
|
||||
Move(Value,IV,8);
|
||||
Reset;
|
||||
end;
|
||||
|
||||
procedure TDCP_blockcipher64.GetIV(var Value);
|
||||
begin
|
||||
if not fInitialized then
|
||||
raise EDCP_blockcipher.Create('Cipher not initialized');
|
||||
Move(CV,Value,8);
|
||||
end;
|
||||
|
||||
procedure TDCP_blockcipher64.Reset;
|
||||
begin
|
||||
if not fInitialized then
|
||||
raise EDCP_blockcipher.Create('Cipher not initialized')
|
||||
else
|
||||
Move(IV,CV,8);
|
||||
end;
|
||||
|
||||
procedure TDCP_blockcipher64.Burn;
|
||||
begin
|
||||
FillChar(IV,8,$FF);
|
||||
FillChar(CV,8,$FF);
|
||||
inherited Burn;
|
||||
end;
|
||||
|
||||
procedure TDCP_blockcipher64.EncryptCBC(const Indata; var Outdata; Size: longword);
|
||||
var
|
||||
i: longword;
|
||||
p1, p2: pointer;
|
||||
begin
|
||||
if not fInitialized then
|
||||
raise EDCP_blockcipher.Create('Cipher not initialized');
|
||||
p1:= @Indata;
|
||||
p2:= @Outdata;
|
||||
for i:= 1 to (Size div 8) do
|
||||
begin
|
||||
Move(p1^,p2^,8);
|
||||
XorBlock(p2^,CV,8);
|
||||
EncryptECB(p2^,p2^);
|
||||
Move(p2^,CV,8);
|
||||
p1:= pointer(p1 + 8);
|
||||
p2:= pointer(p2 + 8);
|
||||
end;
|
||||
if (Size mod 8)<> 0 then
|
||||
begin
|
||||
EncryptECB(CV,CV);
|
||||
Move(p1^,p2^,Size mod 8);
|
||||
XorBlock(p2^,CV,Size mod 8);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TDCP_blockcipher64.DecryptCBC(const Indata; var Outdata; Size: longword);
|
||||
var
|
||||
i: longword;
|
||||
p1, p2: pointer;
|
||||
Temp: array[0..7] of byte;
|
||||
begin
|
||||
if not fInitialized then
|
||||
raise EDCP_blockcipher.Create('Cipher not initialized');
|
||||
dcpFillChar(Temp, SizeOf(Temp), 0);
|
||||
p1:= @Indata;
|
||||
p2:= @Outdata;
|
||||
for i:= 1 to (Size div 8) do
|
||||
begin
|
||||
Move(p1^,p2^,8);
|
||||
Move(p1^,Temp,8);
|
||||
DecryptECB(p2^,p2^);
|
||||
XorBlock(p2^,CV,8);
|
||||
Move(Temp,CV,8);
|
||||
p1:= pointer(p1 + 8);
|
||||
p2:= pointer(p2 + 8);
|
||||
end;
|
||||
if (Size mod 8)<> 0 then
|
||||
begin
|
||||
EncryptECB(CV,CV);
|
||||
Move(p1^,p2^,Size mod 8);
|
||||
XorBlock(p2^,CV,Size mod 8);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TDCP_blockcipher64.EncryptCFB8bit(const Indata; var Outdata; Size: longword);
|
||||
var
|
||||
i: longword;
|
||||
p1, p2: Pbyte;
|
||||
Temp: array[0..7] of byte;
|
||||
begin
|
||||
if not fInitialized then
|
||||
raise EDCP_blockcipher.Create('Cipher not initialized');
|
||||
p1:= @Indata;
|
||||
p2:= @Outdata;
|
||||
dcpFillChar(Temp, SizeOf(Temp), 0);
|
||||
for i:= 1 to Size do
|
||||
begin
|
||||
EncryptECB(CV,Temp);
|
||||
p2^:= p1^ xor Temp[0];
|
||||
Move(CV[1],CV[0],8-1);
|
||||
CV[7]:= p2^;
|
||||
Inc(p1);
|
||||
Inc(p2);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TDCP_blockcipher64.DecryptCFB8bit(const Indata; var Outdata; Size: longword);
|
||||
var
|
||||
i: longword;
|
||||
p1, p2: Pbyte;
|
||||
TempByte: byte;
|
||||
Temp: array[0..7] of byte;
|
||||
begin
|
||||
if not fInitialized then
|
||||
raise EDCP_blockcipher.Create('Cipher not initialized');
|
||||
p1:= @Indata;
|
||||
p2:= @Outdata;
|
||||
dcpFillChar(Temp, SizeOf(Temp), 0);
|
||||
for i:= 1 to Size do
|
||||
begin
|
||||
TempByte:= p1^;
|
||||
EncryptECB(CV,Temp);
|
||||
p2^:= p1^ xor Temp[0];
|
||||
Move(CV[1],CV[0],8-1);
|
||||
CV[7]:= TempByte;
|
||||
Inc(p1);
|
||||
Inc(p2);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TDCP_blockcipher64.EncryptCFBblock(const Indata; var Outdata; Size: longword);
|
||||
var
|
||||
i: longword;
|
||||
p1, p2: Pbyte;
|
||||
begin
|
||||
if not fInitialized then
|
||||
raise EDCP_blockcipher.Create('Cipher not initialized');
|
||||
p1:= @Indata;
|
||||
p2:= @Outdata;
|
||||
for i:= 1 to (Size div 8) do
|
||||
begin
|
||||
EncryptECB(CV,CV);
|
||||
Move(p1^,p2^,8);
|
||||
XorBlock(p2^,CV,8);
|
||||
Move(p2^,CV,8);
|
||||
p1:= pointer(pointer(p1) + 8);
|
||||
p2:= pointer(pointer(p2) + 8);
|
||||
end;
|
||||
if (Size mod 8)<> 0 then
|
||||
begin
|
||||
EncryptECB(CV,CV);
|
||||
Move(p1^,p2^,Size mod 8);
|
||||
XorBlock(p2^,CV,Size mod 8);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TDCP_blockcipher64.DecryptCFBblock(const Indata; var Outdata; Size: longword);
|
||||
var
|
||||
i: longword;
|
||||
p1, p2: Pbyte;
|
||||
Temp: array[0..7] of byte;
|
||||
begin
|
||||
if not fInitialized then
|
||||
raise EDCP_blockcipher.Create('Cipher not initialized');
|
||||
p1:= @Indata;
|
||||
p2:= @Outdata;
|
||||
dcpFillChar(Temp, SizeOf(Temp), 0);
|
||||
for i:= 1 to (Size div 8) do
|
||||
begin
|
||||
Move(p1^,Temp,8);
|
||||
EncryptECB(CV,CV);
|
||||
Move(p1^,p2^,8);
|
||||
XorBlock(p2^,CV,8);
|
||||
Move(Temp,CV,8);
|
||||
p1:= pointer(pointer(p1) + 8);
|
||||
p2:= pointer(pointer(p2) + 8);
|
||||
end;
|
||||
if (Size mod 8)<> 0 then
|
||||
begin
|
||||
EncryptECB(CV,CV);
|
||||
Move(p1^,p2^,Size mod 8);
|
||||
XorBlock(p2^,CV,Size mod 8);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TDCP_blockcipher64.EncryptOFB(const Indata; var Outdata; Size: longword);
|
||||
var
|
||||
i: longword;
|
||||
p1, p2: pointer;
|
||||
begin
|
||||
if not fInitialized then
|
||||
raise EDCP_blockcipher.Create('Cipher not initialized');
|
||||
p1:= @Indata;
|
||||
p2:= @Outdata;
|
||||
for i:= 1 to (Size div 8) do
|
||||
begin
|
||||
EncryptECB(CV,CV);
|
||||
Move(p1^,p2^,8);
|
||||
XorBlock(p2^,CV,8);
|
||||
p1:= pointer(p1 + 8);
|
||||
p2:= pointer(p2 + 8);
|
||||
end;
|
||||
if (Size mod 8)<> 0 then
|
||||
begin
|
||||
EncryptECB(CV,CV);
|
||||
Move(p1^,p2^,Size mod 8);
|
||||
XorBlock(p2^,CV,Size mod 8);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TDCP_blockcipher64.DecryptOFB(const Indata; var Outdata; Size: longword);
|
||||
var
|
||||
i: longword;
|
||||
p1, p2: pointer;
|
||||
begin
|
||||
if not fInitialized then
|
||||
raise EDCP_blockcipher.Create('Cipher not initialized');
|
||||
p1:= @Indata;
|
||||
p2:= @Outdata;
|
||||
for i:= 1 to (Size div 8) do
|
||||
begin
|
||||
EncryptECB(CV,CV);
|
||||
Move(p1^,p2^,8);
|
||||
XorBlock(p2^,CV,8);
|
||||
p1:= pointer(p1 + 8);
|
||||
p2:= pointer(p2 + 8);
|
||||
end;
|
||||
if (Size mod 8)<> 0 then
|
||||
begin
|
||||
EncryptECB(CV,CV);
|
||||
Move(p1^,p2^,Size mod 8);
|
||||
XorBlock(p2^,CV,Size mod 8);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TDCP_blockcipher64.EncryptCTR(const Indata; var Outdata; Size: longword);
|
||||
var
|
||||
temp: array[0..7] of byte;
|
||||
i: longword;
|
||||
p1, p2: pointer;
|
||||
begin
|
||||
if not fInitialized then
|
||||
raise EDCP_blockcipher.Create('Cipher not initialized');
|
||||
p1:= @Indata;
|
||||
p2:= @Outdata;
|
||||
dcpFillChar(Temp, SizeOf(Temp), 0);
|
||||
for i:= 1 to (Size div 8) do
|
||||
begin
|
||||
EncryptECB(CV,temp);
|
||||
IncCounter;
|
||||
Move(p1^,p2^,8);
|
||||
XorBlock(p2^,temp,8);
|
||||
p1:= pointer(p1 + 8);
|
||||
p2:= pointer(p2 + 8);
|
||||
end;
|
||||
if (Size mod 8)<> 0 then
|
||||
begin
|
||||
EncryptECB(CV,temp);
|
||||
IncCounter;
|
||||
Move(p1^,p2^,Size mod 8);
|
||||
XorBlock(p2^,temp,Size mod 8);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TDCP_blockcipher64.DecryptCTR(const Indata; var Outdata; Size: longword);
|
||||
var
|
||||
temp: array[0..7] of byte;
|
||||
i: longword;
|
||||
p1, p2: pointer;
|
||||
begin
|
||||
if not fInitialized then
|
||||
raise EDCP_blockcipher.Create('Cipher not initialized');
|
||||
p1:= @Indata;
|
||||
p2:= @Outdata;
|
||||
dcpFillChar(Temp, SizeOf(Temp), 0);
|
||||
for i:= 1 to (Size div 8) do
|
||||
begin
|
||||
EncryptECB(CV,temp);
|
||||
IncCounter;
|
||||
Move(p1^,p2^,8);
|
||||
XorBlock(p2^,temp,8);
|
||||
p1:= pointer(p1 + 8);
|
||||
p2:= pointer(p2 + 8);
|
||||
end;
|
||||
if (Size mod 8)<> 0 then
|
||||
begin
|
||||
EncryptECB(CV,temp);
|
||||
IncCounter;
|
||||
Move(p1^,p2^,Size mod 8);
|
||||
XorBlock(p2^,temp,Size mod 8);
|
||||
end;
|
||||
end;
|
||||
|
||||
{** TDCP_blockcipher128 ********************************************************}
|
||||
|
||||
procedure TDCP_blockcipher128.IncCounter;
|
||||
var
|
||||
i: integer;
|
||||
begin
|
||||
Inc(CV[15]);
|
||||
i:= 15;
|
||||
while (i> 0) and (CV[i] = 0) do
|
||||
begin
|
||||
Inc(CV[i-1]);
|
||||
Dec(i);
|
||||
end;
|
||||
end;
|
||||
|
||||
class function TDCP_blockcipher128.GetBlockSize: integer;
|
||||
begin
|
||||
Result:= 128;
|
||||
end;
|
||||
|
||||
procedure TDCP_blockcipher128.Init(const Key; Size: longword; InitVector: pointer);
|
||||
begin
|
||||
inherited Init(Key,Size,InitVector);
|
||||
InitKey(Key,Size);
|
||||
if InitVector= nil then
|
||||
begin
|
||||
FillChar(IV,16,{$IFDEF DCP1COMPAT}$FF{$ELSE}0{$ENDIF});
|
||||
EncryptECB(IV,IV);
|
||||
Reset;
|
||||
end
|
||||
else
|
||||
begin
|
||||
Move(InitVector^,IV,16);
|
||||
Reset;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TDCP_blockcipher128.SetIV(const Value);
|
||||
begin
|
||||
if not fInitialized then
|
||||
raise EDCP_blockcipher.Create('Cipher not initialized');
|
||||
Move(Value,IV,16);
|
||||
Reset;
|
||||
end;
|
||||
|
||||
procedure TDCP_blockcipher128.GetIV(var Value);
|
||||
begin
|
||||
if not fInitialized then
|
||||
raise EDCP_blockcipher.Create('Cipher not initialized');
|
||||
Move(CV,Value,16);
|
||||
end;
|
||||
|
||||
procedure TDCP_blockcipher128.Reset;
|
||||
begin
|
||||
if not fInitialized then
|
||||
raise EDCP_blockcipher.Create('Cipher not initialized')
|
||||
else
|
||||
Move(IV,CV,16);
|
||||
end;
|
||||
|
||||
procedure TDCP_blockcipher128.Burn;
|
||||
begin
|
||||
FillChar(IV,16,$FF);
|
||||
FillChar(CV,16,$FF);
|
||||
inherited Burn;
|
||||
end;
|
||||
|
||||
procedure TDCP_blockcipher128.EncryptCBC(const Indata; var Outdata; Size: longword);
|
||||
var
|
||||
i: longword;
|
||||
p1, p2: pointer;
|
||||
begin
|
||||
if not fInitialized then
|
||||
raise EDCP_blockcipher.Create('Cipher not initialized');
|
||||
p1:= @Indata;
|
||||
p2:= @Outdata;
|
||||
for i:= 1 to (Size div 16) do
|
||||
begin
|
||||
Move(p1^,p2^,16);
|
||||
XorBlock(p2^,CV,16);
|
||||
EncryptECB(p2^,p2^);
|
||||
Move(p2^,CV,16);
|
||||
p1:= pointer(p1 + 16);
|
||||
p2:= pointer(p2 + 16);
|
||||
end;
|
||||
if (Size mod 16)<> 0 then
|
||||
begin
|
||||
EncryptECB(CV,CV);
|
||||
Move(p1^,p2^,Size mod 16);
|
||||
XorBlock(p2^,CV,Size mod 16);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TDCP_blockcipher128.DecryptCBC(const Indata; var Outdata; Size: longword);
|
||||
var
|
||||
i: longword;
|
||||
p1, p2: pointer;
|
||||
Temp: array[0..15] of byte;
|
||||
begin
|
||||
if not fInitialized then
|
||||
raise EDCP_blockcipher.Create('Cipher not initialized');
|
||||
p1:= @Indata;
|
||||
p2:= @Outdata;
|
||||
dcpFillChar(Temp, SizeOf(Temp), 0);
|
||||
for i:= 1 to (Size div 16) do
|
||||
begin
|
||||
Move(p1^,p2^,16);
|
||||
Move(p1^,Temp,16);
|
||||
DecryptECB(p2^,p2^);
|
||||
XorBlock(p2^,CV,16);
|
||||
Move(Temp,CV,16);
|
||||
p1:= pointer(p1 + 16);
|
||||
p2:= pointer(p2 + 16);
|
||||
end;
|
||||
if (Size mod 16)<> 0 then
|
||||
begin
|
||||
EncryptECB(CV,CV);
|
||||
Move(p1^,p2^,Size mod 16);
|
||||
XorBlock(p2^,CV,Size mod 16);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TDCP_blockcipher128.EncryptCFB8bit(const Indata; var Outdata; Size: longword);
|
||||
var
|
||||
i: longword;
|
||||
p1, p2: Pbyte;
|
||||
Temp: array[0..15] of byte;
|
||||
begin
|
||||
if not fInitialized then
|
||||
raise EDCP_blockcipher.Create('Cipher not initialized');
|
||||
p1:= @Indata;
|
||||
p2:= @Outdata;
|
||||
dcpFillChar(Temp, SizeOf(Temp), 0);
|
||||
for i:= 1 to Size do
|
||||
begin
|
||||
EncryptECB(CV,Temp);
|
||||
p2^:= p1^ xor Temp[0];
|
||||
Move(CV[1],CV[0],15);
|
||||
CV[15]:= p2^;
|
||||
Inc(p1);
|
||||
Inc(p2);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TDCP_blockcipher128.DecryptCFB8bit(const Indata; var Outdata; Size: longword);
|
||||
var
|
||||
i: longword;
|
||||
p1, p2: Pbyte;
|
||||
TempByte: byte;
|
||||
Temp: array[0..15] of byte;
|
||||
begin
|
||||
if not fInitialized then
|
||||
raise EDCP_blockcipher.Create('Cipher not initialized');
|
||||
p1:= @Indata;
|
||||
p2:= @Outdata;
|
||||
dcpFillChar(Temp, SizeOf(Temp), 0);
|
||||
for i:= 1 to Size do
|
||||
begin
|
||||
TempByte:= p1^;
|
||||
EncryptECB(CV,Temp);
|
||||
p2^:= p1^ xor Temp[0];
|
||||
Move(CV[1],CV[0],15);
|
||||
CV[15]:= TempByte;
|
||||
Inc(p1);
|
||||
Inc(p2);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TDCP_blockcipher128.EncryptCFBblock(const Indata; var Outdata; Size: longword);
|
||||
var
|
||||
i: longword;
|
||||
p1, p2: Pbyte;
|
||||
begin
|
||||
if not fInitialized then
|
||||
raise EDCP_blockcipher.Create('Cipher not initialized');
|
||||
p1:= @Indata;
|
||||
p2:= @Outdata;
|
||||
for i:= 1 to (Size div 16) do
|
||||
begin
|
||||
EncryptECB(CV,CV);
|
||||
Move(p1^,p2^,16);
|
||||
XorBlock(p2^,CV,16);
|
||||
Move(p2^,CV,16);
|
||||
p1:= pointer(pointer(p1) + 16);
|
||||
p2:= pointer(pointer(p2) + 16);
|
||||
end;
|
||||
if (Size mod 16)<> 0 then
|
||||
begin
|
||||
EncryptECB(CV,CV);
|
||||
Move(p1^,p2^,Size mod 16);
|
||||
XorBlock(p2^,CV,Size mod 16);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TDCP_blockcipher128.DecryptCFBblock(const Indata; var Outdata; Size: longword);
|
||||
var
|
||||
i: longword;
|
||||
p1, p2: Pbyte;
|
||||
Temp: array[0..15] of byte;
|
||||
begin
|
||||
if not fInitialized then
|
||||
raise EDCP_blockcipher.Create('Cipher not initialized');
|
||||
p1:= @Indata;
|
||||
p2:= @Outdata;
|
||||
dcpFillChar(Temp, SizeOf(Temp), 0);
|
||||
for i:= 1 to (Size div 16) do
|
||||
begin
|
||||
Move(p1^,Temp,16);
|
||||
EncryptECB(CV,CV);
|
||||
Move(p1^,p2^,16);
|
||||
XorBlock(p2^,CV,16);
|
||||
Move(Temp,CV,16);
|
||||
p1:= pointer(pointer(p1) + 16);
|
||||
p2:= pointer(pointer(p2) + 16);
|
||||
end;
|
||||
if (Size mod 16)<> 0 then
|
||||
begin
|
||||
EncryptECB(CV,CV);
|
||||
Move(p1^,p2^,Size mod 16);
|
||||
XorBlock(p2^,CV,Size mod 16);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TDCP_blockcipher128.EncryptOFB(const Indata; var Outdata; Size: longword);
|
||||
var
|
||||
i: longword;
|
||||
p1, p2: pointer;
|
||||
begin
|
||||
if not fInitialized then
|
||||
raise EDCP_blockcipher.Create('Cipher not initialized');
|
||||
p1:= @Indata;
|
||||
p2:= @Outdata;
|
||||
for i:= 1 to (Size div 16) do
|
||||
begin
|
||||
EncryptECB(CV,CV);
|
||||
Move(p1^,p2^,16);
|
||||
XorBlock(p2^,CV,16);
|
||||
p1:= pointer(p1 + 16);
|
||||
p2:= pointer(p2 + 16);
|
||||
end;
|
||||
if (Size mod 16)<> 0 then
|
||||
begin
|
||||
EncryptECB(CV,CV);
|
||||
Move(p1^,p2^,Size mod 16);
|
||||
XorBlock(p2^,CV,Size mod 16);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TDCP_blockcipher128.DecryptOFB(const Indata; var Outdata; Size: longword);
|
||||
var
|
||||
i: longword;
|
||||
p1, p2: pointer;
|
||||
begin
|
||||
if not fInitialized then
|
||||
raise EDCP_blockcipher.Create('Cipher not initialized');
|
||||
p1:= @Indata;
|
||||
p2:= @Outdata;
|
||||
for i:= 1 to (Size div 16) do
|
||||
begin
|
||||
EncryptECB(CV,CV);
|
||||
Move(p1^,p2^,16);
|
||||
XorBlock(p2^,CV,16);
|
||||
p1:= pointer(p1 + 16);
|
||||
p2:= pointer(p2 + 16);
|
||||
end;
|
||||
if (Size mod 16)<> 0 then
|
||||
begin
|
||||
EncryptECB(CV,CV);
|
||||
Move(p1^,p2^,Size mod 16);
|
||||
XorBlock(p2^,CV,Size mod 16);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TDCP_blockcipher128.EncryptCTR(const Indata; var Outdata; Size: longword);
|
||||
var
|
||||
temp: array[0..15] of byte;
|
||||
i: longword;
|
||||
p1, p2: pointer;
|
||||
begin
|
||||
if not fInitialized then
|
||||
raise EDCP_blockcipher.Create('Cipher not initialized');
|
||||
p1:= @Indata;
|
||||
p2:= @Outdata;
|
||||
dcpFillChar(Temp, SizeOf(Temp), 0);
|
||||
for i:= 1 to (Size div 16) do
|
||||
begin
|
||||
EncryptECB(CV,temp);
|
||||
IncCounter;
|
||||
Move(p1^,p2^,16);
|
||||
XorBlock(p2^,temp,16);
|
||||
p1:= pointer(p1 + 16);
|
||||
p2:= pointer(p2 + 16);
|
||||
end;
|
||||
if (Size mod 16)<> 0 then
|
||||
begin
|
||||
EncryptECB(CV,temp);
|
||||
IncCounter;
|
||||
Move(p1^,p2^,Size mod 16);
|
||||
XorBlock(p2^,temp,Size mod 16);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TDCP_blockcipher128.DecryptCTR(const Indata; var Outdata; Size: longword);
|
||||
var
|
||||
temp: array[0..15] of byte;
|
||||
i: longword;
|
||||
p1, p2: pointer;
|
||||
begin
|
||||
if not fInitialized then
|
||||
raise EDCP_blockcipher.Create('Cipher not initialized');
|
||||
p1:= @Indata;
|
||||
p2:= @Outdata;
|
||||
dcpFillChar(Temp, SizeOf(Temp), 0);
|
||||
for i:= 1 to (Size div 16) do
|
||||
begin
|
||||
EncryptECB(CV,temp);
|
||||
IncCounter;
|
||||
Move(p1^,p2^,16);
|
||||
XorBlock(p2^,temp,16);
|
||||
p1:= pointer(p1 + 16);
|
||||
p2:= pointer(p2 + 16);
|
||||
end;
|
||||
if (Size mod 16)<> 0 then
|
||||
begin
|
||||
EncryptECB(CV,temp);
|
||||
IncCounter;
|
||||
Move(p1^,p2^,Size mod 16);
|
||||
XorBlock(p2^,temp,Size mod 16);
|
||||
end;
|
||||
end;
|
||||
|
||||
end.
|
||||
73
dcpcrypt/dcpconst.pas
Normal file
@@ -0,0 +1,73 @@
|
||||
{******************************************************************************}
|
||||
{* DCPcrypt v2.0 written by David Barton (crypto@cityinthesky.co.uk) **********}
|
||||
{******************************************************************************}
|
||||
{* Constants for use with DCPcrypt ********************************************}
|
||||
{******************************************************************************}
|
||||
{* Copyright (c) 1999-2002 David Barton *}
|
||||
{* Permission is hereby granted, free of charge, to any person obtaining a *}
|
||||
{* copy of this software and associated documentation files (the "Software"), *}
|
||||
{* to deal in the Software without restriction, including without limitation *}
|
||||
{* the rights to use, copy, modify, merge, publish, distribute, sublicense, *}
|
||||
{* and/or sell copies of the Software, and to permit persons to whom the *}
|
||||
{* Software is furnished to do so, subject to the following conditions: *}
|
||||
{* *}
|
||||
{* The above copyright notice and this permission notice shall be included in *}
|
||||
{* all copies or substantial portions of the Software. *}
|
||||
{* *}
|
||||
{* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *}
|
||||
{* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *}
|
||||
{* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *}
|
||||
{* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *}
|
||||
{* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *}
|
||||
{* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *}
|
||||
{* DEALINGS IN THE SOFTWARE. *}
|
||||
{******************************************************************************}
|
||||
unit DCPconst;
|
||||
|
||||
interface
|
||||
|
||||
{******************************************************************************}
|
||||
const
|
||||
{ Component registration }
|
||||
DCPcipherpage = 'DCPciphers';
|
||||
DCPhashpage = 'DCPhashes';
|
||||
|
||||
{ ID values }
|
||||
DCP_rc2 = 1;
|
||||
DCP_sha1 = 2;
|
||||
DCP_rc5 = 3;
|
||||
DCP_rc6 = 4;
|
||||
DCP_blowfish = 5;
|
||||
DCP_twofish = 6;
|
||||
DCP_cast128 = 7;
|
||||
DCP_gost = 8;
|
||||
DCP_rijndael = 9;
|
||||
DCP_ripemd160 = 10;
|
||||
DCP_misty1 = 11;
|
||||
DCP_idea = 12;
|
||||
DCP_mars = 13;
|
||||
DCP_haval = 14;
|
||||
DCP_cast256 = 15;
|
||||
DCP_md5 = 16;
|
||||
DCP_md4 = 17;
|
||||
DCP_tiger = 18;
|
||||
DCP_rc4 = 19;
|
||||
DCP_ice = 20;
|
||||
DCP_thinice = 21;
|
||||
DCP_ice2 = 22;
|
||||
DCP_des = 23;
|
||||
DCP_3des = 24;
|
||||
DCP_tea = 25;
|
||||
DCP_serpent = 26;
|
||||
DCP_ripemd128 = 27;
|
||||
DCP_sha256 = 28;
|
||||
DCP_sha384 = 29;
|
||||
DCP_sha512 = 30;
|
||||
DCP_sfv = 99;
|
||||
|
||||
|
||||
{******************************************************************************}
|
||||
{******************************************************************************}
|
||||
implementation
|
||||
|
||||
end.
|
||||
125
dcpcrypt/dcpcrypt.lpk
Normal file
@@ -0,0 +1,125 @@
|
||||
<?xml version="1.0"?>
|
||||
<CONFIG>
|
||||
<Package Version="4">
|
||||
<Name Value="dcpcrypt"/>
|
||||
<Author Value="David Barton, Barko & Graeme Geldenhuys"/>
|
||||
<CompilerOptions>
|
||||
<Version Value="11"/>
|
||||
<SearchPaths>
|
||||
<OtherUnitFiles Value="Ciphers;Hashes;$(PkgOutDir)"/>
|
||||
<UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)"/>
|
||||
</SearchPaths>
|
||||
<Parsing>
|
||||
<SyntaxOptions>
|
||||
<SyntaxMode Value="Delphi"/>
|
||||
<CStyleOperator Value="False"/>
|
||||
<IncludeAssertionCode Value="True"/>
|
||||
<AllowLabel Value="False"/>
|
||||
<CPPInline Value="False"/>
|
||||
</SyntaxOptions>
|
||||
</Parsing>
|
||||
<Linking>
|
||||
<Debugging>
|
||||
<DebugInfoType Value="dsDwarf2Set"/>
|
||||
</Debugging>
|
||||
</Linking>
|
||||
<Other>
|
||||
<CustomOptions Value="-Xd"/>
|
||||
<CompilerPath Value="$(CompPath)"/>
|
||||
</Other>
|
||||
</CompilerOptions>
|
||||
<Description Value="DCPcrypt Cryptographic Component Library
|
||||
"/>
|
||||
<License Value="DCPcrypt is open source software (released under the MIT license) and as such there is no charge for inclusion in other software.
|
||||
www.cityinthesky.co.uk/cryptography.html
|
||||
"/>
|
||||
<Version Major="2" Release="4" Build="1"/>
|
||||
<Files Count="18">
|
||||
<Item1>
|
||||
<Filename Value="dcpbase64.pas"/>
|
||||
<UnitName Value="DCPbase64"/>
|
||||
</Item1>
|
||||
<Item2>
|
||||
<Filename Value="dcpblockciphers.pas"/>
|
||||
<UnitName Value="DCPblockciphers"/>
|
||||
</Item2>
|
||||
<Item3>
|
||||
<Filename Value="dcpconst.pas"/>
|
||||
<UnitName Value="DCPconst"/>
|
||||
</Item3>
|
||||
<Item4>
|
||||
<Filename Value="dcpcrypt2.pas"/>
|
||||
<UnitName Value="DCPcrypt2"/>
|
||||
</Item4>
|
||||
<Item5>
|
||||
<Filename Value="Hashes/dcphaval.pas"/>
|
||||
<UnitName Value="DCPhaval"/>
|
||||
</Item5>
|
||||
<Item6>
|
||||
<Filename Value="Hashes/dcpmd4.pas"/>
|
||||
<UnitName Value="DCPmd4"/>
|
||||
</Item6>
|
||||
<Item7>
|
||||
<Filename Value="Hashes/dcpmd5.pas"/>
|
||||
<UnitName Value="DCPmd5"/>
|
||||
</Item7>
|
||||
<Item8>
|
||||
<Filename Value="Hashes/dcpripemd128.pas"/>
|
||||
<UnitName Value="DCPripemd128"/>
|
||||
</Item8>
|
||||
<Item9>
|
||||
<Filename Value="Hashes/dcpripemd160.pas"/>
|
||||
<UnitName Value="DCPripemd160"/>
|
||||
</Item9>
|
||||
<Item10>
|
||||
<Filename Value="Hashes/dcpsha1.pas"/>
|
||||
<UnitName Value="DCPsha1"/>
|
||||
</Item10>
|
||||
<Item11>
|
||||
<Filename Value="Hashes/dcpsha256.pas"/>
|
||||
<UnitName Value="DCPsha256"/>
|
||||
</Item11>
|
||||
<Item12>
|
||||
<Filename Value="Hashes/dcpsha512.pas"/>
|
||||
<UnitName Value="DCPsha512"/>
|
||||
</Item12>
|
||||
<Item13>
|
||||
<Filename Value="Hashes/dcptiger.pas"/>
|
||||
<UnitName Value="DCPtiger"/>
|
||||
</Item13>
|
||||
<Item14>
|
||||
<Filename Value="Hashes/DCPhaval3.inc"/>
|
||||
<Type Value="Include"/>
|
||||
</Item14>
|
||||
<Item15>
|
||||
<Filename Value="Hashes/DCPhaval4.inc"/>
|
||||
<Type Value="Include"/>
|
||||
</Item15>
|
||||
<Item16>
|
||||
<Filename Value="Hashes/DCPhaval5.inc"/>
|
||||
<Type Value="Include"/>
|
||||
</Item16>
|
||||
<Item17>
|
||||
<Filename Value="Hashes/dcpsfv.pas"/>
|
||||
<UnitName Value="DCPsfv"/>
|
||||
</Item17>
|
||||
<Item18>
|
||||
<Filename Value="Hashes/DCPtiger.inc"/>
|
||||
<Type Value="Include"/>
|
||||
</Item18>
|
||||
</Files>
|
||||
<RequiredPkgs Count="1">
|
||||
<Item1>
|
||||
<PackageName Value="FCL"/>
|
||||
<MinVersion Major="1" Valid="True"/>
|
||||
</Item1>
|
||||
</RequiredPkgs>
|
||||
<UsageOptions>
|
||||
<UnitPath Value="$(PkgOutDir)"/>
|
||||
</UsageOptions>
|
||||
<PublishOptions>
|
||||
<Version Value="2"/>
|
||||
<IgnoreBinaries Value="False"/>
|
||||
</PublishOptions>
|
||||
</Package>
|
||||
</CONFIG>
|
||||
15
dcpcrypt/dcpcrypt.pas
Normal file
@@ -0,0 +1,15 @@
|
||||
{ This file was automatically created by Lazarus. Do not edit!
|
||||
This source is only used to compile and install the package.
|
||||
}
|
||||
|
||||
unit dcpcrypt;
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
DCPbase64, DCPblockciphers, DCPconst, DCPcrypt2, DCPhaval, DCPmd4, DCPmd5,
|
||||
DCPripemd128, DCPripemd160, DCPsha1, DCPsha256, DCPsha512, DCPtiger, DCPsfv;
|
||||
|
||||
implementation
|
||||
|
||||
end.
|
||||
702
dcpcrypt/dcpcrypt2.pas
Normal file
@@ -0,0 +1,702 @@
|
||||
{******************************************************************************}
|
||||
{* DCPcrypt v2.0 written by David Barton (crypto@cityinthesky.co.uk) **********}
|
||||
{******************************************************************************}
|
||||
{* Main component definitions *************************************************}
|
||||
{******************************************************************************}
|
||||
{* Copyright (c) 1999-2003 David Barton *}
|
||||
{* Permission is hereby granted, free of charge, to any person obtaining a *}
|
||||
{* copy of this software and associated documentation files (the "Software"), *}
|
||||
{* to deal in the Software without restriction, including without limitation *}
|
||||
{* the rights to use, copy, modify, merge, publish, distribute, sublicense, *}
|
||||
{* and/or sell copies of the Software, and to permit persons to whom the *}
|
||||
{* Software is furnished to do so, subject to the following conditions: *}
|
||||
{* *}
|
||||
{* The above copyright notice and this permission notice shall be included in *}
|
||||
{* all copies or substantial portions of the Software. *}
|
||||
{* *}
|
||||
{* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *}
|
||||
{* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *}
|
||||
{* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *}
|
||||
{* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *}
|
||||
{* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *}
|
||||
{* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *}
|
||||
{* DEALINGS IN THE SOFTWARE. *}
|
||||
{******************************************************************************}
|
||||
unit DCPcrypt2;
|
||||
|
||||
{$MODE Delphi}
|
||||
|
||||
interface
|
||||
uses
|
||||
Classes, Sysutils, DCPbase64;
|
||||
|
||||
//{$DEFINE DCP1COMPAT} { DCPcrypt v1.31 compatiblity mode - see documentation }
|
||||
|
||||
{******************************************************************************}
|
||||
{ A few predefined types to help out }
|
||||
|
||||
type
|
||||
{$IFNDEF FPC}
|
||||
Pbyte= ^byte;
|
||||
Pword= ^word;
|
||||
Pdword= ^dword;
|
||||
Pint64= ^int64;
|
||||
dword= longword;
|
||||
Pwordarray= ^Twordarray;
|
||||
Twordarray= array[0..19383] of word;
|
||||
{$ENDIF}
|
||||
Pdwordarray= ^Tdwordarray;
|
||||
Tdwordarray= array[0..8191] of dword;
|
||||
|
||||
|
||||
{******************************************************************************}
|
||||
{ The base class from which all hash algorithms are to be derived }
|
||||
|
||||
type
|
||||
EDCP_hash= class(Exception);
|
||||
TDCP_hash= class(TComponent)
|
||||
protected
|
||||
fInitialized: boolean; { Whether or not the algorithm has been initialized }
|
||||
|
||||
procedure DeadInt(Value: integer); { Knudge to display vars in the object inspector }
|
||||
procedure DeadStr(Value: string); { Knudge to display vars in the object inspector }
|
||||
|
||||
private
|
||||
function _GetId: integer;
|
||||
function _GetAlgorithm: string;
|
||||
function _GetHashSize: integer;
|
||||
|
||||
public
|
||||
property Initialized: boolean
|
||||
read fInitialized;
|
||||
|
||||
class function GetId: integer; virtual;
|
||||
{ Get the algorithm id }
|
||||
class function GetAlgorithm: string; virtual;
|
||||
{ Get the algorithm name }
|
||||
class function GetHashSize: integer; virtual;
|
||||
{ Get the size of the digest produced - in bits }
|
||||
class function SelfTest: boolean; virtual;
|
||||
{ Tests the implementation with several test vectors }
|
||||
|
||||
procedure Init; virtual;
|
||||
{ Initialize the hash algorithm }
|
||||
procedure Final(var Digest); virtual;
|
||||
{ Create the final digest and clear the stored information.
|
||||
The size of the Digest var must be at least equal to the hash size }
|
||||
procedure Burn; virtual;
|
||||
{ Clear any stored information with out creating the final digest }
|
||||
|
||||
procedure Update(const Buffer; Size: longword); virtual;
|
||||
{ Update the hash buffer with Size bytes of data from Buffer }
|
||||
procedure UpdateStream(Stream: TStream; Size: longword);
|
||||
{ Update the hash buffer with Size bytes of data from the stream }
|
||||
procedure UpdateStr(const Str: string);
|
||||
{ Update the hash buffer with the string }
|
||||
|
||||
destructor Destroy; override;
|
||||
|
||||
published
|
||||
property Id: integer
|
||||
read _GetId write DeadInt;
|
||||
property Algorithm: string
|
||||
read _GetAlgorithm write DeadStr;
|
||||
property HashSize: integer
|
||||
read _GetHashSize write DeadInt;
|
||||
end;
|
||||
TDCP_hashclass= class of TDCP_hash;
|
||||
|
||||
|
||||
{******************************************************************************}
|
||||
{ The base class from which all encryption components will be derived. }
|
||||
{ Stream ciphers will be derived directly from this class where as }
|
||||
{ Block ciphers will have a further foundation class TDCP_blockcipher. }
|
||||
|
||||
type
|
||||
EDCP_cipher= class(Exception);
|
||||
TDCP_cipher= class(TComponent)
|
||||
protected
|
||||
fInitialized: boolean; { Whether or not the key setup has been done yet }
|
||||
|
||||
procedure DeadInt(Value: integer); { Knudge to display vars in the object inspector }
|
||||
procedure DeadStr(Value: string); { Knudge to display vars in the object inspector }
|
||||
|
||||
private
|
||||
function _GetId: integer;
|
||||
function _GetAlgorithm: string;
|
||||
function _GetMaxKeySize: integer;
|
||||
|
||||
public
|
||||
property Initialized: boolean
|
||||
read fInitialized;
|
||||
|
||||
class function GetId: integer; virtual;
|
||||
{ Get the algorithm id }
|
||||
class function GetAlgorithm: string; virtual;
|
||||
{ Get the algorithm name }
|
||||
class function GetMaxKeySize: integer; virtual;
|
||||
{ Get the maximum key size (in bits) }
|
||||
class function SelfTest: boolean; virtual;
|
||||
{ Tests the implementation with several test vectors }
|
||||
|
||||
procedure Init(const Key; Size: longword; InitVector: pointer); virtual;
|
||||
{ Do key setup based on the data in Key, size is in bits }
|
||||
procedure InitStr(const Key: string; HashType: TDCP_hashclass);
|
||||
{ Do key setup based on a hash of the key string }
|
||||
procedure Burn; virtual;
|
||||
{ Clear all stored key information }
|
||||
procedure Reset; virtual;
|
||||
{ Reset any stored chaining information }
|
||||
procedure Encrypt(const Indata; var Outdata; Size: longword); virtual;
|
||||
{ Encrypt size bytes of data and place in Outdata }
|
||||
procedure Decrypt(const Indata; var Outdata; Size: longword); virtual;
|
||||
{ Decrypt size bytes of data and place in Outdata }
|
||||
function EncryptStream(InStream, OutStream: TStream; Size: longword): longword;
|
||||
{ Encrypt size bytes of data from InStream and place in OutStream }
|
||||
function DecryptStream(InStream, OutStream: TStream; Size: longword): longword;
|
||||
{ Decrypt size bytes of data from InStream and place in OutStream }
|
||||
function EncryptString(const Str: string): string; virtual;
|
||||
{ Encrypt a string and return Base64 encoded }
|
||||
function DecryptString(const Str: string): string; virtual;
|
||||
{ Decrypt a Base64 encoded string }
|
||||
|
||||
constructor Create(AOwner: TComponent); override;
|
||||
destructor Destroy; override;
|
||||
|
||||
published
|
||||
property Id: integer
|
||||
read _GetId write DeadInt;
|
||||
property Algorithm: string
|
||||
read _GetAlgorithm write DeadStr;
|
||||
property MaxKeySize: integer
|
||||
read _GetMaxKeySize write DeadInt;
|
||||
end;
|
||||
TDCP_cipherclass= class of TDCP_cipher;
|
||||
|
||||
|
||||
{******************************************************************************}
|
||||
{ The base class from which all block ciphers are to be derived, this }
|
||||
{ extra class takes care of the different block encryption modes. }
|
||||
|
||||
type
|
||||
TDCP_ciphermode= (cmCBC, cmCFB8bit, cmCFBblock, cmOFB, cmCTR); // cmCFB8bit is equal to DCPcrypt v1.xx's CFB mode
|
||||
EDCP_blockcipher= class(EDCP_cipher);
|
||||
TDCP_blockcipher= class(TDCP_cipher)
|
||||
protected
|
||||
fCipherMode: TDCP_ciphermode; { The cipher mode the encrypt method uses }
|
||||
|
||||
procedure InitKey(const Key; Size: longword); virtual;
|
||||
|
||||
private
|
||||
function _GetBlockSize: integer;
|
||||
|
||||
public
|
||||
class function GetBlockSize: integer; virtual;
|
||||
{ Get the block size of the cipher (in bits) }
|
||||
|
||||
procedure SetIV(const Value); virtual;
|
||||
{ Sets the IV to Value and performs a reset }
|
||||
procedure GetIV(var Value); virtual;
|
||||
{ Returns the current chaining information, not the actual IV }
|
||||
|
||||
procedure Encrypt(const Indata; var Outdata; Size: longword); override;
|
||||
{ Encrypt size bytes of data and place in Outdata using CipherMode }
|
||||
procedure Decrypt(const Indata; var Outdata; Size: longword); override;
|
||||
{ Decrypt size bytes of data and place in Outdata using CipherMode }
|
||||
function EncryptString(const Str: string): string; override;
|
||||
{ Encrypt a string and return Base64 encoded }
|
||||
function DecryptString(const Str: string): string; override;
|
||||
{ Decrypt a Base64 encoded string }
|
||||
procedure EncryptECB(const Indata; var Outdata); virtual;
|
||||
{ Encrypt a block of data using the ECB method of encryption }
|
||||
procedure DecryptECB(const Indata; var Outdata); virtual;
|
||||
{ Decrypt a block of data using the ECB method of decryption }
|
||||
procedure EncryptCBC(const Indata; var Outdata; Size: longword); virtual;
|
||||
{ Encrypt size bytes of data using the CBC method of encryption }
|
||||
procedure DecryptCBC(const Indata; var Outdata; Size: longword); virtual;
|
||||
{ Decrypt size bytes of data using the CBC method of decryption }
|
||||
procedure EncryptCFB8bit(const Indata; var Outdata; Size: longword); virtual;
|
||||
{ Encrypt size bytes of data using the CFB (8 bit) method of encryption }
|
||||
procedure DecryptCFB8bit(const Indata; var Outdata; Size: longword); virtual;
|
||||
{ Decrypt size bytes of data using the CFB (8 bit) method of decryption }
|
||||
procedure EncryptCFBblock(const Indata; var Outdata; Size: longword); virtual;
|
||||
{ Encrypt size bytes of data using the CFB (block) method of encryption }
|
||||
procedure DecryptCFBblock(const Indata; var Outdata; Size: longword); virtual;
|
||||
{ Decrypt size bytes of data using the CFB (block) method of decryption }
|
||||
procedure EncryptOFB(const Indata; var Outdata; Size: longword); virtual;
|
||||
{ Encrypt size bytes of data using the OFB method of encryption }
|
||||
procedure DecryptOFB(const Indata; var Outdata; Size: longword); virtual;
|
||||
{ Decrypt size bytes of data using the OFB method of decryption }
|
||||
procedure EncryptCTR(const Indata; var Outdata; Size: longword); virtual;
|
||||
{ Encrypt size bytes of data using the CTR method of encryption }
|
||||
procedure DecryptCTR(const Indata; var Outdata; Size: longword); virtual;
|
||||
{ Decrypt size bytes of data using the CTR method of decryption }
|
||||
|
||||
constructor Create(AOwner: TComponent); override;
|
||||
|
||||
published
|
||||
property BlockSize: integer
|
||||
read _GetBlockSize write DeadInt;
|
||||
property CipherMode: TDCP_ciphermode
|
||||
read fCipherMode write fCipherMode default cmCBC;
|
||||
end;
|
||||
TDCP_blockcipherclass= class of TDCP_blockcipher;
|
||||
|
||||
|
||||
{******************************************************************************}
|
||||
{ Helper functions }
|
||||
|
||||
procedure XorBlock(var InData1, InData2; Size: longword);
|
||||
// Supposed to be an optimized version of XorBlock() using 32-bit xor
|
||||
procedure XorBlockEx(var InData1, InData2; Size: longword);
|
||||
// removes the compiler hint due to first param being 'var' instead of 'out'
|
||||
procedure dcpFillChar(out x; count: SizeInt; Value: Byte); overload;
|
||||
procedure dcpFillChar(out x; count: SizeInt; Value: Char); overload;
|
||||
procedure ZeroMemory(Destination: Pointer; Length: PtrUInt);
|
||||
|
||||
|
||||
|
||||
implementation
|
||||
|
||||
{$Q-}{$R-}
|
||||
|
||||
|
||||
{** TDCP_hash *****************************************************************}
|
||||
|
||||
procedure TDCP_hash.DeadInt(Value: integer);
|
||||
begin
|
||||
end;
|
||||
|
||||
procedure TDCP_hash.DeadStr(Value: string);
|
||||
begin
|
||||
end;
|
||||
|
||||
function TDCP_hash._GetId: integer;
|
||||
begin
|
||||
Result:= GetId;
|
||||
end;
|
||||
|
||||
function TDCP_hash._GetAlgorithm: string;
|
||||
begin
|
||||
Result:= GetAlgorithm;
|
||||
end;
|
||||
|
||||
function TDCP_hash._GetHashSize: integer;
|
||||
begin
|
||||
Result:= GetHashSize;
|
||||
end;
|
||||
|
||||
class function TDCP_hash.GetId: integer;
|
||||
begin
|
||||
Result:= -1;
|
||||
end;
|
||||
|
||||
class function TDCP_hash.GetAlgorithm: string;
|
||||
begin
|
||||
Result:= '';
|
||||
end;
|
||||
|
||||
class function TDCP_hash.GetHashSize: integer;
|
||||
begin
|
||||
Result:= -1;
|
||||
end;
|
||||
|
||||
class function TDCP_hash.SelfTest: boolean;
|
||||
begin
|
||||
Result:= false;
|
||||
end;
|
||||
|
||||
procedure TDCP_hash.Init;
|
||||
begin
|
||||
end;
|
||||
|
||||
procedure TDCP_hash.Final(var Digest);
|
||||
begin
|
||||
end;
|
||||
|
||||
procedure TDCP_hash.Burn;
|
||||
begin
|
||||
end;
|
||||
|
||||
procedure TDCP_hash.Update(const Buffer; Size: longword);
|
||||
begin
|
||||
end;
|
||||
|
||||
procedure TDCP_hash.UpdateStream(Stream: TStream; Size: longword);
|
||||
var
|
||||
Buffer: array[0..8191] of byte;
|
||||
i, read: integer;
|
||||
begin
|
||||
dcpFillChar(Buffer, SizeOf(Buffer), 0);
|
||||
for i:= 1 to (Size div Sizeof(Buffer)) do
|
||||
begin
|
||||
read:= Stream.Read(Buffer,Sizeof(Buffer));
|
||||
Update(Buffer,read);
|
||||
end;
|
||||
if (Size mod Sizeof(Buffer))<> 0 then
|
||||
begin
|
||||
read:= Stream.Read(Buffer,Size mod Sizeof(Buffer));
|
||||
Update(Buffer,read);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TDCP_hash.UpdateStr(const Str: string);
|
||||
begin
|
||||
Update(Str[1],Length(Str));
|
||||
end;
|
||||
|
||||
destructor TDCP_hash.Destroy;
|
||||
begin
|
||||
if fInitialized then
|
||||
Burn;
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
|
||||
{** TDCP_cipher ***************************************************************}
|
||||
|
||||
procedure TDCP_cipher.DeadInt(Value: integer);
|
||||
begin
|
||||
end;
|
||||
|
||||
procedure TDCP_cipher.DeadStr(Value: string);
|
||||
begin
|
||||
end;
|
||||
|
||||
function TDCP_cipher._GetId: integer;
|
||||
begin
|
||||
Result:= GetId;
|
||||
end;
|
||||
|
||||
function TDCP_cipher._GetAlgorithm: string;
|
||||
begin
|
||||
Result:= GetAlgorithm;
|
||||
end;
|
||||
|
||||
function TDCP_cipher._GetMaxKeySize: integer;
|
||||
begin
|
||||
Result:= GetMaxKeySize;
|
||||
end;
|
||||
|
||||
class function TDCP_cipher.GetId: integer;
|
||||
begin
|
||||
Result:= -1;
|
||||
end;
|
||||
|
||||
class function TDCP_cipher.GetAlgorithm: string;
|
||||
begin
|
||||
Result:= '';
|
||||
end;
|
||||
|
||||
class function TDCP_cipher.GetMaxKeySize: integer;
|
||||
begin
|
||||
Result:= -1;
|
||||
end;
|
||||
|
||||
class function TDCP_cipher.SelfTest: boolean;
|
||||
begin
|
||||
Result:= false;
|
||||
end;
|
||||
|
||||
procedure TDCP_cipher.Init(const Key; Size: longword; InitVector: pointer);
|
||||
begin
|
||||
if fInitialized then
|
||||
Burn;
|
||||
if (Size <= 0) or ((Size and 3)<> 0) or (Size> longword(GetMaxKeySize)) then
|
||||
raise EDCP_cipher.Create('Invalid key size')
|
||||
else
|
||||
fInitialized:= true;
|
||||
end;
|
||||
|
||||
procedure TDCP_cipher.InitStr(const Key: string; HashType: TDCP_hashclass);
|
||||
var
|
||||
Hash: TDCP_hash;
|
||||
Digest: pointer;
|
||||
begin
|
||||
if fInitialized then
|
||||
Burn;
|
||||
try
|
||||
GetMem(Digest,HashType.GetHashSize div 8);
|
||||
Hash:= HashType.Create(Self);
|
||||
Hash.Init;
|
||||
Hash.UpdateStr(Key);
|
||||
Hash.Final(Digest^);
|
||||
Hash.Free;
|
||||
if MaxKeySize< HashType.GetHashSize then
|
||||
begin
|
||||
Init(Digest^,MaxKeySize,nil);
|
||||
end
|
||||
else
|
||||
begin
|
||||
Init(Digest^,HashType.GetHashSize,nil);
|
||||
end;
|
||||
FillChar(Digest^,HashType.GetHashSize div 8,$FF);
|
||||
FreeMem(Digest);
|
||||
except
|
||||
raise EDCP_cipher.Create('Unable to allocate sufficient memory for hash digest');
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TDCP_cipher.Burn;
|
||||
begin
|
||||
fInitialized:= false;
|
||||
end;
|
||||
|
||||
procedure TDCP_cipher.Reset;
|
||||
begin
|
||||
end;
|
||||
|
||||
procedure TDCP_cipher.Encrypt(const Indata; var Outdata; Size: longword);
|
||||
begin
|
||||
end;
|
||||
|
||||
procedure TDCP_cipher.Decrypt(const Indata; var Outdata; Size: longword);
|
||||
begin
|
||||
end;
|
||||
|
||||
function TDCP_cipher.EncryptStream(InStream, OutStream: TStream; Size: longword): longword;
|
||||
var
|
||||
Buffer: array[0..8191] of byte;
|
||||
i, Read: longword;
|
||||
begin
|
||||
dcpFillChar(Buffer, SizeOf(Buffer), 0);
|
||||
Result:= 0;
|
||||
for i:= 1 to (Size div Sizeof(Buffer)) do
|
||||
begin
|
||||
Read:= InStream.Read(Buffer,Sizeof(Buffer));
|
||||
Inc(Result,Read);
|
||||
Encrypt(Buffer,Buffer,Read);
|
||||
OutStream.Write(Buffer,Read);
|
||||
end;
|
||||
if (Size mod Sizeof(Buffer))<> 0 then
|
||||
begin
|
||||
Read:= InStream.Read(Buffer,Size mod Sizeof(Buffer));
|
||||
Inc(Result,Read);
|
||||
Encrypt(Buffer,Buffer,Read);
|
||||
OutStream.Write(Buffer,Read);
|
||||
end;
|
||||
end;
|
||||
|
||||
function TDCP_cipher.DecryptStream(InStream, OutStream: TStream; Size: longword): longword;
|
||||
var
|
||||
Buffer: array[0..8191] of byte;
|
||||
i, Read: longword;
|
||||
begin
|
||||
dcpFillChar(Buffer, SizeOf(Buffer), 0);
|
||||
Result:= 0;
|
||||
for i:= 1 to (Size div Sizeof(Buffer)) do
|
||||
begin
|
||||
Read:= InStream.Read(Buffer,Sizeof(Buffer));
|
||||
Inc(Result,Read);
|
||||
Decrypt(Buffer,Buffer,Read);
|
||||
OutStream.Write(Buffer,Read);
|
||||
end;
|
||||
if (Size mod Sizeof(Buffer))<> 0 then
|
||||
begin
|
||||
Read:= InStream.Read(Buffer,Size mod Sizeof(Buffer));
|
||||
Inc(Result,Read);
|
||||
Decrypt(Buffer,Buffer,Read);
|
||||
OutStream.Write(Buffer,Read);
|
||||
end;
|
||||
end;
|
||||
|
||||
function TDCP_cipher.EncryptString(const Str: string): string;
|
||||
begin
|
||||
SetLength(Result,Length(Str));
|
||||
Encrypt(Str[1],Result[1],Length(Str));
|
||||
Result:= Base64EncodeStr(Result);
|
||||
end;
|
||||
|
||||
function TDCP_cipher.DecryptString(const Str: string): string;
|
||||
begin
|
||||
Result:= Base64DecodeStr(Str);
|
||||
Decrypt(Result[1],Result[1],Length(Result));
|
||||
end;
|
||||
|
||||
constructor TDCP_cipher.Create(AOwner: TComponent);
|
||||
begin
|
||||
inherited Create(AOwner);
|
||||
Burn;
|
||||
end;
|
||||
|
||||
destructor TDCP_cipher.Destroy;
|
||||
begin
|
||||
if fInitialized then
|
||||
Burn;
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
|
||||
{** TDCP_blockcipher **********************************************************}
|
||||
|
||||
procedure TDCP_blockcipher.InitKey(const Key; Size: longword);
|
||||
begin
|
||||
end;
|
||||
|
||||
function TDCP_blockcipher._GetBlockSize: integer;
|
||||
begin
|
||||
Result:= GetBlockSize;
|
||||
end;
|
||||
|
||||
class function TDCP_blockcipher.GetBlockSize: integer;
|
||||
begin
|
||||
Result:= -1;
|
||||
end;
|
||||
|
||||
procedure TDCP_blockcipher.SetIV(const Value);
|
||||
begin
|
||||
end;
|
||||
|
||||
procedure TDCP_blockcipher.GetIV(var Value);
|
||||
begin
|
||||
end;
|
||||
|
||||
procedure TDCP_blockcipher.Encrypt(const Indata; var Outdata; Size: longword);
|
||||
begin
|
||||
case fCipherMode of
|
||||
cmCBC: EncryptCBC(Indata,Outdata,Size);
|
||||
cmCFB8bit: EncryptCFB8bit(Indata,Outdata,Size);
|
||||
cmCFBblock: EncryptCFBblock(Indata,Outdata,Size);
|
||||
cmOFB: EncryptOFB(Indata,Outdata,Size);
|
||||
cmCTR: EncryptCTR(Indata,Outdata,Size);
|
||||
end;
|
||||
end;
|
||||
|
||||
function TDCP_blockcipher.EncryptString(const Str: string): string;
|
||||
begin
|
||||
SetLength(Result,Length(Str));
|
||||
EncryptCFB8bit(Str[1],Result[1],Length(Str));
|
||||
Result:= Base64EncodeStr(Result);
|
||||
end;
|
||||
|
||||
function TDCP_blockcipher.DecryptString(const Str: string): string;
|
||||
begin
|
||||
Result:= Base64DecodeStr(Str);
|
||||
DecryptCFB8bit(Result[1],Result[1],Length(Result));
|
||||
end;
|
||||
|
||||
procedure TDCP_blockcipher.Decrypt(const Indata; var Outdata; Size: longword);
|
||||
begin
|
||||
case fCipherMode of
|
||||
cmCBC: DecryptCBC(Indata,Outdata,Size);
|
||||
cmCFB8bit: DecryptCFB8bit(Indata,Outdata,Size);
|
||||
cmCFBblock: DecryptCFBblock(Indata,Outdata,Size);
|
||||
cmOFB: DecryptOFB(Indata,Outdata,Size);
|
||||
cmCTR: DecryptCTR(Indata,Outdata,Size);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TDCP_blockcipher.EncryptECB(const Indata; var Outdata);
|
||||
begin
|
||||
end;
|
||||
|
||||
procedure TDCP_blockcipher.DecryptECB(const Indata; var Outdata);
|
||||
begin
|
||||
end;
|
||||
|
||||
procedure TDCP_blockcipher.EncryptCBC(const Indata; var Outdata; Size: longword);
|
||||
begin
|
||||
end;
|
||||
|
||||
procedure TDCP_blockcipher.DecryptCBC(const Indata; var Outdata; Size: longword);
|
||||
begin
|
||||
end;
|
||||
|
||||
procedure TDCP_blockcipher.EncryptCFB8bit(const Indata; var Outdata; Size: longword);
|
||||
begin
|
||||
end;
|
||||
|
||||
procedure TDCP_blockcipher.DecryptCFB8bit(const Indata; var Outdata; Size: longword);
|
||||
begin
|
||||
end;
|
||||
|
||||
procedure TDCP_blockcipher.EncryptCFBblock(const Indata; var Outdata; Size: longword);
|
||||
begin
|
||||
end;
|
||||
|
||||
procedure TDCP_blockcipher.DecryptCFBblock(const Indata; var Outdata; Size: longword);
|
||||
begin
|
||||
end;
|
||||
|
||||
procedure TDCP_blockcipher.EncryptOFB(const Indata; var Outdata; Size: longword);
|
||||
begin
|
||||
end;
|
||||
|
||||
procedure TDCP_blockcipher.DecryptOFB(const Indata; var Outdata; Size: longword);
|
||||
begin
|
||||
end;
|
||||
|
||||
procedure TDCP_blockcipher.EncryptCTR(const Indata; var Outdata; Size: longword);
|
||||
begin
|
||||
end;
|
||||
|
||||
procedure TDCP_blockcipher.DecryptCTR(const Indata; var Outdata; Size: longword);
|
||||
begin
|
||||
end;
|
||||
|
||||
constructor TDCP_blockcipher.Create(AOwner: TComponent);
|
||||
begin
|
||||
inherited Create(AOwner);
|
||||
fCipherMode:= cmCBC;
|
||||
end;
|
||||
|
||||
|
||||
{** Helpher functions *********************************************************}
|
||||
procedure XorBlock(var InData1, InData2; Size: longword);
|
||||
var
|
||||
b1: PByteArray;
|
||||
b2: PByteArray;
|
||||
i: longword;
|
||||
begin
|
||||
b1 := @InData1;
|
||||
b2 := @InData2;
|
||||
for i := 0 to size-1 do
|
||||
b1[i] := b1[i] xor b2[i];
|
||||
end;
|
||||
|
||||
procedure dcpFillChar(out x; count: SizeInt; Value: Byte);
|
||||
begin
|
||||
{$HINTS OFF}
|
||||
FillChar(x, count, value);
|
||||
{$HINTS ON}
|
||||
end;
|
||||
|
||||
procedure ZeroMemory(Destination: Pointer; Length: PtrUInt);
|
||||
begin
|
||||
FillChar(Destination^, Length, 0);
|
||||
end;
|
||||
|
||||
procedure dcpFillChar(out x; count: SizeInt; Value: Char);
|
||||
begin
|
||||
{$HINTS OFF}
|
||||
FillChar(x, count, Value);
|
||||
{$HINTS ON}
|
||||
end;
|
||||
|
||||
// Supposed to be an optimized version of XorBlock() using 32-bit xor
|
||||
procedure XorBlockEx(var InData1, InData2; Size: longword);
|
||||
var
|
||||
l1: PIntegerArray;
|
||||
l2: PIntegerArray;
|
||||
b1: PByteArray;
|
||||
b2: PByteArray;
|
||||
i: integer;
|
||||
c: integer;
|
||||
begin
|
||||
l1 := @inData1;
|
||||
l2 := @inData2;
|
||||
for i := 0 to size div sizeof(LongWord)-1 do
|
||||
l1[i] := l1[i] xor l2[i];
|
||||
|
||||
// the rest of the buffer (3 bytes)
|
||||
c := size mod sizeof(longWord);
|
||||
if c > 0 then begin
|
||||
b1 := @InData1;
|
||||
b2 := @InData2;
|
||||
for i := (size-c) to size-1 do
|
||||
b1[i] := b1[i] xor b2[i];
|
||||
end;
|
||||
end;
|
||||
|
||||
end.
|
||||
|
||||