text: //
  //  HGBKeybordSM4.h
  //  HelloCordova
  //
  //  Created by huangguangbao on 2017/8/9.
  //
  //
  
  #ifndef HGBKeybordSM4_h
  #define HGBKeybordSM4_h
  
  #define SM4_ENCRYPT     1
  #define SM4_DECRYPT     0
  
  /**
   * \brief          SM4 context structure
   */
  typedef struct
  {
      int mode;                   /*!<  encrypt/decrypt   */
      unsigned long sk[32];       /*!<  SM4 subkeys       */
  }
  sm4_context;
  
  
  #ifdef __cplusplus
  extern "C" {
  #endif
  
      /**
       * \brief          SM4 key schedule (128-bit, encryption)
       *
       * \param ctx      SM4 context to be initialized
       * \param key      16-byte secret key
       */
      void hgbkeybordsm4_setkey_enc( sm4_context *ctx, unsigned char key[16] );
  
      /**
       * \brief          SM4 key schedule (128-bit, decryption)
       *
       * \param ctx      SM4 context to be initialized
       * \param key      16-byte secret key
       */
      void hgbkeybordsm4_setkey_dec( sm4_context *ctx, unsigned char key[16] );
  
      /**
       * \brief          SM4-ECB block encryption/decryption
       * \param ctx      SM4 context
       * \param mode     SM4_ENCRYPT or SM4_DECRYPT
       * \param length   length of the input data
       * \param input    input block
       * \param output   output block
       */
      void hgbkeybordsm4_crypt_ecb( sm4_context *ctx,
                            int mode,
                            int length,
                            unsigned char *input,
                            unsigned char *output);
  
      /**
       * \brief          SM4-CBC buffer encryption/decryption
       * \param ctx      SM4 context
       * \param mode     SM4_ENCRYPT or SM4_DECRYPT
       * \param length   length of the input data
       * \param iv       initialization vector (updated after use)
       * \param input    buffer holding the input data
       * \param output   buffer holding the output data
       */
      void hgbkeybordsm4_crypt_cbc( sm4_context *ctx,
                            int mode,
                            int length,
                            unsigned char iv[16],
                            unsigned char *input,
                            unsigned char *output );
  
  #ifdef __cplusplus
  }
  #endif
  
  #endif /* HGBKeybordSM4_h */
  