BlockCiphers.html 7.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <html>
  2. <head>
  3. <title>DCPcrypt v2: Users Guide - Block Ciphers</title>
  4. </head>
  5. <body>
  6. <p align="center"><font size="+2"><b>DCPcrypt Cryptographic Component Library v2</b></font><br>
  7. <font size="+1">Copyright &copy; 1999-2002 David Barton<br>
  8. <a href="http://www.cityinthesky.co.uk/">http://www.cityinthesky.co.uk/</a><br>
  9. <a href="mailto:crypto@cityinthesky.co.uk">crypto@cityinthesky.co.uk</a></font>
  10. <p><font size="+2">Block Ciphers - TDCP_blockcipher</font>
  11. <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).
  12. <p>The TDCP_blockcipher component extends the TDCP_cipher component to provide chaining mode functions. Functions available are:
  13. <pre>
  14. property <a href="Ciphers.html#Initialized">Initialized</a>: boolean;
  15. property <a href="Ciphers.html#Id">Id</a>: integer;
  16. property <a href="Ciphers.html#Algorithm">Algorithm</a>: string;
  17. property <a href="Ciphers.html#MaxKeySize">MaxKeySize</a>: integer;
  18. property <a href="#BlockSize">BlockSize</a>: integer;
  19. property <a href="#CipherMode">CipherMode</a>: TDCP_ciphermode;
  20. class function <a href="Ciphers.html#SelfTest">SelfTest</a>: boolean;
  21. procedure <a href="#SetIV">SetIV</a>(const Value);
  22. procedure <a href="#GetIV">GetIV</a>(var Value);
  23. procedure <a href="Ciphers.html#Init">Init</a>(const Key; Size: longword; InitVector: pointer);
  24. procedure <a href="Ciphers.html#InitStr">InitStr</a>(const Key: string; HashType: TDCP_hashclass);
  25. procedure <a href="Ciphers.html#Burn">Burn</a>;
  26. procedure <a href="Ciphers.html#Reset">Reset</a>;
  27. procedure <a href="Ciphers.html#Encrypt">Encrypt</a>(const Indata; var Outdata; Size: longword);
  28. procedure <a href="Ciphers.html#Decrypt">Decrypt</a>(const Indata; var Outdata; Size: longword);
  29. function <a href="Ciphers.html#EncryptStream">EncryptStream</a>(InStream, OutStream: TStream; Size: longword): longword;
  30. function <a href="Ciphers.html#DecryptStream">DecryptStream</a>(InStream, OutStream: TStream; Size: longword): longword;
  31. function <a href="Ciphers.html#EncryptString">EncryptString</a>(const Str: string): string;
  32. function <a href="Ciphers.html#DecryptString">DecryptString</a>(const Str: string): string;
  33. procedure <a href="#EncryptECB">EncryptECB</a>(const Indata; var Outdata);
  34. procedure <a href="#DecryptECB">DecryptECB</a>(const Indata; var Outdata);
  35. procedure <a href="#EncryptCBC">EncryptCBC</a>(const Indata; var Outdata; Size: longword);
  36. procedure <a href="#DecryptCBC">DecryptCBC</a>(const Indata; var Outdata; Size: longword);
  37. procedure <a href="#EncryptCFB8bit">EncryptCFB8bit</a>(const Indata; var Outdata; Size: longword);
  38. procedure <a href="#DecryptCFB8bit">DecryptCFB8bit</a>(const Indata; var Outdata; Size: longword);
  39. procedure <a href="#EncryptCFBblock">EncryptCFBblock</a>(const Indata; var Outdata; Size: longword);
  40. procedure <a href="#DecryptCFBblock">DecryptCFBblock</a>(const Indata; var Outdata; Size: longword);
  41. procedure <a href="#EncryptOFB">EncryptOFB</a>(const Indata; var Outdata; Size: longword);
  42. procedure <a href="#DecryptOFB">DecryptOFB</a>(const Indata; var Outdata; Size: longword);
  43. procedure <a href="#EncryptCTR">EncryptCTR</a>(const Indata; var Outdata; Size: longword);
  44. procedure <a href="#DecryptCTR">DecryptCTR</a>(const Indata; var Outdata; Size: longword);
  45. </pre>
  46. <hr>
  47. <p><font size="+2">Function descriptions</font>
  48. <p><font size="+1"><a name="BlockSize">property BlockSize: integer;</a></font>
  49. <p>This contains the block size of the cipher in BITS.
  50. <p><font size="+1"><a name="CipherMode">property CipherMode: TDCP_ciphermode;</a></font>
  51. <p>This is the current chaining mode used when <a href="Ciphers.html#Encrypt">Encrypt</a> is called. The available modes are:
  52. <ul>
  53. <li>cmCBC - Cipher block chaining.
  54. <li>cmCFB8bit - 8bit cipher feedback.
  55. <li>cmCFBblock - Cipher feedback (using the block size of the algorithm).
  56. <li>cmOFB - Output feedback.
  57. <li>cmCTR - Counter.
  58. </ul>
  59. <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.
  60. <p><font size="+1"><a name="SetIV">procedure SetIV(const Value);</a></font>
  61. <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.
  62. <p><font size="+1"><a name="GetIV">procedure GetIV(var Value);</a></font>
  63. <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.
  64. <p><font size="+1"><a name="EncryptCBC">procedure EncryptCBC(const Indata; var Outdata; Size: longword);</a></font><br>
  65. <font size="+1"><a name="DecryptCBC">procedure DecryptCBC(const Indata; var Outdata; Size: longword);</a></font><br>
  66. <font size="+1"><a name="EncryptCFB8bit">procedure EncryptCFB8bit(const Indata; var Outdata; Size: longword);</a></font><br>
  67. <font size="+1"><a name="DecryptCFB8bit">procedure DecryptCFB8bit(const Indata; var Outdata; Size: longword);</a></font><br>
  68. <font size="+1"><a name="EncryptCFBblock">procedure EncryptCFBblock(const Indata; var Outdata; Size: longword);</a></font><br>
  69. <font size="+1"><a name="DecryptCFBblock">procedure DecryptCFBblock(const Indata; var Outdata; Size: longword);</a></font><br>
  70. <font size="+1"><a name="EncryptOFB">procedure EncryptOFB(const Indata; var Outdata; Size: longword);</a></font><br>
  71. <font size="+1"><a name="DecryptOFB">procedure DecryptOFB(const Indata; var Outdata; Size: longword);</a></font><br>
  72. <font size="+1"><a name="EncryptCTR">procedure EncryptCTR(const Indata; var Outdata; Size: longword);</a></font><br>
  73. <font size="+1"><a name="DecryptCTR">procedure DecryptCTR(const Indata; var Outdata; Size: longword);</a></font>
  74. <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.
  75. <p>&nbsp;
  76. <p><a href="Index.html">Index</a>, <a href="Ciphers.html">Ciphers</a>, <a href="Hashes.html">Hashes</a>
  77. <p>&nbsp;
  78. <p><em>DCPcrypt is copyrighted &copy; 1999-2002 David Barton.<br>
  79. All trademarks are property of their respective owners.</em>
  80. </body>
  81. </html>