29 #ifndef _SNMP_USM_V3_H_ 30 #define _SNMP_USM_V3_H_ 41 #ifdef SNMP_PP_NAMESPACE 46 #define MAXUINT32 4294967295u 50 #define MAXLEN_USMUSERNAME 32 51 #define MAXLEN_USMSECURITYNAME MAXLEN_USMUSERNAME 53 #define SNMPv3_AUTHFLAG 0x01 54 #define SNMPv3_PRIVFLAG 0x02 55 #define SNMPv3_REPORTABLEFLAG 0x04 69 #define SNMP_SECURITY_LEVEL_NOAUTH_NOPRIV 1 70 #define SNMP_SECURITY_LEVEL_AUTH_NOPRIV 2
71 #define SNMP_SECURITY_LEVEL_AUTH_PRIV 3
80 #define SNMP_AUTHPROTOCOL_NONE 1 81 #define SNMP_AUTHPROTOCOL_HMACMD5 2
82 #define SNMP_AUTHPROTOCOL_HMACSHA 3
83 #define SNMP_AUTHPROTOCOL_HMAC128SHA224 4
84 #define SNMP_AUTHPROTOCOL_HMAC192SHA256 5
85 #define SNMP_AUTHPROTOCOL_HMAC256SHA384 6
86 #define SNMP_AUTHPROTOCOL_HMAC384SHA512 7
95 #define SNMP_PRIVPROTOCOL_NONE 1 96 #define SNMP_PRIVPROTOCOL_DES 2
97 #define SNMP_PRIVPROTOCOL_AES128 4
99 #define SNMP_PRIVPROTOCOL_IDEA 9 100 #define SNMP_PRIVPROTOCOL_AES192 20
101 #define SNMP_PRIVPROTOCOL_AES256 21
102 #define SNMP_PRIVPROTOCOL_3DESEDE 3
103 #define SNMP_PRIVPROTOCOL_AES128W3DESKEYEXT 22
104 #define SNMP_PRIVPROTOCOL_AES192W3DESKEYEXT 23
105 #define SNMP_PRIVPROTOCOL_AES256W3DESKEYEXT 24
114 #define SNMPv3_USM_OK 1400 115 #define SNMPv3_USM_ERROR 1401 116 #define SNMPv3_USM_ERROR_CONFIGFILE 1402 117 #define SNMPv3_USM_UNSUPPORTED_SECURITY_LEVEL 1403 118 #define SNMPv3_USM_UNKNOWN_SECURITY_NAME 1404 119 #define SNMPv3_USM_ENCRYPTION_ERROR 1405 120 #define SNMPv3_USM_DECRYPTION_ERROR 1406 121 #define SNMPv3_USM_AUTHENTICATION_ERROR 1407 122 #define SNMPv3_USM_AUTHENTICATION_FAILURE 1408 123 #define SNMPv3_USM_PARSE_ERROR 1409 124 #define SNMPv3_USM_UNKNOWN_ENGINEID 1410 125 #define SNMPv3_USM_NOT_IN_TIME_WINDOW 1411 126 #define SNMPv3_USM_UNSUPPORTED_AUTHPROTOCOL 1412 127 #define SNMPv3_USM_UNSUPPORTED_PRIVPROTOCOL 1413 128 #define SNMPv3_USM_ADDRESS_ERROR 1414 129 #define SNMPv3_USM_FILECREATE_ERROR 1415 130 #define SNMPv3_USM_FILEOPEN_ERROR 1416 131 #define SNMPv3_USM_FILERENAME_ERROR 1417 132 #define SNMPv3_USM_FILEDELETE_ERROR 1418 133 #define SNMPv3_USM_FILEWRITE_ERROR 1419 134 #define SNMPv3_USM_FILEREAD_ERROR 1420 139 #define SNMPv3_USM_MAX_ERROR SNMPv3_USM_FILEREAD_ERROR 140 #define SNMPv3_USM_MIN_ERROR SNMPv3_USM_OK 141 #define SNMPv3_USM_ERRORCOUNT SNMPv3_USM_MAX_ERROR - SNMPv3_USM_MIN_ERROR 144 #define oidUsmStats "1.3.6.1.6.3.15.1.1" 145 #define oidUsmStatsUnsupportedSecLevels "1.3.6.1.6.3.15.1.1.1.0" 146 #define oidUsmStatsNotInTimeWindows "1.3.6.1.6.3.15.1.1.2.0" 147 #define oidUsmStatsUnknownUserNames "1.3.6.1.6.3.15.1.1.3.0" 148 #define oidUsmStatsUnknownEngineIDs "1.3.6.1.6.3.15.1.1.4.0" 149 #define oidUsmStatsWrongDigests "1.3.6.1.6.3.15.1.1.5.0" 150 #define oidUsmStatsDecryptionErrors "1.3.6.1.6.3.15.1.1.6.0" 152 #define oidUsmUserTable "1.3.6.1.6.3.15.1.2.2" 153 #define oidUsmUserEntry "1.3.6.1.6.3.15.1.2.2.1" 155 #define oidUsmAuthProtocolBase "1.3.6.1.6.3.10.1.1" 156 #define oidUsmNoAuthProtocol "1.3.6.1.6.3.10.1.1.1" 157 #define oidUsmHMACMD5AuthProtocol "1.3.6.1.6.3.10.1.1.2" 158 #define oidUsmHMACSHAAuthProtocol "1.3.6.1.6.3.10.1.1.3" 160 #define oidUsmPrivProtocolBase "1.3.6.1.6.3.10.1.2" 161 #define oidUsmNoPrivProtocol "1.3.6.1.6.3.10.1.2.1" 162 #define oidUsmDESPrivProtocol "1.3.6.1.6.3.10.1.2.2" 163 #define oidUsmIDEAPrivProtocol "1.3.6.1.6.3.10.1.2.9" 164 #define oidUsmAES128PrivProtocol "1.3.6.1.6.3.10.1.2.4" 165 #define oidUsmAES192PrivProtocol "1.3.6.1.6.3.10.1.2.20" 166 #define oidUsmAES256PrivProtocol "1.3.6.1.6.3.10.1.2.21" 167 #define oidUsm3DESEDEPrivProtocol "1.3.6.1.6.3.10.1.2.3" 170 #define USM_KeyUpdate 1 171 #define USM_PasswordUpdate 2 172 #define USM_PasswordKeyUpdate 3 173 #define USM_PasswordAllKeyUpdate 4 212 const OctetStr &usm_user_security_name,
213 const int auth_protocol,
215 const int priv_protocol,
218 struct SecurityStateReference;
222 class USMUserNameTable;
256 USM(
unsigned int engine_boots,
const OctetStr &engine_id,
const v3MP *v3_mp,
257 unsigned int *msg_id,
int &result);
305 int add_usm_user(
const OctetStr& security_name,
306 const long int auth_protocol,
307 const long int priv_protocol,
333 int add_usm_user(
const OctetStr& user_name,
335 const long int auth_protocol,
336 const long int priv_protocol,
369 int add_usm_user(
const OctetStr& user_name,
371 const long int auth_protocol,
372 const long int priv_protocol,
378 const long int auth_protocol,
379 const long int priv_protocol,
383 {
return add_usm_user(security_name, security_name, auth_protocol,
384 priv_protocol, auth_password, priv_password,
394 void delete_usm_user(
const OctetStr& security_name);
405 int save_localized_users(
const char *file);
415 int load_localized_users(
const char *file);
425 int save_users(
const char *file);
435 int load_users(
const char *file);
459 int add_localized_user(
const OctetStr &engine_id,
462 const long auth_protocol,
464 const long priv_protocol,
485 int build_localized_keys(
const OctetStr &engine_id,
488 const unsigned char *auth_password,
489 const unsigned int auth_password_len,
490 const unsigned char *priv_password,
491 const unsigned int priv_password_len,
492 unsigned char *auth_key,
493 unsigned int *auth_key_len,
494 unsigned char *priv_key,
495 unsigned int *priv_key_len);
505 int delete_localized_user(
const OctetStr& user_name);
518 int delete_localized_user(
const OctetStr& engine_id,
540 int remove_time_information(
const OctetStr &engine_id);
558 int update_key(
const unsigned char* user_name,
const long user_name_len,
559 const unsigned char* engine_id,
const long engine_id_len,
560 const unsigned char* new_key,
const long new_key_len,
561 const int type_of_key);
585 void free_user(
struct UsmUser *&user);
597 int get_security_name(
const unsigned char *user_name,
598 const long int user_name_len,
614 int get_user_name(
unsigned char *user_name,
615 long int *user_name_len,
616 const unsigned char *security_name,
617 const long int security_name_len);
644 struct UsmKeyUpdate* key_update_prepare(
const OctetStr& securityName,
658 void key_update_abort(
struct UsmKeyUpdate *uku);
670 int key_update_commit(
struct UsmKeyUpdate *uku,
int update_type);
691 int get_time(
const OctetStr &engine_id,
692 long int *engine_boots,
long int *engine_time);
705 int get_local_time(
long int *engine_boots,
long int *engine_time)
const;
719 {
return usmStatsUnsupportedSecLevels; };
727 {
return usmStatsNotInTimeWindows; };
735 {
return usmStatsUnknownUserNames; };
743 {
return usmStatsUnknownEngineIDs; };
751 {
return usmStatsWrongDigests; };
759 {
return usmStatsDecryptionErrors; };
765 void inc_stats_unsupported_sec_levels();
766 void inc_stats_not_in_time_windows();
767 void inc_stats_unknown_user_names();
768 void inc_stats_unknown_engine_ids();
769 void inc_stats_wrong_digests();
770 void inc_stats_decryption_errors();
777 void lock_user_name_table();
799 void unlock_user_name_table();
805 void lock_user_table();
827 void unlock_user_table();
837 void delete_sec_state_reference(
struct SecurityStateReference *ssr);
881 int get_user_count()
const;
899 int remove_all_users();
908 struct SecurityStateReference *get_new_sec_state_reference();
935 unsigned char *globalData,
936 int globalDataLength,
941 unsigned char *scopedPDU,
943 struct SecurityStateReference *securityStateReference,
944 unsigned char *wholeMsg,
945 int *wholeMsgLength);
978 unsigned char *securityParameters,
979 int securityParametersLength,
980 int securityParametersPosition,
981 long int securityLevel,
982 unsigned char *wholeMsg,
984 unsigned char *msgData,
988 unsigned char *scopedPDU,
989 int *scopedPDULength,
990 long *maxSizeResponseScopedPDU,
991 struct SecurityStateReference *securityStateReference,
1003 void delete_sec_parameters(
struct UsmSecurityParameters *usp);
1032 unsigned char *build_sec_params(
unsigned char *outBuf,
int *maxLength,
1033 struct UsmSecurityParameters sp,
1054 unsigned char *build_whole_msg(
1055 unsigned char *outBuf,
int *maxLength,
1056 unsigned char *globalData,
long int globalDataLength,
1057 int *positionAuthPar,
1058 struct UsmSecurityParameters securityParameters,
1059 unsigned char *msgData,
long int msgDataLength);
1067 inline void delete_user_ptr(
struct UsmUser *user);
1107 #define SecurityLevel_noAuthNoPriv SNMP_SECURITY_LEVEL_NOAUTH_NOPRIV 1108 #define SecurityLevel_authNoPriv SNMP_SECURITY_LEVEL_AUTH_NOPRIV 1109 #define SecurityLevel_authPriv SNMP_SECURITY_LEVEL_AUTH_PRIV 1111 #define SNMPv3_usmNoAuthProtocol SNMP_AUTHPROTOCOL_NONE 1112 #define SNMPv3_usmHMACMD5AuthProtocol SNMP_AUTHPROTOCOL_HMACMD5 1113 #define SNMPv3_usmHMACSHAAuthProtocol SNMP_AUTHPROTOCOL_HMACSHA 1115 #define SNMPv3_usmNoPrivProtocol SNMP_PRIVPROTOCOL_NONE 1116 #define SNMPv3_usmDESPrivProtocol SNMP_PRIVPROTOCOL_DES 1117 #define SNMPv3_usmIDEAPrivProtocol SNMP_PRIVPROTOCOL_IDEA 1118 #define SNMPv3_usmAES128PrivProtocol SNMP_PRIVPROTOCOL_AES128 1119 #define SNMPv3_usmAES192PrivProtocol SNMP_PRIVPROTOCOL_AES192 1120 #define SNMPv3_usmAES256PrivProtocol SNMP_PRIVPROTOCOL_AES256 1122 #ifdef SNMP_PP_NAMESPACE 1128 #endif // _SNMP_USM_V3_H_
long int authPasswordLength
Class that holds all authentication and privacy protocols for a snmp entity.
unsigned long get_stats_unsupported_sec_levels() const
Get the number of received messages with an unsupported securityLevel.
unsigned int usmStatsWrongDigests
unsigned int usmStatsUnknownUserNames
long int usmUserAuthProtocol
unsigned long get_stats_decryption_errors() const
Get the number of received messages with decryption errors.
long int usmUserAuthProtocol
USMUserTable * usm_user_table
long int usmUserEngineIDLength
OctetStr local_snmp_engine_id
local snmp engine id
long int usmUserSecurityNameLength
long int usmUserPrivKeyLength
long int usmUserAuthKeyLength
long int privPasswordLength
unsigned int usmStatsNotInTimeWindows
long int usmUserNameLength
unsigned int usmStatsDecryptionErrors
The SNMPv3 Message Processing Model (v3MP).
USMUserNameTable * usm_user_name_table
unsigned int usmStatsUnknownEngineIDs
unsigned long get_stats_wrong_digests() const
Get the number of received messages with a wrong digest.
long int usmUserPrivProtocol
int add_usm_user(const OctetStr &security_name, const long int auth_protocol, const long int priv_protocol, const OctetStr &auth_password, const OctetStr &priv_password, const OctetStr &engine_id)
long int usmUserNameLength
unsigned int usmStatsUnsupportedSecLevels
int remove_engine_id(const OctetStr &engine_id)
Remove all occurences of this engine id from v3MP and USM.
unsigned long get_stats_unknown_engine_ids() const
Get the number of received messages with a unknown engineID.
OctetStr usmUserSecurityName
unsigned long get_stats_unknown_user_names() const
Get the number of received messages with a unknown userName.
USMTimeTable * usm_time_table
void set_discovery_mode()
Enables the discovery mode of the USM, i.e.
void unset_discovery_mode()
Disables the discovery mode of the USM, i.e.
This is the class for the User Based Security Model.
unsigned long get_stats_not_in_time_windows() const
Get the number of received messages outside time window.
long int usmUserPrivProtocol
long int securityNameLength
bool is_discovery_enabled() const
Return TRUE if the USM discovery mode is enabled, FALSE else.
void(* usm_add_user_callback)(const OctetStr &engine_id, const OctetStr &usm_user_name, const OctetStr &usm_user_security_name, const int auth_protocol, const OctetStr &auth_key, const int priv_protocol, const OctetStr &priv_key)
const OctetStr & get_local_engine_id() const
Return the local snmp engine id.
Abstract class used to provide a virtual interface into Targets.
usm_add_user_callback usm_add_user_cb
const v3MP * v3mp
Pointer to the v3MP that created this object.