Difference between revisions of "Unit Crypto"

From Ultibo.org
Jump to: navigation, search
Line 235: Line 235:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 250: Line 250:
 
{| 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 262:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 274: Line 274:
 
{| 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 286:
 
{| 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 298:
 
{| 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 also include an initialization vector for CBC mode
 
|-
 
|-
Line 310: Line 310:
 
{| 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 322:
 
{| 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 334:
 
{| 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 349:
 
{| 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.
 
| 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 361:
 
{| 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 373:
 
{| 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, 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)). Where iPad is the byte $36 repeated 64 times, oPad is the byte $5c repeated 64 times.
 
|-
 
|-
Line 406: Line 406:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 418: Line 418:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 433: Line 433:
 
{| 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 445:
 
{| 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 460:
 
{| 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 472:
 
{| 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 487:
 
{| 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 499: Line 499:
 
{| 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 514:
 
{| 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.
 
| 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 526:
 
{| 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 538:
 
{| 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, 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)). Where iPad is the byte $36 repeated 64 times, oPad is the byte $5c repeated 64 times.
 
|-
 
|-
Line 553: Line 553:
 
{| 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, Value)). Where iPad is the byte $36 repeated 64 times, oPad is the byte $5c repeated 64 times.
 
|-
 
|-
Line 571: Line 571:
 
{| 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.
 
| 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 583:
 
{| 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 595:
 
{| 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, 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, Data)). Where iPad is the byte $36 repeated 64 times, oPad is the byte $5c repeated 64 times.
 
|-
 
|-
Line 610: Line 610:
 
{| 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.
 
|-
 
|-
Line 628: Line 628:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 643: Line 643:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 655: Line 655:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 670: Line 670:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 682: Line 682:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 694: Line 694:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 706: Line 706:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 721: Line 721:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 733: Line 733:
 
{| 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 739:
 
</div></div>
 
</div></div>
 
<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 MD5Final(var Context:TMD5Context; var Digest:TMD5Digest);</pre>
 
<pre style="border: 0; padding-bottom:0px;">procedure MD5Final(var Context:TMD5Context; var Digest:TMD5Digest);</pre>
Line 746: Line 745:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 758: Line 757:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 770: Line 769:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 785: Line 784:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 797: Line 796:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 809: Line 808:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 821: Line 820:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 833: Line 832:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 845: Line 844:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 857: Line 856:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 869: Line 868:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 881: Line 880:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 893: Line 892:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 905: Line 904:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 917: Line 916:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 929: Line 928:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 941: Line 940:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 953: Line 952:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 965: Line 964:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 980: Line 979:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 992: Line 991:
 
{| 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 1,003:
 
{| 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 1,015:
 
{| 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 1,027:
 
{| 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 1,039:
 
{| 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 1,054:
 
{| 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 1,066:
 
{| 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 1,078:
 
{| 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 1,093:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 1,106: Line 1,105:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-

Revision as of 04:34, 30 March 2018

Return to Unit Reference


Description


Ultibo Crypto interface unit

To be documented

Constants



Crypto cipher algorithms CRYPTO_CIPHER_ALG_*
CRYPTO_CIPHER_ALG_NONE = 0;  
CRYPTO_CIPHER_ALG_AES = 1;  
CRYPTO_CIPHER_ALG_DES = 2;  
CRYPTO_CIPHER_ALG_3DES = 3;  
CRYPTO_CIPHER_ALG_RC4 = 4;  


Crypto cipher modes CRYPTO_CIPHER_MODE_*
CRYPTO_CIPHER_MODE_ECB = 0; Electronic Codebook
CRYPTO_CIPHER_MODE_CBC = 1; Cipher Block Chaining
CRYPTO_CIPHER_MODE_CFB = 2; Cipher Feedback
CRYPTO_CIPHER_MODE_OFB = 3; Output Feedback
CRYPTO_CIPHER_MODE_CRT = 4; Counter


Crypto hash algorithms CRYPTO_HASH_ALG_*
CRYPTO_HASH_ALG_NONE = 0;  
CRYPTO_HASH_ALG_MD5 = 1;  
CRYPTO_HASH_ALG_SHA1 = 2;  
CRYPTO_HASH_ALG_SHA256 = 3;  
CRYPTO_HASH_ALG_HMAC_MD5 = 4;  
CRYPTO_HASH_ALG_HMAC_SHA1 = 5;  
CRYPTO_HASH_ALG_HMAC_SHA256 = 6;  


AES block size AES_BLOCK_*
AES_BLOCK_SIZE = 16; 128 bit blocks


AES key size AES_KEY_*
AES_KEY_SIZE128 = 16; 128 bit keys
AES_KEY_SIZE192 = 24; 192 bit keys
AES_KEY_SIZE256 = 32; 256 bit keys


DES block size DES_BLOCK_*
DES_BLOCK_SIZE = 8; 64 bit blocks


DES key size DES_KEY_*
DES_KEY_SIZE = 8; 64 bit keys


DES key type DES_KEYTYPE_*
DES_KEYTYPE_ENCRYPT = 0;  
DES_KEYTYPE_DECRYPT = 1;  
 
DES_BYTEBIT:array[0..7] of LongWord = (
$80, $40, $20, $10, $08, $04, $02, $01);  


3DES block size DES3_BLOCK_*
DES3_BLOCK_SIZE = 8; 64 bit blocks


3DES key size DES3_KEY_*
DES3_KEY_SIZE = 24; 192 bit (3 x 64 bit) keys


SHA1 constants SHA1_*
SHA1_K20 = $5A827999;  
SHA1_K40 = $6ED9EBA1;  
SHA1_K60 = $8F1BBCDC;  
SHA1_K80 = $CA62C1D6;  


MIME64 constants MIME64_*
MIME64EncodingTable:String = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';  


Type definitions


To be documented

Public variables


To be documented

Function declarations



Initialization functions

procedure CryptoInit;
Description: To be documented
Note None documented


Crypto functions

function HashCreate(Algorithm:LongWord; Key:Pointer; KeySize:LongWord):PHashContext;
Description: Initialize a hash context based on an algorithm and an optional key
Note None documented


function HashDestroy(Context:PHashContext):Boolean;
Description: Free a hash context allocated by HashCreate
Note None documented


function HashUpdate(Context:PHashContext; Data:Pointer; Size:LongWord):Boolean;
Description: Add a block of data to a hash context
Note None documented


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


function CipherCreate(Algorithm:LongWord; Vector,Key:Pointer; KeySize:LongWord):PCipherContext;
Description: Initialize a cipher context based on an algorithm and a key
Note For block ciphers also include an initialization vector for CBC mode


function CipherDestroy(Context:PCipherContext):Boolean;
Description: Free a cipher context allocated by CipherCreate
Note None documented


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


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


MD5 functions

function MD5DigestData(Data:PMD5Block; Digest:PMD5Digest):Boolean;
Description: Generate a 128 bit MD5 digest (Hash) from the supplied 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.


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


function HMACMD5DigestData(const Key:String; Data:PMD5Block; Digest:PMD5Digest):Boolean;
Description: Generate an MD5 HMAC (Hashed Message Authentication Code) using the Key and Data
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 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.


function HMACMD5DigestString(const Key,Value:String; Digest:PMD5Digest):Boolean;
Description: Generate an MD5 HMAC (Hashed Message Authentication Code) using the Key and Value
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 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.


AES functions

function AESEncryptData(Key:Pointer; KeySize:LongWord; Vector,Plain,Crypt:Pointer; Size:LongWord):Boolean;
Description: To be documented
Note None documented


function AESDecryptData(Key:Pointer; KeySize:LongWord; Vector,Crypt,Plain:Pointer; Size:LongWord):Boolean;
Description: To be documented
Note None documented


DES functions

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


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


3DES functions

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


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


RC4 functions

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
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


function RC4DecryptData(Key:Pointer; KeySize:LongWord; Crypt,Plain:Pointer; Size,Start:LongWord):Boolean; inline;
Description: Decrypt the supplied data with a key using the RC4 cipher algorithm
Note None documented


SHA1 functions

function SHA1DigestData(Data:PSHA1Block; Digest:PSHA1Digest):Boolean;
Description: Generate a 160 bit SHA1 digest (Hash) from the supplied 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.


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


function HMACSHA1DigestData(const Key:String; Data:PSHA1Block; Digest:PSHA1Digest):Boolean;
Description: Generate a SHA1 HMAC (Hashed Message Authentication Code) using the Key and Data
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 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.


function HMACSHA1DigestString(const Key,Value:String; Digest:PSHA1Digest):Boolean;
Description: Generate a SHA1 HMAC (Hashed Message Authentication Code) using the Key and Value
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 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.


SHA256 functions

function SHA256DigestData(Data:PSHA256Block; Digest:PSHA256Digest):Boolean;
Description: Generate a 256 bit SHA256 digest (Hash) from the supplied 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.


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


function HMACSHA256DigestData(const Key:String; Data:PSHA256Block; Digest:PSHA256Digest):Boolean;
Description: Generate a SHA256 HMAC (Hashed Message Authentication Code) using the Key and Data
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 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.


function HMACSHA256DigestString(const Key,Value:String; Digest:PSHA256Digest):Boolean;
Description: Generate a SHA256 HMAC (Hashed Message Authentication Code) using the Key and Value
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 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.


CRC functions

function CRC16CCITT(CRC:Word; Data:PByte; Size:LongWord):Word;
Description: To be documented
Note None documented


MIME64 functions

function MIME64EncodeString(const AValue:String):String;
Description: To be documented
Note None documented


function MIME64DecodeString(const AValue:String):String;
Description: To be documented
Note None documented


Crypto helper functions

procedure BytesToLE(Buffer:PByte; Count:LongWord);
Description: Change the byte order of count longwords in the supplied buffer to little endian
Note None documented


procedure BytesToBE(Buffer:PByte; Count:LongWord);
Description: Change the byte order of count longwords in the supplied buffer to big endian
Note None documented


function LongWordToBE(Buffer:PByte):LongWord; inline;
Description: To be documented
Note None documented


procedure BEToLongWord(Value:LongWord; Buffer:PByte); inline;
Description: To be documented
Note None documented


MD5 helper functions

procedure MD5Init(var Context:TMD5Context);
Description: Initialize an MD5 context with constants
Note None documented


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
Note None documented


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
Note None documented


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


function MD5DigestToString(Digest:PMD5Digest):String;
Description: To be documented
Note None documented


AES helper functions

function AESTE0(I:Byte):LongWord; inline;
Description: To be documented
Note None documented


function AESTE1(I:Byte):LongWord; inline;
Description: To be documented
Note None documented


function AESTE2(I:Byte):LongWord; inline;
Description: To be documented
Note None documented


function AESTE3(I:Byte):LongWord; inline;
Description: To be documented
Note None documented


function AESTD0(I:Byte):LongWord; inline;
Description: To be documented
Note None documented


function AESTD1(I:Byte):LongWord; inline;
Description: To be documented
Note None documented


function AESTD2(I:Byte):LongWord; inline;
Description: To be documented
Note None documented


function AESTD3(I:Byte):LongWord; inline;
Description: To be documented
Note None documented


function AESTE4_0(I:Byte):LongWord; inline;
Description: To be documented
Note None documented


function AESTE4_1(I:Byte):LongWord; inline;
Description: To be documented
Note None documented


function AESTE4_2(I:Byte):LongWord; inline;
Description: To be documented
Note None documented


function AESTE4_3(I:Byte):LongWord; inline;
Description: To be documented
Note None documented


function AESByte(X,N:LongWord):Byte; inline;
Description: To be documented
Note None documented


function AESKeySetup(Key:Pointer; KeySize:LongWord; AESKey:PAESKey):Boolean;
Description: To be documented
Note None documented


procedure AESEncryptBlock(Plain,Crypt:Pointer; AESKey:PAESKey);
Description: To be documented
Note None documented


procedure AESDecryptBlock(Crypt,Plain:Pointer; AESKey:PAESKey);
Description: To be documented
Note None documented


DES helper functions

procedure DESKey(Key:PByte; KeyType:LongWord; CryptKey:PDESKey);
Description: To be documented
Note None documented


procedure DESCook(Raw1:PLongWord; Key:PDESKey);
Description: To be documented
Note None documented


procedure DESProcess(Block,Key:PLongWord);
Description: To be documented
Note None documented


function DESKeySetup(Key:Pointer; KeySize:LongWord; EncryptKey,DecryptKey:PDESKey):Boolean;
Description: To be documented
Note None documented


procedure DESEncryptBlock(Plain,Crypt:Pointer; EncryptKey:PDESKey);
Description: To be documented
Note None documented


procedure DESDecryptBlock(Crypt,Plain:Pointer; DecryptKey:PDESKey);
Description: To be documented
Note None documented


3DES helper functions

function DES3KeySetup(Key:Pointer; KeySize:LongWord; DES3Key:PDES3Key):Boolean;
Description: To be documented
Note None documented


procedure DES3EncryptBlock(Plain,Crypt:Pointer; DES3Key:PDES3Key);
Description: To be documented
Note None documented


procedure DES3DecryptBlock(Crypt,Plain:Pointer; DES3Key:PDES3Key);
Description: To be documented
Note None documented


SHA1 helper functions

procedure SHA1Init(var Context:TSHA1Context);
Description: Initialize a SHA1 context with constants
Note None documented


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
Note None documented


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
Note None documented


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


function SHA1DigestToString(Digest:PSHA1Digest):String;
Description: To be documented
Note None documented


SHA256 helper functions

procedure SHA256Init(var Context:TSHA256Context);
Description: Initialize a SHA256 context with constants
Note None documented


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
Note None documented


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
Note None documented


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


function SHA256DigestToString(Digest:PSHA256Digest):String;
Description: To be documented
Note None documented


MIME64 helper functions

procedure MIME64InitTables;
Description: To be documented
Note None documented


Return to Unit Reference