crypto.h 29 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030
  1. /**
  2. * @file crypto.h
  3. * @brief General definitions for cryptographic algorithms
  4. *
  5. * @section License
  6. *
  7. * SPDX-License-Identifier: GPL-2.0-or-later
  8. *
  9. * Copyright (C) 2010-2023 Oryx Embedded SARL. All rights reserved.
  10. *
  11. * This file is part of CycloneCRYPTO Open.
  12. *
  13. * This program is free software; you can redistribute it and/or
  14. * modify it under the terms of the GNU General Public License
  15. * as published by the Free Software Foundation; either version 2
  16. * of the License, or (at your option) any later version.
  17. *
  18. * This program is distributed in the hope that it will be useful,
  19. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  21. * GNU General Public License for more details.
  22. *
  23. * You should have received a copy of the GNU General Public License
  24. * along with this program; if not, write to the Free Software Foundation,
  25. * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  26. *
  27. * @author Oryx Embedded SARL (www.oryx-embedded.com)
  28. * @version 2.2.4
  29. **/
  30. #ifndef _CRYPTO_H
  31. #define _CRYPTO_H
  32. //Dependencies
  33. #include "os_port.h"
  34. #include "crypto_config.h"
  35. #include "crypto_legacy.h"
  36. #include "cpu_endian.h"
  37. #include "error.h"
  38. /*
  39. * CycloneCRYPTO Open is licensed under GPL version 2. In particular:
  40. *
  41. * - If you link your program to CycloneCRYPTO Open, the result is a derivative
  42. * work that can only be distributed under the same GPL license terms.
  43. *
  44. * - If additions or changes to CycloneCRYPTO Open are made, the result is a
  45. * derivative work that can only be distributed under the same license terms.
  46. *
  47. * - The GPL license requires that you make the source code available to
  48. * whoever you make the binary available to.
  49. *
  50. * - If you sell or distribute a hardware product that runs CycloneCRYPTO Open,
  51. * the GPL license requires you to provide public and full access to all
  52. * source code on a nondiscriminatory basis.
  53. *
  54. * If you fully understand and accept the terms of the GPL license, then edit
  55. * the os_port_config.h header and add the following directive:
  56. *
  57. * #define GPL_LICENSE_TERMS_ACCEPTED
  58. */
  59. //Version string
  60. #define CYCLONE_CRYPTO_VERSION_STRING "2.2.4"
  61. //Major version
  62. #define CYCLONE_CRYPTO_MAJOR_VERSION 2
  63. //Minor version
  64. #define CYCLONE_CRYPTO_MINOR_VERSION 2
  65. //Revision number
  66. #define CYCLONE_CRYPTO_REV_NUMBER 4
  67. //Multiple precision integer support
  68. #ifndef MPI_SUPPORT
  69. #define MPI_SUPPORT ENABLED
  70. #elif (MPI_SUPPORT != ENABLED && MPI_SUPPORT != DISABLED)
  71. #error MPI_SUPPORT parameter is not valid
  72. #endif
  73. //Assembly optimizations for time-critical routines
  74. #ifndef MPI_ASM_SUPPORT
  75. #define MPI_ASM_SUPPORT DISABLED
  76. #elif (MPI_ASM_SUPPORT != ENABLED && MPI_ASM_SUPPORT != DISABLED)
  77. #error MPI_ASM_SUPPORT parameter is not valid
  78. #endif
  79. //Base64 encoding support
  80. #ifndef BASE64_SUPPORT
  81. #define BASE64_SUPPORT ENABLED
  82. #elif (BASE64_SUPPORT != ENABLED && BASE64_SUPPORT != DISABLED)
  83. #error BASE64_SUPPORT parameter is not valid
  84. #endif
  85. //Base64url encoding support
  86. #ifndef BASE64URL_SUPPORT
  87. #define BASE64URL_SUPPORT ENABLED
  88. #elif (BASE64URL_SUPPORT != ENABLED && BASE64URL_SUPPORT != DISABLED)
  89. #error BASE64URL_SUPPORT parameter is not valid
  90. #endif
  91. //Radix64 encoding support
  92. #ifndef RADIX64_SUPPORT
  93. #define RADIX64_SUPPORT ENABLED
  94. #elif (RADIX64_SUPPORT != ENABLED && RADIX64_SUPPORT != DISABLED)
  95. #error RADIX64_SUPPORT parameter is not valid
  96. #endif
  97. //MD2 hash support
  98. #ifndef MD2_SUPPORT
  99. #define MD2_SUPPORT DISABLED
  100. #elif (MD2_SUPPORT != ENABLED && MD2_SUPPORT != DISABLED)
  101. #error MD2_SUPPORT parameter is not valid
  102. #endif
  103. //MD4 hash support
  104. #ifndef MD4_SUPPORT
  105. #define MD4_SUPPORT DISABLED
  106. #elif (MD4_SUPPORT != ENABLED && MD4_SUPPORT != DISABLED)
  107. #error MD4_SUPPORT parameter is not valid
  108. #endif
  109. //MD5 hash support
  110. #ifndef MD5_SUPPORT
  111. #define MD5_SUPPORT ENABLED
  112. #elif (MD5_SUPPORT != ENABLED && MD5_SUPPORT != DISABLED)
  113. #error MD5_SUPPORT parameter is not valid
  114. #endif
  115. //RIPEMD-128 hash support
  116. #ifndef RIPEMD128_SUPPORT
  117. #define RIPEMD128_SUPPORT DISABLED
  118. #elif (RIPEMD128_SUPPORT != ENABLED && RIPEMD128_SUPPORT != DISABLED)
  119. #error RIPEMD128_SUPPORT parameter is not valid
  120. #endif
  121. //RIPEMD-160 hash support
  122. #ifndef RIPEMD160_SUPPORT
  123. #define RIPEMD160_SUPPORT DISABLED
  124. #elif (RIPEMD160_SUPPORT != ENABLED && RIPEMD160_SUPPORT != DISABLED)
  125. #error RIPEMD160_SUPPORT parameter is not valid
  126. #endif
  127. //SHA-1 hash support
  128. #ifndef SHA1_SUPPORT
  129. #define SHA1_SUPPORT ENABLED
  130. #elif (SHA1_SUPPORT != ENABLED && SHA1_SUPPORT != DISABLED)
  131. #error SHA1_SUPPORT parameter is not valid
  132. #endif
  133. //SHA-224 hash support
  134. #ifndef SHA224_SUPPORT
  135. #define SHA224_SUPPORT ENABLED
  136. #elif (SHA224_SUPPORT != ENABLED && SHA224_SUPPORT != DISABLED)
  137. #error SHA224_SUPPORT parameter is not valid
  138. #endif
  139. //SHA-256 hash support
  140. #ifndef SHA256_SUPPORT
  141. #define SHA256_SUPPORT ENABLED
  142. #elif (SHA256_SUPPORT != ENABLED && SHA256_SUPPORT != DISABLED)
  143. #error SHA256_SUPPORT parameter is not valid
  144. #endif
  145. //SHA-384 hash support
  146. #ifndef SHA384_SUPPORT
  147. #define SHA384_SUPPORT ENABLED
  148. #elif (SHA384_SUPPORT != ENABLED && SHA384_SUPPORT != DISABLED)
  149. #error SHA384_SUPPORT parameter is not valid
  150. #endif
  151. //SHA-512 hash support
  152. #ifndef SHA512_SUPPORT
  153. #define SHA512_SUPPORT ENABLED
  154. #elif (SHA512_SUPPORT != ENABLED && SHA512_SUPPORT != DISABLED)
  155. #error SHA512_SUPPORT parameter is not valid
  156. #endif
  157. //SHA-512/224 hash support
  158. #ifndef SHA512_224_SUPPORT
  159. #define SHA512_224_SUPPORT DISABLED
  160. #elif (SHA512_224_SUPPORT != ENABLED && SHA512_224_SUPPORT != DISABLED)
  161. #error SHA512_224_SUPPORT parameter is not valid
  162. #endif
  163. //SHA-512/256 hash support
  164. #ifndef SHA512_256_SUPPORT
  165. #define SHA512_256_SUPPORT DISABLED
  166. #elif (SHA512_256_SUPPORT != ENABLED && SHA512_256_SUPPORT != DISABLED)
  167. #error SHA512_256_SUPPORT parameter is not valid
  168. #endif
  169. //SHA3-224 hash support
  170. #ifndef SHA3_224_SUPPORT
  171. #define SHA3_224_SUPPORT DISABLED
  172. #elif (SHA3_224_SUPPORT != ENABLED && SHA3_224_SUPPORT != DISABLED)
  173. #error SHA3_224_SUPPORT parameter is not valid
  174. #endif
  175. //SHA3-256 hash support
  176. #ifndef SHA3_256_SUPPORT
  177. #define SHA3_256_SUPPORT DISABLED
  178. #elif (SHA3_256_SUPPORT != ENABLED && SHA3_256_SUPPORT != DISABLED)
  179. #error SHA3_256_SUPPORT parameter is not valid
  180. #endif
  181. //SHA3-384 hash support
  182. #ifndef SHA3_384_SUPPORT
  183. #define SHA3_384_SUPPORT DISABLED
  184. #elif (SHA3_384_SUPPORT != ENABLED && SHA3_384_SUPPORT != DISABLED)
  185. #error SHA3_384_SUPPORT parameter is not valid
  186. #endif
  187. //SHA3-512 hash support
  188. #ifndef SHA3_512_SUPPORT
  189. #define SHA3_512_SUPPORT DISABLED
  190. #elif (SHA3_512_SUPPORT != ENABLED && SHA3_512_SUPPORT != DISABLED)
  191. #error SHA3_512_SUPPORT parameter is not valid
  192. #endif
  193. //SHAKE support
  194. #ifndef SHAKE_SUPPORT
  195. #define SHAKE_SUPPORT DISABLED
  196. #elif (SHAKE_SUPPORT != ENABLED && SHAKE_SUPPORT != DISABLED)
  197. #error SHAKE_SUPPORT parameter is not valid
  198. #endif
  199. //cSHAKE support
  200. #ifndef CSHAKE_SUPPORT
  201. #define CSHAKE_SUPPORT DISABLED
  202. #elif (CSHAKE_SUPPORT != ENABLED && CSHAKE_SUPPORT != DISABLED)
  203. #error CSHAKE_SUPPORT parameter is not valid
  204. #endif
  205. //Keccak support
  206. #ifndef KECCAK_SUPPORT
  207. #define KECCAK_SUPPORT DISABLED
  208. #elif (KECCAK_SUPPORT != ENABLED && KECCAK_SUPPORT != DISABLED)
  209. #error KECCAK_SUPPORT parameter is not valid
  210. #endif
  211. //BLAKE2b support
  212. #ifndef BLAKE2B_SUPPORT
  213. #define BLAKE2B_SUPPORT DISABLED
  214. #elif (BLAKE2B_SUPPORT != ENABLED && BLAKE2B_SUPPORT != DISABLED)
  215. #error BLAKE2B_SUPPORT parameter is not valid
  216. #endif
  217. //BLAKE2b-160 hash support
  218. #ifndef BLAKE2B160_SUPPORT
  219. #define BLAKE2B160_SUPPORT DISABLED
  220. #elif (BLAKE2B160_SUPPORT != ENABLED && BLAKE2B160_SUPPORT != DISABLED)
  221. #error BLAKE2B160_SUPPORT parameter is not valid
  222. #endif
  223. //BLAKE2b-256 hash support
  224. #ifndef BLAKE2B256_SUPPORT
  225. #define BLAKE2B256_SUPPORT DISABLED
  226. #elif (BLAKE2B256_SUPPORT != ENABLED && BLAKE2B256_SUPPORT != DISABLED)
  227. #error BLAKE2B256_SUPPORT parameter is not valid
  228. #endif
  229. //BLAKE2b-384 hash support
  230. #ifndef BLAKE2B384_SUPPORT
  231. #define BLAKE2B384_SUPPORT DISABLED
  232. #elif (BLAKE2B384_SUPPORT != ENABLED && BLAKE2B384_SUPPORT != DISABLED)
  233. #error BLAKE2B384_SUPPORT parameter is not valid
  234. #endif
  235. //BLAKE2b-512 hash support
  236. #ifndef BLAKE2B512_SUPPORT
  237. #define BLAKE2B512_SUPPORT DISABLED
  238. #elif (BLAKE2B512_SUPPORT != ENABLED && BLAKE2B512_SUPPORT != DISABLED)
  239. #error BLAKE2B512_SUPPORT parameter is not valid
  240. #endif
  241. //BLAKE2s support
  242. #ifndef BLAKE2S_SUPPORT
  243. #define BLAKE2S_SUPPORT DISABLED
  244. #elif (BLAKE2S_SUPPORT != ENABLED && BLAKE2S_SUPPORT != DISABLED)
  245. #error BLAKE2S_SUPPORT parameter is not valid
  246. #endif
  247. //BLAKE2s-128 hash support
  248. #ifndef BLAKE2S128_SUPPORT
  249. #define BLAKE2S128_SUPPORT DISABLED
  250. #elif (BLAKE2S128_SUPPORT != ENABLED && BLAKE2S128_SUPPORT != DISABLED)
  251. #error BLAKE2S128_SUPPORT parameter is not valid
  252. #endif
  253. //BLAKE2s-160 hash support
  254. #ifndef BLAKE2S160_SUPPORT
  255. #define BLAKE2S160_SUPPORT DISABLED
  256. #elif (BLAKE2S160_SUPPORT != ENABLED && BLAKE2S160_SUPPORT != DISABLED)
  257. #error BLAKE2S160_SUPPORT parameter is not valid
  258. #endif
  259. //BLAKE2s-224 hash support
  260. #ifndef BLAKE2S224_SUPPORT
  261. #define BLAKE2S224_SUPPORT DISABLED
  262. #elif (BLAKE2S224_SUPPORT != ENABLED && BLAKE2S224_SUPPORT != DISABLED)
  263. #error BLAKE2S224_SUPPORT parameter is not valid
  264. #endif
  265. //BLAKE2s-256 hash support
  266. #ifndef BLAKE2S256_SUPPORT
  267. #define BLAKE2S256_SUPPORT DISABLED
  268. #elif (BLAKE2S256_SUPPORT != ENABLED && BLAKE2S256_SUPPORT != DISABLED)
  269. #error BLAKE2S256_SUPPORT parameter is not valid
  270. #endif
  271. //Tiger hash support
  272. #ifndef TIGER_SUPPORT
  273. #define TIGER_SUPPORT DISABLED
  274. #elif (TIGER_SUPPORT != ENABLED && TIGER_SUPPORT != DISABLED)
  275. #error TIGER_SUPPORT parameter is not valid
  276. #endif
  277. //Whirlpool hash support
  278. #ifndef WHIRLPOOL_SUPPORT
  279. #define WHIRLPOOL_SUPPORT DISABLED
  280. #elif (WHIRLPOOL_SUPPORT != ENABLED && WHIRLPOOL_SUPPORT != DISABLED)
  281. #error WHIRLPOOL_SUPPORT parameter is not valid
  282. #endif
  283. //CMAC support
  284. #ifndef CMAC_SUPPORT
  285. #define CMAC_SUPPORT DISABLED
  286. #elif (CMAC_SUPPORT != ENABLED && CMAC_SUPPORT != DISABLED)
  287. #error CMAC_SUPPORT parameter is not valid
  288. #endif
  289. //GMAC support
  290. #ifndef GMAC_SUPPORT
  291. #define GMAC_SUPPORT DISABLED
  292. #elif (GMAC_SUPPORT != ENABLED && GMAC_SUPPORT != DISABLED)
  293. #error GMAC_SUPPORT parameter is not valid
  294. #endif
  295. //HMAC support
  296. #ifndef HMAC_SUPPORT
  297. #define HMAC_SUPPORT ENABLED
  298. #elif (HMAC_SUPPORT != ENABLED && HMAC_SUPPORT != DISABLED)
  299. #error HMAC_SUPPORT parameter is not valid
  300. #endif
  301. //KMAC support
  302. #ifndef KMAC_SUPPORT
  303. #define KMAC_SUPPORT DISABLED
  304. #elif (KMAC_SUPPORT != ENABLED && KMAC_SUPPORT != DISABLED)
  305. #error KMAC_SUPPORT parameter is not valid
  306. #endif
  307. //RC2 encryption support
  308. #ifndef RC2_SUPPORT
  309. #define RC2_SUPPORT DISABLED
  310. #elif (RC2_SUPPORT != ENABLED && RC2_SUPPORT != DISABLED)
  311. #error RC2_SUPPORT parameter is not valid
  312. #endif
  313. //RC4 encryption support
  314. #ifndef RC4_SUPPORT
  315. #define RC4_SUPPORT DISABLED
  316. #elif (RC4_SUPPORT != ENABLED && RC4_SUPPORT != DISABLED)
  317. #error RC4_SUPPORT parameter is not valid
  318. #endif
  319. //RC6 encryption support
  320. #ifndef RC6_SUPPORT
  321. #define RC6_SUPPORT DISABLED
  322. #elif (RC6_SUPPORT != ENABLED && RC6_SUPPORT != DISABLED)
  323. #error RC6_SUPPORT parameter is not valid
  324. #endif
  325. //CAST-128 encryption support
  326. #ifndef CAST128_SUPPORT
  327. #define CAST128_SUPPORT DISABLED
  328. #elif (CAST128_SUPPORT != ENABLED && CAST128_SUPPORT != DISABLED)
  329. #error CAST128_SUPPORT parameter is not valid
  330. #endif
  331. //CAST-256 encryption support
  332. #ifndef CAST256_SUPPORT
  333. #define CAST256_SUPPORT DISABLED
  334. #elif (CAST256_SUPPORT != ENABLED && CAST256_SUPPORT != DISABLED)
  335. #error CAST256_SUPPORT parameter is not valid
  336. #endif
  337. //IDEA encryption support
  338. #ifndef IDEA_SUPPORT
  339. #define IDEA_SUPPORT DISABLED
  340. #elif (IDEA_SUPPORT != ENABLED && IDEA_SUPPORT != DISABLED)
  341. #error IDEA_SUPPORT parameter is not valid
  342. #endif
  343. //DES encryption support
  344. #ifndef DES_SUPPORT
  345. #define DES_SUPPORT ENABLED
  346. #elif (DES_SUPPORT != ENABLED && DES_SUPPORT != DISABLED)
  347. #error DES_SUPPORT parameter is not valid
  348. #endif
  349. //Triple DES encryption support
  350. #ifndef DES3_SUPPORT
  351. #define DES3_SUPPORT ENABLED
  352. #elif (DES3_SUPPORT != ENABLED && DES3_SUPPORT != DISABLED)
  353. #error DES3_SUPPORT parameter is not valid
  354. #endif
  355. //AES encryption support
  356. #ifndef AES_SUPPORT
  357. #define AES_SUPPORT ENABLED
  358. #elif (AES_SUPPORT != ENABLED && AES_SUPPORT != DISABLED)
  359. #error AES_SUPPORT parameter is not valid
  360. #endif
  361. //Blowfish encryption support
  362. #ifndef BLOWFISH_SUPPORT
  363. #define BLOWFISH_SUPPORT DISABLED
  364. #elif (BLOWFISH_SUPPORT != ENABLED && BLOWFISH_SUPPORT != DISABLED)
  365. #error BLOWFISH_SUPPORT parameter is not valid
  366. #endif
  367. //Twofish encryption support
  368. #ifndef TWOFISH_SUPPORT
  369. #define TWOFISH_SUPPORT DISABLED
  370. #elif (TWOFISH_SUPPORT != ENABLED && TWOFISH_SUPPORT != DISABLED)
  371. #error TWOFISH_SUPPORT parameter is not valid
  372. #endif
  373. //MARS encryption support
  374. #ifndef MARS_SUPPORT
  375. #define MARS_SUPPORT DISABLED
  376. #elif (MARS_SUPPORT != ENABLED && MARS_SUPPORT != DISABLED)
  377. #error MARS_SUPPORT parameter is not valid
  378. #endif
  379. //Serpent encryption support
  380. #ifndef SERPENT_SUPPORT
  381. #define SERPENT_SUPPORT DISABLED
  382. #elif (SERPENT_SUPPORT != ENABLED && SERPENT_SUPPORT != DISABLED)
  383. #error SERPENT_SUPPORT parameter is not valid
  384. #endif
  385. //Camellia encryption support
  386. #ifndef CAMELLIA_SUPPORT
  387. #define CAMELLIA_SUPPORT DISABLED
  388. #elif (CAMELLIA_SUPPORT != ENABLED && CAMELLIA_SUPPORT != DISABLED)
  389. #error CAMELLIA_SUPPORT parameter is not valid
  390. #endif
  391. //ARIA encryption support
  392. #ifndef ARIA_SUPPORT
  393. #define ARIA_SUPPORT DISABLED
  394. #elif (ARIA_SUPPORT != ENABLED && ARIA_SUPPORT != DISABLED)
  395. #error ARIA_SUPPORT parameter is not valid
  396. #endif
  397. //SEED encryption support
  398. #ifndef SEED_SUPPORT
  399. #define SEED_SUPPORT DISABLED
  400. #elif (SEED_SUPPORT != ENABLED && SEED_SUPPORT != DISABLED)
  401. #error SEED_SUPPORT parameter is not valid
  402. #endif
  403. //PRESENT encryption support
  404. #ifndef PRESENT_SUPPORT
  405. #define PRESENT_SUPPORT DISABLED
  406. #elif (PRESENT_SUPPORT != ENABLED && PRESENT_SUPPORT != DISABLED)
  407. #error PRESENT_SUPPORT parameter is not valid
  408. #endif
  409. //TEA encryption support
  410. #ifndef TEA_SUPPORT
  411. #define TEA_SUPPORT DISABLED
  412. #elif (TEA_SUPPORT != ENABLED && TEA_SUPPORT != DISABLED)
  413. #error TEA_SUPPORT parameter is not valid
  414. #endif
  415. //XTEA encryption support
  416. #ifndef XTEA_SUPPORT
  417. #define XTEA_SUPPORT DISABLED
  418. #elif (XTEA_SUPPORT != ENABLED && XTEA_SUPPORT != DISABLED)
  419. #error XTEA_SUPPORT parameter is not valid
  420. #endif
  421. //Trivium encryption support
  422. #ifndef TRIVIUM_SUPPORT
  423. #define TRIVIUM_SUPPORT DISABLED
  424. #elif (TRIVIUM_SUPPORT != ENABLED && TRIVIUM_SUPPORT != DISABLED)
  425. #error TRIVIUM_SUPPORT parameter is not valid
  426. #endif
  427. //ECB mode support
  428. #ifndef ECB_SUPPORT
  429. #define ECB_SUPPORT ENABLED
  430. #elif (ECB_SUPPORT != ENABLED && ECB_SUPPORT != DISABLED)
  431. #error ECB_SUPPORT parameter is not valid
  432. #endif
  433. //CBC mode support
  434. #ifndef CBC_SUPPORT
  435. #define CBC_SUPPORT ENABLED
  436. #elif (CBC_SUPPORT != ENABLED && CBC_SUPPORT != DISABLED)
  437. #error CBC_SUPPORT parameter is not valid
  438. #endif
  439. //CFB mode support
  440. #ifndef CFB_SUPPORT
  441. #define CFB_SUPPORT ENABLED
  442. #elif (CFB_SUPPORT != ENABLED && CFB_SUPPORT != DISABLED)
  443. #error CFB_SUPPORT parameter is not valid
  444. #endif
  445. //OFB mode support
  446. #ifndef OFB_SUPPORT
  447. #define OFB_SUPPORT ENABLED
  448. #elif (OFB_SUPPORT != ENABLED && OFB_SUPPORT != DISABLED)
  449. #error OFB_SUPPORT parameter is not valid
  450. #endif
  451. //CTR mode support
  452. #ifndef CTR_SUPPORT
  453. #define CTR_SUPPORT ENABLED
  454. #elif (CTR_SUPPORT != ENABLED && CTR_SUPPORT != DISABLED)
  455. #error CTR_SUPPORT parameter is not valid
  456. #endif
  457. //XTS mode support
  458. #ifndef XTS_SUPPORT
  459. #define XTS_SUPPORT ENABLED
  460. #elif (XTS_SUPPORT != ENABLED && XTS_SUPPORT != DISABLED)
  461. #error XTS_SUPPORT parameter is not valid
  462. #endif
  463. //CCM mode support
  464. #ifndef CCM_SUPPORT
  465. #define CCM_SUPPORT ENABLED
  466. #elif (CCM_SUPPORT != ENABLED && CCM_SUPPORT != DISABLED)
  467. #error CCM_SUPPORT parameter is not valid
  468. #endif
  469. //GCM mode support
  470. #ifndef GCM_SUPPORT
  471. #define GCM_SUPPORT ENABLED
  472. #elif (GCM_SUPPORT != ENABLED && GCM_SUPPORT != DISABLED)
  473. #error GCM_SUPPORT parameter is not valid
  474. #endif
  475. //Salsa20 support
  476. #ifndef SALSA20_SUPPORT
  477. #define SALSA20_SUPPORT DISABLED
  478. #elif (SALSA20_SUPPORT != ENABLED && SALSA20_SUPPORT != DISABLED)
  479. #error SALSA20_SUPPORT parameter is not valid
  480. #endif
  481. //ChaCha support
  482. #ifndef CHACHA_SUPPORT
  483. #define CHACHA_SUPPORT DISABLED
  484. #elif (CHACHA_SUPPORT != ENABLED && CHACHA_SUPPORT != DISABLED)
  485. #error CHACHA_SUPPORT parameter is not valid
  486. #endif
  487. //Poly1305 support
  488. #ifndef POLY1305_SUPPORT
  489. #define POLY1305_SUPPORT DISABLED
  490. #elif (POLY1305_SUPPORT != ENABLED && POLY1305_SUPPORT != DISABLED)
  491. #error POLY1305_SUPPORT parameter is not valid
  492. #endif
  493. //ChaCha20Poly1305 support
  494. #ifndef CHACHA20_POLY1305_SUPPORT
  495. #define CHACHA20_POLY1305_SUPPORT DISABLED
  496. #elif (CHACHA20_POLY1305_SUPPORT != ENABLED && CHACHA20_POLY1305_SUPPORT != DISABLED)
  497. #error CHACHA20_POLY1305_SUPPORT parameter is not valid
  498. #endif
  499. //Diffie-Hellman support
  500. #ifndef DH_SUPPORT
  501. #define DH_SUPPORT ENABLED
  502. #elif (DH_SUPPORT != ENABLED && DH_SUPPORT != DISABLED)
  503. #error DH_SUPPORT parameter is not valid
  504. #endif
  505. //RSA support
  506. #ifndef RSA_SUPPORT
  507. #define RSA_SUPPORT ENABLED
  508. #elif (RSA_SUPPORT != ENABLED && RSA_SUPPORT != DISABLED)
  509. #error RSA_SUPPORT parameter is not valid
  510. #endif
  511. //DSA support
  512. #ifndef DSA_SUPPORT
  513. #define DSA_SUPPORT ENABLED
  514. #elif (DSA_SUPPORT != ENABLED && DSA_SUPPORT != DISABLED)
  515. #error DSA_SUPPORT parameter is not valid
  516. #endif
  517. //Elliptic curve cryptography support
  518. #ifndef EC_SUPPORT
  519. #define EC_SUPPORT ENABLED
  520. #elif (EC_SUPPORT != ENABLED && EC_SUPPORT != DISABLED)
  521. #error EC_SUPPORT parameter is not valid
  522. #endif
  523. //ECDH support
  524. #ifndef ECDH_SUPPORT
  525. #define ECDH_SUPPORT ENABLED
  526. #elif (ECDH_SUPPORT != ENABLED && ECDH_SUPPORT != DISABLED)
  527. #error ECDH_SUPPORT parameter is not valid
  528. #endif
  529. //ECDSA support
  530. #ifndef ECDSA_SUPPORT
  531. #define ECDSA_SUPPORT ENABLED
  532. #elif (ECDSA_SUPPORT != ENABLED && ECDSA_SUPPORT != DISABLED)
  533. #error ECDSA_SUPPORT parameter is not valid
  534. #endif
  535. //Streamlined NTRU Prime support
  536. #ifndef SNTRUP761_SUPPORT
  537. #define SNTRUP761_SUPPORT DISABLED
  538. #elif (SNTRUP761_SUPPORT != ENABLED && SNTRUP761_SUPPORT != DISABLED)
  539. #error SNTRUP761_SUPPORT parameter is not valid
  540. #endif
  541. //HKDF support
  542. #ifndef HKDF_SUPPORT
  543. #define HKDF_SUPPORT DISABLED
  544. #elif (HKDF_SUPPORT != ENABLED && HKDF_SUPPORT != DISABLED)
  545. #error HKDF_SUPPORT parameter is not valid
  546. #endif
  547. //PBKDF support
  548. #ifndef PBKDF_SUPPORT
  549. #define PBKDF_SUPPORT ENABLED
  550. #elif (PBKDF_SUPPORT != ENABLED && PBKDF_SUPPORT != DISABLED)
  551. #error PBKDF_SUPPORT parameter is not valid
  552. #endif
  553. //Concat KDF support
  554. #ifndef CONCAT_KDF_SUPPORT
  555. #define CONCAT_KDF_SUPPORT DISABLED
  556. #elif (CONCAT_KDF_SUPPORT != ENABLED && CONCAT_KDF_SUPPORT != DISABLED)
  557. #error CONCAT_KDF_SUPPORT parameter is not valid
  558. #endif
  559. //bcrypt support
  560. #ifndef BCRYPT_SUPPORT
  561. #define BCRYPT_SUPPORT ENABLED
  562. #elif (BCRYPT_SUPPORT != ENABLED && BCRYPT_SUPPORT != DISABLED)
  563. #error BCRYPT_SUPPORT parameter is not valid
  564. #endif
  565. //scrypt support
  566. #ifndef SCRYPT_SUPPORT
  567. #define SCRYPT_SUPPORT ENABLED
  568. #elif (SCRYPT_SUPPORT != ENABLED && SCRYPT_SUPPORT != DISABLED)
  569. #error SCRYPT_SUPPORT parameter is not valid
  570. #endif
  571. //Yarrow PRNG support
  572. #ifndef YARROW_SUPPORT
  573. #define YARROW_SUPPORT ENABLED
  574. #elif (YARROW_SUPPORT != ENABLED && YARROW_SUPPORT != DISABLED)
  575. #error YARROW_SUPPORT parameter is not valid
  576. #endif
  577. //Object identifier support
  578. #ifndef OID_SUPPORT
  579. #define OID_SUPPORT ENABLED
  580. #elif (OID_SUPPORT != ENABLED && OID_SUPPORT != DISABLED)
  581. #error OID_SUPPORT parameter is not valid
  582. #endif
  583. //ASN.1 syntax support
  584. #ifndef ASN1_SUPPORT
  585. #define ASN1_SUPPORT ENABLED
  586. #elif (ASN1_SUPPORT != ENABLED && ASN1_SUPPORT != DISABLED)
  587. #error ASN1_SUPPORT parameter is not valid
  588. #endif
  589. //PEM file support
  590. #ifndef PEM_SUPPORT
  591. #define PEM_SUPPORT ENABLED
  592. #elif (PEM_SUPPORT != ENABLED && PEM_SUPPORT != DISABLED)
  593. #error PEM_SUPPORT parameter is not valid
  594. #endif
  595. //X.509 certificate support
  596. #ifndef X509_SUPPORT
  597. #define X509_SUPPORT ENABLED
  598. #elif (X509_SUPPORT != ENABLED && X509_SUPPORT != DISABLED)
  599. #error X509_SUPPORT parameter is not valid
  600. #endif
  601. //PKCS #5 support
  602. #ifndef PKCS5_SUPPORT
  603. #define PKCS5_SUPPORT DISABLED
  604. #elif (PKCS5_SUPPORT != ENABLED && PKCS5_SUPPORT != DISABLED)
  605. #error PKCS5_SUPPORT parameter is not valid
  606. #endif
  607. //Allocate memory block
  608. #ifndef cryptoAllocMem
  609. #define cryptoAllocMem(size) osAllocMem(size)
  610. #endif
  611. //Deallocate memory block
  612. #ifndef cryptoFreeMem
  613. #define cryptoFreeMem(p) osFreeMem(p)
  614. #endif
  615. //Rotate left operation
  616. #define ROL8(a, n) (((a) << (n)) | ((a) >> (8 - (n))))
  617. #define ROL16(a, n) (((a) << (n)) | ((a) >> (16 - (n))))
  618. #define ROL32(a, n) (((a) << (n)) | ((a) >> (32 - (n))))
  619. #define ROL64(a, n) (((a) << (n)) | ((a) >> (64 - (n))))
  620. //Rotate right operation
  621. #define ROR8(a, n) (((a) >> (n)) | ((a) << (8 - (n))))
  622. #define ROR16(a, n) (((a) >> (n)) | ((a) << (16 - (n))))
  623. #define ROR32(a, n) (((a) >> (n)) | ((a) << (32 - (n))))
  624. #define ROR64(a, n) (((a) >> (n)) | ((a) << (64 - (n))))
  625. //Shift left operation
  626. #define SHL8(a, n) ((a) << (n))
  627. #define SHL16(a, n) ((a) << (n))
  628. #define SHL32(a, n) ((a) << (n))
  629. #define SHL64(a, n) ((a) << (n))
  630. //Shift right operation
  631. #define SHR8(a, n) ((a) >> (n))
  632. #define SHR16(a, n) ((a) >> (n))
  633. #define SHR32(a, n) ((a) >> (n))
  634. #define SHR64(a, n) ((a) >> (n))
  635. //Micellaneous macros
  636. #define _U8(x) ((uint8_t) (x))
  637. #define _U16(x) ((uint16_t) (x))
  638. #define _U32(x) ((uint32_t) (x))
  639. #define _U64(x) ((uint64_t) (x))
  640. //Test if a 8-bit integer is zero
  641. #define CRYPTO_TEST_Z_8(a) \
  642. _U8((_U8((_U8(a) | (~_U8(a) + 1U))) >> 7U) ^ 1U)
  643. //Test if a 8-bit integer is nonzero
  644. #define CRYPTO_TEST_NZ_8(a) \
  645. _U8(_U8((_U8(a) | (~_U8(a) + 1U))) >> 7U)
  646. //Test if two 8-bit integers are equal
  647. #define CRYPTO_TEST_EQ_8(a, b) \
  648. _U8((_U8(((_U8(a) ^ _U8(b)) | (~(_U8(a) ^ _U8(b)) + 1U))) >> 7U) ^ 1U)
  649. //Test if two 8-bit integers are not equal
  650. #define CRYPTO_TEST_NEQ_8(a, b) \
  651. _U8(_U8(((_U8(a) ^ _U8(b)) | (~(_U8(a) ^ _U8(b)) + 1U))) >> 7U)
  652. //Test if a 8-bit integer is lower than another 8-bit integer
  653. #define CRYPTO_TEST_LT_8(a, b) \
  654. _U8(_U8((((_U8(a) - _U8(b)) ^ _U8(b)) | (_U8(a) ^ _U8(b))) ^ _U8(a)) >> 7U)
  655. //Test if a 8-bit integer is lower or equal than another 8-bit integer
  656. #define CRYPTO_TEST_LTE_8(a, b) \
  657. _U8((_U8((((_U8(b) - _U8(a)) ^ _U8(a)) | (_U8(a) ^ _U8(b))) ^ _U8(b)) >> 7U) ^ 1U)
  658. //Test if a 8-bit integer is greater than another 8-bit integer
  659. #define CRYPTO_TEST_GT_8(a, b) \
  660. _U8(_U8((((_U8(b) - _U8(a)) ^ _U8(a)) | (_U8(a) ^ _U8(b))) ^ _U8(b)) >> 7U)
  661. //Test if a 8-bit integer is greater or equal than another 8-bit integer
  662. #define CRYPTO_TEST_GTE_8(a, b) \
  663. _U8((_U8((((_U8(a) - _U8(b)) ^ _U8(b)) | (_U8(a) ^ _U8(b))) ^ _U8(a)) >> 7U) ^ 1U)
  664. //Select between two 8-bit integers
  665. #define CRYPTO_SELECT_8(a, b, c) \
  666. _U8((_U8(a) & (_U8(c) - 1U)) | (_U8(b) & ~(_U8(c) - 1U)))
  667. //Test if a 16-bit integer is zero
  668. #define CRYPTO_TEST_Z_16(a) \
  669. _U16((_U16((_U16(a) | (~_U16(a) + 1U))) >> 15U) ^ 1U)
  670. //Test if a 16-bit integer is nonzero
  671. #define CRYPTO_TEST_NZ_16(a) \
  672. _U16(_U16((_U16(a) | (~_U16(a) + 1U))) >> 15U)
  673. //Test if two 16-bit integers are equal
  674. #define CRYPTO_TEST_EQ_16(a, b) \
  675. _U16((_U16(((_U16(a) ^ _U16(b)) | (~(_U16(a) ^ _U16(b)) + 1U))) >> 15U) ^ 1U)
  676. //Test if two 16-bit integers are not equal
  677. #define CRYPTO_TEST_NEQ_16(a, b) \
  678. _U16(_U16(((_U16(a) ^ _U16(b)) | (~(_U16(a) ^ _U16(b)) + 1U))) >> 15U)
  679. //Test if a 16-bit integer is lower than another 16-bit integer
  680. #define CRYPTO_TEST_LT_16(a, b) \
  681. _U16(_U16((((_U16(a) - _U16(b)) ^ _U16(b)) | (_U16(a) ^ _U16(b))) ^ _U16(a)) >> 15U)
  682. //Test if a 16-bit integer is lower or equal than another 16-bit integer
  683. #define CRYPTO_TEST_LTE_16(a, b) \
  684. _U16((_U16((((_U16(b) - _U16(a)) ^ _U16(a)) | (_U16(a) ^ _U16(b))) ^ _U16(b)) >> 15U) ^ 1U)
  685. //Test if a 16-bit integer is greater than another 16-bit integer
  686. #define CRYPTO_TEST_GT_16(a, b) \
  687. _U16(_U16((((_U16(b) - _U16(a)) ^ _U16(a)) | (_U16(a) ^ _U16(b))) ^ _U16(b)) >> 15U)
  688. //Test if a 16-bit integer is greater or equal than another 16-bit integer
  689. #define CRYPTO_TEST_GTE_16(a, b) \
  690. _U16((_U16((((_U16(a) - _U16(b)) ^ _U16(b)) | (_U16(a) ^ _U16(b))) ^ _U16(a)) >> 15U) ^ 1U)
  691. //Select between two 16-bit integers
  692. #define CRYPTO_SELECT_16(a, b, c) \
  693. _U16((_U16(a) & (_U16(c) - 1U)) | (_U16(b) & ~(_U16(c) - 1U)))
  694. //Test if a 32-bit integer is zero
  695. #define CRYPTO_TEST_Z_32(a) \
  696. _U32((_U32((_U32(a) | (~_U32(a) + 1U))) >> 31U) ^ 1U)
  697. //Test if a 32-bit integer is nonzero
  698. #define CRYPTO_TEST_NZ_32(a) \
  699. _U32(_U32((_U32(a) | (~_U32(a) + 1U))) >> 31U)
  700. //Test if two 32-bit integers are equal
  701. #define CRYPTO_TEST_EQ_32(a, b) \
  702. _U32((_U32(((_U32(a) ^ _U32(b)) | (~(_U32(a) ^ _U32(b)) + 1U))) >> 31U) ^ 1U)
  703. //Test if two 32-bit integers are not equal
  704. #define CRYPTO_TEST_NEQ_32(a, b) \
  705. _U32(_U32(((_U32(a) ^ _U32(b)) | (~(_U32(a) ^ _U32(b)) + 1U))) >> 31U)
  706. //Test if a 32-bit integer is lower than another 32-bit integer
  707. #define CRYPTO_TEST_LT_32(a, b) \
  708. _U32(_U32((((_U32(a) - _U32(b)) ^ _U32(b)) | (_U32(a) ^ _U32(b))) ^ _U32(a)) >> 31U)
  709. //Test if a 32-bit integer is lower or equal than another 32-bit integer
  710. #define CRYPTO_TEST_LTE_32(a, b) \
  711. _U32((_U32((((_U32(b) - _U32(a)) ^ _U32(a)) | (_U32(a) ^ _U32(b))) ^ _U32(b)) >> 31U) ^ 1U)
  712. //Test if a 32-bit integer is greater than another 32-bit integer
  713. #define CRYPTO_TEST_GT_32(a, b) \
  714. _U32(_U32((((_U32(b) - _U32(a)) ^ _U32(a)) | (_U32(a) ^ _U32(b))) ^ _U32(b)) >> 31U)
  715. //Test if a 32-bit integer is greater or equal than another 32-bit integer
  716. #define CRYPTO_TEST_GTE_32(a, b) \
  717. _U32((_U32((((_U32(a) - _U32(b)) ^ _U32(b)) | (_U32(a) ^ _U32(b))) ^ _U32(a)) >> 31U) ^ 1U)
  718. //Select between two 32-bit integers
  719. #define CRYPTO_SELECT_32(a, b, c) \
  720. _U32((_U32(a) & (_U32(c) - 1U)) | (_U32(b) & ~(_U32(c) - 1U)))
  721. //Select between two 64-bit integers
  722. #define CRYPTO_SELECT_64(a, b, c) \
  723. _U64((_U64(a) & (_U64(c) - 1U)) | (_U64(b) & ~(_U64(c) - 1U)))
  724. //Forward declaration of PrngAlgo structure
  725. struct _PrngAlgo;
  726. #define PrngAlgo struct _PrngAlgo
  727. //C++ guard
  728. #ifdef __cplusplus
  729. extern "C" {
  730. #endif
  731. /**
  732. * @brief Encryption algorithm type
  733. **/
  734. typedef enum
  735. {
  736. CIPHER_ALGO_TYPE_STREAM = 0,
  737. CIPHER_ALGO_TYPE_BLOCK = 1
  738. } CipherAlgoType;
  739. /**
  740. * @brief Cipher operation modes
  741. **/
  742. typedef enum
  743. {
  744. CIPHER_MODE_NULL = 0,
  745. CIPHER_MODE_STREAM = 1,
  746. CIPHER_MODE_ECB = 2,
  747. CIPHER_MODE_CBC = 3,
  748. CIPHER_MODE_CFB = 4,
  749. CIPHER_MODE_OFB = 5,
  750. CIPHER_MODE_CTR = 6,
  751. CIPHER_MODE_CCM = 7,
  752. CIPHER_MODE_GCM = 8,
  753. CIPHER_MODE_CHACHA20_POLY1305 = 9,
  754. } CipherMode;
  755. //Common API for hash algorithms
  756. typedef error_t (*HashAlgoCompute)(const void *data, size_t length,
  757. uint8_t *digest);
  758. typedef void (*HashAlgoInit)(void *context);
  759. typedef void (*HashAlgoUpdate)(void *context, const void *data, size_t length);
  760. typedef void (*HashAlgoFinal)(void *context, uint8_t *digest);
  761. typedef void (*HashAlgoFinalRaw)(void *context, uint8_t *digest);
  762. //Common API for encryption algorithms
  763. typedef error_t (*CipherAlgoInit)(void *context, const uint8_t *key,
  764. size_t keyLen);
  765. typedef void (*CipherAlgoEncryptStream)(void *context, const uint8_t *input,
  766. uint8_t *output, size_t length);
  767. typedef void (*CipherAlgoDecryptStream)(void *context, const uint8_t *input,
  768. uint8_t *output, size_t length);
  769. typedef void (*CipherAlgoEncryptBlock)(void *context, const uint8_t *input,
  770. uint8_t *output);
  771. typedef void (*CipherAlgoDecryptBlock)(void *context, const uint8_t *input,
  772. uint8_t *output);
  773. typedef void (*CipherAlgoDeinit)(void *context);
  774. //Common interface for key encapsulation mechanisms (KEM)
  775. typedef error_t (*KemAlgoGenerateKeyPair)(const PrngAlgo *prngAlgo,
  776. void *prngContext, uint8_t *pk, uint8_t *sk);
  777. typedef error_t (*KemAlgoEncapsulate)(const PrngAlgo *prngAlgo,
  778. void *prngContext, uint8_t *ct, uint8_t *ss, const uint8_t *pk);
  779. typedef error_t (*KemAlgoDecapsulate)(uint8_t *ss, const uint8_t *ct,
  780. const uint8_t *sk);
  781. //Common API for pseudo-random number generators (PRNG)
  782. typedef error_t (*PrngAlgoInit)(void *context);
  783. typedef error_t (*PrngAlgoSeed)(void *context, const uint8_t *input,
  784. size_t length);
  785. typedef error_t (*PrngAlgoAddEntropy)(void *context, uint_t source,
  786. const uint8_t *input, size_t length, size_t entropy);
  787. typedef error_t (*PrngAlgoRead)(void *context, uint8_t *output, size_t length);
  788. typedef void (*PrngAlgoDeinit)(void *context);
  789. /**
  790. * @brief Common interface for hash algorithms
  791. **/
  792. typedef struct
  793. {
  794. const char_t *name;
  795. const uint8_t *oid;
  796. size_t oidSize;
  797. size_t contextSize;
  798. size_t blockSize;
  799. size_t digestSize;
  800. size_t minPadSize;
  801. bool_t bigEndian;
  802. HashAlgoCompute compute;
  803. HashAlgoInit init;
  804. HashAlgoUpdate update;
  805. HashAlgoFinal final;
  806. HashAlgoFinalRaw finalRaw;
  807. } HashAlgo;
  808. /**
  809. * @brief Common interface for encryption algorithms
  810. **/
  811. // 定义统一接口,定义一些函数指针
  812. typedef struct
  813. {
  814. const char_t *name;
  815. size_t contextSize;
  816. CipherAlgoType type;
  817. size_t blockSize;
  818. CipherAlgoInit init;
  819. CipherAlgoEncryptStream encryptStream;
  820. CipherAlgoDecryptStream decryptStream;
  821. CipherAlgoEncryptBlock encryptBlock;
  822. CipherAlgoDecryptBlock decryptBlock;
  823. CipherAlgoDeinit deinit;
  824. } CipherAlgo;
  825. /**
  826. * @brief Common interface for key encapsulation mechanisms (KEM)
  827. **/
  828. typedef struct
  829. {
  830. const char_t *name;
  831. size_t publicKeySize;
  832. size_t secretKeySize;
  833. size_t ciphertextSize;
  834. size_t sharedSecretSize;
  835. KemAlgoGenerateKeyPair generateKeyPair;
  836. KemAlgoEncapsulate encapsulate;
  837. KemAlgoDecapsulate decapsulate;
  838. } KemAlgo;
  839. /**
  840. * @brief Common interface for pseudo-random number generators (PRNG)
  841. **/
  842. struct _PrngAlgo
  843. {
  844. const char_t *name;
  845. size_t contextSize;
  846. PrngAlgoInit init;
  847. PrngAlgoSeed seed;
  848. PrngAlgoAddEntropy addEntropy;
  849. PrngAlgoRead read;
  850. PrngAlgoDeinit deinit;
  851. };
  852. //C++ guard
  853. #ifdef __cplusplus
  854. }
  855. #endif
  856. #endif