ippcpdefs.h 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. /*
  2. * Copyright (C) 2016 Intel Corporation. All rights reserved.
  3. *
  4. * Redistribution and use in source and binary forms, with or without
  5. * modification, are permitted provided that the following conditions
  6. * are met:
  7. *
  8. * * Redistributions of source code must retain the above copyright
  9. * notice, this list of conditions and the following disclaimer.
  10. * * Redistributions in binary form must reproduce the above copyright
  11. * notice, this list of conditions and the following disclaimer in
  12. * the documentation and/or other materials provided with the
  13. * distribution.
  14. * * Neither the name of Intel Corporation nor the names of its
  15. * contributors may be used to endorse or promote products derived
  16. * from this software without specific prior written permission.
  17. *
  18. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  19. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  20. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  21. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  22. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  23. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  24. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  25. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  26. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  27. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  28. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  29. *
  30. */
  31. #ifndef __IPPCPDEFS_H__
  32. #define __IPPCPDEFS_H__
  33. #ifdef __cplusplus
  34. extern "C" {
  35. #endif
  36. /*
  37. // AES
  38. */
  39. #define IPP_AES_BLOCK_BITSIZE (128) /* cipher blocksizes (bits) */
  40. typedef enum { /* cipher keysizes (bits) */
  41. ippRijndaelKey128 = 128, IppsRijndaelKey128 = 128, /* 128-bit key */
  42. ippRijndaelKey192 = 192, IppsRijndaelKey192 = 192, /* 192-bit key */
  43. ippRijndaelKey256 = 256, IppsRijndaelKey256 = 256 /* 256-bit key */
  44. } IppsRijndaelKeyLength;
  45. typedef struct _cpRijndael128 IppsAESSpec;
  46. typedef struct _cpAES_GCM IppsAES_GCMState;
  47. typedef struct _cpAES_CMAC IppsAES_CMACState;
  48. /*
  49. // hash
  50. */
  51. typedef enum {
  52. ippHashAlg_Unknown,
  53. ippHashAlg_SHA1,
  54. ippHashAlg_SHA256,
  55. ippHashAlg_SHA224,
  56. ippHashAlg_SHA512,
  57. ippHashAlg_SHA384,
  58. ippHashAlg_MD5,
  59. ippHashAlg_SHA512_224,
  60. ippHashAlg_SHA512_256,
  61. ippHashAlg_MaxNo
  62. } IppHashAlgId;
  63. #define IPP_ALG_HASH_UNKNOWN (ippHashAlg_Unknown) /* unknown */
  64. #define IPP_ALG_HASH_SHA1 (ippHashAlg_SHA1) /* SHA1 */
  65. #define IPP_ALG_HASH_SHA256 (ippHashAlg_SHA256) /* SHA256 */
  66. #define IPP_ALG_HASH_SHA224 (ippHashAlg_SHA224) /* SHA224 or SHA256/224 */
  67. #define IPP_ALG_HASH_SHA512 (ippHashAlg_SHA512) /* SHA512 */
  68. #define IPP_ALG_HASH_SHA384 (ippHashAlg_SHA384) /* SHA384 or SHA512/384 */
  69. #define IPP_ALG_HASH_MD5 (ippHashAlg_MD5) /* MD5 */
  70. #define IPP_ALG_HASH_SHA512_224 (ippHashAlg_SHA512_224) /* SHA512/224 */
  71. #define IPP_ALG_HASH_SHA512_256 (ippHashAlg_SHA512_256) /* SHA512/256 */
  72. #define IPP_ALG_HASH_LIMIT (ippHashAlg_MaxNo) /* hash alg limiter*/
  73. #define IPP_SHA1_DIGEST_BITSIZE 160 /* digest size (bits) */
  74. #define IPP_SHA256_DIGEST_BITSIZE 256
  75. #define IPP_SHA224_DIGEST_BITSIZE 224
  76. #define IPP_SHA384_DIGEST_BITSIZE 384
  77. #define IPP_SHA512_DIGEST_BITSIZE 512
  78. #define IPP_MD5_DIGEST_BITSIZE 128
  79. #define IPP_SHA512_224_DIGEST_BITSIZE 224
  80. #define IPP_SHA512_256_DIGEST_BITSIZE 256
  81. typedef struct _cpHashCtx IppsHashState;
  82. typedef struct _cpHMAC IppsHMACState;
  83. /*
  84. // Big Number Integer Arithmetic
  85. */
  86. #define BN_MAXBITSIZE (16*1024) /* bn max size (bits) */
  87. /* operation results */
  88. #define IPP_IS_EQ (0)
  89. #define IPP_IS_GT (1)
  90. #define IPP_IS_LT (2)
  91. #define IPP_IS_NE (3)
  92. #define IPP_IS_NA (4)
  93. #define IPP_IS_PRIME (5)
  94. #define IPP_IS_COMPOSITE (6)
  95. #define IPP_IS_VALID (7)
  96. #define IPP_IS_INVALID (8)
  97. #define IPP_IS_INCOMPLETE (9)
  98. #define IPP_IS_ATINFINITY (10)
  99. #define IS_ZERO IPP_IS_EQ
  100. #define GREATER_THAN_ZERO IPP_IS_GT
  101. #define LESS_THAN_ZERO IPP_IS_LT
  102. #define IS_PRIME IPP_IS_PRIME
  103. #define IS_COMPOSITE IPP_IS_COMPOSITE
  104. #define IS_VALID_KEY IPP_IS_VALID
  105. #define IS_INVALID_KEY IPP_IS_INVALID
  106. #define IS_INCOMPLETED_KEY IPP_IS_INCOMPLETE
  107. typedef enum {
  108. ippBigNumNEG = 0, IppsBigNumNEG = 0,
  109. ippBigNumPOS = 1, IppsBigNumPOS = 1
  110. } IppsBigNumSGN;
  111. typedef enum {
  112. ippBinaryMethod = 0, IppsBinaryMethod = 0,
  113. ippSlidingWindows = 1, IppsSlidingWindows = 1
  114. } IppsExpMethod;
  115. typedef struct _cpBigNum IppsBigNumState;
  116. typedef struct _cpMontgomery IppsMontState;
  117. typedef struct _cpPRNG IppsPRNGState;
  118. typedef struct _cpPrime IppsPrimeState;
  119. /* External Bit Supplier */
  120. typedef IppStatus (__STDCALL *IppBitSupplier)(Ipp32u* pRand, int nBits, void* pEbsParams);
  121. /*
  122. // RSA
  123. */
  124. #define MIN_RSA_SIZE (8)
  125. #define MAX_RSA_SIZE (4096)
  126. typedef struct _cpRSA IppsRSAState;
  127. typedef struct _cpRSA_public_key IppsRSAPublicKeyState;
  128. typedef struct _cpRSA_private_key IppsRSAPrivateKeyState;
  129. /*
  130. // EC Cryptography
  131. */
  132. #define EC_GFP_MAXBITSIZE (1024)
  133. typedef struct _cpECCP IppsECCPState;
  134. typedef struct _cpECCPPoint IppsECCPPointState;
  135. /* operation result */
  136. typedef enum {
  137. ippECValid, /* validation pass successfully */
  138. ippECCompositeBase, /* field based on composite */
  139. ippECComplicatedBase, /* number of non-zero terms in the polynomial (> PRIME_ARR_MAX) */
  140. ippECIsZeroDiscriminant,/* zero discriminant */
  141. ippECCompositeOrder, /* composite order of base point */
  142. ippECInvalidOrder, /* invalid base point order */
  143. ippECIsWeakMOV, /* weak Meneze-Okamoto-Vanstone reduction attack */
  144. ippECIsWeakSSSA, /* weak Semaev-Smart,Satoh-Araki reduction attack */
  145. ippECIsSupersingular, /* supersingular curve */
  146. ippECInvalidPrivateKey, /* !(0 < Private < order) */
  147. ippECInvalidPublicKey, /* (order*PublicKey != Infinity) */
  148. ippECInvalidKeyPair, /* (Private*BasePoint != PublicKey) */
  149. ippECPointOutOfGroup, /* out of group (order*P != Infinity) */
  150. ippECPointIsAtInfinite, /* point (P=(Px,Py)) at Infinity */
  151. ippECPointIsNotValid, /* point (P=(Px,Py)) out-of EC */
  152. ippECPointIsEqual, /* compared points are equal */
  153. ippECPointIsNotEqual, /* compared points are different */
  154. ippECInvalidSignature /* invalid signature */
  155. } IppECResult;
  156. typedef enum {
  157. ippECarbitrary =0x00000, IppECCArbitrary = 0x00000, /* arbitrary ECC */
  158. ippECPstd = 0x10000, IppECCPStd = 0x10000, /* random (recommended) EC over FG(p): */
  159. ippECPstd112r1 = ippECPstd, IppECCPStd112r1 = IppECCPStd, /* secp112r1 curve */
  160. ippECPstd112r2 = ippECPstd+1, IppECCPStd112r2 = IppECCPStd+1, /* secp112r2 curve */
  161. ippECPstd128r1 = ippECPstd+2, IppECCPStd128r1 = IppECCPStd+2, /* secp128r1 curve */
  162. ippECPstd128r2 = ippECPstd+3, IppECCPStd128r2 = IppECCPStd+3, /* secp128r2 curve */
  163. ippECPstd160r1 = ippECPstd+4, IppECCPStd160r1 = IppECCPStd+4, /* secp160r1 curve */
  164. ippECPstd160r2 = ippECPstd+5, IppECCPStd160r2 = IppECCPStd+5, /* secp160r2 curve */
  165. ippECPstd192r1 = ippECPstd+6, IppECCPStd192r1 = IppECCPStd+6, /* secp192r1 curve */
  166. ippECPstd224r1 = ippECPstd+7, IppECCPStd224r1 = IppECCPStd+7, /* secp224r1 curve */
  167. ippECPstd256r1 = ippECPstd+8, IppECCPStd256r1 = IppECCPStd+8, /* secp256r1 curve */
  168. ippECPstd384r1 = ippECPstd+9, IppECCPStd384r1 = IppECCPStd+9, /* secp384r1 curve */
  169. ippECPstd521r1 = ippECPstd+10, IppECCPStd521r1 = IppECCPStd+10, /* secp521r1 curve */
  170. } IppsECType, IppECCType;
  171. #ifdef __cplusplus
  172. }
  173. #endif
  174. #endif /* __IPPCPDEFS_H__ */