scapi.h
上传用户:wxp200602
上传日期:2007-10-30
资源大小:4028k
文件大小:4k
源码类别:

SNMP编程

开发平台:

Unix_Linux

  1. /*
  2.  * scapi.h
  3.  */
  4. #ifndef _SCAPI_H
  5. #define _SCAPI_H
  6. #ifdef __cplusplus
  7. extern          "C" {
  8. #endif
  9.     /*
  10.      * Authentication/privacy transform bitlengths.
  11.      */
  12. #define SNMP_TRANS_AUTHLEN_HMACMD5 128
  13. #define SNMP_TRANS_AUTHLEN_HMACSHA1 160
  14. #define SNMP_TRANS_AUTHLEN_HMAC96 96
  15. #define SNMP_TRANS_PRIVLEN_1DES 64
  16. #define SNMP_TRANS_PRIVLEN_1DES_IV 64
  17. #define SNMP_TRANS_PRIVLEN_AES 128
  18. #define SNMP_TRANS_PRIVLEN_AES_IV 128
  19. #define SNMP_TRANS_AES_PADSIZE     128  /* backwards compat */
  20. #define SNMP_TRANS_PRIVLEN_AES128 128  /* backwards compat */
  21. #define SNMP_TRANS_PRIVLEN_AES128_IV 128  /* backwards compat */
  22. #define SNMP_TRANS_AES_AES128_PADSIZE   128  /* backwards compat */
  23.     /*
  24.      * Prototypes.
  25.      */
  26.     int             sc_get_properlength(const oid * hashtype,
  27.                                         u_int hashtype_len);
  28.     int             sc_get_proper_priv_length(const oid * privtype,
  29.                                               u_int privtype_len);
  30.     int             sc_init(void);
  31.     int             sc_shutdown(int majorID, int minorID, void *serverarg,
  32.                                 void *clientarg);
  33.     int             sc_random(u_char * buf, size_t * buflen);
  34.     int             sc_generate_keyed_hash(const oid * authtype,
  35.                                            size_t authtypelen,
  36.                                            u_char * key, u_int keylen,
  37.                                            u_char * message, u_int msglen,
  38.                                            u_char * MAC, size_t * maclen);
  39.     int             sc_check_keyed_hash(const oid * authtype,
  40.                                         size_t authtypelen, u_char * key,
  41.                                         u_int keylen, u_char * message,
  42.                                         u_int msglen, u_char * MAC,
  43.                                         u_int maclen);
  44.     int             sc_encrypt(const oid * privtype, size_t privtypelen,
  45.                                u_char * key, u_int keylen,
  46.                                u_char * iv, u_int ivlen,
  47.                                u_char * plaintext, u_int ptlen,
  48.                                u_char * ciphertext, size_t * ctlen);
  49.     int             sc_decrypt(const oid * privtype, size_t privtypelen,
  50.                                u_char * key, u_int keylen,
  51.                                u_char * iv, u_int ivlen,
  52.                                u_char * ciphertext, u_int ctlen,
  53.                                u_char * plaintext, size_t * ptlen);
  54.     int             sc_hash(const oid * hashtype, size_t hashtypelen,
  55.                             u_char * buf, size_t buf_len,
  56.                             u_char * MAC, size_t * MAC_len);
  57.     int             sc_get_transform_type(oid * hashtype,
  58.                                           u_int hashtype_len,
  59.                                           int (**hash_fn) (const int mode,
  60.                                                            void **context,
  61.                                                            const u_char *
  62.                                                            data,
  63.                                                            const int
  64.                                                            data_len,
  65.                                                            u_char **
  66.                                                            digest,
  67.                                                            size_t *
  68.                                                            digest_len));
  69.     /*
  70.      * All functions devolve to the following block if we can't do cryptography
  71.      */
  72. #define _SCAPI_NOT_CONFIGURED
  73. {
  74.         snmp_log(LOG_ERR, "Encryption support not enabled.n"); 
  75.         DEBUGMSGTL(("scapi", "SCAPI not configured"));
  76. return SNMPERR_SC_NOT_CONFIGURED;
  77. }
  78.     /*
  79.      * define a transform type if we're using the internal md5 support 
  80.      */
  81. #ifdef USE_INTERNAL_MD5
  82. #define INTERNAL_MD5 1
  83. #endif
  84. #ifdef __cplusplus
  85. }
  86. #endif
  87. #endif                          /* _SCAPI_H */