xrn_settings.h 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. /*
  2. Software License
  3. Copyright (C) 2021-05-24 Xoronos
  4. This program is free software: you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation, version 3.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program. If not, see <https://www.gnu.org/licenses/>.
  13. */
  14. /*
  15. Liabilities
  16. The software is provided "AS IS" without any warranty of any kind, either expressed,
  17. implied, or statutory, including, but not limited to, any warranty that the software
  18. will conform to specifications, any implied warranties of merchantability, fitness
  19. for a particular purpose, and freedom from infringement, and any warranty that the
  20. documentation will conform to the software, or any warranty that the software will
  21. be error free.
  22. In no event shall Xoronos be liable for any damages, including, but not limited to,
  23. direct, indirect, special or consequential damages, arising out of, resulting from,
  24. or in any way connected with this software, whether or not based upon warranty,
  25. contract, tort, or otherwise, whether or not injury was sustained by persons or
  26. property or otherwise, and whether or not loss was sustained from, or arose out of
  27. the results of, or use of, the software or services provided hereunder.
  28. To request the provided software under a different license you can contact us at
  29. support@xoronos.com
  30. */
  31. #ifndef XSETTINGS_LIB_H
  32. #define XSETTINGS_LIB_H
  33. // 16 bits
  34. #define XRN_ALGORITHM_VERSION 0
  35. // 16 bits
  36. #define XRN_IO_VERSION 0
  37. // 32 bits
  38. #define XRN_COMPONENT_ID 0
  39. // action
  40. #if !defined( XCOMPILEPARSER )
  41. #define XCOMPILEPARSER 0
  42. #endif
  43. #if !defined( XCOMPILETESTS )
  44. #define XCOMPILETESTS 0
  45. #endif
  46. #if !defined( XCOMPILEEXAMPLES )
  47. #define XCOMPILEEXAMPLES 1
  48. #endif
  49. #if !defined( XRUNCONFGEN )
  50. #define XRUNCONFGEN 0
  51. #endif
  52. #if !defined( XSKIPMAIN )
  53. #define XSKIPMAIN 0
  54. #endif
  55. #if !defined( XRN_GNU_LINUX )
  56. #define XRN_GNU_LINUX 1
  57. #endif
  58. #define PRINT_SETTINGS 1
  59. // number of bits
  60. #if !defined( XNBITS )
  61. #define XNBITS 256
  62. #endif
  63. // define function to use
  64. #if !defined( XUSE_BUILT_IN_INSTRUCTIONS )
  65. #define XUSE_BUILT_IN_INSTRUCTIONS 1
  66. #endif
  67. // DO NOT MODIFY BELOW
  68. // magic numbers
  69. #define XRN_MAGIC_NUMBER 0x22fe2022
  70. // define git version
  71. #define XRN_GIT_DIRTY_FLAG_INT (XRN_GIT_DIRTY_FLAG[0]-'0')
  72. #define XRN_GIT_VERSION ((uint32_t)(GIT_VERSION | ( XRN_GIT_DIRTY_FLAG_INT << 31 )))
  73. //define permutation
  74. #if ( XRUNCONFGEN == 1 )
  75. #include <stdint.h>
  76. #define XRN_PERMUTATION_NUMBER 0x00000000
  77. #if ( XNBITS == 256 )
  78. #define XRN_PERMUTATIONS { 41, 157, 187, 70, 185, 227, 64, 254, 20, 75, 53, 23, 123, 0, 84, 193, 194, 134, 138, 10, 168, 90, 211, 28, 66, 15, 230, 192, 210, 163, 131, 4, 34, 203, 132, 160, 144, 156, 91, 76, 226, 196, 222, 106, 116, 89, 43, 217, 104, 215, 55,209, 79, 95, 30, 205, 122, 228, 246, 35, 182, 244, 190, 135, 225, 158, 175, 179, 14, 170, 93, 96, 120, 115, 62, 165, 51, 60, 102, 48, 130, 129, 86, 176, 47, 68, 83, 171, 52, 218, 251, 22, 243, 250, 27, 25, 140, 169, 166, 219, 107, 174, 248, 186, 110, 94, 99, 213, 33, 87, 77, 245, 37, 235, 232, 26, 136, 13, 126, 221, 207, 61, 24, 229, 167, 59, 121, 114, 100, 212, 152, 238, 21, 50, 223, 44, 80, 199, 36, 188, 40, 201, 103, 3, 178, 220, 17, 249, 69, 253, 18, 161, 216, 240, 214, 173, 137, 153, 19, 234, 189, 72, 184, 32, 208, 81, 149, 1, 162, 127, 7, 74, 57, 2, 177, 12, 252, 241, 200, 164, 141, 239, 109, 159, 143, 45, 206, 242, 71, 49, 5, 58, 78, 101, 191, 63, 142, 113, 197, 108, 67, 119, 124, 236, 9, 11, 111, 31, 233, 145, 73, 155, 6, 42, 46, 139, 237, 38, 195, 172, 98, 247, 29, 54, 147, 202, 117, 16, 204, 39, 85, 118, 231, 224, 97, 8, 148, 154, 198, 125, 150, 92, 105, 146, 112, 65, 88, 183, 128, 181, 180, 151, 82, 255, 56, 133 };
  79. #elif ( XNBITS == 128 )
  80. #define XRN_PERMUTATIONS { 95, 47, 63, 40, 5, 0, 93, 1, 59, 107, 118, 57, 12, 117, 124, 44, 122, 100, 16, 88, 85, 4, 34, 105, 71, 113, 25, 20, 127, 81, 108, 17, 84, 13, 55, 112, 18, 38, 115, 11, 70, 75, 86, 87, 126, 123, 91, 32, 78, 24, 9, 53, 76, 7, 2, 121, 41, 83, 68, 45, 56, 103, 106, 69, 35, 10, 110, 54, 66, 60, 43, 36, 27, 120, 104, 14, 97, 37, 6, 61, 3, 46, 31, 42, 33, 82, 72, 102, 67, 49, 77, 39, 51, 98, 21, 79, 74, 26, 8, 92, 28, 65, 111, 62, 64, 29, 30, 116, 109, 19, 99, 22, 58, 101, 119, 50, 89, 90, 23, 96, 15, 80, 48, 73, 94, 52, 114, 125 };
  81. #endif
  82. static const uint8_t STD_ENC_PARAM_TABLE[] = {
  83. UINT8_C( 9 ), UINT8_C( 216 ), UINT8_C( 151 ), UINT8_C( 107 ), UINT8_C( 43 ), UINT8_C( 85 ),
  84. UINT8_C( 215 ), UINT8_C( 41 ), UINT8_C( 96 ), UINT8_C( 133 ), UINT8_C( 255 ), UINT8_C( 3 ),
  85. UINT8_C( 165 ), UINT8_C( 112 ), UINT8_C( 88 ), UINT8_C( 74 ), UINT8_C( 142 ), UINT8_C( 15 ),
  86. UINT8_C( 121 ), UINT8_C( 122 ), UINT8_C( 235 ), UINT8_C( 29 ), UINT8_C( 129 ), UINT8_C( 196 ),
  87. UINT8_C( 120 ), UINT8_C( 214 ), UINT8_C( 149 ), UINT8_C( 160 ), UINT8_C( 50 ), UINT8_C( 59 ),
  88. UINT8_C( 152 ), UINT8_C( 232 ), UINT8_C( 139 ), UINT8_C( 194 ), UINT8_C( 7 ), UINT8_C( 154 ),
  89. UINT8_C( 25 ), UINT8_C( 207 ), UINT8_C( 135 ), UINT8_C( 234 ), UINT8_C( 87 ), UINT8_C( 190 ),
  90. UINT8_C( 36 ), UINT8_C( 197 ), UINT8_C( 193 ), UINT8_C( 61 ), UINT8_C( 12 ), UINT8_C( 150 ),
  91. UINT8_C( 225 ), UINT8_C( 212 ), UINT8_C( 168 ), UINT8_C( 117 ), UINT8_C( 84 ), UINT8_C( 81 ),
  92. UINT8_C( 103 ), UINT8_C( 98 ), UINT8_C( 146 ), UINT8_C( 203 ), UINT8_C( 69 ), UINT8_C( 130 ),
  93. UINT8_C( 44 ), UINT8_C( 145 ), UINT8_C( 11 ), UINT8_C( 52 ), UINT8_C( 143 ), UINT8_C( 137 ),
  94. UINT8_C( 54 ), UINT8_C( 51 ), UINT8_C( 224 ), UINT8_C( 254 ), UINT8_C( 162 ), UINT8_C( 246 ),
  95. UINT8_C( 205 ), UINT8_C( 248 ), UINT8_C( 10 ), UINT8_C( 102 ), UINT8_C( 91 ), UINT8_C( 60 ),
  96. UINT8_C( 134 ), UINT8_C( 169 ), UINT8_C( 175 ), UINT8_C( 89 ), UINT8_C( 70 ), UINT8_C( 46 ),
  97. UINT8_C( 153 ), UINT8_C( 42 ), UINT8_C( 105 ), UINT8_C( 167 ), UINT8_C( 1 ), UINT8_C( 176 ),
  98. UINT8_C( 239 ), UINT8_C( 28 ), UINT8_C( 19 ), UINT8_C( 113 ), UINT8_C( 99 ), UINT8_C( 227 ),
  99. UINT8_C( 226 ), UINT8_C( 181 ), UINT8_C( 173 ), UINT8_C( 126 ), UINT8_C( 249 ), UINT8_C( 76 ),
  100. UINT8_C( 202 ), UINT8_C( 185 ), UINT8_C( 18 ), UINT8_C( 48 ), UINT8_C( 106 ), UINT8_C( 49 ),
  101. UINT8_C( 157 ), UINT8_C( 148 ), UINT8_C( 53 ), UINT8_C( 20 ), UINT8_C( 209 ), UINT8_C( 180 ),
  102. UINT8_C( 30 ), UINT8_C( 158 ), UINT8_C( 223 ), UINT8_C( 195 ), UINT8_C( 233 ), UINT8_C( 159 ),
  103. UINT8_C( 22 ), UINT8_C( 198 ), UINT8_C( 208 ), UINT8_C( 100 ), UINT8_C( 33 ), UINT8_C( 183 ),
  104. UINT8_C( 125 ), UINT8_C( 115 ), UINT8_C( 131 ), UINT8_C( 132 ), UINT8_C( 178 ), UINT8_C( 191 ),
  105. UINT8_C( 250 ), UINT8_C( 177 ), UINT8_C( 79 ), UINT8_C( 171 ), UINT8_C( 72 ), UINT8_C( 57 ),
  106. UINT8_C( 242 ), UINT8_C( 247 ), UINT8_C( 155 ), UINT8_C( 13 ), UINT8_C( 186 ), UINT8_C( 170 ),
  107. UINT8_C( 14 ), UINT8_C( 65 ), UINT8_C( 109 ), UINT8_C( 66 ), UINT8_C( 219 ), UINT8_C( 73 ),
  108. UINT8_C( 75 ), UINT8_C( 199 ), UINT8_C( 237 ), UINT8_C( 9 ), UINT8_C( 8 ), UINT8_C( 27 ),
  109. UINT8_C( 101 ), UINT8_C( 47 ), UINT8_C( 241 ), UINT8_C( 92 ), UINT8_C( 128 ), UINT8_C( 144 ),
  110. UINT8_C( 83 ), UINT8_C( 93 ), UINT8_C( 222 ), UINT8_C( 243 ), UINT8_C( 231 ), UINT8_C( 140 ),
  111. UINT8_C( 97 ), UINT8_C( 166 ), UINT8_C( 221 ), UINT8_C( 45 ), UINT8_C( 38 ), UINT8_C( 204 ),
  112. UINT8_C( 40 ), UINT8_C( 123 ), UINT8_C( 39 ), UINT8_C( 37 ), UINT8_C( 141 ), UINT8_C( 24 ),
  113. UINT8_C( 251 ), UINT8_C( 210 ), UINT8_C( 217 ), UINT8_C( 172 ), UINT8_C( 108 ), UINT8_C( 21 ),
  114. UINT8_C( 244 ), UINT8_C( 63 ), UINT8_C( 62 ), UINT8_C( 230 ), UINT8_C( 187 ), UINT8_C( 245 ),
  115. UINT8_C( 184 ), UINT8_C( 192 ), UINT8_C( 116 ), UINT8_C( 127 ), UINT8_C( 206 ), UINT8_C( 200 ),
  116. UINT8_C( 80 ), UINT8_C( 238 ), UINT8_C( 163 ), UINT8_C( 118 ), UINT8_C( 211 ), UINT8_C( 147 ),
  117. UINT8_C( 26 ), UINT8_C( 114 ), UINT8_C( 23 ), UINT8_C( 94 ), UINT8_C( 82 ), UINT8_C( 77 ),
  118. UINT8_C( 64 ), UINT8_C( 189 ), UINT8_C( 119 ), UINT8_C( 236 ), UINT8_C( 4 ), UINT8_C( 218 ),
  119. UINT8_C( 188 ), UINT8_C( 161 ), UINT8_C( 228 ), UINT8_C( 34 ), UINT8_C( 16 ), UINT8_C( 17 ),
  120. UINT8_C( 138 ), UINT8_C( 124 ), UINT8_C( 156 ), UINT8_C( 252 ), UINT8_C( 71 ), UINT8_C( 6 ),
  121. UINT8_C( 229 ), UINT8_C( 95 ), UINT8_C( 2 ), UINT8_C( 111 ), UINT8_C( 90 ), UINT8_C( 31 ),
  122. UINT8_C( 78 ), UINT8_C( 32 ), UINT8_C( 104 ), UINT8_C( 220 ), UINT8_C( 174 ), UINT8_C( 35 ),
  123. UINT8_C( 110 ), UINT8_C( 164 ), UINT8_C( 58 ), UINT8_C( 56 ), UINT8_C( 182 ), UINT8_C( 86 ),
  124. UINT8_C( 68 ), UINT8_C( 55 ), UINT8_C( 201 ), UINT8_C( 136 ), UINT8_C( 253 ), UINT8_C( 240 ),
  125. UINT8_C( 179 ), UINT8_C( 67 ), UINT8_C( 5 ), UINT8_C( 213 )
  126. };
  127. static const uint32_t STD_ENC_PARAM_CNT[] = {
  128. UINT32_C( 338688665 ), UINT32_C( 3337861206 ), UINT32_C( 3468740409 ), UINT32_C( 3335515952 ),
  129. UINT32_C( 3947386749 ), UINT32_C( 3474824703 ), UINT32_C( 367420878 ), UINT32_C( 853996506 )
  130. };
  131. #endif
  132. #if ( XRUNCONFGEN == 0 )
  133. #include "default_permutation_settings.h"
  134. #include "default_encoding_settings.h"
  135. #endif
  136. #define XRN_LIB_VERSION ((( XRN_ALGORITHM_VERSION & 0x0000ffff ) << 16 ) | ( XRN_IO_VERSION & 0x0000ffff))
  137. #if XRN_GNU_LINUX == 0
  138. #if !defined( _WIN32 )
  139. #define _WIN32
  140. #endif
  141. #endif
  142. // include headers
  143. #if XRN_GNU_LINUX == 0
  144. #include <windows.h>
  145. #include <process.h>
  146. #include <bcrypt.h>
  147. #endif
  148. // define architecture
  149. #if !defined( XRN_ARC )
  150. #define XRN_ARC
  151. #if (( XNBITS == 256 ) || ( XNBITS == 128 ))
  152. #define XARC64BIT 1
  153. #define XARC32BIT 0
  154. #define XARC16BIT 0
  155. #define XARC08BIT 0
  156. #elif ( XNBITS == 64 )
  157. #define XARC64BIT 0
  158. #define XARC32BIT 1
  159. #define XARC16BIT 0
  160. #define XARC08BIT 0
  161. #elif ( XNBITS == 32 )
  162. #define XARC64BIT 0
  163. #define XARC32BIT 0
  164. #define XARC16BIT 1
  165. #define XARC08BIT 0
  166. #elif ( XNBITS == 16 )
  167. #define XARC64BIT 0
  168. #define XARC32BIT 0
  169. #define XARC16BIT 0
  170. #define XARC08BIT 1
  171. #endif
  172. #endif
  173. #define XNBYTES_ORIGIN (( XNBITS*XNBITS - ((XNBITS-1)*(XNBITS))/2) / 8 ) - 1
  174. #endif