Subversion Repositories Kolibri OS

Rev

Rev 6461 | Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

  1. ;    libcrash -- cryptographic hash functions
  2. ;
  3. ;    Copyright (C) 2012-2014,2016 Ivan Baravy (dunkaist)
  4. ;
  5. ;    This program is free software: you can redistribute it and/or modify
  6. ;    it under the terms of the GNU General Public License as published by
  7. ;    the Free Software Foundation, either version 3 of the License, or
  8. ;    (at your option) any later version.
  9. ;
  10. ;    This program is distributed in the hope that it will be useful,
  11. ;    but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ;    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13. ;    GNU General Public License for more details.
  14. ;
  15. ;    You should have received a copy of the GNU General Public License
  16. ;    along with this program.  If not, see <http://www.gnu.org/licenses/>.
  17.  
  18.  
  19. LIBCRASH_CRC32          = 0
  20. LIBCRASH_MD4            = 1
  21. LIBCRASH_MD5            = 2
  22. LIBCRASH_SHA1           = 3
  23. LIBCRASH_SHA224         = 4
  24. LIBCRASH_SHA256         = 5
  25. LIBCRASH_SHA384         = 6
  26. LIBCRASH_SHA512         = 7
  27. LIBCRASH_SHA3_224       = 8
  28. LIBCRASH_SHA3_256       = 9
  29. LIBCRASH_SHA3_384       = 10
  30. LIBCRASH_SHA3_512       = 11
  31. LIBCRASH_LAST           = 11
  32.  
  33.  
  34. struct crash_item
  35.         init    dd ?
  36.         update  dd ?
  37.         final   dd ?
  38.         len_out dd ?
  39. ends
  40.  
  41. ; CRC32
  42.  
  43. CRC32_HASH_SIZE = 4
  44. CRC32_ALIGN = 4
  45. CRC32_ALIGN_MASK = CRC32_ALIGN - 1
  46.  
  47. struct ctx_crc32
  48.         hash    rd 1
  49. ends
  50.  
  51. ; MD4
  52.  
  53. MD4_BLOCK_SIZE = 64
  54. MD4_HASH_SIZE  = 16
  55. MD4_ALIGN      = 4
  56. MD4_ALIGN_MASK = MD4_ALIGN - 1
  57.  
  58. struct ctx_md4
  59.         hash            rb MD4_HASH_SIZE
  60.         block           rb MD4_BLOCK_SIZE
  61.         index           rd 1
  62.         msglen_0        rd 1
  63.         msglen_1        rd 1
  64. ends
  65.  
  66. ; MD5
  67.  
  68. MD5_BLOCK_SIZE = 64
  69. MD5_HASH_SIZE  = 16
  70. MD5_ALIGN      = 4
  71. MD5_ALIGN_MASK = MD5_ALIGN - 1
  72.  
  73. struct ctx_md5
  74.         hash            rb MD5_HASH_SIZE
  75.         block           rb MD5_BLOCK_SIZE
  76.         index           rd 1
  77.         msglen_0        rd 1
  78.         msglen_1        rd 1
  79. ends
  80.  
  81. ; SHA1
  82.  
  83. SHA1_BLOCK_SIZE = 64
  84. SHA1_HASH_SIZE  = 20
  85. SHA1_ALIGN      = 4
  86. SHA1_ALIGN_MASK = SHA1_ALIGN - 1
  87.  
  88. struct ctx_sha1
  89.         hash            rb SHA1_HASH_SIZE
  90.         block           rb SHA1_BLOCK_SIZE
  91.         index           rd 1
  92.         msglen_0        rd 1
  93.         msglen_1        rd 1
  94. ends
  95.  
  96. ; SHA2
  97.  
  98. SHA224256_BLOCK_SIZE = 64
  99. SHA224256_INIT_SIZE  = 32
  100. SHA224_HASH_SIZE     = 28
  101. SHA256_HASH_SIZE     = 32
  102. SHA224256_ALIGN      = 4
  103. SHA224256_ALIGN_MASK = SHA224256_ALIGN - 1
  104.  
  105. struct ctx_sha224256
  106.         hash            rb SHA224256_INIT_SIZE
  107.         block           rb SHA224256_BLOCK_SIZE
  108.         index           rd 1
  109.         msglen_0        rd 1
  110.         msglen_1        rd 1
  111. ends
  112.  
  113. SHA384512_BLOCK_SIZE = 128
  114. SHA384512_INIT_SIZE  = 64
  115.  
  116. SHA384_HASH_SIZE     = 48
  117. SHA512_HASH_SIZE     = 64
  118.  
  119. SHA384512_ALIGN      = 16
  120. SHA384512_ALIGN_MASK = SHA384512_ALIGN - 1
  121.  
  122. struct ctx_sha384512
  123.         hash            rb SHA384512_INIT_SIZE
  124.         block           rb SHA384512_BLOCK_SIZE
  125.         index           rd 1
  126.         msglen_0        rd 1
  127.         msglen_1        rd 1
  128.         msglen_2        rd 1
  129.         msglen_3        rd 1
  130.                         rd 3    ; align
  131.         ; tmp vars
  132.         w               rq 80
  133.         A               rq 1
  134.         B               rq 1
  135.         C               rq 1
  136.         D               rq 1
  137.         E               rq 1
  138.         F               rq 1
  139.         G               rq 1
  140.         H               rq 1
  141.         temp            rq 1
  142. ends
  143.  
  144. ; SHA3
  145.  
  146. SHA3224_BLOCK_SIZE      = 144
  147. SHA3256_BLOCK_SIZE      = 136
  148. SHA3384_BLOCK_SIZE      = 104
  149. SHA3512_BLOCK_SIZE      = 72
  150. SHA3MAX_BLOCK_SIZE      = SHA3224_BLOCK_SIZE
  151.  
  152. SHA3_INIT_SIZE          = 200
  153.  
  154. SHA3224_HASH_SIZE       = 28
  155. SHA3256_HASH_SIZE       = 32
  156. SHA3384_HASH_SIZE       = 48
  157. SHA3512_HASH_SIZE       = 64
  158.  
  159. SHA3_ALIGN              = 16
  160. SHA3_ALIGN_MASK         = SHA3_ALIGN-1
  161.  
  162. struct ctx_sha3
  163.         hash            rb SHA3_INIT_SIZE
  164.                         rb SHA3_ALIGN - (SHA3_INIT_SIZE mod SHA3_ALIGN)
  165.         block           rb SHA3MAX_BLOCK_SIZE
  166.                         rb SHA3_ALIGN - (SHA3MAX_BLOCK_SIZE mod SHA3_ALIGN)
  167.         index           rd 1
  168.         block_size      rd 1
  169.         rounds_cnt      rd 1
  170.                         rd 1    ; align
  171.         ; tmp vars
  172.         C               rq 5
  173.         D               rq 5
  174. ends
  175.  
  176.