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