Difference between revisions of "Unit Crypto"

From Ultibo.org
Jump to: navigation, search
 
(16 intermediate revisions by the same user not shown)
Line 5: Line 5:
 
----
 
----
  
'''Ultibo Crypto interface unit'''
+
'''Ultibo Crypto Interface unit'''
 
+
''To be documented''
+
  
 
=== Constants ===
 
=== Constants ===
Line 14: Line 12:
  
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 20px; padding-bottom: 15px;">
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 20px; padding-bottom: 15px;">
<div style="font-size: 14px; padding-left: 12px;">'''Crypto cipher algorithms''' <code> CRYPTO_CIPHER_ALG_* </code></div>
+
<div style="font-size: 14px; padding-left: 12px;">'''Cipher algorithms''' <code> CRYPTO_CIPHER_ALG_* </code></div>
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
Line 37: Line 35:
 
<br />  
 
<br />  
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 20px; padding-bottom: 15px;">
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 20px; padding-bottom: 15px;">
<div style="font-size: 14px; padding-left: 12px;">'''Crypto cipher modes''' <code> CRYPTO_CIPHER_MODE_* </code></div>
+
<div style="font-size: 14px; padding-left: 12px;">'''Cipher modes''' <code> CRYPTO_CIPHER_MODE_* </code></div>
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
Line 53: Line 51:
 
| Output Feedback
 
| Output Feedback
 
|-
 
|-
| <code>CRYPTO_CIPHER_MODE_CRT = 4;</code>
+
| <code>CRYPTO_CIPHER_MODE_CTR = 4;</code>
 
| Counter
 
| Counter
 +
|-
 +
| <code>CRYPTO_CIPHER_MODE_CCM = 5;</code>
 +
| Counter with CBC-MAC
 +
|-
 +
| <code>CRYPTO_CIPHER_MODE_GCM = 5;</code>
 +
| Galois/Counter Mode
 
|-
 
|-
 
|}
 
|}
Line 60: Line 64:
 
<br />  
 
<br />  
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 20px; padding-bottom: 15px;">
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 20px; padding-bottom: 15px;">
<div style="font-size: 14px; padding-left: 12px;">'''Crypto hash algorithms''' <code> CRYPTO_HASH_ALG_* </code></div>
+
<div style="font-size: 14px; padding-left: 12px;">'''Hash algorithms''' <code> CRYPTO_HASH_ALG_* </code></div>
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
Line 83: Line 87:
 
|-
 
|-
 
| <code>CRYPTO_HASH_ALG_HMAC_SHA256 = 6;</code>
 
| <code>CRYPTO_HASH_ALG_HMAC_SHA256 = 6;</code>
 +
| &nbsp;
 +
|-
 +
| <code>CRYPTO_HASH_ALG_SHA384 = 7;</code>
 +
| &nbsp;
 +
|-
 +
| <code>CRYPTO_HASH_ALG_SHA512 = 8;</code>
 +
| &nbsp;
 +
|-
 +
| <code>CRYPTO_HASH_ALG_HMAC_SHA384 = 9;</code>
 +
| &nbsp;
 +
|-
 +
| <code>CRYPTO_HASH_ALG_HMAC_SHA512 = 10;</code>
 +
| &nbsp;
 +
|-
 +
| <code>CRYPTO_HASH_ALG_SHA224 = 11;</code>
 +
| &nbsp;
 +
|-
 +
| <code>CRYPTO_HASH_ALG_HMAC_SHA224 = 12;</code>
 
| &nbsp;
 
| &nbsp;
 
|-
 
|-
 
|}
 
|}
 
</div></div>
 
</div></div>
<br />  
+
<br />
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 20px; padding-bottom: 15px;">
 +
<div style="font-size: 14px; padding-left: 12px;">'''MD5 digest size''' <code> MD5_DIGEST_* </code></div>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
| <code>MD5_DIGEST_SIZE = 16;</code>
 +
| style="width: 50%;"|&nbsp;
 +
|-
 +
|}
 +
</div></div>
 +
<br /> 
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 20px; padding-bottom: 15px;">
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 20px; padding-bottom: 15px;">
 
<div style="font-size: 14px; padding-left: 12px;">'''AES block size''' <code> AES_BLOCK_* </code></div>
 
<div style="font-size: 14px; padding-left: 12px;">'''AES block size''' <code> AES_BLOCK_* </code></div>
Line 113: Line 146:
 
| 256 bit keys
 
| 256 bit keys
 
|-
 
|-
 +
|colspan="2"|&nbsp;
 +
|-
 +
| <code>AES_IV_SIZE = 16;</code>
 +
| 128 bit initialization vector
 +
|-
 
|}
 
|}
 
</div></div>
 
</div></div>
Line 185: Line 223:
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
| <code>SHA1_DIGEST_SIZE = 20;</code>
 +
| style="width: 50%;"|&nbsp;
 +
|-
 +
|colspan="2"|&nbsp;
 
|-
 
|-
 
| <code>SHA1_K20 = $5A827999;</code>
 
| <code>SHA1_K20 = $5A827999;</code>
Line 202: Line 245:
 
<br />  
 
<br />  
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 20px; padding-bottom: 15px;">
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 20px; padding-bottom: 15px;">
<div style="font-size: 14px; padding-left: 12px;">'''MIME64 constants''' <code> MIME64_* </code></div>
+
<div style="font-size: 14px; padding-left: 12px;">'''SHA256 constants''' <code> SHA256_* </code></div>
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
| <code>MIME64EncodingTable:String = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';</code>
+
| <code>SHA256_DIGEST_SIZE = 32;</code>
 
| style="width: 50%;"|&nbsp;
 
| style="width: 50%;"|&nbsp;
 
|-
 
|-
Line 212: Line 255:
 
</div></div>
 
</div></div>
 
<br />
 
<br />
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 20px; padding-bottom: 15px;">
 +
<div style="font-size: 14px; padding-left: 12px;">'''SHA384 constants''' <code> SHA384_* </code></div>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
| <code>SHA384_DIGEST_SIZE = 48;</code>
 +
| style="width: 50%;"|&nbsp;
 +
|-
 +
|}
 +
</div></div>
 +
<br />
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 20px; padding-bottom: 15px;">
 +
<div style="font-size: 14px; padding-left: 12px;">'''SHA512 constants''' <code> SHA512_* </code></div>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
| <code>SHA512_DIGEST_SIZE = 64;</code>
 +
| style="width: 50%;"|&nbsp;
 +
|-
 +
|}
 +
</div></div>
 +
<br />
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 20px; padding-bottom: 15px;">
 +
<div style="font-size: 14px; padding-left: 12px;">'''RSA constants''' <code> RSA_* </code></div>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
| <code>RSA_MODULUS_BYTES_MAX = 512;</code>
 +
| 4096 bit maximum
 +
|-
 +
|}
 +
</div></div>
 +
<br />
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 20px; padding-bottom: 15px;">
 +
<div style="font-size: 14px; padding-left: 12px;">'''Base64 constants''' <code> BASE64_* </code></div>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
| <code>Base64EncodeTable:String = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';</code>
 +
| style="width: 50%;"|&nbsp;
 +
|-
 +
|}
 +
</div></div>
 +
<br />
  
 
=== Type definitions ===
 
=== Type definitions ===
 
----
 
----
  
''To be documented''
+
 
 +
'''MD5 digest'''
 +
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
 +
<code>PMD5Digest = ^TMD5Digest;</code>
 +
 
 +
<code>TMD5Digest = array[0..15] of Byte;</code>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
| &nbsp;
 +
| style="width: 50%;"|&nbsp;
 +
|-
 +
|}
 +
</div></div>
 +
 +
'''MD5 block'''
 +
 
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
 +
<code>PMD5Block = ^TMD5Block;</code>
 +
 
 +
<code>TMD5Block = record</code>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
| <code>Data:Pointer;</code>
 +
| style="width: 50%;"|&nbsp;
 +
|-
 +
| <code>Size:LongWord;</code>
 +
| &nbsp;
 +
|-
 +
| <code>Next:PMD5Block;</code>
 +
| &nbsp;
 +
|-
 +
|}
 +
</div></div>
 +
 
 +
'''MD5 context'''
 +
 
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
 +
<code>PMD5Context = ^TMD5Context;</code>
 +
 
 +
<code>TMD5Context = record</code>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
| <code>Data:array[0..63] of Byte;</code>
 +
| style="width: 50%;"|&nbsp;
 +
|-
 +
| <code>Buffer:array[0..3] of LongWord;</code>
 +
| &nbsp;
 +
|-
 +
| <code>Count:QWord;</code>
 +
| &nbsp;
 +
|-
 +
|}
 +
</div></div>
 +
 +
'''MD5 byte buffer'''
 +
 
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
 +
<code>PMD5ByteBuffer = ^TMD5ByteBuffer;</code>
 +
 
 +
<code>TMD5ByteBuffer = array[0..63] of Byte;</code>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
| &nbsp;
 +
| style="width: 50%;"|&nbsp;
 +
|-
 +
|}
 +
</div></div>
 +
 +
'''MD5 long buffer'''
 +
 
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
 +
<code>PMD5LongBuffer = ^TMD5LongBuffer;</code>
 +
 
 +
<code>TMD5LongBuffer = array[0..15] of LongWord;</code>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
| &nbsp;
 +
| style="width: 50%;"|&nbsp;
 +
|-
 +
|}
 +
</div></div>
 +
 
 +
'''AES key'''
 +
 
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
 +
<code>PAESKey = ^TAESKey;</code>
 +
 
 +
<code>TAESKey = record</code>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
| <code>Rounds:LongWord;</code>
 +
| style="width: 50%;"|&nbsp;
 +
|-
 +
| <code>EncryptKey:array[0..59] of LongWord;</code>
 +
| &nbsp;
 +
|-
 +
| <code>DecryptKey:array[0..59] of LongWord;</code>
 +
| &nbsp;
 +
|-
 +
|}
 +
</div></div>
 +
 
 +
'''AES context'''
 +
 
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
 +
<code>PAESContext = ^TAESContext;</code>
 +
 
 +
<code>TAESContext = record</code>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
| <code>AESKey:TAESKey;</code>
 +
| style="width: 50%;"|&nbsp;
 +
|-
 +
| <code>CBC:array[0..AES_BLOCK_SIZE - 1] of Byte;</code>
 +
| &nbsp;
 +
|-
 +
| <code>CTR:array[0..AES_BLOCK_SIZE - 1] of Byte;</code>
 +
| &nbsp;
 +
|-
 +
|}
 +
</div></div>
 +
 +
'''DES key'''
 +
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
 +
<code>PDESKey = ^TDESKey;</code>
 +
 
 +
<code>TDESKey = array[0..31] of LongWord;</code>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
| &nbsp;
 +
| style="width: 50%;"|&nbsp;
 +
|-
 +
|}
 +
</div></div>
 +
 
 +
'''DES context'''
 +
 
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
 +
<code>PDESContext = ^TDESContext;</code>
 +
 
 +
<code>TDESContext = record</code>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
| <code>EncryptKey:TDESKey;</code>
 +
| style="width: 50%;"|&nbsp;
 +
|-
 +
| <code>DecryptKey:TDESKey;</code>
 +
| &nbsp;
 +
|-
 +
| <code>CBC:array[0..DES_BLOCK_SIZE - 1] of Byte;</code>
 +
| &nbsp;
 +
|-
 +
|}
 +
</div></div>
 +
 
 +
'''3DES key'''
 +
 
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
 +
<code>PDES3Key = ^TDES3Key;</code>
 +
 
 +
<code>TDES3Key = record</code>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
| <code>EncryptKey:array[0..2] of TDESKey;</code>
 +
| style="width: 50%;"|&nbsp;
 +
|-
 +
| <code>DecryptKey:array[0..2] of TDESKey;</code>
 +
| &nbsp;
 +
|-
 +
|}
 +
</div></div>
 +
 +
'''3DES context'''
 +
 
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
 +
<code>PDES3Context = ^TDES3Context;</code>
 +
 
 +
<code>TDES3Context = record</code>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
| <code>DES3Key:TDES3Key;</code>
 +
| style="width: 50%;"|&nbsp;
 +
|-
 +
| <code>CBC:array[0..DES3_BLOCK_SIZE - 1] of Byte;</code>
 +
| &nbsp;
 +
|-
 +
|}
 +
</div></div>
 +
 +
'''RC4 state'''
 +
 
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
 +
<code>PRC4State = ^TRC4State;</code>
 +
 
 +
<code>TRC4State = array[0..255] of Byte;</code>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
| &nbsp;
 +
| style="width: 50%;"|&nbsp;
 +
|-
 +
|}
 +
</div></div>
 +
 +
'''RC4 context'''
 +
 
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
 +
<code>PRC4Context = ^TRC4Context;</code>
 +
 
 +
<code>TRC4Context = record</code>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
| <code>Key:array[0..31] of Byte;</code>
 +
| style="width: 50%;"|&nbsp;
 +
|-
 +
| <code>KeySize:LongWord;</code>
 +
| &nbsp;
 +
|-
 +
| <code>Start:LongWord;</code>
 +
| &nbsp;
 +
|-
 +
|}
 +
</div></div>
 +
 
 +
'''SHA1 digest'''
 +
 
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
 +
<code>PSHA1Digest = ^TSHA1Digest;</code>
 +
 
 +
<code>TSHA1Digest = array[0..19] of Byte;</code>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
| &nbsp;
 +
| style="width: 50%;"|&nbsp;
 +
|-
 +
|}
 +
</div></div>
 +
 +
'''SHA1 block'''
 +
 
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
 +
<code>PSHA1Block = ^TSHA1Block;</code>
 +
 
 +
<code>TSHA1Block = record</code>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
| <code>Data:Pointer;</code>
 +
| style="width: 50%;"|&nbsp;
 +
|-
 +
| <code>Size:LongWord;</code>
 +
| &nbsp;
 +
|-
 +
| <code>Next:PSHA1Block;</code>
 +
| &nbsp;
 +
|-
 +
|}
 +
</div></div>
 +
 
 +
'''SHA1 context'''
 +
 
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
 +
<code>PSHA1Context = ^TSHA1Context;</code>
 +
 
 +
<code>TSHA1Context = record</code>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
| <code>Data:array[0..63] of Byte;</code>
 +
| style="width: 50%;"|&nbsp;
 +
|-
 +
| <code>State:array[0..4] of LongWord;</code>
 +
| &nbsp;
 +
|-
 +
| <code>Count:QWord;</code>
 +
| &nbsp;
 +
|-
 +
|}
 +
</div></div>
 +
   
 +
'''SHA1 byte buffer'''
 +
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
 +
<code>PSHA1ByteBuffer = ^TSHA1ByteBuffer;</code>
 +
 
 +
<code>TSHA1ByteBuffer = array[0..63] of Byte;</code>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
| &nbsp;
 +
| style="width: 50%;"|&nbsp;
 +
|-
 +
|}
 +
</div></div>
 +
 +
'''SHA1 long buffer'''
 +
 
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
 +
<code>PSHA1LongBuffer = ^TSHA1LongBuffer;</code>
 +
 
 +
<code>TSHA1LongBuffer = array[0..15] of LongWord;</code>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
| &nbsp;
 +
| style="width: 50%;"|&nbsp;
 +
|-
 +
|}
 +
</div></div>
 +
 +
'''SHA256 digest'''
 +
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
 +
<code>PSHA256Digest = ^TSHA256Digest;</code>
 +
 
 +
<code>TSHA256Digest = array[0..31] of Byte;</code>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
| &nbsp;
 +
| style="width: 50%;"|&nbsp;
 +
|-
 +
|}
 +
</div></div>
 +
 +
'''SHA256 block'''
 +
 
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
 +
<code>PSHA256Block = ^TSHA256Block;</code>
 +
 
 +
<code>TSHA256Block = record</code>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
| <code>Data:Pointer;</code>
 +
| style="width: 50%;"|&nbsp;
 +
|-
 +
| <code>Size:LongWord;</code>
 +
| &nbsp;
 +
|-
 +
| <code>Next:PSHA256Block;</code>
 +
| &nbsp;
 +
|-
 +
|}
 +
</div></div>
 +
 
 +
'''SHA256 context'''
 +
 
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
 +
<code>PSHA256Context = ^TSHA256Context;</code>
 +
 
 +
<code>TSHA256Context = record</code>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
| <code>Data:array[0..63] of Byte;</code>
 +
| style="width: 50%;"|&nbsp;
 +
|-
 +
| <code>State:array[0..7] of LongWord;</code>
 +
| &nbsp;
 +
|-
 +
| <code>Count:QWord;</code>
 +
| &nbsp;
 +
|-
 +
|}
 +
</div></div>
 +
 
 +
'''SHA256 byte buffer'''
 +
 
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
 +
<code>PSHA256ByteBuffer = ^TSHA256ByteBuffer;</code>
 +
 
 +
<code>TSHA256ByteBuffer = array[0..63] of Byte;</code>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
| &nbsp;
 +
| style="width: 50%;"|&nbsp;
 +
|-
 +
|}
 +
</div></div>
 +
 +
'''SHA256 long buffer'''
 +
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
 +
<code>PSHA256LongBuffer = ^TSHA256LongBuffer;</code>
 +
 
 +
<code>TSHA256LongBuffer = array[0..15] of LongWord;</code>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
| &nbsp;
 +
| style="width: 50%;"|&nbsp;
 +
|-
 +
|}
 +
</div></div>
 +
 
 +
'''SHA256 algorithm'''
 +
 
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
 +
<code>PSHA256_W = ^TSHA256_W;</code>
 +
 
 +
<code>TSHA256_W = array[0..63] of LongWord;</code>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
|colspan="2"|Note: This is the W array for the SHA256 algorithm
 +
|-
 +
| &nbsp;
 +
| style="width: 50%;"|&nbsp;
 +
|-
 +
|}
 +
</div></div>
 +
 
 +
'''SHA512 digest'''
 +
 
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
 +
<code>PSHA512Digest = ^TSHA512Digest;</code>
 +
 
 +
<code>TSHA512Digest = array[0..63] of Byte;</code>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
| &nbsp;
 +
| style="width: 50%;"|&nbsp;
 +
|-
 +
|}
 +
</div></div>
 +
 
 +
'''SHA512 block'''
 +
 
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
 +
<code>PSHA512Block = ^TSHA512Block;</code>
 +
 
 +
<code>TSHA512Block = record</code>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
| <code>Data:Pointer;</code>
 +
| style="width: 50%;"|&nbsp;
 +
|-
 +
| <code>Size:LongWord;</code>
 +
| &nbsp;
 +
|-
 +
| <code>Next:PSHA512Block;</code>
 +
| &nbsp;
 +
|-
 +
|}
 +
</div></div>
 +
 
 +
'''SHA512 context'''
 +
 
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
 +
<code>PSHA512Context = ^TSHA512Context;</code>
 +
 
 +
<code>TSHA512Context = record</code>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
| <code>Data:array[0..127] of Byte;</code>
 +
| style="width: 50%;"|&nbsp;
 +
|-
 +
| <code>State:array[0..7] of QWord;</code>
 +
| &nbsp;
 +
|-
 +
| <code>Count:QWord;</code>
 +
| &nbsp;
 +
|-
 +
|}
 +
</div></div>
 +
 
 +
'''SHA512 byte buffer'''
 +
 
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
 +
<code>PSHA512ByteBuffer = ^TSHA512ByteBuffer;</code>
 +
 
 +
<code>TSHA512ByteBuffer = array[0..127] of Byte;</code>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
| &nbsp;
 +
| style="width: 50%;"|&nbsp;
 +
|-
 +
|}
 +
</div></div>
 +
 
 +
'''SHA512 algorithm'''
 +
 
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
 +
<code>PSHA512_W = ^TSHA512_W;</code>
 +
 
 +
<code>TSHA512_W = array[0..79] of QWord;</code>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
|colspan="2"|Note: This is the W array for the SHA512 algorithm
 +
|-
 +
| &nbsp;
 +
| style="width: 50%;"|&nbsp;
 +
|-
 +
|}
 +
</div></div>
 +
 
 +
'''SHA384 digest'''
 +
 
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
 +
<code>PSHA384Digest = ^TSHA384Digest;</code>
 +
 
 +
<code>TSHA384Digest = array[0..47] of Byte;</code>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
| &nbsp;
 +
| style="width: 50%;"|&nbsp;
 +
|-
 +
|}
 +
</div></div>
 +
 
 +
'''SHA384 block'''
 +
 
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
 +
<code>PSHA384Block = PSHA512Block;</code>
 +
 
 +
<code>TSHA384Block = TSHA512Block;</code>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
| &nbsp;
 +
| style="width: 50%;"|&nbsp;
 +
|-
 +
|}
 +
</div></div>
 +
 
 +
'''SHA384 context'''
 +
 
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
 +
<code>PSHA384Context = PSHA512Context;</code>
 +
 
 +
<code>TSHA384Context = TSHA512Context;</code>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
| &nbsp;
 +
| style="width: 50%;"|&nbsp;
 +
|-
 +
|}
 +
</div></div>
 +
 
 +
'''SHA384 byte buffer'''
 +
 
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
 +
<code>PSHA384ByteBuffer = PSHA512ByteBuffer;</code>
 +
 
 +
<code>TSHA384ByteBuffer = TSHA512ByteBuffer;</code>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
| &nbsp;
 +
| style="width: 50%;"|&nbsp;
 +
|-
 +
|}
 +
</div></div>
 +
 
 +
'''RSA context'''
 +
 
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
 +
<code>PRSAContext = ^TRSAContext;</code>
 +
 
 +
<code>TRSAContext = record</code>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
| <code>M:PBigInt;</code>
 +
| Modulus
 +
|-
 +
| <code>E:PBigInt;</code>
 +
| Public exponent
 +
|-
 +
| <code>D:PBigInt;</code>
 +
| Private exponent
 +
|-
 +
| <code>P:PBigInt;</code>
 +
| p in m = pq
 +
|-
 +
| <code>Q:PBigInt;</code>
 +
| q in m = pq
 +
|-
 +
| <code>DP:PBigInt;</code>
 +
| d mod (p-1)
 +
|-
 +
| <code>DQ:PBigInt;</code>
 +
| d mod (q-1)
 +
|-
 +
| <code>QInv:PBigInt;</code>
 +
| q^-1 mod p
 +
|-
 +
| <code>ModulusLen:Integer;</code>
 +
| &nbsp;
 +
|-
 +
| <code>Context:PBigIntContext;</code>
 +
| &nbsp;
 +
|-
 +
|}
 +
</div></div>
 +
 
 +
'''Get random bytes'''
 +
 
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| <code>TGetRandomBytes = function(Buffer:PByte; Count:Integer):Boolean;</code>
 +
| style="width: 40%;"|
 +
|-
 +
|}
 +
 
 +
'''Base64 decode table'''
 +
 
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| <code>TBase64DecodeTable = array[0..255] of Char;</code>
 +
| style="width: 40%;"|
 +
|-
 +
|}
 +
 +
'''Hash context'''
 +
 
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
 +
<code>PHashContext = ^THashContext;</code>
 +
 
 +
<code>THashContext = record</code>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
| <code>Algorithm:LongWord;</code>
 +
| style="width: 50%;"|&nbsp;
 +
|-
 +
| <code>Key:array[0..127] of Byte;</code>
 +
| &nbsp;
 +
|-
 +
| <code>KeySize:LongWord;</code>
 +
| &nbsp;
 +
|-
 +
| <code>case Integer of</code>
 +
| &nbsp;
 +
|-
 +
| <code>0:(MD5:TMD5Context);</code>
 +
| &nbsp;
 +
|-
 +
| <code>1:(SHA1:TSHA1Context);</code>
 +
| &nbsp;
 +
|-
 +
| <code>2:(SHA256:TSHA256Context);</code>
 +
| &nbsp;
 +
|-
 +
| <code>3:(SHA384:TSHA384Context);</code>
 +
| &nbsp;
 +
|-
 +
| <code>4:(SHA512:TSHA512Context);</code>
 +
| &nbsp;
 +
|-
 +
|}
 +
</div></div>
 +
 
 +
'''Cipher context'''
 +
 
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
 +
<code>PCipherContext = ^TCipherContext;</code>
 +
 
 +
<code>TCipherContext = record</code>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
| <code>Algorithm:LongWord;</code>
 +
| style="width: 50%;"|&nbsp;
 +
|-
 +
| <code>Mode:LongWord;</code>
 +
| style="width: 50%;"|&nbsp;
 +
|-
 +
| <code>case Integer of</code>
 +
| &nbsp;
 +
|-
 +
| <code>0:(RC4:TRC4Context);</code>
 +
| &nbsp;
 +
|-
 +
| <code>1:(DES:TDESContext);</code>
 +
| &nbsp;
 +
|-
 +
| <code>2:(DES3:TDES3Context);</code>
 +
| &nbsp;
 +
|-
 +
| <code>3:(AES:TAESContext);</code>
 +
| &nbsp;
 +
|-
 +
|}
 +
</div></div>
 +
<br />
  
 
=== Public variables ===
 
=== Public variables ===
 
----
 
----
  
''To be documented''
+
 
 +
'''Crypto specific variables'''
 +
 
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| <code>CryptoGetRandomBytesHandler:TGetRandomBytes;</code>
 +
| style="width: 40%;"|
 +
|-
 +
|}
 +
<br />
  
 
=== Function declarations ===
 
=== Function declarations ===
Line 235: Line 1,040:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 246: Line 1,051:
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 
<pre style="border: 0; padding-bottom:0px;">function HashCreate(Algorithm:LongWord; Key:Pointer; KeySize:LongWord):PHashContext;</pre>
 
<pre style="border: 0; padding-bottom:0px;">function HashCreate(Algorithm:LongWord; Key:Pointer; KeySize:LongWord):PHashContext;</pre>
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Initialize a hash context based on an algorithm and an optional key</div>
+
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Initialize a hash context based on an algorithm and (if applicable) a key</div>
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 262: Line 1,067:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 +
| None documented
 +
|-
 +
|}
 +
</div></div>
 +
<br />
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 +
<pre style="border: 0; padding-bottom:0px;">function HashReset(Context:PHashContext):Boolean;</pre>
 +
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Clear and reinitialize an existing hash context using the existing algorithm and key</div>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
! Note
 +
| None documented
 +
|-
 +
|}
 +
</div></div>
 +
<br />
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 +
<pre style="border: 0; padding-bottom:0px;">function HashReset(Context:PHashContext; Algorithm:LongWord; Key:Pointer; KeySize:LongWord):Boolean;</pre>
 +
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Clear and reinitialize an existing hash context using a new algorithm and key</div>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 274: Line 1,103:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 286: Line 1,115:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 298: Line 1,127:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
| For block ciphers also include an initialization vector for CBC mode
+
| For block ciphers an initialization vector can be passed to enable CBC mode
 +
|-
 +
|}
 +
</div></div>
 +
<br />
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 +
<pre style="border: 0; padding-bottom:0px;">function CipherCreate(Algorithm,Mode:LongWord; Nonce,Vector,Key:Pointer; VectorSize,KeySize:LongWord):PCipherContext;</pre>
 +
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Initialize a cipher context based on an algorithm, mode and key</div>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
! Note
 +
| For block ciphers a Nonce or IV can be passed if the selected mode requires it
 
|-
 
|-
 
|}
 
|}
Line 310: Line 1,151:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 322: Line 1,163:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 334: Line 1,175:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 349: Line 1,190:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Data'''
+
! Data
| A linked list which can contain multiple independent blocks to be included in the hash. The data block itself does not form part of the hash.
+
| Data is a linked list which can contain multiple independent blocks to be included in the hash. The data block itself does not form part of the hash.
 
|-
 
|-
 
|}
 
|}
Line 361: Line 1,202:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 373: Line 1,214:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Key'''
+
! Note
| If Key is more than 64 bytes it will be hashed to Key = MD5(Key) instead. If Key is less than 64 bytes it will be padded with zeros.
+
| None documented
 +
|-
 +
|}
 +
</div></div>
 +
<br />
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 +
<pre style="border: 0; padding-bottom:0px;">function HMACMD5DigestData(Key:Pointer; KeySize:LongWord; Data:PMD5Block; Digest:PMD5Digest):Boolean;</pre>
 +
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Generate an MD5 HMAC (Hashed Message Authentication Code) using the Key and Data</div>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
! Key
 +
| If Key is more than 64 bytes it will be hashed to Key = MD5(Key) instead
 +
If Key is less than 64 bytes it will be padded with zeros
 
|-
 
|-
! '''Note'''
+
! Note
| The MD5 HMAC algorithm is: MD5(Key xor oPad, MD5(Key xor iPad, Data)). Where iPad is the byte $36 repeated 64 times, oPad is the byte $5c repeated 64 times.
+
| The MD5 HMAC algorithm is:
 +
MD5(Key xor oPad, MD5(Key xor iPad, Data))
 +
<br />Where iPad is the byte $36 repeated 64 times, oPad is the byte $5c repeated 64 times.
 
|-
 
|-
 
|}
 
|}
Line 388: Line 1,244:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Key'''
+
! Key
| If Key is more than 64 bytes it will be hashed to Key = MD5(Key) instead. If Key is less than 64 bytes it will be padded with zeros.
+
| If Key is more than 64 bytes it will be hashed to Key = MD5(Key) instead
 +
If Key is less than 64 bytes it will be padded with zeros
 
|-
 
|-
! '''Note'''
+
! Note
| The MD5 HMAC algorithm is: MD5(Key xor oPad, MD5(Key xor iPad, Value)). Where iPad is the byte $36 repeated 64 times, oPad is the byte $5c repeated 64 times.
+
| The MD5 HMAC algorithm is:
 +
MD5(Key xor oPad, MD5(Key xor iPad, Data))
 +
<br />Where iPad is the byte $36 repeated 64 times, oPad is the byte $5c repeated 64 times.
 
|-
 
|-
 
|}
 
|}
Line 402: Line 1,261:
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 
<pre style="border: 0; padding-bottom:0px;">function AESEncryptData(Key:Pointer; KeySize:LongWord; Vector,Plain,Crypt:Pointer; Size:LongWord):Boolean;</pre>
 
<pre style="border: 0; padding-bottom:0px;">function AESEncryptData(Key:Pointer; KeySize:LongWord; Vector,Plain,Crypt:Pointer; Size:LongWord):Boolean;</pre>
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' To be documented</div>
+
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Encrypt a block of data using the AES cipher, if Vector is supplied use CBC mode else use ECB</div>
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! KeySize
| None documented
+
| Key size must be 16, 24 or 32 bytes (128, 192 or 256 bits)
 +
|-
 +
! Vector
 +
| Vector must be 16 bytes (128 bits) long if supplied
 +
|-
 +
! Size
 +
| Size must be a multiple of 16 bytes long
 +
|-
 +
! Note
 +
| Plain text and Crypt data pointers must be the same length (and can point to the same value)
 
|-
 
|-
 
|}
 
|}
Line 414: Line 1,282:
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 
<pre style="border: 0; padding-bottom:0px;">function AESDecryptData(Key:Pointer; KeySize:LongWord; Vector,Crypt,Plain:Pointer; Size:LongWord):Boolean;</pre>
 
<pre style="border: 0; padding-bottom:0px;">function AESDecryptData(Key:Pointer; KeySize:LongWord; Vector,Crypt,Plain:Pointer; Size:LongWord):Boolean;</pre>
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' To be documented</div>
+
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Decrypt a block of data using the AES cipher, if Vector is supplied use CBC mode else use ECB</div>
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! KeySize
| None documented
+
| Key size must be 16, 24 or 32 bytes (128, 192 or 256 bits)
 +
|-
 +
! Vector
 +
| Vector must be 16 bytes (128 bits) long if supplied
 +
|-
 +
! Size
 +
| Size must be a multiple of 16 bytes long
 +
|-
 +
! Note
 +
| Plain text and Crypt data pointers must be the same length (and can point to the same value)
 +
|-
 +
|}
 +
</div></div>
 +
<br />
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 +
<pre style="border: 0; padding-bottom:0px;">function AESCTREncryptData(Key:Pointer; KeySize:LongWord; Nonce,Plain,Crypt:Pointer; Size:LongWord):Boolean;</pre>
 +
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Encrypt a block of data with the supplied Key and Nonce using AES CTR mode</div>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
! KeySize
 +
| Key size must be 16, 24 or 32 bytes (128, 192 or 256 bits)
 +
|-
 +
! Nonce
 +
| Nonce must be 16 bytes (128 bits) long
 +
|-
 +
! Note
 +
| Plain text and Crypt data pointers must be the same length (and can point to the same value)
 +
|-
 +
|}
 +
</div></div>
 +
<br />
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 +
<pre style="border: 0; padding-bottom:0px;">function AESCTRDecryptData(Key:Pointer; KeySize:LongWord; Nonce,Crypt,Plain:Pointer; Size:LongWord):Boolean; inline;</pre>
 +
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Decrypt a block of data with the supplied Key and Nonce using AES CTR mode</div>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
! KeySize
 +
| Key size must be 16, 24 or 32 bytes (128, 192 or 256 bits)
 +
|-
 +
! Nonce
 +
| Nonce must be 16 bytes (128 bits) long
 +
|-
 +
! Note
 +
| Plain text and Crypt data pointers must be the same length (and can point to the same value)
 +
|-
 +
|}
 +
</div></div>
 +
<br />
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 +
<pre style="border: 0; padding-bottom:0px;">function AESGCMEncryptData(Key:Pointer; KeySize:LongWord; IV,AAD,Plain,Crypt:Pointer; IVSize,AADSize,Size:LongWord; Tag:Pointer):Boolean;</pre>
 +
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Encrypt a block of data with the supplied Key, IV and AAD using AES GCM mode, return the authentication Tag</div>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
! Tag
 +
| Tag must be 16 bytes (128 bits) long
 +
|-
 +
! Note
 +
| Plain text and Crypt data pointers must be the same length (and can point to the same value)
 +
|-
 +
|}
 +
</div></div>
 +
<br />
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 +
<pre style="border: 0; padding-bottom:0px;">function AESGCMDecryptData(Key:Pointer; KeySize:LongWord; IV,AAD,Crypt,Plain:Pointer; IVSize,AADSize,Size:LongWord; const Tag:Pointer):Boolean;</pre>
 +
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Decrypt a block of data with the supplied Key, IV and AAD using AES GCM mode, validate the authentication Tag</div>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
! Tag
 +
| Tag must be 16 bytes (128 bits) long
 +
|-
 +
! Note
 +
| Plain text and Crypt data pointers must be the same length (and can point to the same value)
 +
|-
 +
|}
 +
</div></div>
 +
<br />
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 +
<pre style="border: 0; padding-bottom:0px;">function AESGCMGMAC(Key:Pointer; KeySize:LongWord; IV,AAD:Pointer; IVSize,AADSize:LongWord; Tag:Pointer):Boolean;</pre>
 +
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Generate the GMAC authentication Tag for a given Key, IV and AAD using AES GCM mode</div>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
! Tag
 +
| Tag must be 16 bytes (128 bits) long
 
|-
 
|-
 
|}
 
|}
Line 433: Line 1,388:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 445: Line 1,400:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 460: Line 1,415:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 472: Line 1,427:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 487: Line 1,442:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Start'''
+
! Start
 
| Specify how many bytes of the RC4 cipher stream to skip to allow for previous blocks of data or to comply with RFC4345 requirements to discard the first 1536 bytes of the RC4 cipher stream
 
| Specify how many bytes of the RC4 cipher stream to skip to allow for previous blocks of data or to comply with RFC4345 requirements to discard the first 1536 bytes of the RC4 cipher stream
 
|-
 
|-
Line 495: Line 1,450:
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 
<pre style="border: 0; padding-bottom:0px;">function RC4DecryptData(Key:Pointer; KeySize:LongWord; Crypt,Plain:Pointer; Size,Start:LongWord):Boolean; inline;</pre>
 
<pre style="border: 0; padding-bottom:0px;">function RC4DecryptData(Key:Pointer; KeySize:LongWord; Crypt,Plain:Pointer; Size,Start:LongWord):Boolean; inline;</pre>
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Decrypt the supplied data with a key using the RC4 cipher algorithm</div>
+
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Encrypt the supplied data with a key using the RC4 cipher algorithm</div>
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 514: Line 1,469:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Data'''
+
! Data
| A linked list which can contain multiple independent blocks to be included in the hash. The data block itself does not form part of the hash.
+
| Data is a linked list which can contain multiple independent blocks to be included in the hash. The data block itself does not form part of the hash.
 
|-
 
|-
 
|}
 
|}
Line 526: Line 1,481:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 538: Line 1,493:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Key'''
+
! Note
| If Key is more than 64 bytes it will be hashed to Key = SHA1(Key) instead. If Key is less than 64 bytes it will be padded with zeros.
+
| None documented
 +
|-
 +
|}
 +
</div></div>
 +
<br />
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 +
<pre style="border: 0; padding-bottom:0px;">function HMACSHA1DigestData(Key:Pointer; KeySize:LongWord; Data:PSHA1Block; Digest:PSHA1Digest):Boolean;</pre>
 +
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Generate a SHA1 HMAC (Hashed Message Authentication Code) using the Key and Data</div>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
! Key
 +
| If Key is more than 64 bytes it will be hashed to Key = SHA1(Key) instead
 +
If Key is less than 64 bytes it will be padded with zeros
 
|-
 
|-
! '''Note'''
+
! Note
| The SHA1 HMAC algorithm is: SHA1(Key xor oPad, SHA1(Key xor iPad, Data)). Where iPad is the byte $36 repeated 64 times, oPad is the byte $5c repeated 64 times.
+
| The SHA1 HMAC algorithm is:
 +
SHA1(Key xor oPad, SHA1(Key xor iPad, Data))
 +
<br />Where iPad is the byte $36 repeated 64 times, oPad is the byte $5c repeated 64 times.
 
|-
 
|-
 
|}
 
|}
Line 553: Line 1,523:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Key'''
+
! Key
| If Key is more than 64 bytes it will be hashed to Key = SHA1(Key) instead. If Key is less than 64 bytes it will be padded with zeros.
+
| If Key is more than 64 bytes it will be hashed to Key = SHA1(Key) instead
 +
If Key is less than 64 bytes it will be padded with zeros
 
|-
 
|-
! '''Note'''
+
! Note
| The SHA1 HMAC algorithm is: SHA1(Key xor oPad, SHA1(Key xor iPad, Value)). Where iPad is the byte $36 repeated 64 times, oPad is the byte $5c repeated 64 times.
+
| The SHA1 HMAC algorithm is:
 +
SHA1(Key xor oPad, SHA1(Key xor iPad, Data))
 +
<br />Where iPad is the byte $36 repeated 64 times, oPad is the byte $5c repeated 64 times.
 
|-
 
|-
 
|}
 
|}
Line 571: Line 1,544:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Data'''
+
! Data
| A linked list which can contain multiple independent blocks to be included in the hash. The data block itself does not form part of the hash.
+
| Data is a linked list which can contain multiple independent blocks to be included in the hash. The data block itself does not form part of the hash.
 
|-
 
|-
 
|}
 
|}
Line 583: Line 1,556:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 595: Line 1,568:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Key'''
+
! Note
| If Key is more than 64 bytes it will be hashed to Key = SHA256(Key) instead. If Key is less than 64 bytes it will be padded with zeros.
+
| None documented
 +
|-
 +
|}
 +
</div></div>
 +
<br />
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 +
<pre style="border: 0; padding-bottom:0px;">function HMACSHA256DigestData(Key:Pointer; KeySize:LongWord; Data:PSHA256Block; Digest:PSHA256Digest):Boolean;</pre>
 +
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Generate a SHA256 HMAC (Hashed Message Authentication Code) using the Key and Data</div>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
! Key
 +
| If Key is more than 64 bytes it will be hashed to Key = SHA256(Key) instead
 +
If Key is less than 64 bytes it will be padded with zeros.
 
|-
 
|-
! '''Note'''
+
! Note
| The SHA256 HMAC algorithm is: SHA256(Key xor oPad, SHA256(Key xor iPad, Data)). Where iPad is the byte $36 repeated 64 times, oPad is the byte $5c repeated 64 times.
+
| The SHA256 HMAC algorithm is:  
 +
SHA256(Key xor oPad, SHA256(Key xor iPad, Value))
 +
<br />Where iPad is the byte $36 repeated 64 times, oPad is the byte $5c repeated 64 times.
 
|-
 
|-
 
|}
 
|}
Line 610: Line 1,598:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Key'''
+
! Key
| If Key is more than 64 bytes it will be hashed to Key = SHA256(Key) instead. If Key is less than 64 bytes it will be padded with zeros.
+
| If Key is more than 64 bytes it will be hashed to Key = SHA256(Key) instead
 +
If Key is less than 64 bytes it will be padded with zeros.
 
|-
 
|-
! '''Note'''
+
! Note
| The SHA256 HMAC algorithm is: SHA256(Key xor oPad, SHA256(Key xor iPad, Value)). Where iPad is the byte $36 repeated 64 times, oPad is the byte $5c repeated 64 times.
+
| The SHA256 HMAC algorithm is:  
 +
SHA256(Key xor oPad, SHA256(Key xor iPad, Value))
 +
<br />Where iPad is the byte $36 repeated 64 times, oPad is the byte $5c repeated 64 times.
 
|-
 
|-
 
|}
 
|}
Line 620: Line 1,611:
 
<br />
 
<br />
  
'''CRC functions'''
+
'''SHA384 functions'''
  
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
<pre style="border: 0; padding-bottom:0px;">function CRC16CCITT(CRC:Word; Data:PByte; Size:LongWord):Word;</pre>
+
<pre style="border: 0; padding-bottom:0px;">function SHA384DigestData(Data:PSHA384Block; Digest:PSHA384Digest):Boolean;</pre>
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' To be documented</div>
+
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Generate a 384 bit SHA384 digest (Hash) from the supplied data</div>
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Data
 +
| Data is a linked list which can contain multiple independent blocks to be included in the hash. The data block itself does not form part of the hash.
 +
|-
 +
|}
 +
</div></div>
 +
<br />
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 +
<pre style="border: 0; padding-bottom:0px;">function SHA384DigestString(const Value:String; Digest:PSHA384Digest):Boolean;</pre>
 +
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Generate a 384 bit SHA384 digest (Hash) from the supplied string value</div>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 634: Line 1,637:
 
</div></div>
 
</div></div>
 
<br />
 
<br />
 
'''MIME64 functions'''
 
 
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
<pre style="border: 0; padding-bottom:0px;">function MIME64EncodeString(const AValue:String):String;</pre>
+
<pre style="border: 0; padding-bottom:0px;">function HMACSHA384DigestData(const Key:String; Data:PSHA384Block; Digest:PSHA384Digest):Boolean;</pre>
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' To be documented</div>
+
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Generate a SHA384 HMAC (Hashed Message Authentication Code) using the Key and Data</div>
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 650: Line 1,650:
 
<br />
 
<br />
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
<pre style="border: 0; padding-bottom:0px;">function MIME64DecodeString(const AValue:String):String;</pre>
+
<pre style="border: 0; padding-bottom:0px;">function HMACSHA384DigestData(Key:Pointer; KeySize:LongWord; Data:PSHA384Block; Digest:PSHA384Digest):Boolean;</pre>
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' To be documented</div>
+
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Generate a SHA384 HMAC (Hashed Message Authentication Code) using the Key and Data</div>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
! Key
 +
| If Key is more than 128 bytes it will be hashed to Key = SHA384(Key) instead
 +
If Key is less than 128 bytes it will be padded with zeros
 +
|-
 +
! Note
 +
| The SHA384 HMAC algorithm is:
 +
SHA384(Key xor oPad, SHA384(Key xor iPad, Data))
 +
<br />Where iPad is the byte $36 repeated 128 times, oPad is the byte $5c repeated 128 times.
 +
|-
 +
|}
 +
</div></div>
 +
<br />
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 +
<pre style="border: 0; padding-bottom:0px;">function HMACSHA384DigestString(const Key,Value:String; Digest:PSHA384Digest):Boolean;</pre>
 +
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Generate a SHA384 HMAC (Hashed Message Authentication Code) using the Key and Value</div>
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 662: Line 1,680:
 
<br />
 
<br />
  
'''Crypto helper functions'''
+
'''SHA512 functions'''
  
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
<pre style="border: 0; padding-bottom:0px;">procedure BytesToLE(Buffer:PByte; Count:LongWord);</pre>
+
<pre style="border: 0; padding-bottom:0px;">function SHA512DigestData(Data:PSHA512Block; Digest:PSHA512Digest):Boolean;</pre>
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Change the byte order of count longwords in the supplied buffer to little endian</div>
+
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Generate a 512 bit SHA512 digest (Hash) from the supplied data</div>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
! Data
 +
| Data is a linked list which can contain multiple independent blocks to be included in the hash. The data block itself does not form part of the hash.
 +
|-
 +
|}
 +
</div></div>
 +
<br />
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 +
<pre style="border: 0; padding-bottom:0px;">function SHA512DigestString(const Value:String; Digest:PSHA512Digest):Boolean;</pre>
 +
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Generate a 512 bit SHA512 digest (Hash) from the supplied string value</div>
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 677: Line 1,707:
 
<br />
 
<br />
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
<pre style="border: 0; padding-bottom:0px;">procedure BytesToBE(Buffer:PByte; Count:LongWord);</pre>
+
<pre style="border: 0; padding-bottom:0px;">function HMACSHA512DigestData(const Key:String; Data:PSHA512Block; Digest:PSHA512Digest):Boolean;</pre>
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Change the byte order of count longwords in the supplied buffer to big endian</div>
+
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Generate a SHA512 HMAC (Hashed Message Authentication Code) using the Key and Data</div>
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 689: Line 1,719:
 
<br />
 
<br />
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
<pre style="border: 0; padding-bottom:0px;">function LongWordToBE(Buffer:PByte):LongWord; inline;</pre>
+
<pre style="border: 0; padding-bottom:0px;">function HMACSHA512DigestData(Key:Pointer; KeySize:LongWord; Data:PSHA512Block; Digest:PSHA512Digest):Boolean;</pre>
 +
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Generate a SHA512 HMAC (Hashed Message Authentication Code) using the Key and Data</div>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
! Key
 +
| If Key is more than 128 bytes it will be hashed to Key = SHA512(Key) instead
 +
If Key is less than 128 bytes it will be padded with zeros
 +
|-
 +
! Note
 +
| The SHA512 HMAC algorithm is:
 +
SHA512(Key xor oPad, SHA384(Key xor iPad, Data))
 +
<br />Where iPad is the byte $36 repeated 128 times, oPad is the byte $5c repeated 128 times.
 +
|-
 +
|}
 +
</div></div>
 +
<br />
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 +
<pre style="border: 0; padding-bottom:0px;">function HMACSHA512DigestString(const Key,Value:String; Digest:PSHA512Digest):Boolean;</pre>
 +
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Generate a SHA512 HMAC (Hashed Message Authentication Code) using the Key and Value</div>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
! Note
 +
| None documented
 +
|-
 +
|}
 +
</div></div>
 +
<br />
 +
 
 +
'''RSA functions'''
 +
 
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 +
<pre style="border: 0; padding-bottom:0px;">function RSAInitPrivateKey(Modulus,PublicExp,PrivateExp,P,Q,DP,DQ,QInv:PByte; ModulusLen,PublicExpLen,PrivateExpLen,PLen,QLen,DPLen,DQLen,QInvLen:Integer):PRSAContext;</pre>
 
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' To be documented</div>
 
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' To be documented</div>
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 701: Line 1,764:
 
<br />
 
<br />
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
<pre style="border: 0; padding-bottom:0px;">procedure BEToLongWord(Value:LongWord; Buffer:PByte); inline;</pre>
+
<pre style="border: 0; padding-bottom:0px;">function RSAInitPublicKey(Modulus,PublicExp:PByte; ModulusLen,PublicExpLen:Integer):PRSAContext;</pre>
 
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' To be documented</div>
 
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' To be documented</div>
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 +
|-
 +
|}
 +
</div></div>
 +
<br />
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 +
<pre style="border: 0; padding-bottom:0px;">function RSAFreeKey(Context:PRSAContext):Boolean;</pre>
 +
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Free an RSA context containing Private and/or Public keys</div>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
! Note
 +
| None documented
 +
|-
 +
|}
 +
</div></div>
 +
<br />
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 +
<pre style="border: 0; padding-bottom:0px;">function RSAEncryptSign(Context:PRSAContext; const Input:PByte; Len:Integer; Output:PByte; Sign:Boolean):Integer;</pre>
 +
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Perform PKCS1.5 Encryption or Signing</div>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
! Context
 +
| The RSA context containing Private and/or Public keys
 +
|-
 +
! Input
 +
| The data to be encrypted
 +
|-
 +
! Len
 +
| The size of the input data in bytes (Must be <= Modulus length - 11 to make the padding at least 8 bytes as recommended by RFC2313)
 +
|-
 +
! Output
 +
| The buffer for the encrypted result (Must always be Modulus length)
 +
|-
 +
! Sign
 +
| If true then sign instead of encrypting
 +
|-
 +
! Return
 +
| The number of bytes encrypted or -1 on error
 +
|-
 +
|}
 +
</div></div>
 +
<br />
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 +
<pre style="border: 0; padding-bottom:0px;">function RSADecryptVerify(Context:PRSAContext; const Input:PByte; Output:PByte; Len:Integer; Verify:Boolean):Integer;</pre>
 +
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Perform PKCS1.5 Decryption or Verification</div>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
! Context
 +
| The RSA context containing Private and/or Public keys
 +
|-
 +
! Input
 +
| The data to be decrypted (Must always be Modulus length)
 +
|-
 +
! Output
 +
| The buffer for the decrypted result
 +
|-
 +
! Len
 +
| The size of the output buffer in bytes
 +
|-
 +
! Verify
 +
| If true then verify instead of decrypting
 +
|-
 +
! Return
 +
| The number of bytes decrypted or -1 on error
 
|-
 
|-
 
|}
 
|}
Line 713: Line 1,842:
 
<br />
 
<br />
  
'''MD5 helper functions'''
+
'''Random functions'''
  
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
<pre style="border: 0; padding-bottom:0px;">procedure MD5Init(var Context:TMD5Context);</pre>
+
<pre style="border: 0; padding-bottom:0px;">function GetRandomBytes(Buffer:PByte; Count:Integer):Boolean;</pre>
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Initialize an MD5 context with constants</div>
+
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' To be documented</div>
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 728: Line 1,857:
 
<br />
 
<br />
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
<pre style="border: 0; padding-bottom:0px;">procedure MD5Update(var Context:TMD5Context; Data:Pointer; Size:LongWord);</pre>
+
<pre style="border: 0; padding-bottom:0px;">function GetRandomBytesNonZero(Buffer:PByte; Count:Integer):Boolean;</pre>
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Add more bytes to the data buffer, add to the hash in 64 byte chunks</div>
+
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' To be documented</div>
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 739: Line 1,868:
 
</div></div>
 
</div></div>
 
<br />
 
<br />
 +
 +
'''CRC functions'''
  
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
<pre style="border: 0; padding-bottom:0px;">procedure MD5Final(var Context:TMD5Context; var Digest:TMD5Digest);</pre>
+
<pre style="border: 0; padding-bottom:0px;">function CRC16CCITT(CRC:Word; Data:PByte; Size:LongWord):Word;</pre>
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Finalize the MD5 context by padding to a 64 Byte boundary, adding QWord count of bits processed and copying the hash to the digest</div>
+
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' To be documented</div>
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 752: Line 1,883:
 
</div></div>
 
</div></div>
 
<br />
 
<br />
 +
 +
'''Base64 functions'''
 +
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
<pre style="border: 0; padding-bottom:0px;">procedure MD5Transform(var Context:TMD5Context; Buffer:Pointer);</pre>
+
<pre style="border: 0; padding-bottom:0px;">function Base64EncodeString(const Value:String):String;</pre>
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' The core MD5 algorithm, adds an additional 64 Bytes (16 LongWords) to the hash</div>
+
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Encode a string using Base64 encoding and return the encoded result</div>
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 765: Line 1,899:
 
<br />
 
<br />
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
<pre style="border: 0; padding-bottom:0px;">function MD5DigestToString(Digest:PMD5Digest):String;</pre>
+
<pre style="border: 0; padding-bottom:0px;">function Base64DecodeString(const Value:String):String;</pre>
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' To be documented</div>
+
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Decode a Base64 encoded string and return the decoded result</div>
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 +
|-
 +
|}
 +
</div></div>
 +
<br />
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 +
<pre style="border: 0; padding-bottom:0px;">function Base64EncodeBuffer(const Source:PChar; SourceLen:Integer; Dest:PChar; var DestLen:Integer):Boolean;</pre>
 +
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Encode the source buffer using Base64 encoding and return the encoded result in the destination buffer</div>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
! Note
 +
| On success DestLen contains the actual encoded length including a null terminator
 +
If Dest is nil then return success (True) with the required size in DestLen
 +
|-
 +
|}
 +
</div></div>
 +
<br />
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 +
<pre style="border: 0; padding-bottom:0px;">function Base64DecodeBuffer(const Source:PChar; SourceLen:Integer; Dest:PChar; var DestLen:Integer):Boolean;</pre>
 +
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Decode a Base64 encoded source buffer and return the decoded result in the destination buffer</div>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
! Note
 +
| On success DestLen contains the actual decoded length (Null terminator is not added to this value)
 +
If Dest is nil then return success (True) with the required size in DestLen
 
|-
 
|-
 
|}
 
|}
Line 777: Line 1,937:
 
<br />
 
<br />
  
'''AES helper functions'''
+
'''Crypto helper functions'''
  
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
<pre style="border: 0; padding-bottom:0px;">function AESTE0(I:Byte):LongWord; inline;</pre>
+
<pre style="border: 0; padding-bottom:0px;">procedure BytesToLE32(Buffer:PByte; Count:LongWord);</pre>
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' To be documented</div>
+
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Change the byte order of count longwords in the supplied buffer to little endian</div>
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 792: Line 1,952:
 
<br />
 
<br />
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
<pre style="border: 0; padding-bottom:0px;">function AESTE1(I:Byte):LongWord; inline;</pre>
+
<pre style="border: 0; padding-bottom:0px;">procedure BytesToBE32(Buffer:PByte; Count:LongWord);</pre>
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' To be documented</div>
+
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Change the byte order of count longwords in the supplied buffer to big endian</div>
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 804: Line 1,964:
 
<br />
 
<br />
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
<pre style="border: 0; padding-bottom:0px;">function AESTE2(I:Byte):LongWord; inline;</pre>
+
<pre style="border: 0; padding-bottom:0px;">procedure BytesToLE64(Buffer:PByte; Count:LongWord);</pre>
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' To be documented</div>
+
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Change the byte order of count quadwords in the supplied buffer to little endian</div>
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 816: Line 1,976:
 
<br />
 
<br />
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
<pre style="border: 0; padding-bottom:0px;">function AESTE3(I:Byte):LongWord; inline;</pre>
+
<pre style="border: 0; padding-bottom:0px;">procedure BytesToBE64(Buffer:PByte; Count:LongWord);</pre>
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' To be documented</div>
+
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Change the byte order of count quadwords in the supplied buffer to big endian</div>
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 828: Line 1,988:
 
<br />
 
<br />
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
<pre style="border: 0; padding-bottom:0px;">function AESTD0(I:Byte):LongWord; inline;</pre>
+
<pre style="border: 0; padding-bottom:0px;">function LongWordToBE(Buffer:PByte):LongWord; inline;</pre>
 
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' To be documented</div>
 
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' To be documented</div>
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 840: Line 2,000:
 
<br />
 
<br />
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
<pre style="border: 0; padding-bottom:0px;">function AESTD1(I:Byte):LongWord; inline;</pre>
+
<pre style="border: 0; padding-bottom:0px;">procedure BEToLongWord(Value:LongWord; Buffer:PByte); inline;</pre>
 
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' To be documented</div>
 
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' To be documented</div>
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 852: Line 2,012:
 
<br />
 
<br />
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
<pre style="border: 0; padding-bottom:0px;">function AESTD2(I:Byte):LongWord; inline;</pre>
+
<pre style="border: 0; padding-bottom:0px;">function QWordToBE(Buffer:PByte):QWord; inline;</pre>
 
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' To be documented</div>
 
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' To be documented</div>
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 864: Line 2,024:
 
<br />
 
<br />
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
<pre style="border: 0; padding-bottom:0px;">function AESTD3(I:Byte):LongWord; inline;</pre>
+
<pre style="border: 0; padding-bottom:0px;">procedure BEToQWord(Value:QWord; Buffer:PByte); inline;</pre>
 
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' To be documented</div>
 
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' To be documented</div>
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 875: Line 2,035:
 
</div></div>
 
</div></div>
 
<br />
 
<br />
 +
 +
'''MD5 helper functions'''
 +
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
<pre style="border: 0; padding-bottom:0px;">function AESTE4_0(I:Byte):LongWord; inline;</pre>
+
<pre style="border: 0; padding-bottom:0px;">procedure MD5Init(var Context:TMD5Context);</pre>
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' To be documented</div>
+
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Initialize an MD5 context with constants</div>
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 888: Line 2,051:
 
<br />
 
<br />
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
<pre style="border: 0; padding-bottom:0px;">function AESTE4_1(I:Byte):LongWord; inline;</pre>
+
<pre style="border: 0; padding-bottom:0px;">procedure MD5Transform(var Context:TMD5Context; Buffer:Pointer);</pre>
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' To be documented</div>
+
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' The core MD5 algorithm, adds an additional 64 Bytes (16 LongWords) to the hash</div>
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 900: Line 2,063:
 
<br />
 
<br />
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
<pre style="border: 0; padding-bottom:0px;">function AESTE4_2(I:Byte):LongWord; inline;</pre>
+
<pre style="border: 0; padding-bottom:0px;">procedure MD5Update(var Context:TMD5Context; Data:Pointer; Size:LongWord);</pre>
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' To be documented</div>
+
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Add more bytes to the data buffer, add to the hash in 64 byte chunks</div>
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 912: Line 2,075:
 
<br />
 
<br />
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
<pre style="border: 0; padding-bottom:0px;">function AESTE4_3(I:Byte):LongWord; inline;</pre>
+
<pre style="border: 0; padding-bottom:0px;">procedure MD5Final(var Context:TMD5Context; var Digest:TMD5Digest);</pre>
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' To be documented</div>
+
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Finalize the MD5 context by padding to a 64 Byte boundary, adding QWord count of bits processed and copying the hash to the digest</div>
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 924: Line 2,087:
 
<br />
 
<br />
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
<pre style="border: 0; padding-bottom:0px;">function AESByte(X,N:LongWord):Byte; inline;</pre>
+
<pre style="border: 0; padding-bottom:0px;">function MD5DigestToString(Digest:PMD5Digest):String;</pre>
 
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' To be documented</div>
 
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' To be documented</div>
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 935: Line 2,098:
 
</div></div>
 
</div></div>
 
<br />
 
<br />
 +
 +
'''AES helper functions'''
 +
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 
<pre style="border: 0; padding-bottom:0px;">function AESKeySetup(Key:Pointer; KeySize:LongWord; AESKey:PAESKey):Boolean;</pre>
 
<pre style="border: 0; padding-bottom:0px;">function AESKeySetup(Key:Pointer; KeySize:LongWord; AESKey:PAESKey):Boolean;</pre>
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' To be documented</div>
+
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Create a pair of AES keys using the supplied key</div>
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! KeySize
| None documented
+
| Key size must be 16, 24 or 32 bytes (128, 192 or 256 bits)
 
|-
 
|-
 
|}
 
|}
Line 949: Line 2,115:
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 
<pre style="border: 0; padding-bottom:0px;">procedure AESEncryptBlock(Plain,Crypt:Pointer; AESKey:PAESKey);</pre>
 
<pre style="border: 0; padding-bottom:0px;">procedure AESEncryptBlock(Plain,Crypt:Pointer; AESKey:PAESKey);</pre>
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' To be documented</div>
+
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' AES Encrypt a 16 byte (128 bit) block of data using the supplied key</div>
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 961: Line 2,127:
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 
<pre style="border: 0; padding-bottom:0px;">procedure AESDecryptBlock(Crypt,Plain:Pointer; AESKey:PAESKey);</pre>
 
<pre style="border: 0; padding-bottom:0px;">procedure AESDecryptBlock(Crypt,Plain:Pointer; AESKey:PAESKey);</pre>
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' To be documented</div>
+
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' AES Decrypt a 16 byte (128 bit) block of data using the supplied key</div>
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 975: Line 2,141:
  
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
<pre style="border: 0; padding-bottom:0px;">procedure DESKey(Key:PByte; KeyType:LongWord; CryptKey:PDESKey);</pre>
+
<pre style="border: 0; padding-bottom:0px;">procedure DESCook(Raw1:PLongWord; Key:PDESKey);</pre>
 
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' To be documented</div>
 
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' To be documented</div>
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 987: Line 2,153:
 
<br />
 
<br />
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
<pre style="border: 0; padding-bottom:0px;">procedure DESCook(Raw1:PLongWord; Key:PDESKey);</pre>
+
<pre style="border: 0; padding-bottom:0px;">procedure DESKey(Key:PByte; KeyType:LongWord; CryptKey:PDESKey);</pre>
 
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' To be documented</div>
 
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' To be documented</div>
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 1,004: Line 2,170:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 1,016: Line 2,182:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 1,028: Line 2,194:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 1,040: Line 2,206:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 1,055: Line 2,221:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 1,067: Line 2,233:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 1,079: Line 2,245:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 1,094: Line 2,260:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 1,101: Line 2,267:
 
<br />
 
<br />
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
<pre style="border: 0; padding-bottom:0px;">procedure SHA1Update(var Context:TSHA1Context; Data:Pointer; Size:LongWord);</pre>
+
<pre style="border: 0; padding-bottom:0px;">procedure SHA1Transform(var Context:TSHA1Context; Buffer:Pointer);</pre>
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Add more bytes to the data buffer, add to the hash in 64 byte chunks</div>
+
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' The core SHA1 algorithm, adds an additional 64 Bytes (512 bits) to the hash</div>
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 1,113: Line 2,279:
 
<br />
 
<br />
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
<pre style="border: 0; padding-bottom:0px;">procedure SHA1Final(var Context:TSHA1Context; var Digest:TSHA1Digest);</pre>
+
<pre style="border: 0; padding-bottom:0px;">procedure SHA1Update(var Context:TSHA1Context; Data:Pointer; Size:LongWord);</pre>
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Finalize the SHA1 context by padding to a 64 Byte boundary, adding QWord count of bits processed and copying the hash to the digest</div>
+
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Add more bytes to the data buffer, add to the hash in 64 byte chunks</div>
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 1,125: Line 2,291:
 
<br />
 
<br />
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
<pre style="border: 0; padding-bottom:0px;">procedure SHA1Transform(var Context:TSHA1Context; Buffer:Pointer);</pre>
+
<pre style="border: 0; padding-bottom:0px;">procedure SHA1Final(var Context:TSHA1Context; var Digest:TSHA1Digest);</pre>
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' The core SHA1 algorithm, adds an additional 64 Bytes (512 bits) to the hash</div>
+
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Finalize the SHA1 context by padding to a 64 Byte boundary, adding QWord count of bits processed and copying the hash to the digest</div>
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 1,142: Line 2,308:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 1,157: Line 2,323:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 +
| None documented
 +
|-
 +
|}
 +
</div></div>
 +
<br />
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 +
<pre style="border: 0; padding-bottom:0px;">procedure SHA256Compress(var Context:TSHA256Context; Buffer:Pointer);</pre>
 +
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' The core SHA256 algorithm, adds an additional 64 Bytes (512 bits) to the hash</div>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 1,169: Line 2,347:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 1,181: Line 2,359:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 1,188: Line 2,366:
 
<br />
 
<br />
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
<pre style="border: 0; padding-bottom:0px;">procedure SHA256Compress(var Context:TSHA256Context; Buffer:Pointer);</pre>
+
<pre style="border: 0; padding-bottom:0px;">function SHA256DigestToString(Digest:PSHA256Digest):String;</pre>
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' The core SHA256 algorithm, adds an additional 64 Bytes (512 bits) to the hash</div>
+
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' To be documented</div>
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 1,199: Line 2,377:
 
</div></div>
 
</div></div>
 
<br />
 
<br />
 +
 +
'''SHA384 helper functions'''
 +
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
<pre style="border: 0; padding-bottom:0px;">function SHA256DigestToString(Digest:PSHA256Digest):String;</pre>
+
<pre style="border: 0; padding-bottom:0px;">procedure SHA384Init(var Context:TSHA384Context);</pre>
 +
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Initialize a SHA384 context with constants</div>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
! Note
 +
| None documented
 +
|-
 +
|}
 +
</div></div>
 +
<br />
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 +
<pre style="border: 0; padding-bottom:0px;">procedure SHA384Process(var Context:TSHA384Context; Data:Pointer; Size:LongWord);</pre>
 +
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Add more bytes to the data buffer, add to the hash in 128 byte chunks</div>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
! Note
 +
| None documented
 +
|-
 +
|}
 +
</div></div>
 +
<br />
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 +
<pre style="border: 0; padding-bottom:0px;">procedure SHA384Complete(var Context:TSHA384Context; var Digest:TSHA384Digest);</pre>
 +
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Finalize the SHA384 context by padding to a 128 Byte boundary, adding QWord count of bits processed and copying the hash to the digest</div>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
! Note
 +
| None documented
 +
|-
 +
|}
 +
</div></div>
 +
<br />
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 +
<pre style="border: 0; padding-bottom:0px;">function SHA384DigestToString(Digest:PSHA384Digest):String;</pre>
 +
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' To be documented</div>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
! Note
 +
| None documented
 +
|-
 +
|}
 +
</div></div>
 +
<br />
 +
 
 +
'''SHA512 helper functions'''
 +
 
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 +
<pre style="border: 0; padding-bottom:0px;">procedure SHA512Init(var Context:TSHA512Context);</pre>
 +
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Initialize a SHA512 context with constants</div>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
! Note
 +
| None documented
 +
|-
 +
|}
 +
</div></div>
 +
<br />
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 +
<pre style="border: 0; padding-bottom:0px;">procedure SHA512Compress(var Context:TSHA512Context; Buffer:Pointer);</pre>
 +
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' The core SHA512 algorithm, adds an additional 128 Bytes (1024 bits) to the hash</div>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
! Note
 +
| None documented
 +
|-
 +
|}
 +
</div></div>
 +
<br />
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 +
<pre style="border: 0; padding-bottom:0px;">procedure SHA512Process(var Context:TSHA512Context; Data:Pointer; Size:LongWord);</pre>
 +
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Add more bytes to the data buffer, add to the hash in 128 byte chunks</div>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
! Note
 +
| None documented
 +
|-
 +
|}
 +
</div></div>
 +
<br />
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 +
<pre style="border: 0; padding-bottom:0px;">procedure SHA512Complete(var Context:TSHA512Context; var Digest:TSHA512Digest);</pre>
 +
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Finalize the SHA512 context by padding to a 128 Byte boundary, adding QWord count of bits processed and copying the hash to the digest</div>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
! Note
 +
| None documented
 +
|-
 +
|}
 +
</div></div>
 +
<br />
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 +
<pre style="border: 0; padding-bottom:0px;">function SHA512DigestToString(Digest:PSHA512Digest):String;</pre>
 
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' To be documented</div>
 
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' To be documented</div>
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 1,212: Line 2,492:
 
<br />
 
<br />
  
'''MIME64 helper functions'''
+
'''Base64 helper functions'''
  
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
<pre style="border: 0; padding-bottom:0px;">procedure MIME64InitTables;</pre>
+
<pre style="border: 0; padding-bottom:0px;">procedure Base64InitTables;</pre>
 
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' To be documented</div>
 
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' To be documented</div>
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-

Latest revision as of 04:40, 31 August 2021

Return to Unit Reference


Description


Ultibo Crypto Interface unit

Constants



[Expand]
Cipher algorithms CRYPTO_CIPHER_ALG_*


[Expand]
Cipher modes CRYPTO_CIPHER_MODE_*


[Expand]
Hash algorithms CRYPTO_HASH_ALG_*


[Expand]
MD5 digest size MD5_DIGEST_*


[Expand]
AES block size AES_BLOCK_*


[Expand]
AES key size AES_KEY_*


[Expand]
DES block size DES_BLOCK_*


[Expand]
DES key size DES_KEY_*


[Expand]
DES key type DES_KEYTYPE_*


[Expand]
3DES block size DES3_BLOCK_*


[Expand]
3DES key size DES3_KEY_*


[Expand]
SHA1 constants SHA1_*


[Expand]
SHA256 constants SHA256_*


[Expand]
SHA384 constants SHA384_*


[Expand]
SHA512 constants SHA512_*


[Expand]
RSA constants RSA_*


[Expand]
Base64 constants BASE64_*


Type definitions



MD5 digest

[Expand]

PMD5Digest = ^TMD5Digest;

TMD5Digest = array[0..15] of Byte;

MD5 block

[Expand]

PMD5Block = ^TMD5Block;

TMD5Block = record

MD5 context

[Expand]

PMD5Context = ^TMD5Context;

TMD5Context = record

MD5 byte buffer

[Expand]

PMD5ByteBuffer = ^TMD5ByteBuffer;

TMD5ByteBuffer = array[0..63] of Byte;

MD5 long buffer

[Expand]

PMD5LongBuffer = ^TMD5LongBuffer;

TMD5LongBuffer = array[0..15] of LongWord;

AES key

[Expand]

PAESKey = ^TAESKey;

TAESKey = record

AES context

[Expand]

PAESContext = ^TAESContext;

TAESContext = record

DES key

[Expand]

PDESKey = ^TDESKey;

TDESKey = array[0..31] of LongWord;

DES context

[Expand]

PDESContext = ^TDESContext;

TDESContext = record

3DES key

[Expand]

PDES3Key = ^TDES3Key;

TDES3Key = record

3DES context

[Expand]

PDES3Context = ^TDES3Context;

TDES3Context = record

RC4 state

[Expand]

PRC4State = ^TRC4State;

TRC4State = array[0..255] of Byte;

RC4 context

[Expand]

PRC4Context = ^TRC4Context;

TRC4Context = record

SHA1 digest

[Expand]

PSHA1Digest = ^TSHA1Digest;

TSHA1Digest = array[0..19] of Byte;

SHA1 block

[Expand]

PSHA1Block = ^TSHA1Block;

TSHA1Block = record

SHA1 context

[Expand]

PSHA1Context = ^TSHA1Context;

TSHA1Context = record

SHA1 byte buffer

[Expand]

PSHA1ByteBuffer = ^TSHA1ByteBuffer;

TSHA1ByteBuffer = array[0..63] of Byte;

SHA1 long buffer

[Expand]

PSHA1LongBuffer = ^TSHA1LongBuffer;

TSHA1LongBuffer = array[0..15] of LongWord;

SHA256 digest

[Expand]

PSHA256Digest = ^TSHA256Digest;

TSHA256Digest = array[0..31] of Byte;

SHA256 block

[Expand]

PSHA256Block = ^TSHA256Block;

TSHA256Block = record

SHA256 context

[Expand]

PSHA256Context = ^TSHA256Context;

TSHA256Context = record

SHA256 byte buffer

[Expand]

PSHA256ByteBuffer = ^TSHA256ByteBuffer;

TSHA256ByteBuffer = array[0..63] of Byte;

SHA256 long buffer

[Expand]

PSHA256LongBuffer = ^TSHA256LongBuffer;

TSHA256LongBuffer = array[0..15] of LongWord;

SHA256 algorithm

[Expand]

PSHA256_W = ^TSHA256_W;

TSHA256_W = array[0..63] of LongWord;

SHA512 digest

[Expand]

PSHA512Digest = ^TSHA512Digest;

TSHA512Digest = array[0..63] of Byte;

SHA512 block

[Expand]

PSHA512Block = ^TSHA512Block;

TSHA512Block = record

SHA512 context

[Expand]

PSHA512Context = ^TSHA512Context;

TSHA512Context = record

SHA512 byte buffer

[Expand]

PSHA512ByteBuffer = ^TSHA512ByteBuffer;

TSHA512ByteBuffer = array[0..127] of Byte;

SHA512 algorithm

[Expand]

PSHA512_W = ^TSHA512_W;

TSHA512_W = array[0..79] of QWord;

SHA384 digest

[Expand]

PSHA384Digest = ^TSHA384Digest;

TSHA384Digest = array[0..47] of Byte;

SHA384 block

[Expand]

PSHA384Block = PSHA512Block;

TSHA384Block = TSHA512Block;

SHA384 context

[Expand]

PSHA384Context = PSHA512Context;

TSHA384Context = TSHA512Context;

SHA384 byte buffer

[Expand]

PSHA384ByteBuffer = PSHA512ByteBuffer;

TSHA384ByteBuffer = TSHA512ByteBuffer;

RSA context

[Expand]

PRSAContext = ^TRSAContext;

TRSAContext = record

Get random bytes

TGetRandomBytes = function(Buffer:PByte; Count:Integer):Boolean;

Base64 decode table

TBase64DecodeTable = array[0..255] of Char;

Hash context

[Expand]

PHashContext = ^THashContext;

THashContext = record

Cipher context

[Expand]

PCipherContext = ^TCipherContext;

TCipherContext = record


Public variables



Crypto specific variables

CryptoGetRandomBytesHandler:TGetRandomBytes;


Function declarations



Initialization functions

[Expand]
procedure CryptoInit;
Description: To be documented


Crypto functions

[Expand]
function HashCreate(Algorithm:LongWord; Key:Pointer; KeySize:LongWord):PHashContext;
Description: Initialize a hash context based on an algorithm and (if applicable) a key


[Expand]
function HashDestroy(Context:PHashContext):Boolean;
Description: Free a hash context allocated by HashCreate


[Expand]
function HashReset(Context:PHashContext):Boolean;
Description: Clear and reinitialize an existing hash context using the existing algorithm and key


[Expand]
function HashReset(Context:PHashContext; Algorithm:LongWord; Key:Pointer; KeySize:LongWord):Boolean;
Description: Clear and reinitialize an existing hash context using a new algorithm and key


[Expand]
function HashUpdate(Context:PHashContext; Data:Pointer; Size:LongWord):Boolean;
Description: Add a block of data to a hash context


[Expand]
function HashFinish(Context:PHashContext; Digest:Pointer; Size:LongWord):Boolean;
Description: Finalize a hash context and return the digest (Hash) value


[Expand]
function CipherCreate(Algorithm:LongWord; Vector,Key:Pointer; KeySize:LongWord):PCipherContext;
Description: Initialize a cipher context based on an algorithm and a key


[Expand]
function CipherCreate(Algorithm,Mode:LongWord; Nonce,Vector,Key:Pointer; VectorSize,KeySize:LongWord):PCipherContext;
Description: Initialize a cipher context based on an algorithm, mode and key


[Expand]
function CipherDestroy(Context:PCipherContext):Boolean;
Description: Free a cipher context allocated by CipherCreate


[Expand]
function CipherEncrypt(Context:PCipherContext; Plain,Crypt:Pointer; Size:LongWord):Boolean;
Description: Encrypt a block of data using an existing cipher context


[Expand]
function CipherDecrypt(Context:PCipherContext; Crypt,Plain:Pointer; Size:LongWord):Boolean;
Description: Decrypt a block of data using an existing cipher context


MD5 functions

[Expand]
function MD5DigestData(Data:PMD5Block; Digest:PMD5Digest):Boolean;
Description: Generate a 128 bit MD5 digest (Hash) from the supplied data


[Expand]
function MD5DigestString(const Value:String; Digest:PMD5Digest):Boolean;
Description: Generate a 128 bit MD5 digest (Hash) from the supplied string value


[Expand]
function HMACMD5DigestData(const Key:String; Data:PMD5Block; Digest:PMD5Digest):Boolean;
Description: Generate an MD5 HMAC (Hashed Message Authentication Code) using the Key and Data


[Expand]
function HMACMD5DigestData(Key:Pointer; KeySize:LongWord; Data:PMD5Block; Digest:PMD5Digest):Boolean;
Description: Generate an MD5 HMAC (Hashed Message Authentication Code) using the Key and Data


[Expand]
function HMACMD5DigestString(const Key,Value:String; Digest:PMD5Digest):Boolean;
Description: Generate an MD5 HMAC (Hashed Message Authentication Code) using the Key and Value


AES functions

[Expand]
function AESEncryptData(Key:Pointer; KeySize:LongWord; Vector,Plain,Crypt:Pointer; Size:LongWord):Boolean;
Description: Encrypt a block of data using the AES cipher, if Vector is supplied use CBC mode else use ECB


[Expand]
function AESDecryptData(Key:Pointer; KeySize:LongWord; Vector,Crypt,Plain:Pointer; Size:LongWord):Boolean;
Description: Decrypt a block of data using the AES cipher, if Vector is supplied use CBC mode else use ECB


[Expand]
function AESCTREncryptData(Key:Pointer; KeySize:LongWord; Nonce,Plain,Crypt:Pointer; Size:LongWord):Boolean;
Description: Encrypt a block of data with the supplied Key and Nonce using AES CTR mode


[Expand]
function AESCTRDecryptData(Key:Pointer; KeySize:LongWord; Nonce,Crypt,Plain:Pointer; Size:LongWord):Boolean; inline;
Description: Decrypt a block of data with the supplied Key and Nonce using AES CTR mode


[Expand]
function AESGCMEncryptData(Key:Pointer; KeySize:LongWord; IV,AAD,Plain,Crypt:Pointer; IVSize,AADSize,Size:LongWord; Tag:Pointer):Boolean;
Description: Encrypt a block of data with the supplied Key, IV and AAD using AES GCM mode, return the authentication Tag


[Expand]
function AESGCMDecryptData(Key:Pointer; KeySize:LongWord; IV,AAD,Crypt,Plain:Pointer; IVSize,AADSize,Size:LongWord; const Tag:Pointer):Boolean;
Description: Decrypt a block of data with the supplied Key, IV and AAD using AES GCM mode, validate the authentication Tag


[Expand]
function AESGCMGMAC(Key:Pointer; KeySize:LongWord; IV,AAD:Pointer; IVSize,AADSize:LongWord; Tag:Pointer):Boolean;
Description: Generate the GMAC authentication Tag for a given Key, IV and AAD using AES GCM mode


DES functions

[Expand]
function DESEncryptData(Key:Pointer; KeySize:LongWord; Vector,Plain,Crypt:Pointer; Size:LongWord):Boolean;
Description: To be documented


[Expand]
function DESDecryptData(Key:Pointer; KeySize:LongWord; Vector,Crypt,Plain:Pointer; Size:LongWord):Boolean;
Description: To be documented


3DES functions

[Expand]
function DES3EncryptData(Key:Pointer; KeySize:LongWord; Vector,Plain,Crypt:Pointer; Size:LongWord):Boolean;
Description: To be documented


[Expand]
function DES3DecryptData(Key:Pointer; KeySize:LongWord; Vector,Crypt,Plain:Pointer; Size:LongWord):Boolean;
Description: To be documented


RC4 functions

[Expand]
function RC4EncryptData(Key:Pointer; KeySize:LongWord; Plain,Crypt:Pointer; Size,Start:LongWord):Boolean;
Description: Encrypt the supplied data with a key using the RC4 cipher algorithm


[Expand]
function RC4DecryptData(Key:Pointer; KeySize:LongWord; Crypt,Plain:Pointer; Size,Start:LongWord):Boolean; inline;
Description: Encrypt the supplied data with a key using the RC4 cipher algorithm


SHA1 functions

[Expand]
function SHA1DigestData(Data:PSHA1Block; Digest:PSHA1Digest):Boolean;
Description: Generate a 160 bit SHA1 digest (Hash) from the supplied data


[Expand]
function SHA1DigestString(const Value:String; Digest:PSHA1Digest):Boolean;
Description: Generate a 160 bit SHA1 digest (Hash) from the supplied string value


[Expand]
function HMACSHA1DigestData(const Key:String; Data:PSHA1Block; Digest:PSHA1Digest):Boolean;
Description: Generate a SHA1 HMAC (Hashed Message Authentication Code) using the Key and Data


[Expand]
function HMACSHA1DigestData(Key:Pointer; KeySize:LongWord; Data:PSHA1Block; Digest:PSHA1Digest):Boolean;
Description: Generate a SHA1 HMAC (Hashed Message Authentication Code) using the Key and Data


[Expand]
function HMACSHA1DigestString(const Key,Value:String; Digest:PSHA1Digest):Boolean;
Description: Generate a SHA1 HMAC (Hashed Message Authentication Code) using the Key and Value


SHA256 functions

[Expand]
function SHA256DigestData(Data:PSHA256Block; Digest:PSHA256Digest):Boolean;
Description: Generate a 256 bit SHA256 digest (Hash) from the supplied data


[Expand]
function SHA256DigestString(const Value:String; Digest:PSHA256Digest):Boolean;
Description: Generate a 256 bit SHA256 digest (Hash) from the supplied string value


[Expand]
function HMACSHA256DigestData(const Key:String; Data:PSHA256Block; Digest:PSHA256Digest):Boolean;
Description: Generate a SHA256 HMAC (Hashed Message Authentication Code) using the Key and Data


[Expand]
function HMACSHA256DigestData(Key:Pointer; KeySize:LongWord; Data:PSHA256Block; Digest:PSHA256Digest):Boolean;
Description: Generate a SHA256 HMAC (Hashed Message Authentication Code) using the Key and Data


[Expand]
function HMACSHA256DigestString(const Key,Value:String; Digest:PSHA256Digest):Boolean;
Description: Generate a SHA256 HMAC (Hashed Message Authentication Code) using the Key and Value


SHA384 functions

[Expand]
function SHA384DigestData(Data:PSHA384Block; Digest:PSHA384Digest):Boolean;
Description: Generate a 384 bit SHA384 digest (Hash) from the supplied data


[Expand]
function SHA384DigestString(const Value:String; Digest:PSHA384Digest):Boolean;
Description: Generate a 384 bit SHA384 digest (Hash) from the supplied string value


[Expand]
function HMACSHA384DigestData(const Key:String; Data:PSHA384Block; Digest:PSHA384Digest):Boolean;
Description: Generate a SHA384 HMAC (Hashed Message Authentication Code) using the Key and Data


[Expand]
function HMACSHA384DigestData(Key:Pointer; KeySize:LongWord; Data:PSHA384Block; Digest:PSHA384Digest):Boolean;
Description: Generate a SHA384 HMAC (Hashed Message Authentication Code) using the Key and Data


[Expand]
function HMACSHA384DigestString(const Key,Value:String; Digest:PSHA384Digest):Boolean;
Description: Generate a SHA384 HMAC (Hashed Message Authentication Code) using the Key and Value


SHA512 functions

[Expand]
function SHA512DigestData(Data:PSHA512Block; Digest:PSHA512Digest):Boolean;
Description: Generate a 512 bit SHA512 digest (Hash) from the supplied data


[Expand]
function SHA512DigestString(const Value:String; Digest:PSHA512Digest):Boolean;
Description: Generate a 512 bit SHA512 digest (Hash) from the supplied string value


[Expand]
function HMACSHA512DigestData(const Key:String; Data:PSHA512Block; Digest:PSHA512Digest):Boolean;
Description: Generate a SHA512 HMAC (Hashed Message Authentication Code) using the Key and Data


[Expand]
function HMACSHA512DigestData(Key:Pointer; KeySize:LongWord; Data:PSHA512Block; Digest:PSHA512Digest):Boolean;
Description: Generate a SHA512 HMAC (Hashed Message Authentication Code) using the Key and Data


[Expand]
function HMACSHA512DigestString(const Key,Value:String; Digest:PSHA512Digest):Boolean;
Description: Generate a SHA512 HMAC (Hashed Message Authentication Code) using the Key and Value


RSA functions

[Expand]
function RSAInitPrivateKey(Modulus,PublicExp,PrivateExp,P,Q,DP,DQ,QInv:PByte; ModulusLen,PublicExpLen,PrivateExpLen,PLen,QLen,DPLen,DQLen,QInvLen:Integer):PRSAContext;
Description: To be documented


[Expand]
function RSAInitPublicKey(Modulus,PublicExp:PByte; ModulusLen,PublicExpLen:Integer):PRSAContext;
Description: To be documented


[Expand]
function RSAFreeKey(Context:PRSAContext):Boolean;
Description: Free an RSA context containing Private and/or Public keys


[Expand]
function RSAEncryptSign(Context:PRSAContext; const Input:PByte; Len:Integer; Output:PByte; Sign:Boolean):Integer;
Description: Perform PKCS1.5 Encryption or Signing


[Expand]
function RSADecryptVerify(Context:PRSAContext; const Input:PByte; Output:PByte; Len:Integer; Verify:Boolean):Integer;
Description: Perform PKCS1.5 Decryption or Verification


Random functions

[Expand]
function GetRandomBytes(Buffer:PByte; Count:Integer):Boolean;
Description: To be documented


[Expand]
function GetRandomBytesNonZero(Buffer:PByte; Count:Integer):Boolean;
Description: To be documented


CRC functions

[Expand]
function CRC16CCITT(CRC:Word; Data:PByte; Size:LongWord):Word;
Description: To be documented


Base64 functions

[Expand]
function Base64EncodeString(const Value:String):String;
Description: Encode a string using Base64 encoding and return the encoded result


[Expand]
function Base64DecodeString(const Value:String):String;
Description: Decode a Base64 encoded string and return the decoded result


[Expand]
function Base64EncodeBuffer(const Source:PChar; SourceLen:Integer; Dest:PChar; var DestLen:Integer):Boolean;
Description: Encode the source buffer using Base64 encoding and return the encoded result in the destination buffer


[Expand]
function Base64DecodeBuffer(const Source:PChar; SourceLen:Integer; Dest:PChar; var DestLen:Integer):Boolean;
Description: Decode a Base64 encoded source buffer and return the decoded result in the destination buffer


Crypto helper functions

[Expand]
procedure BytesToLE32(Buffer:PByte; Count:LongWord);
Description: Change the byte order of count longwords in the supplied buffer to little endian


[Expand]
procedure BytesToBE32(Buffer:PByte; Count:LongWord);
Description: Change the byte order of count longwords in the supplied buffer to big endian


[Expand]
procedure BytesToLE64(Buffer:PByte; Count:LongWord);
Description: Change the byte order of count quadwords in the supplied buffer to little endian


[Expand]
procedure BytesToBE64(Buffer:PByte; Count:LongWord);
Description: Change the byte order of count quadwords in the supplied buffer to big endian


[Expand]
function LongWordToBE(Buffer:PByte):LongWord; inline;
Description: To be documented


[Expand]
procedure BEToLongWord(Value:LongWord; Buffer:PByte); inline;
Description: To be documented


[Expand]
function QWordToBE(Buffer:PByte):QWord; inline;
Description: To be documented


[Expand]
procedure BEToQWord(Value:QWord; Buffer:PByte); inline;
Description: To be documented


MD5 helper functions

[Expand]
procedure MD5Init(var Context:TMD5Context);
Description: Initialize an MD5 context with constants


[Expand]
procedure MD5Transform(var Context:TMD5Context; Buffer:Pointer);
Description: The core MD5 algorithm, adds an additional 64 Bytes (16 LongWords) to the hash


[Expand]
procedure MD5Update(var Context:TMD5Context; Data:Pointer; Size:LongWord);
Description: Add more bytes to the data buffer, add to the hash in 64 byte chunks


[Expand]
procedure MD5Final(var Context:TMD5Context; var Digest:TMD5Digest);
Description: Finalize the MD5 context by padding to a 64 Byte boundary, adding QWord count of bits processed and copying the hash to the digest


[Expand]
function MD5DigestToString(Digest:PMD5Digest):String;
Description: To be documented


AES helper functions

[Expand]
function AESKeySetup(Key:Pointer; KeySize:LongWord; AESKey:PAESKey):Boolean;
Description: Create a pair of AES keys using the supplied key


[Expand]
procedure AESEncryptBlock(Plain,Crypt:Pointer; AESKey:PAESKey);
Description: AES Encrypt a 16 byte (128 bit) block of data using the supplied key


[Expand]
procedure AESDecryptBlock(Crypt,Plain:Pointer; AESKey:PAESKey);
Description: AES Decrypt a 16 byte (128 bit) block of data using the supplied key


DES helper functions

[Expand]
procedure DESCook(Raw1:PLongWord; Key:PDESKey);
Description: To be documented


[Expand]
procedure DESKey(Key:PByte; KeyType:LongWord; CryptKey:PDESKey);
Description: To be documented


[Expand]
procedure DESProcess(Block,Key:PLongWord);
Description: To be documented


[Expand]
function DESKeySetup(Key:Pointer; KeySize:LongWord; EncryptKey,DecryptKey:PDESKey):Boolean;
Description: To be documented


[Expand]
procedure DESEncryptBlock(Plain,Crypt:Pointer; EncryptKey:PDESKey);
Description: To be documented


[Expand]
procedure DESDecryptBlock(Crypt,Plain:Pointer; DecryptKey:PDESKey);
Description: To be documented


3DES helper functions

[Expand]
function DES3KeySetup(Key:Pointer; KeySize:LongWord; DES3Key:PDES3Key):Boolean;
Description: To be documented


[Expand]
procedure DES3EncryptBlock(Plain,Crypt:Pointer; DES3Key:PDES3Key);
Description: To be documented


[Expand]
procedure DES3DecryptBlock(Crypt,Plain:Pointer; DES3Key:PDES3Key);
Description: To be documented


SHA1 helper functions

[Expand]
procedure SHA1Init(var Context:TSHA1Context);
Description: Initialize a SHA1 context with constants


[Expand]
procedure SHA1Transform(var Context:TSHA1Context; Buffer:Pointer);
Description: The core SHA1 algorithm, adds an additional 64 Bytes (512 bits) to the hash


[Expand]
procedure SHA1Update(var Context:TSHA1Context; Data:Pointer; Size:LongWord);
Description: Add more bytes to the data buffer, add to the hash in 64 byte chunks


[Expand]
procedure SHA1Final(var Context:TSHA1Context; var Digest:TSHA1Digest);
Description: Finalize the SHA1 context by padding to a 64 Byte boundary, adding QWord count of bits processed and copying the hash to the digest


[Expand]
function SHA1DigestToString(Digest:PSHA1Digest):String;
Description: To be documented


SHA256 helper functions

[Expand]
procedure SHA256Init(var Context:TSHA256Context);
Description: Initialize a SHA256 context with constants


[Expand]
procedure SHA256Compress(var Context:TSHA256Context; Buffer:Pointer);
Description: The core SHA256 algorithm, adds an additional 64 Bytes (512 bits) to the hash


[Expand]
procedure SHA256Process(var Context:TSHA256Context; Data:Pointer; Size:LongWord);
Description: Add more bytes to the data buffer, add to the hash in 64 byte chunks


[Expand]
procedure SHA256Complete(var Context:TSHA256Context; var Digest:TSHA256Digest);
Description: Finalize the SHA256 context by padding to a 64 Byte boundary, adding QWord count of bits processed and copying the hash to the digest


[Expand]
function SHA256DigestToString(Digest:PSHA256Digest):String;
Description: To be documented


SHA384 helper functions

[Expand]
procedure SHA384Init(var Context:TSHA384Context);
Description: Initialize a SHA384 context with constants


[Expand]
procedure SHA384Process(var Context:TSHA384Context; Data:Pointer; Size:LongWord);
Description: Add more bytes to the data buffer, add to the hash in 128 byte chunks


[Expand]
procedure SHA384Complete(var Context:TSHA384Context; var Digest:TSHA384Digest);
Description: Finalize the SHA384 context by padding to a 128 Byte boundary, adding QWord count of bits processed and copying the hash to the digest


[Expand]
function SHA384DigestToString(Digest:PSHA384Digest):String;
Description: To be documented


SHA512 helper functions

[Expand]
procedure SHA512Init(var Context:TSHA512Context);
Description: Initialize a SHA512 context with constants


[Expand]
procedure SHA512Compress(var Context:TSHA512Context; Buffer:Pointer);
Description: The core SHA512 algorithm, adds an additional 128 Bytes (1024 bits) to the hash


[Expand]
procedure SHA512Process(var Context:TSHA512Context; Data:Pointer; Size:LongWord);
Description: Add more bytes to the data buffer, add to the hash in 128 byte chunks


[Expand]
procedure SHA512Complete(var Context:TSHA512Context; var Digest:TSHA512Digest);
Description: Finalize the SHA512 context by padding to a 128 Byte boundary, adding QWord count of bits processed and copying the hash to the digest


[Expand]
function SHA512DigestToString(Digest:PSHA512Digest):String;
Description: To be documented


Base64 helper functions

[Expand]
procedure Base64InitTables;
Description: To be documented


Return to Unit Reference