Go to the documentation of this file.
32 #define TRACE_LEVEL SNMP_TRACE_LEVEL
46 #if (SNMP_USM_MIB_SUPPORT == ENABLED)
82 TRACE_INFO(
"Initializing SNMP-USM-MIB base...\r\n");
162 value->integer, commit);
202 #if (SNMP_USM_MIB_SET_SUPPORT == ENABLED)
206 size_t userEngineIdLen;
237 if(userName[0] ==
'\0')
250 if(
osStrcmp(object->name,
"usmUserCloneFrom") == 0)
315 else if(
osStrcmp(object->name,
"usmUserAuthProtocol") == 0)
397 else if(
osStrcmp(object->name,
"usmUserAuthKeyChange") == 0 ||
398 osStrcmp(object->name,
"usmUserOwnAuthKeyChange") == 0)
407 if(
osStrcmp(object->name,
"usmUserOwnAuthKeyChange") == 0)
445 else if(
osStrcmp(object->name,
"usmUserPrivProtocol") == 0)
501 else if(
osStrcmp(object->name,
"usmUserPrivKeyChange") == 0 ||
502 osStrcmp(object->name,
"usmUserOwnPrivKeyChange") == 0)
511 if(
osStrcmp(object->name,
"usmUserOwnPrivKeyChange") == 0)
549 else if(
osStrcmp(object->name,
"usmUserPublic") == 0)
586 else if(
osStrcmp(object->name,
"usmUserStorageType") == 0)
600 else if(
osStrcmp(object->name,
"usmUserStatus") == 0)
794 size_t userEngineIdLen;
827 if(userEngineIdLen != context->contextEngineLen)
831 if(
osMemcmp(userEngineId, context->contextEngine, userEngineIdLen))
841 if(
osStrcmp(object->name,
"usmUserSecurityName") == 0)
861 else if(
osStrcmp(object->name,
"usmUserCloneFrom") == 0)
864 uint8_t zeroDotZeroOid[] = {0};
867 if(*valueLen >=
sizeof(zeroDotZeroOid))
870 osMemcpy(
value->octetString, zeroDotZeroOid,
sizeof(zeroDotZeroOid));
872 *valueLen =
sizeof(zeroDotZeroOid);
881 else if(
osStrcmp(object->name,
"usmUserAuthProtocol") == 0)
883 size_t authProtocolLen;
884 const uint8_t *authProtocol;
927 if(*valueLen >= authProtocolLen)
932 *valueLen = authProtocolLen;
941 else if(
osStrcmp(object->name,
"usmUserAuthKeyChange") == 0)
947 else if(
osStrcmp(object->name,
"usmUserOwnAuthKeyChange") == 0)
953 else if(
osStrcmp(object->name,
"usmUserPrivProtocol") == 0)
955 size_t privProtocolLen;
956 const uint8_t *privProtocol;
979 if(*valueLen >= privProtocolLen)
984 *valueLen = privProtocolLen;
993 else if(
osStrcmp(object->name,
"usmUserPrivKeyChange") == 0)
999 else if(
osStrcmp(object->name,
"usmUserOwnPrivKeyChange") == 0)
1005 else if(
osStrcmp(object->name,
"usmUserPublic") == 0)
1024 else if(
osStrcmp(object->name,
"usmUserStorageType") == 0)
1030 else if(
osStrcmp(object->name,
"usmUserStatus") == 0)
1058 size_t oidLen, uint8_t *nextOid,
size_t *nextOidLen)
1078 if(*nextOidLen < object->
oidLen)
1082 osMemcpy(nextOid, object->oid, object->oidLen);
1088 entry = &context->userTable[i];
1098 context->contextEngine, context->contextEngineLen,
FALSE);
1114 if(nextEntry == NULL)
1145 if(nextEntry == NULL)
1153 context->contextEngine, context->contextEngineLen,
FALSE);
@ MIB_ROW_STATUS_NOT_IN_SERVICE
error_t mibEncodeString(uint8_t *oid, size_t maxOidLen, size_t *pos, const char_t *string, bool_t implied)
Encode instance identifier (string)
@ SNMP_AUTH_PROTOCOL_MD5
HMAC-MD5-96.
uint32_t netGetRandRange(uint32_t min, uint32_t max)
Generate a random value in the specified range.
@ MIB_ROW_STATUS_CREATE_AND_GO
@ MIB_STORAGE_TYPE_NON_VOLATILE
uint8_t publicValue[SNMP_MAX_PUBLIC_VALUE_SIZE]
Public value.
SnmpKey localizedPrivKey
Localized privacy key.
@ SNMP_AUTH_PROTOCOL_SHA224
HMAC-SHA-224-128.
SnmpAccess mode
Access mode.
const uint8_t usmHMAC384SHA512AuthProtocolOid[9]
#define SNMP_AGENT_MAX_USERS
@ SNMP_AUTH_PROTOCOL_SHA384
HMAC-SHA-384-256.
#define osMemcmp(p1, p2, length)
@ SNMP_SECURITY_MODEL_USM
User-based security model.
const uint8_t usmUserEntryOid[10]
@ MIB_ROW_STATUS_NOT_READY
int_t oidComp(const uint8_t *oid1, size_t oidLen1, const uint8_t *oid2, size_t oidLen2)
Compare object identifiers.
@ MIB_STORAGE_TYPE_READ_ONLY
SNMP agent (Simple Network Management Protocol)
error_t snmpUsmMibLoad(void *context)
Load SNMP USM MIB module.
void snmpCloneSecurityParameters(SnmpUserEntry *user, const SnmpUserEntry *cloneFromUser)
Clone security parameters.
SnmpUserEntry * snmpCreateUserEntry(SnmpAgentContext *context)
Create a new user entry.
const uint8_t usmHMACMD5AuthProtocolOid[9]
size_t publicValueLen
Length of the public value.
SnmpKey localizedAuthKey
Localized authentication key.
error_t snmpUsmMibGetUserSpinLock(const MibObject *object, const uint8_t *oid, size_t oidLen, MibVariant *value, size_t *valueLen)
Get usmUserSpinLock object value.
error_t snmpUsmMibSetUserEntry(const MibObject *object, const uint8_t *oid, size_t oidLen, const MibVariant *value, size_t valueLen, bool_t commit)
Set usmUserEntry object value.
SnmpUsmMibBase snmpUsmMibBase
SNMP USM MIB base.
#define osMemcpy(dest, src, length)
@ SNMP_PRIV_PROTOCOL_NONE
No privacy.
@ ERROR_INSTANCE_NOT_FOUND
const uint8_t usmHMAC192SHA256AuthProtocolOid[9]
#define SNMP_MAX_USER_NAME_LEN
SnmpUserEntry * snmpFindUserEntry(SnmpAgentContext *context, const char_t *name, size_t length)
Search the user table for a given user name.
const uint8_t usmHMAC128SHA224AuthProtocolOid[9]
const uint8_t usmHMACSHAAuthProtocolOid[9]
@ SNMP_AUTH_PROTOCOL_SHA256
HMAC-SHA-256-192.
void snmpUsmMibUnlock(void)
Unlock SNMP USM MIB base.
const HashAlgo * snmpGetHashAlgo(SnmpAuthProtocol authProtocol)
Get the hash algorithm to be used for a given authentication protocol.
General definitions for cryptographic algorithms.
const uint8_t usmNoPrivProtocolOid[9]
@ SNMP_AUTH_PROTOCOL_SHA1
HMAC-SHA-1-96.
@ SNMP_AUTH_PROTOCOL_SHA512
HMAC-SHA-512-384.
const uint8_t usmHMAC256SHA384AuthProtocolOid[9]
void snmpUsmMibUnload(void *context)
Unload SNMP USM MIB module.
#define SNMP_MAX_PUBLIC_VALUE_SIZE
error_t snmpUsmMibGetNextUserEntry(const MibObject *object, const uint8_t *oid, size_t oidLen, uint8_t *nextOid, size_t *nextOidLen)
Get next usmUserEntry object.
MibRowStatus status
Status of the user.
error_t snmpUsmMibGetUserEntry(const MibObject *object, const uint8_t *oid, size_t oidLen, MibVariant *value, size_t *valueLen)
Get usmUserEntry object value.
void snmpChangeKey(const HashAlgo *hashAlgo, const uint8_t *random, const uint8_t *delta, SnmpKey *key)
Change secret key.
error_t mibEncodeOctetString(uint8_t *oid, size_t maxOidLen, size_t *pos, const uint8_t *data, size_t dataLen, bool_t implied)
Encode instance identifier (octet string)
SnmpAuthProtocol authProtocol
Authentication protocol.
char_t name[SNMP_MAX_USER_NAME_LEN+1]
User name.
Common definitions for MIB modules.
SNMP USM MIB module implementation.
const uint8_t usmNoAuthProtocolOid[9]
error_t snmpUsmMibInit(void)
SNMP USM MIB module initialization.
SnmpKey rawAuthKey
Raw authentication key.
error_t snmpUsmMibSetUserSpinLock(const MibObject *object, const uint8_t *oid, size_t oidLen, const MibVariant *value, size_t valueLen, bool_t commit)
Set usmUserSpinLock object value.
@ MIB_ROW_STATUS_CREATE_AND_WAIT
@ MIB_STORAGE_TYPE_VOLATILE
SnmpPrivProtocol privProtocol
Privacy protocol.
#define SNMP_MAX_CONTEXT_ENGINE_SIZE
const uint8_t usmAesCfb128ProtocolOid[9]
Common interface for hash algorithms.
error_t mibTestAndIncSpinLock(int32_t *spinLock, int32_t value, bool_t commit)
Test and increment spin lock.
error_t mibDecodeString(const uint8_t *oid, size_t oidLen, size_t *pos, char_t *string, size_t maxStringLen, bool_t implied)
Decode instance identifier (string)
@ SNMP_PRIV_PROTOCOL_AES
AES-128-CFB.
SnmpAgentContext * context
#define osMemset(p, value, length)
@ SNMP_AUTH_PROTOCOL_NONE
No authentication.
error_t mibDecodeOctetString(const uint8_t *oid, size_t oidLen, size_t *pos, uint8_t *data, size_t maxDataLen, size_t *dataLen, bool_t implied)
Decode instance identifier (octet string)
@ SNMP_PRIV_PROTOCOL_DES
DES-CBC.
SnmpKey rawPrivKey
Raw privacy key.
const uint8_t usmDESPrivProtocolOid[9]
@ ERROR_INCONSISTENT_VALUE
void snmpUsmMibLock(void)
Lock SNMP USM MIB base.
ASN.1 (Abstract Syntax Notation One)
@ MIB_STORAGE_TYPE_PERMANENT