net-snmp 5.7
scapi.h
00001 /*
00002  * scapi.h
00003  */
00004 
00005 #ifndef _SCAPI_H
00006 #define _SCAPI_H
00007 
00008 #ifdef __cplusplus
00009 extern          "C" {
00010 #endif
00011 
00012     /*
00013      * Authentication/privacy transform bitlengths.
00014      */
00015 #define SNMP_TRANS_AUTHLEN_HMACMD5      128
00016 #define SNMP_TRANS_AUTHLEN_HMACSHA1     160
00017 
00018 #define SNMP_TRANS_AUTHLEN_HMAC96       96
00019 
00020 #define SNMP_TRANS_PRIVLEN_1DES         64
00021 #define SNMP_TRANS_PRIVLEN_1DES_IV      64
00022 
00023 #define SNMP_TRANS_PRIVLEN_AES          128
00024 #define SNMP_TRANS_PRIVLEN_AES_IV       128
00025 #define SNMP_TRANS_AES_PADSIZE          128  /* backwards compat */
00026 #define SNMP_TRANS_PRIVLEN_AES128       128  /* backwards compat */
00027 #define SNMP_TRANS_PRIVLEN_AES128_IV    128  /* backwards compat */
00028 #define SNMP_TRANS_AES_AES128_PADSIZE   128  /* backwards compat */
00029 
00030     /*
00031      * Prototypes.
00032      */
00033     int             sc_get_properlength(const oid * hashtype,
00034                                         u_int hashtype_len);
00035     int             sc_get_proper_priv_length(const oid * privtype,
00036                                               u_int privtype_len);
00037 
00038     NETSNMP_IMPORT
00039     int             sc_init(void);
00040     int             sc_shutdown(int majorID, int minorID, void *serverarg,
00041                                 void *clientarg);
00042 
00043     int             sc_random(u_char * buf, size_t * buflen);
00044 
00045     int             sc_generate_keyed_hash(const oid * authtype,
00046                                            size_t authtypelen,
00047                                            const u_char * key, u_int keylen,
00048                                            const u_char * message, u_int msglen,
00049                                            u_char * MAC, size_t * maclen);
00050 
00051     int             sc_check_keyed_hash(const oid * authtype,
00052                                         size_t authtypelen, const u_char * key,
00053                                         u_int keylen, const u_char * message,
00054                                         u_int msglen, const u_char * MAC,
00055                                         u_int maclen);
00056 
00057     int             sc_encrypt(const oid * privtype, size_t privtypelen,
00058                                u_char * key, u_int keylen,
00059                                u_char * iv, u_int ivlen,
00060                                const u_char * plaintext, u_int ptlen,
00061                                u_char * ciphertext, size_t * ctlen);
00062 
00063     int             sc_decrypt(const oid * privtype, size_t privtypelen,
00064                                u_char * key, u_int keylen,
00065                                u_char * iv, u_int ivlen,
00066                                u_char * ciphertext, u_int ctlen,
00067                                u_char * plaintext, size_t * ptlen);
00068 
00069     int             sc_hash(const oid * hashtype, size_t hashtypelen,
00070                             const u_char * buf, size_t buf_len,
00071                             u_char * MAC, size_t * MAC_len);
00072 
00073     int             sc_get_transform_type(oid * hashtype,
00074                                           u_int hashtype_len,
00075                                           int (**hash_fn) (const int mode,
00076                                                            void **context,
00077                                                            const u_char *
00078                                                            data,
00079                                                            const int
00080                                                            data_len,
00081                                                            u_char **
00082                                                            digest,
00083                                                            size_t *
00084                                                            digest_len));
00085 
00086 
00087     /*
00088      * All functions devolve to the following block if we can't do cryptography
00089      */
00090 #define _SCAPI_NOT_CONFIGURED                                   \
00091 {                                                               \
00092         snmp_log(LOG_ERR, "Encryption support not enabled.\n"); \
00093         DEBUGMSGTL(("scapi", "SCAPI not configured"));          \
00094         return SNMPERR_SC_NOT_CONFIGURED;                       \
00095 }
00096 
00097     /*
00098      * define a transform type if we're using the internal md5 support 
00099      */
00100 #ifdef NETSNMP_USE_INTERNAL_MD5
00101 #define INTERNAL_MD5 1
00102 #endif
00103 
00104 #ifdef __cplusplus
00105 }
00106 #endif
00107 #endif                          /* _SCAPI_H */