| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 | 
							- #ifndef _DEF_SM_H
 
- #define _DEF_SM_H
 
- #include <cstddef>
 
- //#ifdef __GNUC__
 
- //#ifdef __i386
 
- //typedef unsigned int size_t;
 
- //#else
 
- //typedef long unsigned int size_t;
 
- //#endif // __i386
 
- //#endif
 
- typedef unsigned char uint8_t;
 
- typedef unsigned int  uint32_t;
 
- /*
 
- * 32-bit integer manipulation macros (big endian)
 
- */
 
- #ifndef GET_ULONG_BE
 
- #define GET_ULONG_BE(n,b,i)                             \
 
- {                                                       \
 
-     (n) = ( (unsigned long) (b)[(i)    ] << 24 )        \
 
-         | ( (unsigned long) (b)[(i) + 1] << 16 )        \
 
-         | ( (unsigned long) (b)[(i) + 2] <<  8 )        \
 
-         | ( (unsigned long) (b)[(i) + 3]       );       \
 
- }
 
- #endif
 
- #ifndef PUT_ULONG_BE
 
- #define PUT_ULONG_BE(n,b,i)                             \
 
- {                                                       \
 
-     (b)[(i)    ] = (unsigned char) ( (n) >> 24 );       \
 
-     (b)[(i) + 1] = (unsigned char) ( (n) >> 16 );       \
 
-     (b)[(i) + 2] = (unsigned char) ( (n) >>  8 );       \
 
-     (b)[(i) + 3] = (unsigned char) ( (n)       );       \
 
- }
 
- #endif
 
- #define FF0(x,y,z) ( (x) ^ (y) ^ (z)) 
 
- #define FF1(x,y,z) (((x) & (y)) | ( (x) & (z)) | ( (y) & (z)))
 
- #define GG0(x,y,z) ( (x) ^ (y) ^ (z)) 
 
- #define GG1(x,y,z) (((x) & (y)) | ( (~(x)) & (z)) )
 
- /*
 
- * rotate shift left marco definition
 
- */
 
- #define SHL(x,n) (((x) & 0xFFFFFFFF) << n)
 
- #define ROTL(x,n) (SHL((x),n) | ((x) >> (32 - n)))
 
- #define SWAP(a,b) { unsigned long t = a; a = b; b = t; t = 0; }
 
- #define P0(x) ((x) ^  ROTL((x),9) ^ ROTL((x),17)) 
 
- #define P1(x) ((x) ^  ROTL((x),15) ^ ROTL((x),23)) 
 
- struct st_point
 
- {
 
- 	uint8_t x[32];
 
- 	uint8_t y[32];
 
- };
 
- /**
 
- * \brief          SM2 context structure
 
- */
 
- struct sm2_context
 
- {
 
- 	st_point pubkey;
 
- 	uint8_t prikey[32];
 
- };
 
- /**
 
- * \brief          SM3 context structure
 
- */
 
- struct sm3_context
 
- {
 
- 	unsigned long total[2];     /*!< number of bytes processed  */
 
- 	unsigned long state[8];     /*!< intermediate digest state  */
 
- 	unsigned char buffer[64];   /*!< data block being processed */
 
- 	unsigned char ipad[64];     /*!< HMAC: inner padding        */
 
- 	unsigned char opad[64];     /*!< HMAC: outer padding        */
 
- };
 
- /**
 
- * \brief          SM4 context structure
 
- */
 
- struct sm4_context
 
- {
 
- 	uint32_t sk[32];       /*!<  SM4 subkeys          */
 
- };
 
- #endif // _DEF_SM_H
 
 
  |