ippcpdefs.h 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785
  1. /*
  2. // Copyright 2012-2018 Intel Corporation All Rights Reserved.
  3. //
  4. // The source code, information and material ("Material") contained herein is
  5. // owned by Intel Corporation or its suppliers or licensors, and title
  6. // to such Material remains with Intel Corporation or its suppliers or
  7. // licensors. The Material contains proprietary information of Intel
  8. // or its suppliers and licensors. The Material is protected by worldwide
  9. // copyright laws and treaty provisions. No part of the Material may be used,
  10. // copied, reproduced, modified, published, uploaded, posted, transmitted,
  11. // distributed or disclosed in any way without Intel's prior express written
  12. // permission. No license under any patent, copyright or other intellectual
  13. // property rights in the Material is granted to or conferred upon you,
  14. // either expressly, by implication, inducement, estoppel or otherwise.
  15. // Any license under such intellectual property rights must be express and
  16. // approved by Intel in writing.
  17. //
  18. // Unless otherwise agreed by Intel in writing,
  19. // you may not remove or alter this notice or any other notice embedded in
  20. // Materials by Intel or Intel's suppliers or licensors in any way.
  21. //
  22. */
  23. /*
  24. // Intel(R) Integrated Performance Primitives (Intel(R) IPP)
  25. // Cryptographic Primitives (ippCP) definitions.
  26. //
  27. //
  28. */
  29. /*
  30. // Intel(R) Integrated Performance Primitives (Intel(R) IPP)
  31. // Basic Types and Macro Definitions
  32. //
  33. //
  34. */
  35. #ifndef IPPBASE_H__
  36. #define IPPBASE_H__
  37. #ifdef __cplusplus
  38. extern "C" {
  39. #endif
  40. #if defined (_WIN64)
  41. #define INTEL_PLATFORM "intel64/"
  42. #elif defined (_WIN32)
  43. #define INTEL_PLATFORM "ia32/"
  44. #endif
  45. #if !defined( IPPAPI )
  46. #if defined( IPP_W32DLL ) && (defined( _WIN32 ) || defined( _WIN64 ))
  47. #if defined( _MSC_VER ) || defined( __ICL )
  48. #define IPPAPI( type,name,arg ) \
  49. __declspec(dllimport) type IPP_STDCALL name arg;
  50. #else
  51. #define IPPAPI( type,name,arg ) type IPP_STDCALL name arg;
  52. #endif
  53. #else
  54. #define IPPAPI( type,name,arg ) type IPP_STDCALL name arg;
  55. #endif
  56. #endif
  57. #if (defined( __ICL ) || defined( __ECL ) || defined(_MSC_VER)) && !defined( _PCS ) && !defined( _PCS_GENSTUBS )
  58. #if( __INTEL_COMPILER >= 1100 ) /* icl 11.0 supports additional comment */
  59. #if( _MSC_VER >= 1400 )
  60. #define IPP_DEPRECATED( comment ) __declspec( deprecated ( comment ))
  61. #else
  62. #pragma message ("your icl version supports additional comment for deprecated functions but it can't be displayed")
  63. #pragma message ("because internal _MSC_VER macro variable setting requires compatibility with MSVC7.1")
  64. #pragma message ("use -Qvc8 switch for icl command line to see these additional comments")
  65. #define IPP_DEPRECATED( comment ) __declspec( deprecated )
  66. #endif
  67. #elif( _MSC_FULL_VER >= 140050727 )&&( !defined( __INTEL_COMPILER )) /* VS2005 supports additional comment */
  68. #define IPP_DEPRECATED( comment ) __declspec( deprecated ( comment ))
  69. #elif( _MSC_VER <= 1200 )&&( !defined( __INTEL_COMPILER )) /* VS 6 doesn't support deprecation */
  70. #define IPP_DEPRECATED( comment )
  71. #else
  72. #define IPP_DEPRECATED( comment ) __declspec( deprecated )
  73. #endif
  74. #elif (defined(__ICC) || defined(__ECC) || defined( __GNUC__ )) && !defined( _PCS ) && !defined( _PCS_GENSTUBS )
  75. #if defined( __GNUC__ )
  76. #if __GNUC__ >= 4 && __GNUC_MINOR__ >= 5
  77. #define IPP_DEPRECATED( message ) __attribute__(( deprecated( message )))
  78. #else
  79. #define IPP_DEPRECATED( message ) __attribute__(( deprecated ))
  80. #endif
  81. #else
  82. #define IPP_DEPRECATED( comment ) __attribute__(( deprecated ))
  83. #endif
  84. #else
  85. #define IPP_DEPRECATED( comment )
  86. #endif
  87. #if (defined( __ICL ) || defined( __ECL ) || defined(_MSC_VER))
  88. #if !defined( IPP_NO_DEFAULT_LIB )
  89. #if (( defined( _IPP_PARALLEL_DYNAMIC ) && !defined( _IPP_PARALLEL_STATIC ) && !defined( _IPP_SEQUENTIAL_DYNAMIC ) && !defined( _IPP_SEQUENTIAL_STATIC )) || \
  90. (!defined( _IPP_PARALLEL_DYNAMIC ) && defined( _IPP_PARALLEL_STATIC ) && !defined( _IPP_SEQUENTIAL_DYNAMIC ) && !defined( _IPP_SEQUENTIAL_STATIC )) || \
  91. (!defined( _IPP_PARALLEL_DYNAMIC ) && !defined( _IPP_PARALLEL_STATIC ) && defined( _IPP_SEQUENTIAL_DYNAMIC ) && !defined( _IPP_SEQUENTIAL_STATIC )) || \
  92. (!defined( _IPP_PARALLEL_DYNAMIC ) && !defined( _IPP_PARALLEL_STATIC ) && !defined( _IPP_SEQUENTIAL_DYNAMIC ) && defined( _IPP_SEQUENTIAL_STATIC )))
  93. #elif (!defined( _IPP_PARALLEL_DYNAMIC ) && !defined( _IPP_PARALLEL_STATIC ) && !defined( _IPP_SEQUENTIAL_DYNAMIC ) && !defined( _IPP_SEQUENTIAL_STATIC ))
  94. #define IPP_NO_DEFAULT_LIB
  95. #else
  96. #error Illegal combination of _IPP_PARALLEL_DYNAMIC/_IPP_PARALLEL_STATIC/_IPP_SEQUENTIAL_DYNAMIC/_IPP_SEQUENTIAL_STATIC, only one definition can be defined
  97. #endif
  98. #endif
  99. #else
  100. #define IPP_NO_DEFAULT_LIB
  101. #if (defined( _IPP_PARALLEL_DYNAMIC ) || defined( _IPP_PARALLEL_STATIC ) || defined(_IPP_SEQUENTIAL_DYNAMIC) || defined(_IPP_SEQUENTIAL_STATIC))
  102. #pragma message ("defines _IPP_PARALLEL_DYNAMIC/_IPP_PARALLEL_STATIC/_IPP_SEQUENTIAL_DYNAMIC/_IPP_SEQUENTIAL_STATIC do not have any effect in current configuration")
  103. #endif
  104. #endif
  105. #if !defined( IPP_NO_DEFAULT_LIB )
  106. #if defined( _IPP_PARALLEL_STATIC )
  107. #pragma comment( lib, "libiomp5md" )
  108. #endif
  109. #endif
  110. #if defined( _WIN32 ) || defined ( _WIN64 )
  111. #define IPP_STDCALL __stdcall
  112. #define IPP_CDECL __cdecl
  113. #define IPP_INT64 __int64
  114. #define IPP_UINT64 unsigned __int64
  115. #else
  116. #define IPP_STDCALL
  117. #define IPP_CDECL
  118. #define IPP_INT64 long long
  119. #define IPP_UINT64 unsigned long long
  120. #endif
  121. #define IPP_PI ( 3.14159265358979323846 ) /* ANSI C does not support M_PI */
  122. #define IPP_2PI ( 6.28318530717958647692 ) /* 2*pi */
  123. #define IPP_PI2 ( 1.57079632679489661923 ) /* pi/2 */
  124. #define IPP_PI4 ( 0.78539816339744830961 ) /* pi/4 */
  125. #define IPP_PI180 ( 0.01745329251994329577 ) /* pi/180 */
  126. #define IPP_RPI ( 0.31830988618379067154 ) /* 1/pi */
  127. #define IPP_SQRT2 ( 1.41421356237309504880 ) /* sqrt(2) */
  128. #define IPP_SQRT3 ( 1.73205080756887729353 ) /* sqrt(3) */
  129. #define IPP_LN2 ( 0.69314718055994530942 ) /* ln(2) */
  130. #define IPP_LN3 ( 1.09861228866810969139 ) /* ln(3) */
  131. #define IPP_E ( 2.71828182845904523536 ) /* e */
  132. #define IPP_RE ( 0.36787944117144232159 ) /* 1/e */
  133. #define IPP_EPS23 ( 1.19209289e-07f )
  134. #define IPP_EPS52 ( 2.2204460492503131e-016 )
  135. #define IPP_MAX_8U ( 0xFF )
  136. #define IPP_MAX_16U ( 0xFFFF )
  137. #define IPP_MAX_32U ( 0xFFFFFFFF )
  138. #define IPP_MIN_8U ( 0 )
  139. #define IPP_MIN_16U ( 0 )
  140. #define IPP_MIN_32U ( 0 )
  141. #define IPP_MIN_8S (-128 )
  142. #define IPP_MAX_8S ( 127 )
  143. #define IPP_MIN_16S (-32768 )
  144. #define IPP_MAX_16S ( 32767 )
  145. #define IPP_MIN_32S (-2147483647 - 1 )
  146. #define IPP_MAX_32S ( 2147483647 )
  147. #define IPP_MIN_64U ( 0 )
  148. #if defined( _WIN32 ) || defined ( _WIN64 )
  149. #define IPP_MAX_64S ( 9223372036854775807i64 )
  150. #define IPP_MIN_64S (-9223372036854775807i64 - 1 )
  151. #define IPP_MAX_64U ( 0xffffffffffffffffL ) /* 18446744073709551615 */
  152. #else
  153. #define IPP_MAX_64S ( 9223372036854775807LL )
  154. #define IPP_MIN_64S (-9223372036854775807LL - 1 )
  155. #define IPP_MAX_64U ( 0xffffffffffffffffLL ) /* 18446744073709551615 */
  156. #endif
  157. #define IPP_MINABS_32F ( 1.175494351e-38f )
  158. #define IPP_MAXABS_32F ( 3.402823466e+38f )
  159. #define IPP_EPS_32F ( 1.192092890e-07f )
  160. #define IPP_MINABS_64F ( 2.2250738585072014e-308 )
  161. #define IPP_MAXABS_64F ( 1.7976931348623158e+308 )
  162. #define IPP_EPS_64F ( 2.2204460492503131e-016 )
  163. #define IPP_MAX( a, b ) ( ((a) > (b)) ? (a) : (b) )
  164. #define IPP_MIN( a, b ) ( ((a) < (b)) ? (a) : (b) )
  165. #define IPP_ABS( a ) ( ((a) < 0) ? (-(a)) : (a) )
  166. typedef struct {
  167. int major; /* e.g. 1 */
  168. int minor; /* e.g. 2 */
  169. int majorBuild; /* e.g. 3 */
  170. int build; /* e.g. 10, always >= majorBuild */
  171. char targetCpu[4]; /* corresponding to Intel(R) processor */
  172. const char* Name; /* e.g. "ippsw7" */
  173. const char* Version; /* e.g. "v1.2 Beta" */
  174. const char* BuildDate; /* e.g. "Jul 20 99" */
  175. } IppLibraryVersion;
  176. typedef unsigned char Ipp8u;
  177. typedef unsigned short Ipp16u;
  178. typedef unsigned int Ipp32u;
  179. typedef signed char Ipp8s;
  180. typedef signed short Ipp16s;
  181. typedef signed int Ipp32s;
  182. typedef float Ipp32f;
  183. typedef IPP_INT64 Ipp64s;
  184. typedef IPP_UINT64 Ipp64u;
  185. typedef double Ipp64f;
  186. typedef Ipp16s Ipp16f;
  187. typedef struct {
  188. Ipp8s re;
  189. Ipp8s im;
  190. } Ipp8sc;
  191. typedef struct {
  192. Ipp16s re;
  193. Ipp16s im;
  194. } Ipp16sc;
  195. typedef struct {
  196. Ipp16u re;
  197. Ipp16u im;
  198. } Ipp16uc;
  199. typedef struct {
  200. Ipp32s re;
  201. Ipp32s im;
  202. } Ipp32sc;
  203. typedef struct {
  204. Ipp32f re;
  205. Ipp32f im;
  206. } Ipp32fc;
  207. typedef struct {
  208. Ipp64s re;
  209. Ipp64s im;
  210. } Ipp64sc;
  211. typedef struct {
  212. Ipp64f re;
  213. Ipp64f im;
  214. } Ipp64fc;
  215. typedef enum {
  216. ippUndef = -1,
  217. ipp1u = 0,
  218. ipp8u = 1,
  219. ipp8uc = 2,
  220. ipp8s = 3,
  221. ipp8sc = 4,
  222. ipp16u = 5,
  223. ipp16uc = 6,
  224. ipp16s = 7,
  225. ipp16sc = 8,
  226. ipp32u = 9,
  227. ipp32uc = 10,
  228. ipp32s = 11,
  229. ipp32sc = 12,
  230. ipp32f = 13,
  231. ipp32fc = 14,
  232. ipp64u = 15,
  233. ipp64uc = 16,
  234. ipp64s = 17,
  235. ipp64sc = 18,
  236. ipp64f = 19,
  237. ipp64fc = 20
  238. } IppDataType;
  239. typedef enum {
  240. ippFalse = 0,
  241. ippTrue = 1
  242. } IppBool;
  243. #ifdef __cplusplus
  244. }
  245. #endif
  246. #endif /* IPPBASE_H__ */
  247. #ifndef IPP_CPU_FEATURES__
  248. #define IPP_CPU_FEATURES__
  249. #define ippCPUID_MMX 0x00000001 /* Intel(R) Architecture MMX technology supported */
  250. #define ippCPUID_SSE 0x00000002 /* Intel(R) Streaming SIMD Extensions */
  251. #define ippCPUID_SSE2 0x00000004 /* Intel(R) Streaming SIMD Extensions 2 */
  252. #define ippCPUID_SSE3 0x00000008 /* Intel(R) Streaming SIMD Extensions 3 */
  253. #define ippCPUID_SSSE3 0x00000010 /* Supplemental Streaming SIMD Extensions 3 */
  254. #define ippCPUID_MOVBE 0x00000020 /* Intel(R) MOVBE instruction */
  255. #define ippCPUID_SSE41 0x00000040 /* Intel(R) Streaming SIMD Extensions 4.1 */
  256. #define ippCPUID_SSE42 0x00000080 /* Intel(R) Streaming SIMD Extensions 4.2 */
  257. #define ippCPUID_AVX 0x00000100 /* Intel(R) Advanced Vector Extensions instruction set */
  258. #define ippAVX_ENABLEDBYOS 0x00000200 /* Intel(R) Advanced Vector Extensions instruction set is supported by OS */
  259. #define ippCPUID_AES 0x00000400 /* Intel(R) AES New Instructions */
  260. #define ippCPUID_CLMUL 0x00000800 /* Intel(R) CLMUL instruction */
  261. #define ippCPUID_ABR 0x00001000 /* Reserved */
  262. #define ippCPUID_RDRAND 0x00002000 /* Intel(R) RDRAND instruction */
  263. #define ippCPUID_F16C 0x00004000 /* Intel(R) F16C new instructions */
  264. #define ippCPUID_AVX2 0x00008000 /* Intel(R) Advanced Vector Extensions 2 instruction set */
  265. #define ippCPUID_ADCOX 0x00010000 /* Intel(R) ADOX/ADCX new instructions */
  266. #define ippCPUID_RDSEED 0x00020000 /* Intel(R) RDSEED instruction */
  267. #define ippCPUID_PREFETCHW 0x00040000 /* Intel(R) PREFETCHW instruction */
  268. #define ippCPUID_SHA 0x00080000 /* Intel(R) SHA new instructions */
  269. #define ippCPUID_AVX512F 0x00100000 /* Intel(R) Advanced Vector Extensions 512 Foundation instruction set */
  270. #define ippCPUID_AVX512CD 0x00200000 /* Intel(R) Advanced Vector Extensions 512 CD instruction set */
  271. #define ippCPUID_AVX512ER 0x00400000 /* Intel(R) Advanced Vector Extensions 512 ER instruction set */
  272. #define ippCPUID_AVX512PF 0x00800000 /* Intel(R) Advanced Vector Extensions 512 PF instruction set */
  273. #define ippCPUID_AVX512BW 0x01000000 /* Intel(R) Advanced Vector Extensions 512 BW instruction set */
  274. #define ippCPUID_AVX512DQ 0x02000000 /* Intel(R) Advanced Vector Extensions 512 DQ instruction set */
  275. #define ippCPUID_AVX512VL 0x04000000 /* Intel(R) Advanced Vector Extensions 512 VL instruction set */
  276. #define ippCPUID_AVX512VBMI 0x08000000 /* Intel(R) Advanced Vector Extensions 512 Bit Manipulation instructions */
  277. #define ippCPUID_MPX 0x10000000 /* Intel(R) Memory Protection Extensions */
  278. #define ippCPUID_AVX512_4FMADDPS 0x20000000 /* Intel(R) Advanced Vector Extensions 512 DL floating-point single precision */
  279. #define ippCPUID_AVX512_4VNNIW 0x40000000 /* Intel(R) Advanced Vector Extensions 512 DL enhanced word variable precision */
  280. #define ippCPUID_KNC 0x80000000 /* Intel(R) Xeon Phi(TM) Coprocessor */
  281. #if defined( _WIN32 ) || defined ( _WIN64 )
  282. #define INT64_SUFFIX(name) name##L
  283. #else
  284. #define INT64_SUFFIX(name) name##LL
  285. #endif
  286. #define ippCPUID_AVX512IFMA INT64_SUFFIX(0x100000000) /* Intel(R) Advanced Vector Extensions 512 IFMA (PMADD52) instruction set */
  287. #define ippCPUID_NOCHECK INT64_SUFFIX(0x8000000000000000) /* Force ippSetCpuFeatures to set CPU features without check */
  288. #define ippCPUID_GETINFO_A INT64_SUFFIX(0x616f666e69746567) /* Force ippGetCpuFeatures to work as cpuid instruction */
  289. #define ippAVX512_ENABLEDBYOS INT64_SUFFIX(0x200000000) /* Intel(R) Advanced Vector Extensions 512 is supported by OS */
  290. #endif /* IPP_CPU_FEATURES__ */
  291. #ifndef IPPSTATUS_H__
  292. #define IPPSTATUS_H__
  293. #ifdef __cplusplus
  294. extern "C" {
  295. #endif
  296. typedef signed int IppStatus;
  297. /* start of common with ippCrypto part - any changes MUST be done in both repositories - IPP & ippCrypto */
  298. #define ippStsLoadDynErr -221 /* Error when loading the dynamic library. */
  299. #define ippStsLengthErr -15 /* Incorrect value for string length. */
  300. #define ippStsNotSupportedModeErr -14 /* The requested mode is currently not supported. */
  301. #define ippStsContextMatchErr -13 /* Context parameter does not match the operation. */
  302. #define ippStsScaleRangeErr -12 /* Scale bounds are out of range. */
  303. #define ippStsOutOfRangeErr -11 /* Argument is out of range, or point is outside the image. */
  304. #define ippStsDivByZeroErr -10 /* An attempt to divide by zero. */
  305. #define ippStsMemAllocErr -9 /* Memory allocated for the operation is not enough.*/
  306. #define ippStsNullPtrErr -8 /* Null pointer error. */
  307. #define ippStsRangeErr -7 /* Incorrect values for bounds: the lower bound is greater than the upper bound. */
  308. #define ippStsSizeErr -6 /* Incorrect value for data size. */
  309. #define ippStsBadArgErr -5 /* Incorrect arg/param of the function. */
  310. #define ippStsNoMemErr -4 /* Not enough memory for the operation. */
  311. #define ippStsErr -2 /* Unknown/unspecified error */
  312. /* no errors */
  313. #define ippStsNoErr 0 /* No errors. */
  314. /* warnings */
  315. #define ippStsNoOperation 1 /* No operation has been executed. */
  316. #define ippStsDivByZero 2 /* Zero value(s) for the divisor in the Div function. */
  317. #define ippStsWaterfall 43 /* Cannot load required library, waterfall is used. */
  318. /* end of common with ippCrypto part */
  319. #ifdef __cplusplus
  320. }
  321. #endif
  322. #endif /* IPPSTATUS_H__ */
  323. #define ippStsCpuNotSupportedErr -9999/* The target CPU is not supported. */
  324. /* ippCrypto specific statuses - any changes MUST be done in both repositories - IPP & ippCrypto */
  325. #define ippStsQuadraticNonResidueErr -1016 /* SQRT operation on quadratic non-residue value. */
  326. #define ippStsPointAtInfinity -1015 /* Point at infinity is detected. */
  327. #define ippStsOFBSizeErr -1014 /* Incorrect value for crypto OFB block size. */
  328. #define ippStsIncompleteContextErr -1013 /* Crypto: set up of context is not complete. */
  329. #define ippStsCTRSizeErr -1012 /* Incorrect value for crypto CTR block size. */
  330. #define ippStsEphemeralKeyErr -1011 /* ECC: Invalid ephemeral key. */
  331. #define ippStsMessageErr -1010 /* ECC: Invalid message digest. */
  332. #define ippStsShareKeyErr -1009 /* ECC: Invalid share key. */
  333. #define ippStsIvalidPrivateKey -1008 /* ECC: Invalid private key. */
  334. #define ippStsOutOfECErr -1007 /* ECC: Point out of EC. */
  335. #define ippStsECCInvalidFlagErr -1006 /* ECC: Invalid Flag. */
  336. #define ippStsUnderRunErr -1005 /* Error in data under run. */
  337. #define ippStsPaddingErr -1004 /* Detected padding error indicates the possible data corruption. */
  338. #define ippStsCFBSizeErr -1003 /* Incorrect value for crypto CFB block size. */
  339. #define ippStsPaddingSchemeErr -1002 /* Invalid padding scheme. */
  340. #define ippStsBadModulusErr -1001 /* Bad modulus caused a failure in module inversion. */
  341. #define ippStsInsufficientEntropy 25 /* Generation of the prime/key failed due to insufficient entropy in the random seed and stimulus bit string. */
  342. /* end of ippCrypto specific statuses - any changes MUST be done in both repositories - IPP & ippCrypto */
  343. #ifndef IPPCPDEFS_H__
  344. #define IPPCPDEFS_H__
  345. #ifdef __cplusplus
  346. extern "C" {
  347. #endif
  348. #if !defined( _OWN_BLDPCS )
  349. typedef Ipp32u IppAlgId;
  350. /*
  351. // =========================================================
  352. // Symmetric Ciphers
  353. // =========================================================
  354. */
  355. typedef enum {
  356. ippPaddingNONE = 0, /*NONE = 0,*/ IppsCPPaddingNONE = 0,
  357. ippPaddingPKCS7 = 1, /*PKCS7 = 1,*/ IppsCPPaddingPKCS7 = 1,
  358. ippPaddingZEROS = 2, /*ZEROS = 2,*/ IppsCPPaddingZEROS = 2
  359. } IppsPadding, IppsCPPadding;
  360. typedef struct _cpDES IppsDESSpec;
  361. typedef struct _cpRijndael128 IppsAESSpec;
  362. typedef struct _cpRijndael128 IppsRijndael128Spec;
  363. typedef struct _cpSMS4 IppsSMS4Spec;
  364. /* TDES */
  365. #define DES_BLOCKSIZE (64) /* cipher blocksize (bits) */
  366. #define TDES_BLOCKSIZE DES_BLOCKSIZE
  367. #define DES_KEYSIZE (64) /* cipher keysize (bits) */
  368. #define TDES_KEYSIZE DES_KEYSIZE
  369. /* AES */
  370. #define IPP_AES_BLOCK_BITSIZE (128) /* cipher blocksizes (bits) */
  371. /* Rijndael */
  372. typedef enum {
  373. ippRijndaelKey128 = 128, IppsRijndaelKey128 = 128, /* 128-bit key */
  374. ippRijndaelKey192 = 192, IppsRijndaelKey192 = 192, /* 192-bit key */
  375. ippRijndaelKey256 = 256, IppsRijndaelKey256 = 256 /* 256-bit key */
  376. } IppsRijndaelKeyLength;
  377. /* AES-CCM (authentication & confidence) */
  378. typedef struct _cpAES_CCM IppsAES_CCMState;
  379. /* AES-GCM (authentication & confidence) */
  380. typedef struct _cpAES_GCM IppsAES_GCMState;
  381. /* AES-XTS (confidence) */
  382. typedef struct _cpAES_XTS IppsAES_XTSSpec;
  383. /* SMS4-CCM (authentication & confidence) */
  384. typedef struct _cpSMS4_CCM IppsSMS4_CCMState;
  385. /*
  386. // =========================================================
  387. // ARCFOUR Stream Cipher
  388. // =========================================================
  389. */
  390. typedef struct _cpARCfour IppsARCFourState;
  391. #define IPP_ARCFOUR_KEYMAX_SIZE (256) /* max key length (bytes) */
  392. #define MAX_ARCFOUR_KEY_LEN IPP_ARCFOUR_KEYMAX_SIZE /* obsolete */
  393. /*
  394. // =========================================================
  395. // One-Way Hash Functions
  396. // =========================================================
  397. */
  398. typedef enum {
  399. ippHashAlg_Unknown,
  400. ippHashAlg_SHA1,
  401. ippHashAlg_SHA256,
  402. ippHashAlg_SHA224,
  403. ippHashAlg_SHA512,
  404. ippHashAlg_SHA384,
  405. ippHashAlg_MD5,
  406. ippHashAlg_SM3,
  407. ippHashAlg_SHA512_224,
  408. ippHashAlg_SHA512_256,
  409. ippHashAlg_MaxNo
  410. } IppHashAlgId;
  411. #define IPP_ALG_HASH_UNKNOWN (ippHashAlg_Unknown) /* unknown */
  412. #define IPP_ALG_HASH_SHA1 (ippHashAlg_SHA1) /* SHA1 */
  413. #define IPP_ALG_HASH_SHA256 (ippHashAlg_SHA256) /* SHA256 */
  414. #define IPP_ALG_HASH_SHA224 (ippHashAlg_SHA224) /* SHA224 or SHA256/224 */
  415. #define IPP_ALG_HASH_SHA512 (ippHashAlg_SHA512) /* SHA512 */
  416. #define IPP_ALG_HASH_SHA384 (ippHashAlg_SHA384) /* SHA384 or SHA512/384 */
  417. #define IPP_ALG_HASH_MD5 (ippHashAlg_MD5) /* MD5 */
  418. #define IPP_ALG_HASH_SM3 (ippHashAlg_SM3) /* SM3 */
  419. #define IPP_ALG_HASH_SHA512_224 (ippHashAlg_SHA512_224) /* SHA512/224 */
  420. #define IPP_ALG_HASH_SHA512_256 (ippHashAlg_SHA512_256) /* SHA512/256 */
  421. #define IPP_ALG_HASH_LIMIT (ippHashAlg_MaxNo) /* hash alg limiter*/
  422. typedef struct _cpSHA1 IppsSHA1State;
  423. typedef struct _cpSHA256 IppsSHA256State;
  424. typedef struct _cpSHA256 IppsSHA224State;
  425. typedef struct _cpSHA512 IppsSHA512State;
  426. typedef struct _cpSHA512 IppsSHA384State;
  427. typedef struct _cpMD5 IppsMD5State;
  428. typedef struct _cpSM3 IppsSM3State;
  429. typedef struct _cpHashCtx IppsHashState;
  430. typedef struct _cpHashMethod_rmf IppsHashMethod;
  431. typedef struct _cpHashCtx_rmf IppsHashState_rmf;
  432. /* MGF */
  433. typedef IppStatus (IPP_STDCALL *IppMGF)(const Ipp8u* pSeed, int seedLen, Ipp8u* pMask, int maskLen);
  434. /* HASH function */
  435. typedef IppStatus (IPP_STDCALL *IppHASH)(const Ipp8u* pMsg, int len, Ipp8u* pMD);
  436. #define IPP_SHA1_DIGEST_BITSIZE 160 /* digest size (bits) */
  437. #define IPP_SHA256_DIGEST_BITSIZE 256
  438. #define IPP_SHA224_DIGEST_BITSIZE 224
  439. #define IPP_SHA384_DIGEST_BITSIZE 384
  440. #define IPP_SHA512_DIGEST_BITSIZE 512
  441. #define IPP_MD5_DIGEST_BITSIZE 128
  442. #define IPP_SM3_DIGEST_BITSIZE 256
  443. #define IPP_SHA512_224_DIGEST_BITSIZE 224
  444. #define IPP_SHA512_256_DIGEST_BITSIZE 256
  445. /*
  446. // =========================================================
  447. // Keyed-Hash Message Authentication Codes
  448. // =========================================================
  449. */
  450. typedef struct _cpHMAC IppsHMACState;
  451. typedef struct _cpHMAC IppsHMACSHA1State;
  452. typedef struct _cpHMAC IppsHMACSHA256State;
  453. typedef struct _cpHMAC IppsHMACSHA224State;
  454. typedef struct _cpHMAC IppsHMACSHA384State;
  455. typedef struct _cpHMAC IppsHMACSHA512State;
  456. typedef struct _cpHMAC IppsHMACMD5State;
  457. typedef struct _cpHMAC_rmf IppsHMACState_rmf;
  458. /*
  459. // =========================================================
  460. // Data Authentication Codes
  461. // =========================================================
  462. */
  463. typedef struct _cpAES_CMAC IppsAES_CMACState;
  464. /*
  465. // =========================================================
  466. // Big Number Integer Arithmetic
  467. // =========================================================
  468. */
  469. #define BN_MAXBITSIZE (16*1024) /* bn max size (bits) */
  470. typedef enum {
  471. ippBigNumNEG = 0, IppsBigNumNEG = 0,
  472. ippBigNumPOS = 1, IppsBigNumPOS = 1
  473. } IppsBigNumSGN;
  474. typedef enum {
  475. ippBinaryMethod = 0, IppsBinaryMethod = 0,
  476. ippSlidingWindows = 1, IppsSlidingWindows = 1
  477. } IppsExpMethod;
  478. typedef struct _cpBigNum IppsBigNumState;
  479. typedef struct _cpMontgomery IppsMontState;
  480. typedef struct _cpPRNG IppsPRNGState;
  481. typedef struct _cpPrime IppsPrimeState;
  482. /* External Bit Supplier */
  483. typedef IppStatus (IPP_STDCALL *IppBitSupplier)(Ipp32u* pRand, int nBits, void* pEbsParams);
  484. #define IPP_IS_EQ (0)
  485. #define IPP_IS_GT (1)
  486. #define IPP_IS_LT (2)
  487. #define IPP_IS_NE (3)
  488. #define IPP_IS_NA (4)
  489. #define IPP_IS_PRIME (5)
  490. #define IPP_IS_COMPOSITE (6)
  491. #define IPP_IS_VALID (7)
  492. #define IPP_IS_INVALID (8)
  493. #define IPP_IS_INCOMPLETE (9)
  494. #define IPP_IS_ATINFINITY (10)
  495. #define IS_ZERO IPP_IS_EQ
  496. #define GREATER_THAN_ZERO IPP_IS_GT
  497. #define LESS_THAN_ZERO IPP_IS_LT
  498. #define IS_PRIME IPP_IS_PRIME
  499. #define IS_COMPOSITE IPP_IS_COMPOSITE
  500. #define IS_VALID_KEY IPP_IS_VALID
  501. #define IS_INVALID_KEY IPP_IS_INVALID
  502. #define IS_INCOMPLETED_KEY IPP_IS_INCOMPLETE
  503. /*
  504. // =========================================================
  505. // RSA Cryptography
  506. // =========================================================
  507. */
  508. #define MIN_RSA_SIZE (8)
  509. #define MAX_RSA_SIZE (8*1024)
  510. typedef struct _cpRSA IppsRSAState;
  511. /* key types */
  512. typedef enum {
  513. ippRSApublic = 0x20000000, IppRSApublic = 0x20000000,
  514. ippRSAprivate = 0x40000000, IppRSAprivate = 0x40000000
  515. } IppRSAKeyType;
  516. /* key component's tag */
  517. typedef enum {
  518. ippRSAkeyN = 0x01, IppRSAkeyN = 0x01,
  519. ippRSAkeyE = 0x02, IppRSAkeyE = 0x02,
  520. ippRSAkeyD = 0x04, IppRSAkeyD = 0x04,
  521. ippRSAkeyP = 0x08, IppRSAkeyP = 0x08,
  522. ippRSAkeyQ = 0x10, IppRSAkeyQ = 0x10,
  523. ippRSAkeyDp = 0x20, IppRSAkeyDp = 0x20,
  524. ippRSAkeyDq = 0x40, IppRSAkeyDq = 0x40,
  525. ippRSAkeyQinv = 0x80, IppRSAkeyQinv = 0x80
  526. } IppRSAKeyTag;
  527. typedef struct _cpRSA_public_key IppsRSAPublicKeyState;
  528. typedef struct _cpRSA_private_key IppsRSAPrivateKeyState;
  529. /*
  530. // =========================================================
  531. // DL Cryptography
  532. // =========================================================
  533. */
  534. #define MIN_DLP_BITSIZE (512)
  535. #define MIN_DLP_BITSIZER (160)
  536. #define MIN_DLPDH_BITSIZE (512)
  537. #define MIN_DLPDH_BITSIZER (160)
  538. #define DEF_DLPDH_BITSIZER (160)
  539. #define MIN_DLPDSA_BITSIZE (512)
  540. #define MAX_DLPDSA_BITSIZE (1024)
  541. #define MIN_DLPDSA_BITSIZER (160)
  542. #define DEF_DLPDSA_BITSIZER (160)
  543. #define MAX_DLPDSA_BITSIZER (160)
  544. #define MIN_DLPDSA_SEEDSIZE (160)
  545. typedef struct _cpDLP IppsDLPState;
  546. /* domain parameter tags */
  547. typedef enum {
  548. ippDLPkeyP = 0x01, IppDLPkeyP = 0x01,
  549. ippDLPkeyR = 0x02, IppDLPkeyR = 0x02,
  550. ippDLPkeyG = 0x04, IppDLPkeyG = 0x04
  551. } IppDLPKeyTag;
  552. typedef enum {
  553. ippDLValid, /* validation pass successfully */
  554. ippDLBaseIsEven, /* !(P is odd) */
  555. ippDLOrderIsEven, /* !(R is odd) */
  556. ippDLInvalidBaseRange, /* !(2^(L-1) < P < 2^L) */
  557. ippDLInvalidOrderRange, /* !(2^(M-1) < R < 2^M) */
  558. ippDLCompositeBase,
  559. ippDLCompositeOrder,
  560. ippDLInvalidCofactor, /* !( R|(P-1) ) */
  561. ippDLInvalidGenerator, /* !( G^R == 1 (mod P) ) */
  562. /* !(1 < G < (P-1)) */
  563. ippDLInvalidPrivateKey, /* !(1 < private < (R-1)) */
  564. ippDLInvalidPublicKey, /* !(1 < public <=(P-1)) */
  565. ippDLInvalidKeyPair, /* !(G^private == public */
  566. ippDLInvalidSignature /* invalid signature */
  567. } IppDLResult;
  568. /*
  569. // =========================================================
  570. // EC Cryptography
  571. // =========================================================
  572. */
  573. #define EC_GFP_MAXBITSIZE (1024)
  574. /* operation result */
  575. typedef enum {
  576. ippECValid, /* validation pass successfully */
  577. ippECCompositeBase, /* field based on composite */
  578. ippECComplicatedBase, /* number of non-zero terms in the polynomial (> PRIME_ARR_MAX) */
  579. ippECIsZeroDiscriminant,/* zero discriminant */
  580. ippECCompositeOrder, /* composite order of base point */
  581. ippECInvalidOrder, /* invalid base point order */
  582. ippECIsWeakMOV, /* weak Meneze-Okamoto-Vanstone reduction attack */
  583. ippECIsWeakSSSA, /* weak Semaev-Smart,Satoh-Araki reduction attack */
  584. ippECIsSupersingular, /* supersingular curve */
  585. ippECInvalidPrivateKey, /* !(0 < Private < order) */
  586. ippECInvalidPublicKey, /* (order*PublicKey != Infinity) */
  587. ippECInvalidKeyPair, /* (Private*BasePoint != PublicKey) */
  588. ippECPointOutOfGroup, /* out of group (order*P != Infinity) */
  589. ippECPointIsAtInfinite, /* point (P=(Px,Py)) at Infinity */
  590. ippECPointIsNotValid, /* point (P=(Px,Py)) out-of EC */
  591. ippECPointIsEqual, /* compared points are equal */
  592. ippECPointIsNotEqual, /* compared points are different */
  593. ippECInvalidSignature /* invalid signature */
  594. } IppECResult;
  595. /* domain parameter set/get flags */
  596. typedef enum {
  597. ippECarbitrary =0x00000, IppECCArbitrary = 0x00000, /* arbitrary ECC */
  598. ippECPstd = 0x10000, IppECCPStd = 0x10000, /* random (recommended) EC over FG(p): */
  599. ippECPstd112r1 = ippECPstd, IppECCPStd112r1 = IppECCPStd, /* secp112r1 curve */
  600. ippECPstd112r2 = ippECPstd+1, IppECCPStd112r2 = IppECCPStd+1, /* secp112r2 curve */
  601. ippECPstd128r1 = ippECPstd+2, IppECCPStd128r1 = IppECCPStd+2, /* secp128r1 curve */
  602. ippECPstd128r2 = ippECPstd+3, IppECCPStd128r2 = IppECCPStd+3, /* secp128r2 curve */
  603. ippECPstd160r1 = ippECPstd+4, IppECCPStd160r1 = IppECCPStd+4, /* secp160r1 curve */
  604. ippECPstd160r2 = ippECPstd+5, IppECCPStd160r2 = IppECCPStd+5, /* secp160r2 curve */
  605. ippECPstd192r1 = ippECPstd+6, IppECCPStd192r1 = IppECCPStd+6, /* secp192r1 curve */
  606. ippECPstd224r1 = ippECPstd+7, IppECCPStd224r1 = IppECCPStd+7, /* secp224r1 curve */
  607. ippECPstd256r1 = ippECPstd+8, IppECCPStd256r1 = IppECCPStd+8, /* secp256r1 curve */
  608. ippECPstd384r1 = ippECPstd+9, IppECCPStd384r1 = IppECCPStd+9, /* secp384r1 curve */
  609. ippECPstd521r1 = ippECPstd+10, IppECCPStd521r1 = IppECCPStd+10, /* secp521r1 curve */
  610. ippECPstdSM2 = ippECPstd+11, IppECCPStdSM2 = IppECCPStd+11, /* TMP SM2 curve */
  611. ippEC_TPM_SM2_P256= ippECPstd+11,
  612. ippEC_TPM_BN_P256 = ippECPstd+12, /* TPM BN_P256 curve */
  613. /* curves over binary finit fields are not supported in Intel(R) IPP 9.0 */
  614. IppECCBStd = 0x20000, /* random (recommended) EC over FG(2^m): */
  615. IppECCBStd113r1 = IppECCBStd, /* sect113r1 curve */
  616. IppECCBStd113r2 = IppECCBStd+1, /* sect113r2 curve */
  617. IppECCBStd131r1 = IppECCBStd+2, /* sect131r1 curve */
  618. IppECCBStd131r2 = IppECCBStd+3, /* sect131r2 curve */
  619. IppECCBStd163r1 = IppECCBStd+4, /* sect163r1 curve */
  620. IppECCBStd163r2 = IppECCBStd+5, /* sect163r2 curve */
  621. IppECCBStd193r1 = IppECCBStd+6, /* sect193r1 curve */
  622. IppECCBStd193r2 = IppECCBStd+7, /* sect193r2 curve */
  623. IppECCBStd233r1 = IppECCBStd+8, /* sect233r1 curve */
  624. IppECCBStd283r1 = IppECCBStd+9, /* sect283r1 curve */
  625. IppECCBStd409r1 = IppECCBStd+10, /* sect409r1 curve */
  626. IppECCBStd571r1 = IppECCBStd+11, /* sect571r1 curve */
  627. IppECCKStd = 0x40000, /* Koblitz (recommended) EC over FG(2^m): */
  628. IppECCBStd163k1 = IppECCKStd, /* Koblitz 163 curve */
  629. IppECCBStd233k1 = IppECCKStd+1, /* Koblitz 233 curve */
  630. IppECCBStd239k1 = IppECCKStd+2, /* Koblitz 239 curve */
  631. IppECCBStd283k1 = IppECCKStd+3, /* Koblitz 283 curve */
  632. IppECCBStd409k1 = IppECCKStd+4, /* Koblitz 409 curve */
  633. IppECCBStd571k1 = IppECCKStd+5 /* Koblitz 571 curve */
  634. } IppsECType, IppECCType;
  635. /*
  636. // GF over prime and its extension
  637. */
  638. #define IPP_MIN_GF_CHAR (3) /* min characteristic of GF */
  639. #define IPP_MIN_GF_BITSIZE (2) /* min bitsize of element over prime GF */
  640. #define IPP_MAX_GF_BITSIZE (1024) /* max bitsize of element over prime GF */
  641. #define IPP_MIN_GF_EXTDEG (2) /* min GF extension degree */
  642. #define IPP_MAX_GF_EXTDEG (8) /* max GF extension degree */
  643. #define IPP_MAX_EXPONENT_NUM (6) /* max number of exponents, equals to LOG_CACHE_LINE_SIZE */
  644. typedef struct _cpGFpMethod IppsGFpMethod;
  645. typedef struct _cpGFp IppsGFpState;
  646. typedef struct _cpGFpElement IppsGFpElement;
  647. typedef struct _cpGFpEC IppsGFpECState;
  648. typedef struct _cpGFpECPoint IppsGFpECPoint;
  649. typedef struct _cpGFpEC IppsECCPState;
  650. typedef struct _cpGFpECPoint IppsECCPPointState;
  651. typedef struct {
  652. const IppsGFpState* pBasicGF;
  653. const IppsGFpState* pGroundGF;
  654. int basicGFdegree;
  655. int groundGFdegree;
  656. int elementLen;
  657. } IppsGFpInfo;
  658. #endif /* _OWN_BLDPCS */
  659. #ifndef _PCS
  660. IPPAPI( IppStatus, ippcpSetNumThreads, ( int numThr ))
  661. IPPAPI( IppStatus, ippcpGetNumThreads, (int* pNumThr) )
  662. IPPAPI( IppStatus, ippcpGetCpuFeatures, ( Ipp64u* pFeaturesMask ))
  663. IPPAPI( IppStatus, ippcpSetCpuFeatures, ( Ipp64u features ))
  664. IPPAPI( Ipp64u, ippcpGetEnabledCpuFeatures, ( void ) )
  665. IPPAPI( IppStatus, ippcpInit,( void ))
  666. IPPAPI( const char*, ippcpGetStatusString, ( IppStatus StsCode ))
  667. IPPAPI( int, ippcpGetEnabledNumThreads, ( void ) )
  668. #endif
  669. #ifdef __cplusplus
  670. }
  671. #endif
  672. #endif /* IPPCPDEFS_H__ */