RFC 2274

User-based Security Model (USM) for version 3 of the Simple Network Management Protocol (SNMPv3)

๐Ÿ“… published January 1998, from ietf

RFC 2274: User-based Security Model (USM) for SNMPv3 ๐ŸŽ€

okay bestie, this is the spec for USM, the security model that keeps SNMPv3 messages safe ๐Ÿ”โœจ here's the title block so you know who's behind it:

  • Series: Network Working Group ๐ŸŒธ
  • Authors: U. Blumenthal and B. Wijnen, both at IBM T. J. Watson Research ๐Ÿ’…
  • Category: Standards Track ๐Ÿ”ฅ
  • Date: January 1998 ๐Ÿ“…
  • Obsoletes: RFC 2264 ๐Ÿฆ‹

Status of this Memo โœจ

okay so this document is an Internet standards track protocol for the Internet community ๐ŸŒˆ it also asks people to talk about it and send over ideas for making it better ๐Ÿ’ฌ if you want to know where this protocol stands officially, check the current "Internet Official Protocol Standards" (STD 1) ๐Ÿ“š and the memo can be shared as widely as you like, no limits ๐Ÿซถ

Copyright (C) The Internet Society (1998). All Rights Reserved.

IANA Note ๐Ÿงš

so there was a clerical mix-up when the snmpModules got their numbers in this memo ๐Ÿ˜ญ this RFC fixes that with the corrected number assignment for the protocol ๐Ÿ’– and yep, it obsoletes RFC 2264 ๐Ÿซถ

Abstract ๐ŸŽ€

this doc describes the User-based Security Model (USM) for SNMP version 3, built for the SNMP architecture [RFC2271] โœจ it lays out the Elements of Procedure for SNMP message level security ๐Ÿ” and it also comes with a MIB so you can remotely monitor and manage the configuration parameters for this Security Model ๐Ÿฆ‹

Table of Contents ๐ŸŒธ

1.  Introduction                                                       3
1.1.  Threats                                                          4
1.2.  Goals and Constraints                                            5
1.3.  Security Services                                                6
1.4.  Module Organization                                              7
1.4.1.  Timeliness Module                                              7
1.4.2.  Authentication Protocol                                        8
1.4.3.  Privacy Protocol                                               8
1.5.  Protection against Message Replay, Delay and Redirection         8
1.5.1.  Authoritative SNMP engine                                      8
1.5.2.  Mechanisms                                                     9
1.6.  Abstract Service Interfaces.                                    10
1.6.1.  User-based Security Model Primitives for Authentication       11
1.6.2.  User-based Security Model Primitives for Privacy              11
2.  Elements of the Model                                             12
2.1.  User-based Security Model Users                                 12
2.2.  Replay Protection                                               13
2.2.1.  msgAuthoritativeEngineID                                      13
2.2.2.  msgAuthoritativeEngineBoots and msgAuthoritativeEngineTime    14
2.2.3.  Time Window                                                   15
2.3.  Time Synchronization                                            15
2.4.  SNMP Messages Using this Security Model                         16
2.5.  Services provided by the User-based Security Model              17
2.5.1.  Services for Generating an Outgoing SNMP Message              17
2.5.2.  Services for Processing an Incoming SNMP Message              19
2.6.  Key Localization Algorithm.                                     21
3.  Elements of Procedure                                             21
3.1.  Generating an Outgoing SNMP Message                             22
3.2.  Processing an Incoming SNMP Message                             25
4.  Discovery                                                         30
5.  Definitions                                                       31
6.  HMAC-MD5-96 Authentication Protocol                               45
6.1.  Mechanisms                                                      45
6.1.1.  Digest Authentication Mechanism                               46
6.2.  Elements of the Digest Authentication Protocol                  46
6.2.1.  Users                                                         46
6.2.2.  msgAuthoritativeEngineID                                      47
6.2.3.  SNMP Messages Using this Authentication Protocol              47
6.2.4.  Services provided by the HMAC-MD5-96 Authentication Module    47
6.2.4.1.  Services for Generating an Outgoing SNMP Message            47
6.2.4.2.  Services for Processing an Incoming SNMP Message            48
6.3.  Elements of Procedure                                           49
6.3.1.  Processing an Outgoing Message                                49
6.3.2.  Processing an Incoming Message                                50
7.  HMAC-SHA-96 Authentication Protocol                               51
7.1.  Mechanisms                                                      51
7.1.1.  Digest Authentication Mechanism                               51
7.2.  Elements of the HMAC-SHA-96 Authentication Protocol             52
7.2.1.  Users                                                         52
7.2.2.  msgAuthoritativeEngineID                                      52
7.2.3.  SNMP Messages Using this Authentication Protocol              53
7.2.4.  Services provided by the HMAC-SHA-96 Authentication Module    53
7.2.4.1.  Services for Generating an Outgoing SNMP Message            53
7.2.4.2.  Services for Processing an Incoming SNMP Message            54
7.3.  Elements of Procedure                                           54
7.3.1.  Processing an Outgoing Message                                55
7.3.2.  Processing an Incoming Message                                55
8.  CBC-DES Symmetric Encryption Protocol                             56
8.1.  Mechanisms                                                      56
8.1.1.  Symmetric Encryption Protocol                                 57
8.1.1.1.  DES key and Initialization Vector.                          57
8.1.1.2.  Data Encryption.                                            58
8.1.1.3.  Data Decryption                                             59
8.2.  Elements of the DES Privacy Protocol                            59
8.2.1.  Users                                                         59
8.2.2.  msgAuthoritativeEngineID                                      59
8.2.3.  SNMP Messages Using this Privacy Protocol                     60
8.2.4.  Services provided by the DES Privacy Module                   60
8.2.4.1.  Services for Encrypting Outgoing Data                       60
8.2.4.2.  Services for Decrypting Incoming Data                       61
8.3.  Elements of Procedure.                                          61
8.3.1.  Processing an Outgoing Message                                61
8.3.2.  Processing an Incoming Message                                62
9.  Intellectual Property                                             62
10. Acknowledgements                                                  63
11. Security Considerations                                           64
11.1. Recommended Practices                                           64
11.2. Defining Users                                                  66
11.3. Conformance                                                     67
12. References                                                        67
13. Editors' Addresses                                                69
A.1.  SNMP engine Installation Parameters                             70
A.2.  Password to Key Algorithm                                       71
A.2.1.  Password to Key Sample Code for MD5                           71
A.2.2.  Password to Key Sample Code for SHA                           72
A.3.  Password to Key Sample Results                                  73
A.3.1.  Password to Key Sample Results using MD5                      73
A.3.2.  Password to Key Sample Results using SHA                      74
A.4.  Sample encoding of msgSecurityParameters                        74
B.  Full Copyright Statement                                          76

1. Introduction โœจ

okay so the Architecture for describing Internet Management Frameworks [RFC2271] says an SNMP engine is made up of four things ๐Ÿ‘‘

  1) a Dispatcher
  2) a Message Processing Subsystem,
  3) a Security Subsystem, and
  4) an Access Control Subsystem.

applications get to use the services these subsystems offer ๐Ÿ’…

it's really important to get the SNMP architecture and its vocab down so you can see where the Security Model in this doc fits in and how it talks to the other subsystems ๐Ÿง  the reader is expected to already understand the SNMP architecture as defined in [RFC2271], so make sure you've read that first bestie ๐Ÿ“–

this memo [RFC2274] describes the User-based Security Model as it's used inside the SNMP Architecture ๐ŸŽ€ the big idea is that we use the classic idea of a user (identified by a userName) and attach security information to that user ๐Ÿซถ

this memo also covers HMAC-MD5-96 and HMAC-SHA-96 as the authentication protocols, and CBC-DES as the privacy protocol ๐Ÿ” but USM isn't locked into these: it can use other protocols instead of them or alongside them ๐ŸŒˆ that's why HMAC-MD5-96, HMAC-SHA-96 and CBC-DES each get their own section, since they're self-contained and can be swapped out or supplemented later on ๐Ÿฆ‹

the key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be read as described in [RFC2119] ๐Ÿ“

1.1. Threats ๐ŸŽ€

Okay so, a bunch of the classic network protocol threats totally apply to network management, which means they'd apply to any SNMP Security Model too ๐Ÿ˜ญ. Other threats just aren't relevant to network management at all. This section covers the principal threats, the secondary ones, and the ones that are lowkey less important. ๐Ÿ’…

The principal threats this SNMP Security Model should protect against are:

  • Modification of Information The modification threat is the danger that some unauthorized entity may alter in-transit SNMP messages generated on behalf of an authorized user in such a way as to effect unauthorized management operations, including falsifying the value of an object. ๐Ÿ™ˆ
  • Masquerade The masquerade threat is the danger that management operations not authorized for some user may be attempted by assuming the identity of another user that has the appropriate authorizations. ๐ŸŽญ

Two secondary threats are also identified. The Security Model defined in this memo provides limited protection against:

  • Disclosure The disclosure threat is the danger of eavesdropping on the exchanges between managed agents and a management station. Protecting against this threat may be required as a matter of local policy. ๐Ÿ‘€
  • Message Stream Modification The SNMP protocol is typically based upon a connection-less transport service which may operate over any sub-network service. The re-ordering, delay or replay of messages can and does occur through the natural operation of many such sub-network services. The message stream modification threat is the danger that messages may be maliciously re-ordered, delayed or replayed to an extent which is greater than can occur through the natural operation of a sub-network service, in order to effect unauthorized management operations. ๐ŸŒ€

There are at least two threats that an SNMP Security Model need not protect against. The security protocols defined in this memo do not provide protection against:

  • Denial of Service This SNMP Security Model does not attempt to address the broad range of attacks by which service on behalf of authorized users is denied. Indeed, such denial-of-service attacks are in many cases indistinguishable from the type of network failures with which any viable network management protocol must cope as a matter of course. ๐ŸŒง๏ธ
  • Traffic Analysis This SNMP Security Model does not attempt to address traffic analysis attacks. Indeed, many traffic patterns are predictable (devices may be managed on a regular basis by a relatively small number of management applications), and therefore there is no significant advantage afforded by protecting against traffic analysis. ๐Ÿ“Š

1.2. Goals and Constraints ๐ŸŽฏ

Based on everything we just covered about threats in the SNMP network management environment, the goals of this SNMP Security Model are as follows. ๐Ÿงš

  1. Provide for verification that each received SNMP message has not been modified during its transmission through the network.
  2. Provide for verification of the identity of the user on whose behalf a received SNMP message claims to have been generated.
  3. Provide for detection of received SNMP messages, which request or contain management information, whose time of generation was not recent.
  4. Provide, when necessary, that the contents of each received SNMP message are protected from disclosure.

Besides the main goal of supporting secure network management, the design of this SNMP Security Model is also shaped by the following constraints. ๐Ÿงฑ

  1. When the requirements of effective management in times of network stress are inconsistent with those of security, the design should prefer the former.
  2. Neither the security protocol nor its underlying security mechanisms should depend upon the ready availability of other network services (e.g., Network Time Protocol (NTP) or key management protocols).
  3. A security mechanism should entail no changes to the basic SNMP network management philosophy.

1.3. Security Services ๐Ÿ”

The security services needed to support the goals of this SNMP Security Model are as follows. โœจ

  • Data Integrity is the provision of the property that data has not been altered or destroyed in an unauthorized manner, nor have data sequences been altered to an extent greater than can occur non-maliciously.
  • Data Origin Authentication is the provision of the property that the claimed identity of the user on whose behalf received data was originated is corroborated.
  • Data Confidentiality is the provision of the property that information is not made available or disclosed to unauthorized individuals, entities, or processes.
  • Message timeliness and limited replay protection is the provision of the property that a message whose generation time is outside of a specified time window is not accepted. Note that message reordering is not dealt with and can occur in normal conditions too.

For the protocols specified in this memo, it is not possible to assure the specific originator of a received SNMP message. Instead, it's the user on whose behalf the message was originated that gets authenticated. ๐Ÿชช

For these protocols, it's not possible to get data integrity without data origin authentication, and it's not possible to get data origin authentication without data integrity. Also, there's no provision for data confidentiality without both data integrity and data origin authentication. They really come as a package deal ๐Ÿ’•.

The security protocols used in this memo are considered acceptably secure at the time of writing. However, the procedures allow for new authentication and privacy methods to be specified at a future time if the need arises. ๐Ÿ”„

1.4. Module Organization ๐Ÿงฉ

The security protocols defined in this memo are split into three different modules. Each one has its own responsibilities, and together they realize the goals and security services described above. It's giving teamwork ๐Ÿซถ.

  • The authentication module MUST provide for:
    • Data Integrity,
    • Data Origin Authentication
  • The timeliness module MUST provide for:
    • Protection against message delay or replay (to an extent greater than can occur through normal operation)
  • The privacy module MUST provide for:
    • Protection against disclosure of the message payload.

The timeliness module is fixed for the User-based Security Model, while there is provision for multiple authentication and/or privacy modules. Each of those implements a specific authentication or privacy protocol, respectively. ๐Ÿ”€

1.4.1. Timeliness Module โฐ

Section 3 (Elements of Procedure) uses the timeliness values in an SNMP message to do timeliness checking. The timeliness check is only performed if authentication is applied to the message. Since the complete message is checked for integrity, we can assume that the timeliness values in a message that passes the authentication module are trustworthy. ๐Ÿฅน

1.4.2. Authentication Protocol ๐Ÿช„

Section 6 describes the HMAC-MD5-96 authentication protocol, which is the first authentication protocol that MUST be supported with the User-based Security Model. Section 7 describes the HMAC-SHA-96 authentication protocol, which is another authentication protocol that SHOULD be supported with the User-based Security Model. In the future, additional or replacement authentication protocols may be defined as new needs arise. ๐Ÿ†•

The User-based Security Model prescribes that, if authentication is used, then the complete message is checked for integrity in the authentication module.

For a message to be authenticated, it needs to pass the authentication check by the authentication module and the timeliness check, which is a fixed part of this User-based Security Model. Both are required, no skipping ๐Ÿšซ.

1.4.3. Privacy Protocol ๐Ÿคซ

Section 8 describes the CBC-DES Symmetric Encryption Protocol, which is the first privacy protocol to be used with the User-based Security Model. In the future, additional or replacement privacy protocols may be defined as new needs arise. ๐Ÿ—๏ธ

The User-based Security Model prescribes that the scopedPDU is protected from disclosure when a message is sent with privacy.

The User-based Security Model also prescribes that a message needs to be authenticated if privacy is in use. ๐Ÿ”’

1.5. Protection against Message Replay, Delay and Redirection ๐Ÿ›ก๏ธ

1.5.1. Authoritative SNMP engine ๐Ÿ‘‘

In order to protect against message replay, delay and redirection, one of the SNMP engines involved in each communication is designated to be the authoritative SNMP engine. When an SNMP message contains a payload which expects a response (for example a Get, GetNext, GetBulk, Set or Inform PDU), then the receiver of such messages is authoritative. When an SNMP message contains a payload which does not expect a response (for example an SNMPv2-Trap, Response or Report PDU), then the sender of such a message is authoritative. The whole thing hinges on who's the authority for each message type, so keep that straight, bestie ๐Ÿซต.

1.5.2. Mechanisms โœจ

okay so here's how the security model actually keeps the bad guys out ๐Ÿ•ต๏ธโ€โ™€๏ธ there are three main mechanisms, and they're lowkey genius:

  1. Timeliness checks ๐Ÿ•ฐ๏ธ To stop messages from being delayed or replayed (in a way that goes beyond normal network lag), every message carries a set of timeliness indicators from the authoritative SNMP engine. Receivers check those indicators to see if a message is recent. An SNMP engine MAY check them to make sure a message is at least as recent as the last one it got from that same source. A non-authoritative SNMP engine uses messages that pass authentication to move forward its idea of the remote authoritative engine's timeliness indicators.

An SNMP engine MUST also have a way to match incoming Responses with the Requests it's waiting on, and it MUST drop any Responses that don't match an outstanding Request. For example, a msgID can be stuck into every message to handle this.

These mechanisms catch authenticated messages that weren't generated recently. But here's the tea โ˜•: this protection against delay and replay doesn't imply or provide any protection against unauthorized deletion or suppression of messages. An SNMP engine also might not notice reordering if every message involved is sent inside the Time Window interval. Other mechanisms that live outside the security protocol can be used to catch reordered, deleted, or suppressed messages that contain Set operations (for example, the MIB variable snmpSetSerialNo [RFC1907]). ๐Ÿ”

  1. Keeping engines apart ๐Ÿšง Messages sent to or from one authoritative SNMP engine can't be replayed to or pretend to be from another authoritative SNMP engine. How? Every message includes an identifier that's unique to the authoritative SNMP engine that's either sending it or meant to receive it.

Now, a Report, Response, or Trap sent from an authoritative SNMP engine to one non-authoritative SNMP engine can get replayed to another non-authoritative SNMP engine. That second engine might (if it knows the same userName with the same secrets at the authoritative engine) update its idea of the authoritative engine's timeliness indicators, but that's not considered a threat ๐Ÿ™…โ€โ™€๏ธ

In this situation, a Report or Response gets discarded by the Message Processing Model, since there shouldn't be an outstanding Request for it. A Trap might get accepted, though. Again, not a threat, because the communication was authenticated and timely. It's basically as if the authoritative engine had been configured to start sending Traps to the second engine, which can theoretically happen without the second engine knowing about it anyway. Anyway, the second SNMP engine might not expect this Trap, but it's allowed to see the management information inside it. ๐Ÿ‘€

  1. Spotting messages that aren't fresh ๐Ÿฅ€ A set of time indicators gets included in the message, showing when it was generated. Messages without recent time indicators are not considered authentic. On top of that, an SNMP engine MUST drop any Responses that don't match an outstanding request. This part, however, is the responsibility of the Message Processing Model. ๐Ÿ’…
This memo lets the same user be defined on multiple SNMP engines. ๐Ÿง‘โ€๐Ÿคโ€๐Ÿง‘

Each SNMP engine keeps a value called snmpEngineID, which uniquely identifies that engine. This value is included in every message sent to or from the engine when it's the authoritative one (see section 1.5.1). When a message comes in, an authoritative SNMP engine checks this value to make sure it's the intended recipient. A non-authoritative SNMP engine uses the value to make sure the message gets processed with the correct state information. ๐ŸŽฏ

Each SNMP engine also keeps two values, snmpEngineBoots and snmpEngineTime. Together they give an indication of time at that engine. Both get included in an authenticated message sent to or received from that engine. When one arrives, the values are checked to make sure the timeliness value is within a Time Window of the current time. The Time Window is an administrative upper bound on how long protocol messages are allowed to take to arrive. โณ

So, for an SNMP engine to generate a message that an authoritative SNMP engine will accept as authentic, and to verify that a message from that authoritative engine is authentic, the engine must first achieve timeliness synchronization with the authoritative SNMP engine. See section 2.3. ๐Ÿซถ


1.6. Abstract Service Interfaces โœจ

Abstract service interfaces describe the conceptual interfaces between the different subsystems inside an SNMP entity. There's also a set of abstract service interfaces defined within the User-based Security Model (USM), which describe the conceptual interfaces between the generic USM services and the self-contained authentication and privacy services. ๐Ÿงฉ

These abstract service interfaces are defined by a set of primitives. The primitives describe the services provided and the abstract data elements that must be passed when the services get invoked. This section lists the primitives defined for the User-based Security Model. ๐Ÿ“‹

1.6.1. User-based Security Model Primitives for Authentication

The User-based Security Model has these internal primitives for passing data back and forth between the Security Model itself and the authentication service ๐Ÿ”

statusInformation =
  authenticateOutgoingMsg(
  IN   authKey                   -- secret key for authentication
  IN   wholeMsg                  -- unauthenticated complete message
  OUT  authenticatedWholeMsg     -- complete authenticated message
       )

statusInformation =
  authenticateIncomingMsg(
  IN   authKey                   -- secret key for authentication
  IN   authParameters            -- as received on the wire
  IN   wholeMsg                  -- as received on the wire
  OUT  authenticatedWholeMsg     -- complete authenticated message
       )

1.6.2. User-based Security Model Primitives for Privacy

The User-based Security Model has these internal primitives for passing data back and forth between the Security Model itself and the privacy service ๐Ÿ™ˆ

statusInformation =
  encryptData(
  IN    encryptKey               -- secret key for encryption
  IN    dataToEncrypt            -- data to encrypt (scopedPDU)
  OUT   encryptedData            -- encrypted data (encryptedPDU)
  OUT   privParameters           -- filled in by service provider
        )

statusInformation =
  decryptData(
  IN    decryptKey               -- secret key for decrypting
  IN    privParameters           -- as received on the wire
  IN    encryptedData            -- encrypted data (encryptedPDU)
  OUT   decryptedData            -- decrypted data (scopedPDU)
        )

2. Elements of the Model ๐ŸŽ€

This section has the definitions you need to actually realize the security model defined by this memo. ๐Ÿ“–

2.1. User-based Security Model Users ๐Ÿ‘ฉโ€๐Ÿ’ป

Management operations using this Security Model rely on a defined set of user identities. For any user on whose behalf management operations are authorized at a particular SNMP engine, that engine must have knowledge of that user. An SNMP engine that wants to talk to another SNMP engine must also have knowledge of a user known to that engine, including the applicable attributes of that user. ๐Ÿซ 

Here's what a user and its attributes look like ๐Ÿ’…

  • userName: a string representing the name of the user.
  • securityName: a human-readable string representing the user, in a format that's independent of the Security Model.
  • authProtocol: says whether messages sent on behalf of this user can be authenticated, and if so, which authentication protocol is used. Two are defined in this memo: the HMAC-MD5-96 authentication protocol and the HMAC-SHA-96 authentication protocol.
  • authKey: if messages sent for this user can be authenticated, this is the (private) authentication key used with the authentication protocol. A user's authentication key will normally be different at different authoritative SNMP engines. The authKey isn't accessible via SNMP. The length requirements for authKey are defined by the authProtocol in use. ๐Ÿ”‘
  • authKeyChange and authOwnKeyChange: the only way to remotely update the authentication key. They do this in a secure manner, so the update can be completed without needing privacy protection. ๐Ÿ”„
  • privProtocol: says whether messages sent for this user can be protected from disclosure, and if so, which privacy protocol is used. One is defined in this memo: the CBC-DES Symmetric Encryption Protocol. ๐Ÿ”’
  • privKey: if messages sent for this user can be en/decrypted, this is the (private) privacy key used with the privacy protocol. A user's privacy key will normally be different at different authoritative SNMP engines. The privKey isn't accessible via SNMP. The length requirements for privKey are defined by the privProtocol in use. ๐Ÿ—๏ธ
  • privKeyChange and privOwnKeyChange: the only way to remotely update the encryption key. They do this in a secure manner, so the update can be completed without needing privacy protection. ๐Ÿ’Œ

2.2. Replay Protection ๐Ÿ›ก๏ธ

Each SNMP engine maintains three objects:

  • snmpEngineID, which (at least within an administrative domain) uniquely and unambiguously identifies an SNMP engine.
  • snmpEngineBoots, which counts how many times the SNMP engine has re-booted or re-initialized since snmpEngineID was last configured; and,
  • snmpEngineTime, which is the number of seconds since the snmpEngineBoots counter was last incremented.

Each SNMP engine is always authoritative for these objects in its own SNMP entity. It's the responsibility of a non-authoritative SNMP engine to synchronize with the authoritative SNMP engine, as appropriate. ๐Ÿค

An authoritative SNMP engine is required to maintain the values of its snmpEngineID and snmpEngineBoots in non-volatile storage. ๐Ÿ’พ

2.2.1. msgAuthoritativeEngineID

The msgAuthoritativeEngineID value in an authenticated message is what defeats attacks where messages from one SNMP engine to another get replayed to a different SNMP engine. It represents the snmpEngineID at the authoritative SNMP engine involved in the message exchange. ๐Ÿšซ

When an authoritative SNMP engine is first installed, it sets its local snmpEngineID value according to an enterprise-specific algorithm (see the definition of the Textual Convention for SnmpEngineID in the SNMP Architecture document [RFC2271]). ๐ŸŒธ

2.2.2. msgAuthoritativeEngineBoots and msgAuthoritativeEngineTime ๐Ÿฆ‹

Okay so these two values are literally the anti-replay bodyguards ๐Ÿ’… The msgAuthoritativeEngineBoots and msgAuthoritativeEngineTime values sitting inside an authenticated message exist to stop replay attacks, where someone sneaks in an old message after it's stopped being valid ๐Ÿ™ˆ They're basically a copy of the snmpEngineBoots and snmpEngineTime values at the authoritative SNMP engine in that exchange โœจ

Here's the lowkey genius part: an SNMP engine doesn't need a non-volatile clock that keeps ticking while it's powered off ๐Ÿ˜ญ Instead, every time an engine reboots, it grabs its snmpEngineBoots, bumps it up, saves it back to non-volatile storage, and resets snmpEngineTime to zero โฐ Iconic.

When an engine is first installed, it sets both of its local values to zero ๐Ÿ“ If snmpEngineTime ever hits its max value (2147483647), then snmpEngineBoots goes up as if the engine rebooted, snmpEngineTime resets to zero, and it starts counting again ๐Ÿ”

Every time an authoritative engine reboots, any engine holding that authoritative engine's snmpEngineBoots and snmpEngineTime values needs to re-synchronize before it sends correctly authenticated messages to it (see Section 2.3 for (re-)synchronization procedures). Ngl, there's a twist ๐Ÿ‘€ The procedures still provide for a notification to be accepted as authentic by a receiving engine when it was sent by an authoritative engine that has rebooted since the receiver last (re-)synchronized ๐Ÿ’–

If an authoritative engine is ever unable to determine its latest snmpEngineBoots value, then it must set its snmpEngineBoots value to 2147483647 ๐Ÿ˜ฑ

Whenever the local snmpEngineBoots value is 2147483647, it latches at that value, and an authenticated message always causes a notInTimeWindow authentication failure ๐Ÿšซ

To reset an engine whose snmpEngineBoots has reached 2147483647, manual intervention is required ๐Ÿ› ๏ธ Someone has to physically visit the engine and reconfigure it, either with a new snmpEngineID value or with new secret values for the authentication and privacy protocols of all users known to that engine ๐Ÿง‘โ€๐Ÿ”ง Even if an engine rebooted once a second, it would still take approximately 68 years to reach that max value of 2147483647 ๐ŸŒˆ

2.2.3. Time Window โณ

The Time Window is the window of time in which a message generated on behalf of any user is valid ๐Ÿ’• This memo specifies that the same Time Window value, 150 seconds, is used for all users ๐ŸŽ€

2.3. Time Synchronization ๐Ÿ•ฐ๏ธ

Time synchronization is what a non-authoritative SNMP engine needs before it can proceed with authentic communications โœจ It's considered done once that engine has obtained a local notion of the authoritative engine's snmpEngineBoots and snmpEngineTime values from the authoritative engine itself ๐Ÿ’ซ Those values must be (and remain) within the authoritative engine's Time Window, so the local copy has to be kept loosely synchronized with the values stored at the authoritative engine ๐Ÿงš On top of its local copy of snmpEngineBoots and snmpEngineTime, a non-authoritative engine must also keep one more local variable, latestReceivedEngineTime ๐Ÿ‘‘ This records the highest snmpEngineTime it has received from the authoritative engine, and it's used to eliminate the possibility of replaying messages that would stop the non-authoritative engine's notion of snmpEngineTime from advancing ๐Ÿ™…โ€โ™€๏ธ

A non-authoritative engine must keep local notions of these values for each authoritative engine it wishes to communicate with ๐Ÿ“š Since each authoritative engine is uniquely and unambiguously identified by its snmpEngineID, the non-authoritative engine can use that value as a key to cache its local notions ๐Ÿ—๏ธ

Time synchronization occurs as part of the procedure for receiving an SNMP message (Section 3.2, step 7b) ๐Ÿซถ So no explicit time synchronization procedure is required by a non-authoritative engine ๐Ÿ™Œ Note, though, that whenever the local value of snmpEngineID is changed (e.g., through discovery), or when secure communications are first established with an authoritative engine, the local values of snmpEngineBoots and latestReceivedEngineTime should be set to zero ๐Ÿ”„ That makes time synchronization happen when the next authentic message is received ๐Ÿ’œ

2.4. SNMP Messages Using this Security Model ๐Ÿ“จ

The syntax of an SNMP message using this Security Model follows the message format defined in the version-specific Message Processing Model document (for example [RFC2272]) ๐Ÿ’Œ

The field msgSecurityParameters in SNMPv3 messages has a data type of OCTET STRING ๐Ÿงพ Its value is the BER serialization of the following ASN.1 sequence:

USMSecurityParametersSyntax DEFINITIONS IMPLICIT TAGS ::= BEGIN

   UsmSecurityParameters ::=
       SEQUENCE {
        -- global User-based security parameters
           msgAuthoritativeEngineID     OCTET STRING,
           msgAuthoritativeEngineBoots  INTEGER (0..2147483647),
           msgAuthoritativeEngineTime   INTEGER (0..2147483647),
           msgUserName                  OCTET STRING (SIZE(1..32)),
        -- authentication protocol specific parameters
           msgAuthenticationParameters  OCTET STRING,
        -- privacy protocol specific parameters
           msgPrivacyParameters         OCTET STRING
       }
END

The fields of this sequence are:

  • msgAuthoritativeEngineID specifies the snmpEngineID of the authoritative SNMP engine involved in the exchange of the message. ๐Ÿ†”
  • msgAuthoritativeEngineBoots specifies the snmpEngineBoots value at the authoritative SNMP engine involved in the exchange of the message. ๐Ÿ”ข
  • msgAuthoritativeEngineTime specifies the snmpEngineTime value at the authoritative SNMP engine involved in the exchange of the message. โฑ๏ธ
  • msgUserName specifies the user (principal) on whose behalf the message is being exchanged. ๐Ÿง‘โ€๐ŸŽค
  • msgAuthenticationParameters are defined by the authentication protocol in use for the message, as defined by the usmUserAuthProtocol column in the user's entry in the usmUserTable. ๐Ÿ”
  • msgPrivacyParameters are defined by the privacy protocol in use for the message, as defined by the usmUserPrivProtocol column in the user's entry in the usmUserTable). ๐Ÿ•ต๏ธโ€โ™€๏ธ

See appendix A.4 for an example of the BER encoding of field msgSecurityParameters ๐Ÿ“–

2.5. Services provided by the User-based Security Model ๐ŸŽ

This section describes the services provided by the User-based Security Model, with their inputs and outputs ๐Ÿ’–

The services are described as primitives of an abstract service interface, and the inputs and outputs are described as abstract data elements as they are passed in these abstract service primitives ๐Ÿงš

2.5.1. Services for Generating an Outgoing SNMP Message โœจ

okay so when the Message Processing (MP) Subsystem wants the User-based Security module to lock down an outgoing SNMP message, it must use the right service that the Security module offers. there are two of them, and they're both giving main character energy ๐Ÿ’…

  1. a service to generate a Request message. the abstract service primitive looks like this:
statusInformation =            -- success or errorIndication
  generateRequestMsg(
  IN   messageProcessingModel  -- typically, SNMP version
  IN   globalData              -- message header, admin data
  IN   maxMessageSize          -- of the sending SNMP entity
  IN   securityModel           -- for the outgoing message
  IN   securityEngineID        -- authoritative SNMP entity
  IN   securityName            -- on behalf of this principal
  IN   securityLevel           -- Level of Security requested
  IN   scopedPDU               -- message (plaintext) payload
  OUT  securityParameters      -- filled in by Security Module
  OUT  wholeMsg                -- complete generated message
  OUT  wholeMsgLength          -- length of generated message
  )
  1. a service to generate a Response message. the abstract service primitive looks like this:
statusInformation =            -- success or errorIndication
  generateResponseMsg(
  IN   messageProcessingModel  -- typically, SNMP version
  IN   globalData              -- message header, admin data
  IN   maxMessageSize          -- of the sending SNMP entity
  IN   securityModel           -- for the outgoing message
  IN   securityEngineID        -- authoritative SNMP entity
  IN   securityName            -- on behalf of this principal
  IN   securityLevel           -- Level of Security requested
  IN   scopedPDU               -- message (plaintext) payload
  IN   securityStateReference  -- reference to security state
                               -- information from original
                               -- request
  OUT  securityParameters      -- filled in by Security Module
  OUT  wholeMsg                -- complete generated message
  OUT  wholeMsgLength          -- length of generated message
  )

the abstract data elements passed as parameters in these primitives work like this ๐Ÿซถ

  • statusInformation: tells you whether encoding and securing the message worked. if it didn't, it tells you what went wrong.
  • messageProcessingModel: the SNMP version number for the message being generated. the User-based Security module doesn't use this one.
  • globalData: the message header, meaning its administrative info. the User-based Security module doesn't use this one either.
  • maxMessageSize: the maximum message size, as it's included in the message. the User-based Security module doesn't use this one.
  • securityParameters: the security parameters. the User-based Security module fills these in ๐Ÿ”
  • securityModel: the securityModel in use, which should be the User-based Security Model. the User-based Security module doesn't use this one.
  • securityName: together with the snmpEngineID, this identifies a row in the usmUserTable that gets used to secure the message. the securityName has a format that doesn't depend on the Security Model. for a response, this parameter gets ignored and the value from the cache is used instead.
  • securityLevel: the Level of Security. the User-based Security module uses it to decide whether the message needs to be protected from disclosure and whether it needs to be authenticated. for a response, this parameter gets ignored and the value from the cache is used instead.
  • securityEngineID: the snmpEngineID of the authoritative SNMP engine that a Request message is headed to. for a response, it's implied to be the processing SNMP engine's own snmpEngineID, so if you do pass it in, it gets ignored ๐Ÿ™ˆ
  • scopedPDU: the message payload. it's opaque as far as the User-based Security Model is concerned, so it just rides along ๐ŸŽ€
  • securityStateReference: a handle or reference to cachedSecurityData, used when securing an outgoing Response message. it's the exact same handle that the User-based Security module generated while it was processing the incoming Request this Response is answering ๐Ÿฆ‹
  • wholeMsg: the fully encoded and secured message, ready to go out on the wire.
  • wholeMsgLength: the length of the encoded and secured message (wholeMsg).

when the process is done, the User-based Security module hands back a statusInformation. if it went well, you get the completed message, with privacy and authentication applied if the specified securityLevel asked for them. if it didn't go well, you get an errorIndication instead ๐Ÿ’€

2.5.2. Services for Processing an Incoming SNMP Message ๐ŸŒธ

when the Message Processing (MP) Subsystem asks the User-based Security module to check that an incoming message is secure, it must use the service that's provided for incoming messages. the abstract service primitive is:

statusInformation =             -- errorIndication or success
                                -- error counter OID/value if error
  processIncomingMsg(
  IN   messageProcessingModel   -- typically, SNMP version
  IN   maxMessageSize           -- of the sending SNMP entity
  IN   securityParameters       -- for the received message
  IN   securityModel            -- for the received message
  IN   securityLevel            -- Level of Security
  IN   wholeMsg                 -- as received on the wire
  IN   wholeMsgLength           -- length as received on the wire
  OUT  securityEngineID         -- authoritative SNMP entity
  OUT  securityName             -- identification of the principal
  OUT  scopedPDU,               -- message (plaintext) payload
  OUT  maxSizeResponseScopedPDU -- maximum size of the Response PDU
  OUT  securityStateReference   -- reference to security state
       )                        -- information, needed for response

the abstract data elements passed as parameters in this primitive are like so ๐Ÿ’–

  • statusInformation: says whether the process worked or not. if it didn't, the statusInformation includes the OID and the value of the error counter that got incremented.
  • messageProcessingModel: the SNMP version number, as received in the message. the User-based Security module doesn't use this one.
  • maxMessageSize: the maximum message size, as it's included in the message. the User-based Security module uses this value to work out the maxSizeResponseScopedPDU ๐Ÿงฎ
  • securityParameters: the security parameters, exactly as they were received in the message.
  • securityModel: the securityModel in use, which should be the User-based Security Model. the User-based Security module doesn't use this one.
  • securityLevel: the Level of Security. the User-based Security module uses it to decide whether the message needs to be protected from disclosure and whether it needs to be authenticated.
  • wholeMsg: the whole message, exactly as it came in.
  • wholeMsgLength: the length of the message as it came in (wholeMsg).
  • securityEngineID: the snmpEngineID that got pulled out of the msgAuthoritativeEngineID field. it's also the one used to look up the secrets in the usmUserTable ๐Ÿ”‘
  • securityName: the security name for the user on whose behalf the message was received. like before, its format doesn't depend on the Security Model.
  • scopedPDU: the message payload. again, opaque to the User-based Security Model, so hands off ๐Ÿ™Œ
  • maxSizeResponseScopedPDU: the largest scopedPDU that could fit in a possible Response message. the User-base Security module works this out from the mms (as received in the message) and the room the header needs for that Response message, including the securityParameters ๐Ÿ“
  • securityStateReference: a handle or reference to cachedSecurityData, for when securing an outgoing Response message. when the Message Processing Subsystem asks the User-based Security module to generate a response to this incoming message, it must pass this handle back in ๐Ÿฆ‹

when the process finishes, the User-based Security module returns a statusInformation and, if everything went right, the extra data elements needed to keep processing the message. if it didn't, you get an errorIndication, possibly along with an OID and value pair for whichever error counter got incremented ๐Ÿ˜ญ


2.6. Key Localization Algorithm. ๐ŸŒˆ

okay, this part is lowkey so clever. a localized key is a secret key shared between a user U and one authoritative SNMP engine E. even if a user only has one password (and so one key for the whole network), the actual secrets shared between that user and each authoritative SNMP engine are different. that's the magic of key localization [Localized-key] โœจ

first up, if a user uses a password, that password gets turned into a key Ku, using one of the two algorithms described in Appendices A.2.1 and A.2.2.

to turn key Ku into a localized key Kul for user U at the authoritative SNMP engine E, you stick the snmpEngineID of that authoritative SNMP engine onto the key Ku, then stick the key Ku on again after it. so the snmpEngineID ends up wrapped in two copies of the user's key Ku, like a little burrito ๐ŸŒฏ then you run a secure hash function on it. which hash function you use depends on the authentication protocol defined for this user U at authoritative SNMP engine E. this document defines two authentication protocols, with their associated algorithms based on MD5 and SHA. the output of the hash function is the localized key Kul for user U at the authoritative SNMP engine E ๐Ÿ’œ

3. Elements of Procedure ๐ŸŽ€

this section describes the security related procedures that an SNMP engine follows when it processes SNMP messages according to the User-based Security Model. let's get into it, bestie ๐Ÿ’…

3.1. Generating an Outgoing SNMP Message โœจ

Okay so this section walks through what an SNMP engine does every time it builds a message with a management operation (a request, response, notification, or report) for a user at a particular securityLevel. Let's gooo ๐Ÿ’…

  1. Check the state first ๐Ÿ”
    • a) If any securityStateReference is passed (that's a Response message), the user info gets pulled from cachedSecurityData. The securityEngineID and the securityLevel get extracted from there too. After that, the cachedSecurityData can be discarded ๐Ÿ—‘๏ธ

Otherwise,

  • b) based on the securityName, the user's info at the destination snmpEngineID (the one named by securityEngineID) gets pulled from the Local Configuration Datastore (LCD, usmUserTable). If the user isn't in the LCD at all, an error indication (unknownSecurityName) gets returned to the calling module ๐Ÿ™ˆ
  1. Privacy check ๐Ÿ” If the securityLevel says the message has to be protected from disclosure, but the user doesn't support both an authentication and a privacy protocol, then the message can't be sent. An error indication (unsupportedSecurityLevel) gets returned to the calling module. Not it ๐Ÿ’€
  2. Auth check ๐Ÿ›ก๏ธ If the securityLevel says the message has to be authenticated, but the user doesn't support an authentication protocol, then the message can't be sent either. An error indication (unsupportedSecurityLevel) gets returned to the calling module.
  3. Encryption time ๐ŸŽ€
    • a) If the securityLevel says the message has to be protected from disclosure, the octet sequence that represents the serialized scopedPDU gets encrypted with the user's privacy protocol. To do that, we call the privacy module that implements the user's privacy protocol, using this abstract primitive:
statusInformation =       -- success or failure
  encryptData(
  IN    encryptKey        -- user's localized privKey
  IN    dataToEncrypt     -- serialized scopedPDU
  OUT   encryptedData     -- serialized encryptedPDU
  OUT   privParameters    -- serialized privacy parameters
        )
  • statusInformation tells us whether the encryption worked or not ๐Ÿ™Œ
  • encryptKey is the user's localized private privKey, the secret key the encryption algorithm can use ๐Ÿ”‘
  • dataToEncrypt is the serialized scopedPDU, the data that's getting encrypted ๐Ÿ“ฆ
  • encryptedData is the encryptedPDU (the encrypted scopedPDU), encoded as an OCTET STRING ๐Ÿซถ
  • privParameters are the privacy parameters, encoded as an OCTET STRING โœจ

If the privacy module says failure, the message can't be sent and an error indication (encryptionError) gets returned to the calling module ๐Ÿ˜ญ

If the privacy module says success, the returned privParameters get put into the msgPrivacyParameters field of the securityParameters, and the encryptedPDU becomes the payload of the message being prepared ๐ŸŽ‰

Otherwise,

  • b) If the securityLevel says the message does not need to be protected from disclosure, then the NULL string gets encoded as an OCTET STRING and put into the msgPrivacyParameters field of the securityParameters. The plaintext scopedPDU becomes the payload of the message being prepared ๐ŸŒธ
  1. Engine ID ๐Ÿ†” The snmpEngineID gets encoded as an OCTET STRING into the msgAuthoritativeEngineID field of the securityParameters. Here's the tea: an empty (zero length) snmpEngineID is totally fine for a Request message, because the remote (authoritative) SNMP engine will send back a Report PDU with the proper snmpEngineID included in the msgAuthoritativeEngineID in the securityParameters of that Report PDU ๐Ÿงš
  2. Boots and time โฐ
    • a) If the securityLevel says the message has to be authenticated, then the current values of snmpEngineBoots and snmpEngineTime for the snmpEngineID from the LCD are used.

Otherwise,

  • b) If this is a Response message, then the current values of snmpEngineBoots and snmpEngineTime for the local snmpEngineID from the LCD are used.

Otherwise,

  • c) If this is a Request message, then a zero value is used for both snmpEngineBoots and snmpEngineTime. That zero value gets used if snmpEngineID is empty 0๏ธโƒฃ

The values get encoded as INTEGERs into the msgAuthoritativeEngineBoots and msgAuthoritativeEngineTime fields of the securityParameters ๐Ÿ’–

  1. Username ๐Ÿ‘ค The userName gets encoded as an OCTET STRING into the msgUserName field of the securityParameters.
  2. Auth stamp โœ๏ธ
    • a) If the securityLevel says the message has to be authenticated, the message gets authenticated with the user's authentication protocol. We do that by calling the authentication module that implements the user's authentication protocol, using this abstract service primitive:
statusInformation =
  authenticateOutgoingMsg(
  IN  authKey               -- the user's localized authKey
  IN  wholeMsg              -- unauthenticated message
  OUT authenticatedWholeMsg -- authenticated complete message
      )
  • statusInformation tells us whether the authentication worked ๐Ÿ’ซ
  • authKey is the user's localized private authKey, the secret key the authentication algorithm can use ๐Ÿ—๏ธ
  • wholeMsg is the complete serialized message that needs authenticating ๐Ÿ“จ
  • authenticatedWholeMsg is the same as the input given to the authenticateOutgoingMsg service, but with msgAuthenticationParameters properly filled in โœ…

If the authentication module says failure, the message can't be sent and an error indication (authenticationFailure) gets returned to the calling module ๐Ÿ’€

If the authentication module says success, the msgAuthenticationParameters field gets put into the securityParameters, and the authenticatedWholeMsg represents the serialized authenticated message being prepared ๐Ÿฆ‹

Otherwise,

  • b) If the securityLevel says the message does not need to be authenticated, then the NULL string gets encoded as an OCTET STRING into the msgAuthenticationParameters field of the securityParameters. The wholeMsg is now serialized and represents the unauthenticated message being prepared ๐ŸŒˆ
  1. Send it off ๐Ÿš€ The completed message, along with its length, gets returned to the calling module with the statusInformation set to success.

3.2. Processing an Incoming SNMP Message ๐Ÿฆ‹

This section is the other side of the coin: what an SNMP engine does whenever it receives a message with a management operation for a user at a particular securityLevel. Pay attention, bestie ๐Ÿ‘€

To keep the elements of procedure simple, the release of state information isn't always spelled out. The general rule is: if state information exists when a message gets discarded, the state information should also be released ๐Ÿงน Also, when an error indication comes back with an OID and value for an incremented counter, the available information (like securityStateReference) must be passed back to the caller so it can generate a Report PDU ๐Ÿ“ฃ

  1. Parse check ๐Ÿง If the received securityParameters isn't the serialization (following the conventions of [RFC1906]) of an OCTET STRING formatted according to the UsmSecurityParameters defined in section 2.4, then the snmpInASNParseErrs counter [RFC1907] gets incremented, and an error indication (parseError) gets returned to the calling module. Note that we return without the OID and value of the incremented counter, because there isn't enough info in this case to generate a Report PDU ๐Ÿ˜ญ
  2. Unpack the goods ๐Ÿ“ฆ The values of the security parameter fields get extracted from the securityParameters. The securityEngineID to be returned to the caller is the value of the msgAuthoritativeEngineID field. The cachedSecurityData gets prepared, and a securityStateReference gets prepared to reference this data. The values to be cached are:
    • msgUserName
    • securityEngineID
    • securityLevel
  3. Unknown engine? ๐Ÿ‘ฝ If the value of the msgAuthoritativeEngineID field in the securityParameters is unknown, then:
    • a) a non-authoritative SNMP engine that performs discovery may optionally create a new entry in its Local Configuration Datastore (LCD) and keep processing;

or

  • b) the usmStatsUnknownEngineIDs counter gets incremented, and an error indication (unknownEngineID) gets returned to the calling module, together with the OID and value of the incremented counter ๐Ÿšซ
  1. User lookup ๐Ÿ”Ž Info about the values of the msgUserName and msgAuthoritativeEngineID fields gets pulled from the Local Configuration Datastore (LCD, usmUserTable). If there's no info for the user, the usmStatsUnknownUserNames counter gets incremented, and an error indication (unknownSecurityName) gets returned to the calling module, together with the OID and value of the incremented counter ๐Ÿ™…โ€โ™€๏ธ
  2. Level check ๐ŸŽš๏ธ If the user info says the user doesn't support the securityLevel the caller asked for, then the usmStatsUnsupportedSecLevels counter gets incremented, and an error indication (unsupportedSecurityLevel) gets returned to the calling module, together with the OID and value of the incremented counter ๐Ÿ’…
  3. Verify the signature ๐Ÿ” If the securityLevel says the message has to be authenticated, then the message gets authenticated with the user's authentication protocol. We call the authentication module that implements that protocol, using this abstract service primitive:
statusInformation =          -- success or failure
  authenticateIncomingMsg(
  IN   authKey               -- the user's localized authKey
  IN   authParameters        -- as received on the wire
  IN   wholeMsg              -- as received on the wire
  OUT  authenticatedWholeMsg -- checked for authentication
          )
  • statusInformation tells us whether authentication worked or not โœจ
  • authKey is the user's localized private authKey, the secret key the authentication algorithm can use ๐Ÿ—๏ธ
  • wholeMsg is the complete serialized message that needs authenticating ๐Ÿ“จ
  • authenticatedWholeMsg is the same as the input given to the authenticateIncomingMsg service, but after authentication has been checked ๐Ÿซถ

If the authentication module says failure, the message can't be trusted, so the usmStatsWrongDigests counter gets incremented, and an error indication (authenticationFailure) gets returned to the calling module, together with the OID and value of the incremented counter ๐Ÿ˜ฑ

If the authentication module says success, the message is authentic and can be trusted, so processing keeps going ๐ŸŽ€

  1. If the securityLevel says the message is authenticated, the engine pulls out the local snmpEngineBoots and snmpEngineTime that match the msgAuthoritativeEngineID from the Local Configuration Datastore (LCD) ๐Ÿ”
    • a) We're the authoritative engine ๐Ÿ‘‘ If the extracted msgAuthoritativeEngineID matches this engine's snmpEngineID, then the message is considered outside of the Time Window if ANY of these are true:
      • the local snmpEngineBoots is 2147483647;
      • the msgAuthoritativeEngineBoots field differs from the local snmpEngineBoots; or,
      • the msgAuthoritativeEngineTime field differs from the local snmpEngineTime by more than +/- 150 seconds.

If the message is outside the Time Window, the usmStatsNotInTimeWindows counter goes up ๐Ÿ“ˆ, and an error indication (notInTimeWindow) plus the OID and value of that counter gets sent back to the calling module ๐Ÿ™ˆ

  • b) Someone else is the authoritative engine ๐Ÿงš If the extracted msgAuthoritativeEngineID does NOT match this engine's snmpEngineID, then:
    1. if at least one of these is true:
      • the extracted msgAuthoritativeEngineBoots is greater than the local snmpEngineBoots; or,
      • the extracted msgAuthoritativeEngineBoots equals the local snmpEngineBoots, and the extracted msgAuthoritativeEngineTime is greater than latestReceivedEngineTime,

then the LCD entry for the extracted msgAuthoritativeEngineID gets updated ๐ŸŽ€: the local snmpEngineBoots is set to msgAuthoritativeEngineBoots, the local snmpEngineTime is set to msgAuthoritativeEngineTime, and latestReceivedEngineTime is set to msgAuthoritativeEngineTime.

  1. if ANY of these is true, the message is outside the Time Window ๐Ÿ’€:
    • the local snmpEngineBoots is 2147483647;
    • msgAuthoritativeEngineBoots is less than the local snmpEngineBoots; or,
    • msgAuthoritativeEngineBoots equals the local snmpEngineBoots and msgAuthoritativeEngineTime is more than 150 seconds less than the local snmpEngineTime.

If it's outside the Time Window, an error indication (notInTimeWindow) goes back to the calling module.

Lowkey important: this means a message that's way too old (maybe replayed) got caught and is treated as not authentic ๐Ÿšซ

Also, msgAuthoritativeEngineBoots is allowed to be greater than the local snmpEngineBoots. This lets messages from an authoritative engine that rebooted since the receiver last (re-)synchronized still be accepted as authentic ๐Ÿ”„

Be aware though: this procedure does NOT do automatic time sync when the non-authoritative engine is really out of sync, meaning the authoritative engine is more than 150 seconds behind the non-authoritative one. That's a real out-of-sync situation and it doesn't fix itself ๐Ÿ˜ญ

  1. a) If the securityLevel says the message was protected from disclosure, the OCTET STRING holding the encryptedPDU gets decrypted with the user's privacy protocol to get back an unencrypted serialized scopedPDU ๐Ÿ”“ To do that, the engine calls the privacy module that implements the user's privacy protocol, using this abstract primitive:
statusInformation =       -- success or failure
  decryptData(
  IN    decryptKey        -- the user's localized privKey
  IN    privParameters    -- as received on the wire
  IN    encryptedData     -- encryptedPDU as received
  OUT   decryptedData     -- serialized decrypted scopedPDU
        )

Here's what each piece means ๐Ÿง 

  • statusInformation tells you if the decryption worked or not.
  • decryptKey is the user's localized private privKey, the secret key the decryption algorithm can use.
  • privParameters is the msgPrivacyParameters, encoded as an OCTET STRING.
  • encryptedData is the encryptedPDU (the encrypted scopedPDU), encoded as an OCTET STRING.
  • decryptedData is the serialized scopedPDU if decryption works.

If the privacy module returns failure, the message can't be processed ๐Ÿ˜ฉ so the usmStatsDecryptionErrors counter goes up, and an error indication (decryptionError) plus the OID and value of that counter goes back to the calling module.

If the privacy module returns success, the decrypted scopedPDU becomes the message payload that gets handed back to the calling module โœจ

Otherwise, if the message wasn't encrypted:

b) The scopedPDU is assumed to already be plain text, and it becomes the message payload handed back to the calling module ๐Ÿ“

  1. The maxSizeResponseScopedPDU gets calculated ๐Ÿงฎ This is the biggest scopedPDU allowed for a possible Response message. It leaves room for a message header that allows the same securityLevel as the received Request.
  2. The securityName for the user gets retrieved from the usmUserTable ๐Ÿ™‹โ€โ™€๏ธ
  3. The security data gets cached as cachedSecurityData ๐Ÿ’พ That way, a possible response to this message can use the very same authentication and privacy secrets, the same securityLevel, and the same msgAuthoritativeEngineID. Here's what gets saved:
msgUserName,
usmUserAuthProtocol, usmUserAuthKey
usmUserPrivProtocol, usmUserPrivKey
securityEngineID, securityLevel
  1. The statusInformation is set to success, and the engine returns to the calling module, passing back the OUT parameters as specified in the processIncomingMsg primitive ๐ŸŽ‰

4. Discovery ๐Ÿ”Ž

The User-based Security Model needs a discovery process to get enough info about other SNMP engines so they can talk to each other ๐Ÿค Discovery means a non-authoritative SNMP engine has to learn the authoritative SNMP engine's snmpEngineID value before any communication can happen. One way to do this is to send a Request message with a securityLevel of noAuthNoPriv, a msgUserName of initial, a msgAuthoritativeEngineID with zero length, and an empty varBindList ๐Ÿซถ The response will be a Report message with the authoritative engine's snmpEngineID as the value of the msgAuthoritativeEngineID field inside msgSecurityParameters. It also has a Report PDU with the usmStatsUnknownEngineIDs counter in the varBindList ๐Ÿ’…

If authenticated communication is required, discovery should also set up time synchronization with the authoritative SNMP engine โฐ To do that, send an authenticated Request message where msgAuthoritativeEngineID is set to the newly learned snmpEngineID, and msgAuthoritativeEngineBoots and msgAuthoritativeEngineTime are both set to zero. The response will be a Report message with the up-to-date snmpEngineBoots and snmpEngineTime values from the authoritative engine, given as the value of the msgAuthoritativeEngineBoots and msgAuthoritativeEngineTime fields respectively. It also includes the usmStatsNotInTimeWindows counter in the varBindList of the Report PDU. After that, time sync happens automatically through the procedures in section 3.2 step 7b. See also section 2.3 ๐Ÿฆ‹

5. Definitions ๐Ÿ’œ

Here's the start of the SNMP-USER-BASED-SM-MIB module, with the imports, the module identity, and the first protocol identifiers ๐ŸŒธ

SNMP-USER-BASED-SM-MIB DEFINITIONS ::= BEGIN

IMPORTS
    MODULE-IDENTITY, OBJECT-TYPE,
    OBJECT-IDENTITY,
    snmpModules, Counter32                FROM SNMPv2-SMI
    TEXTUAL-CONVENTION, TestAndIncr,
    RowStatus, RowPointer,
    StorageType, AutonomousType           FROM SNMPv2-TC
    MODULE-COMPLIANCE, OBJECT-GROUP       FROM SNMPv2-CONF
    SnmpAdminString, SnmpEngineID,
    snmpAuthProtocols, snmpPrivProtocols  FROM SNMP-FRAMEWORK-MIB;

snmpUsmMIB MODULE-IDENTITY
    LAST-UPDATED "9711200000Z"            -- 20 Nov 1997, midnight
    ORGANIZATION "SNMPv3 Working Group"
    CONTACT-INFO "WG-email:   snmpv3@tis.com
                  Subscribe:  majordomo@tis.com
                              In msg body:  subscribe snmpv3

                  Chair:      Russ Mundy
                              Trusted Information Systems
                  postal:     3060 Washington Rd
                              Glenwood MD 21738
                              USA
                  email:      mundy@tis.com
                  phone:      +1-301-854-6889

                  Co-editor   Uri Blumenthal
                              IBM T. J. Watson Research
                  postal:     30 Saw Mill River Pkwy,
                              Hawthorne, NY 10532
                              USA
                  email:      uri@watson.ibm.com
                  phone:      +1-914-784-7964

                  Co-editor:  Bert Wijnen
                              IBM T. J. Watson Research
                  postal:     Schagen 33
                              3461 GL Linschoten
                              Netherlands
                  email:      wijnen@vnet.ibm.com
                  phone:      +31-348-432-794
                 "

    DESCRIPTION  "The management information definitions for the
                  SNMP User-based Security Model.
                 "
    ::= { snmpModules 15 }

-- Administrative assignments ****************************************

usmMIBObjects     OBJECT IDENTIFIER ::= { snmpUsmMIB 1 }
usmMIBConformance OBJECT IDENTIFIER ::= { snmpUsmMIB 2 }

-- Identification of Authentication and Privacy Protocols ************

usmNoAuthProtocol OBJECT-IDENTITY
    STATUS        current
    DESCRIPTION  "No Authentication Protocol."
    ::= { snmpAuthProtocols 1 }

usmHMACMD5AuthProtocol OBJECT-IDENTITY
    STATUS        current
    DESCRIPTION  "The HMAC-MD5-96 Digest Authentication Protocol."
    REFERENCE    "- H. Krawczyk, M. Bellare, R. Canetti HMAC:
                    Keyed-Hashing for Message Authentication,
                    RFC2104, Feb 1997.
                  - Rivest, R., Message Digest Algorithm MD5, RFC1321.
                 "
    ::= { snmpAuthProtocols 2 }

Okay bestie, the MIB is getting extra dramatic now ๐Ÿ’… so grab your snacks ๐Ÿ“

Here's the SHA one, which is basically the MD5 one's glow-up with its own key sizes and references ๐Ÿฆ‹

usmHMACSHAAuthProtocol OBJECT-IDENTITY
    STATUS        current
    DESCRIPTION  "The HMAC-SHA-96 Digest Authentication Protocol."
    REFERENCE    "- H. Krawczyk, M. Bellare, R. Canetti, HMAC:
                    Keyed-Hashing for Message Authentication,
                    RFC2104, Feb 1997.
                  - Secure Hash Algorithm. NIST FIPS 180-1.
                 "
    ::= { snmpAuthProtocols 3 }

usmNoPrivProtocol OBJECT-IDENTITY
    STATUS        current
    DESCRIPTION  "No Privacy Protocol."
    ::= { snmpPrivProtocols 1 }

usmDESPrivProtocol OBJECT-IDENTITY
    STATUS        current
    DESCRIPTION  "The CBC-DES Symmetric Encryption Protocol."
    REFERENCE    "- Data Encryption Standard, National Institute of
                    Standards and Technology.  Federal Information
                    Processing Standard (FIPS) Publication 46-1.
                    Supersedes FIPS Publication 46,
                    (January, 1977; reaffirmed January, 1988).

                  - Data Encryption Algorithm, American National
                    Standards Institute.  ANSI X3.92-1981,
                    (December, 1980).

                  - DES Modes of Operation, National Institute of
                    Standards and Technology.  Federal Information
                    Processing Standard (FIPS) Publication 81,
                    (December, 1980).

                  - Data Encryption Algorithm - Modes of Operation,
                    American National Standards Institute.
                    ANSI X3.106-1983, (May 1983).
                 "
    ::= { snmpPrivProtocols 2 }

So the privacy side gets its own little lineup: usmNoPrivProtocol is the "no privacy, bestie" option ๐Ÿ™ˆ and usmDESPrivProtocol is the CBC-DES one, with a whole stack of FIPS and ANSI references stapled on ๐Ÿ“š


Now the textual conventions ๐Ÿซถ The KeyChange one is lowkey the most intense thing in this whole document ๐Ÿ˜ญ

-- Textual Conventions ***********************************************


KeyChange ::=     TEXTUAL-CONVENTION
   STATUS         current
   DESCRIPTION
         "Every definition of an object with this syntax must identify
          a protocol P, a secret key K, and a hash algorithm H
          that produces output of L octets.

          The object's value is a manager-generated, partially-random
          value which, when modified, causes the value of the secret
          key K, to be modified via a one-way function.

          The value of an instance of this object is the concatenation
          of two components: first a 'random' component and then a
          'delta' component.

          The lengths of the random and delta components
          are given by the corresponding value of the protocol P;
          if P requires K to be a fixed length, the length of both the
          random and delta components is that fixed length; if P
          allows the length of K to be variable up to a particular
          maximum length, the length of the random component is that
          maximum length and the length of the delta component is any
          length less than or equal to that maximum length.
          For example, usmHMACMD5AuthProtocol requires K to be a fixed
          length of 16 octets and L - of 16 octets.
          usmHMACSHAAuthProtocol requires K to be a fixed length of
          20 octets and L - of 20 octets. Other protocols may define
          other sizes, as deemed appropriate.

          When a requestor wants to change the old key K to a new
          key keyNew on a remote entity, the 'random' component is
          obtained from either a true random generator, or from a
          pseudorandom generator, and the 'delta' component is
          computed as follows:

           - a temporary variable is initialized to the existing value
             of K;
           - if the length of the keyNew is greater than L octets,
             then:
              - the random component is appended to the value of the
                temporary variable, and the result is input to the
                the hash algorithm H to produce a digest value, and
                the temporary variable is set to this digest value;
              - the value of the temporary variable is XOR-ed with
                the first (next) L-octets (16 octets in case of MD5)
                of the keyNew to produce the first (next) L-octets
                (16 octets in case of MD5) of the 'delta' component.
              - the above two steps are repeated until the unused
                portion of the delta component is L octets or less,
           - the random component is appended to the value of the
             temporary variable, and the result is input to the
             hash algorithm H to produce a digest value;
           - this digest value, truncated if necessary to be the same
             length as the unused portion of the keyNew, is XOR-ed
             with the unused portion of the keyNew to produce the
             (final portion of the) 'delta' component.

           For example, using MD5 as the hash algorithm H:

              iterations = (lenOfDelta - 1)/16; /* integer division */
              temp = keyOld;
              for (i = 0; i < iterations; i++) {
                  temp = MD5 (temp || random);
                  delta[i*16 .. (i*16)+15] =
                         temp XOR keyNew[i*16 .. (i*16)+15];
              }
              temp = MD5 (temp || random);
              delta[i*16 .. lenOfDelta-1] =
                     temp XOR keyNew[i*16 .. lenOfDelta-1];

          The 'random' and 'delta' components are then concatenated as
          described above, and the resulting octet string is sent to
          the receipient as the new value of an instance of this
          object.

          At the receiver side, when an instance of this object is set
          to a new value, then a new value of K is computed as follows:

           - a temporary variable is initialized to the existing value
             of K;
           - if the length of the delta component is greater than L
             octets, then:
              - the random component is appended to the value of the
                temporary variable, and the result is input to the
                the hash algorithm H to produce a digest value, and
                the temporary variable is set to this digest value;
              - the value of the temporary variable is XOR-ed with
                the first (next) L-octets (16 octets in case of MD5)
                of the delta component to produce the first (next)
                L-octets (16 octets in case of MD5) of the new value
                of K.
              - the above two steps are repeated until the unused
                portion of the delta component is L octets or less,
           - the random component is appended to the value of the
             temporary variable, and the result is input to the
             hash algorithm H to produce a digest value;
           - this digest value, truncated if necessary to be the same
             length as the unused portion of the delta component, is
             XOR-ed with the unused portion of the delta component to
             produce the (final portion of the) new value of K.

           For example, using MD5 as the hash algorithm H:

              iterations = (lenOfDelta - 1)/16; /* integer division */
              temp = keyOld;
              for (i = 0; i < iterations; i++) {
                  temp = MD5 (temp || random);
                  keyNew[i*16 .. (i*16)+15] =
                         temp XOR delta[i*16 .. (i*16)+15];
              }
              temp = MD5 (temp || random);
              keyNew[i*16 .. lenOfDelta-1] =
                     temp XOR delta[i*16 .. lenOfDelta-1];

          The value of an object with this syntax, whenever it is
          retrieved by the management protocol, is always the zero
          length string.
         "
    SYNTAX       OCTET STRING

Here's the vibe in plain terms โœจ the requestor makes a random chunk, does a bunch of hashing and XOR-ing to build a delta, and sends random plus delta together. The receiver runs the same dance backwards to get the new key K ๐Ÿ”ฅ And the wildest bit is that reading the object always gives back the zero length string ๐Ÿ’€ so nobody gets to peek at the secret, periodt ๐Ÿคซ


Next up are the stats counters for the User-based Security Model, which are basically the drama tracker of dropped packets ๐Ÿ“Š

-- Statistics for the User-based Security Model **********************


usmStats         OBJECT IDENTIFIER ::= { usmMIBObjects 1 }


usmStatsUnsupportedSecLevels OBJECT-TYPE
    SYNTAX       Counter32
    MAX-ACCESS   read-only
    STATUS       current
    DESCRIPTION "The total number of packets received by the SNMP
                 engine which were dropped because they requested a
                 securityLevel that was unknown to the SNMP engine
                 or otherwise unavailable.
                "
    ::= { usmStats 1 }

usmStatsNotInTimeWindows OBJECT-TYPE
    SYNTAX       Counter32
    MAX-ACCESS   read-only
    STATUS       current
    DESCRIPTION "The total number of packets received by the SNMP
                 engine which were dropped because they appeared
                 outside of the authoritative SNMP engine's window.
                "
    ::= { usmStats 2 }

usmStatsUnknownUserNames OBJECT-TYPE
    SYNTAX       Counter32
    MAX-ACCESS   read-only
    STATUS       current
    DESCRIPTION "The total number of packets received by the SNMP
                 engine which were dropped because they referenced a
                 user that was not known to the SNMP engine.
                "
    ::= { usmStats 3 }

usmStatsUnknownEngineIDs OBJECT-TYPE

    SYNTAX       Counter32
    MAX-ACCESS   read-only
    STATUS       current
    DESCRIPTION "The total number of packets received by the SNMP
                 engine which were dropped because they referenced an
                 snmpEngineID that was not known to the SNMP engine.
                "
    ::= { usmStats 4 }

usmStatsWrongDigests OBJECT-TYPE
    SYNTAX       Counter32
    MAX-ACCESS   read-only
    STATUS       current
    DESCRIPTION "The total number of packets received by the SNMP
                 engine which were dropped because they didn't
                 contain the expected digest value.
                "
    ::= { usmStats 5 }

usmStatsDecryptionErrors OBJECT-TYPE
    SYNTAX       Counter32
    MAX-ACCESS   read-only
    STATUS       current
    DESCRIPTION "The total number of packets received by the SNMP
                 engine which were dropped because they could not be
                 decrypted.
                "
    ::= { usmStats 6 }

So each counter is a little tally of packets that got bounced for a specific reason: an unsupported security level, a message outside the authoritative engine's window, an unknown user, an unknown snmpEngineID, a wrong digest, or a decryption failure ๐Ÿ™…โ€โ™€๏ธ Six counters, six different ways to get rejected, iconic ๐Ÿ‘‘


Last stop for this part: the usmUser group and its table, where the users actually live ๐ŸŽ€

-- The usmUser Group ************************************************

usmUser          OBJECT IDENTIFIER ::= { usmMIBObjects 2 }

usmUserSpinLock  OBJECT-TYPE
    SYNTAX       TestAndIncr
    MAX-ACCESS   read-write
    STATUS       current
    DESCRIPTION "An advisory lock used to allow several cooperating
                 Command Generator Applications to coordinate their
                 use of facilities to alter secrets in the
                 usmUserTable.
                "
    ::= { usmUser 1 }

-- The table of valid users for the User-based Security Model ********

usmUserTable     OBJECT-TYPE
    SYNTAX       SEQUENCE OF UsmUserEntry
    MAX-ACCESS   not-accessible
    STATUS       current
    DESCRIPTION "The table of users configured in the SNMP engine's
                 Local Configuration Datastore (LCD)."
    ::= { usmUser 2 }

usmUserEntry     OBJECT-TYPE
    SYNTAX       UsmUserEntry
    MAX-ACCESS   not-accessible
    STATUS       current
    DESCRIPTION "A user configured in the SNMP engine's Local
                 Configuration Datastore (LCD) for the User-based
                 Security Model.
                "
    INDEX       { usmUserEngineID,
                  usmUserName
                }
    ::= { usmUserTable 1 }

UsmUserEntry ::= SEQUENCE
    {
        usmUserEngineID         SnmpEngineID,
        usmUserName             SnmpAdminString,
        usmUserSecurityName     SnmpAdminString,
        usmUserCloneFrom        RowPointer,
        usmUserAuthProtocol     AutonomousType,
        usmUserAuthKeyChange    KeyChange,
        usmUserOwnAuthKeyChange KeyChange,
        usmUserPrivProtocol     AutonomousType,
        usmUserPrivKeyChange    KeyChange,
        usmUserOwnPrivKeyChange KeyChange,
        usmUserPublic           OCTET STRING,
        usmUserStorageType      StorageType,
        usmUserStatus           RowStatus
    }

The usmUserSpinLock is an advisory lock so several Command Generator Applications can coordinate when they change secrets in the usmUserTable ๐Ÿ”’ The table itself holds the users configured in the engine's Local Configuration Datastore (LCD), indexed by usmUserEngineID and usmUserName ๐Ÿ’œ And each row, the UsmUserEntry, bundles up the engine ID, names, protocols, key-change objects, storage type and row status for one user ๐Ÿงš

okay so this part is all about the columns of the user table ๐Ÿ’– Each one holds a different piece of a user's info: who they are, how they authenticate, and how their messages get protected ๐Ÿ”

usmUserEngineID  OBJECT-TYPE
    SYNTAX       SnmpEngineID
    MAX-ACCESS   not-accessible
    STATUS       current
    DESCRIPTION "An SNMP engine's administratively-unique identifier.

                 In a simple agent, this value is always that agent's
                 own snmpEngineID value.

                 The value can also take the value of the snmpEngineID
                 of a remote SNMP engine with which this user can
                 communicate.

                "
    ::= { usmUserEntry 1 }

usmUserName      OBJECT-TYPE
    SYNTAX       SnmpAdminString (SIZE(1..32))
    MAX-ACCESS   not-accessible
    STATUS       current
    DESCRIPTION "A human readable string representing the name of
                 the user.

                 This is the (User-based Security) Model dependent
                 security ID.
                "
    ::= { usmUserEntry 2 }

usmUserSecurityName OBJECT-TYPE
    SYNTAX       SnmpAdminString
    MAX-ACCESS   read-only
    STATUS       current
    DESCRIPTION "A human readable string representing the user in
                 Security Model independent format.

                 The default transformation of the User-based Security
                 Model dependent security ID to the securityName and
                 vice versa is the identity function so that the
                 securityName is the same as the userName.
                "
    ::= { usmUserEntry 3 }

usmUserCloneFrom OBJECT-TYPE
    SYNTAX       RowPointer
    MAX-ACCESS   read-create
    STATUS       current
    DESCRIPTION "A pointer to another conceptual row in this
                 usmUserTable.  The user in this other conceptual
                 row is called the clone-from user.

                 When a new user is created (i.e., a new conceptual
                 row is instantiated in this table), the privacy and
                 authentication parameters of the new user are cloned
                 from its clone-from user.

                 The first time an instance of this object is set by
                 a management operation (either at or after its
                 instantiation), the cloning process is invoked.
                 Subsequent writes are successful but invoke no
                 action to be taken by the receiver.
                 The cloning process fails with an 'inconsistentName'
                 error if the conceptual row representing the
                 clone-from user is not in an active state when the
                 cloning process is invoked.

                 Cloning also causes the initial values of the secret
                 authentication key and the secret encryption key of
                 the new user to be set to the same value as the
                 corresponding secret of the clone-from user.

                 When this object is read, the ZeroDotZero OID
                 is returned.
                "
    ::= { usmUserEntry 4 }

the usmUserCloneFrom one is giving main character energy โœจ It's basically "copy my settings from this other user" ๐Ÿฆ‹ And the cloning only happens the first time someone sets it, so later writes are just... vibes, no action ๐Ÿ™ˆ

usmUserAuthProtocol OBJECT-TYPE
    SYNTAX       AutonomousType
    MAX-ACCESS   read-create
    STATUS       current
    DESCRIPTION "An indication of whether messages sent on behalf of
                 this user to/from the SNMP engine identified by
                 usmUserEngineID, can be authenticated, and if so,
                 the type of authentication protocol which is used.

                 An instance of this object is created concurrently
                 with the creation of any other object instance for
                 the same user (i.e., as part of the processing of
                 the set operation which creates the first object
                 instance in the same conceptual row).  Once created,
                 the value of an instance of this object can not be
                 changed.

                 If a set operation tries to set a value for an unknown
                 or unsupported protocol, then a wrongValue error must
                 be returned.
                "
    DEFVAL      { usmHMACMD5AuthProtocol }
    ::= { usmUserEntry 5 }

usmUserAuthKeyChange OBJECT-TYPE
    SYNTAX       KeyChange   -- typically (SIZE (0..32))
    MAX-ACCESS   read-create
    STATUS       current
    DESCRIPTION "An object, which when modified, causes the secret
                 authentication key used for messages sent on behalf
                 of this user to/from the SNMP engine identified by
                 usmUserEngineID, to be modified via a one-way
                 function.

                 The associated protocol is the usmUserAuthProtocol.
                 The associated secret key is the user's secret
                 authentication key (authKey). The associated hash
                 algorithm is the algorithm used by the user's
                 usmUserAuthProtocol.

                 When creating a new user, it is an 'inconsistentName'
                 error for a Set operation to refer to this object
                 unless it is previously or concurrently initialized
                 through a set operation on the corresponding value
                 of usmUserCloneFrom.
                "
    DEFVAL      { ''H }    -- the empty string
    ::= { usmUserEntry 6 }

usmUserOwnAuthKeyChange OBJECT-TYPE
    SYNTAX       KeyChange  -- typically (SIZE (0..32))
    MAX-ACCESS   read-create
    STATUS       current
    DESCRIPTION "Behaves exactly as usmUserAuthKeyChange, with one
                 notable difference: in order for the Set operation
                 to succeed, the usmUserName of the operation
                 requester must match the usmUserName that
                 indexes the row which is targeted by this
                 operation.

                 The idea here is that access to this column can be
                 public, since it will only allow a user to change
                 his own secret authentication key (authKey).
                "
    DEFVAL      { ''H }    -- the empty string
    ::= { usmUserEntry 7 }

usmUserPrivProtocol OBJECT-TYPE
    SYNTAX       AutonomousType
    MAX-ACCESS   read-create
    STATUS       current
    DESCRIPTION "An indication of whether messages sent on behalf of
                 this user to/from the SNMP engine identified by
                 usmUserEngineID, can be protected from disclosure,
                 and if so, the type of privacy protocol which is used.

                 An instance of this object is created concurrently
                 with the creation of any other object instance for
                 the same user (i.e., as part of the processing of
                 the set operation which creates the first object
                 instance in the same conceptual row).  Once created,
                 the value of an instance of this object can not be
                 changed.

                 If a set operation tries to set a value for an unknown
                 or unsupported protocol, then a wrongValue error must
                 be returned.
                "
    DEFVAL      { usmNoPrivProtocol }
    ::= { usmUserEntry 8 }

usmUserPrivKeyChange OBJECT-TYPE
    SYNTAX       KeyChange  -- typically (SIZE (0..32))
    MAX-ACCESS   read-create
    STATUS       current
    DESCRIPTION "An object, which when modified, causes the secret
                 encryption key used for messages sent on behalf
                 of this user to/from the SNMP engine identified by
                 usmUserEngineID, to be modified via a one-way
                 function.

                 The associated protocol is the usmUserPrivProtocol.
                 The associated secret key is the user's secret
                 privacy key (privKey). The associated hash
                 algorithm is the algorithm used by the user's
                 usmUserAuthProtocol.

                 When creating a new user, it is an 'inconsistentName'
                 error for a set operation to refer to this object
                 unless it is previously or concurrently initialized
                 through a set operation on the corresponding value
                 of usmUserCloneFrom.
                "
    DEFVAL      { ''H }    -- the empty string
    ::= { usmUserEntry 9 }

usmUserOwnPrivKeyChange OBJECT-TYPE
    SYNTAX       KeyChange  -- typically (SIZE (0..32))
    MAX-ACCESS   read-create
    STATUS       current
    DESCRIPTION "Behaves exactly as usmUserPrivKeyChange, with one
                 notable difference: in order for the Set operation
                 to succeed, the usmUserName of the operation
                 requester must match the usmUserName that indexes
                 the row which is targeted by this operation.

                 The idea here is that access to this column can be
                 public, since it will only allow a user to change
                 his own secret privacy key (privKey).
                "

    DEFVAL      { ''H }    -- the empty string
    ::= { usmUserEntry 10 }

usmUserPublic    OBJECT-TYPE
    SYNTAX       OCTET STRING (SIZE(0..32))
    MAX-ACCESS   read-create
    STATUS       current
    DESCRIPTION "A publicly-readable value which is written as part
                 of the procedure for changing a user's secret
                 authentication and/or privacy key, and later read to
                 determine whether the change of the secret was
                 effected.
                "
    DEFVAL      { ''H }  -- the empty string
    ::= { usmUserEntry 11 }

the auth and priv key pairs are literally a whole mood ๐Ÿ”ฅ The "OwnKeyChange" versions let a user change their own key, and the usmUserName has to match the row they're targeting ๐Ÿซถ

usmUserStorageType OBJECT-TYPE
    SYNTAX       StorageType
    MAX-ACCESS   read-create
    STATUS       current
    DESCRIPTION "The storage type for this conceptual row.

                 Conceptual rows having the value 'permanent'
                 must allow write-access at a minimum to:

                 - usmUserAuthKeyChange, usmUserOwnAuthKeyChange
                   and usmUserPublic for a user who employs
                   authentication, and
                 - usmUserPrivKeyChange, usmUserOwnPrivKeyChange
                   and usmUserPublic for a user who employs
                   privacy.

                 Note that any user who employs authentication or
                 privacy must allow its secret(s) to be updated and
                 thus cannot be 'readOnly'.
                "
    DEFVAL      { nonVolatile }
    ::= { usmUserEntry 12 }

usmUserStatus    OBJECT-TYPE
    SYNTAX       RowStatus
    MAX-ACCESS   read-create
    STATUS       current
    DESCRIPTION "The status of this conceptual row.

                 Until instances of all corresponding columns are
                 appropriately configured, the value of the
                 corresponding instance of the usmUserStatus column
                 is 'notReady'.

                 In particular, a newly created row cannot be made
                 active until the corresponding usmUserCloneFrom,
                 usmUserAuthKeyChange, usmUserOwnAuthKeyChange,
                 usmUserPrivKeyChange and usmUserOwnPrivKeyChange
                 have all been set.

                 The  RowStatus TC [RFC1903] requires that this
                 DESCRIPTION clause states under which circumstances
                 other objects in this row can be modified:

                 The value of this object has no effect on whether
                 other objects in this conceptual row can be modified.
                "
    ::= { usmUserEntry 13 }

and now we're at the conformance bit ๐ŸŽ€ Two OBJECT IDENTIFIERs live under usmMIBConformance, one for the compliance statements and one for the groups ๐Ÿงš

-- Conformance Information *******************************************

usmMIBCompliances OBJECT IDENTIFIER ::= { usmMIBConformance 1 }
usmMIBGroups      OBJECT IDENTIFIER ::= { usmMIBConformance 2 }

-- Compliance statements
usmMIBCompliance MODULE-COMPLIANCE
    STATUS       current
    DESCRIPTION "The compliance statement for SNMP engines which
                 implement the SNMP-USER-BASED-SM-MIB.
                "

    MODULE       -- this module
        MANDATORY-GROUPS { usmMIBBasicGroup }

        OBJECT           usmUserAuthProtocol
        MIN-ACCESS       read-only
        DESCRIPTION     "Write access is not required."

        OBJECT           usmUserPrivProtocol
        MIN-ACCESS       read-only
        DESCRIPTION     "Write access is not required."

    ::= { usmMIBCompliances 1 }

-- Units of compliance
usmMIBBasicGroup OBJECT-GROUP
    OBJECTS     {
                  usmStatsUnsupportedSecLevels,
                  usmStatsNotInTimeWindows,
                  usmStatsUnknownUserNames,
                  usmStatsUnknownEngineIDs,
                  usmStatsWrongDigests,
                  usmStatsDecryptionErrors,
                  usmUserSpinLock,
                  usmUserSecurityName,
                  usmUserCloneFrom,
                  usmUserAuthProtocol,
                  usmUserAuthKeyChange,
                  usmUserOwnAuthKeyChange,
                  usmUserPrivProtocol,
                  usmUserPrivKeyChange,
                  usmUserOwnPrivKeyChange,
                  usmUserPublic,
                  usmUserStorageType,
                  usmUserStatus
                }
    STATUS       current
    DESCRIPTION "A collection of objects providing for configuration
                 of an SNMP engine which implements the SNMP
                 User-based Security Model.
                "
    ::= { usmMIBGroups 1 }

END

6. HMAC-MD5-96 Authentication Protocol ๐Ÿฆ‹

Okay so this section is all about the HMAC-MD5-96 authentication protocol ๐Ÿ” It's the very first one defined for the User-based Security Model, so it's kind of the OG, no cap โœจ It uses MD5 [MD5] (the message digest algorithm) in HMAC mode [RFC2104], and then it chops the output down to 96 bits. Iconic trim, honestly ๐Ÿ’…

This protocol is identified by usmHMACMD5AuthProtocol ๐ŸŽ€

Bestie, just so you know, other authentication protocols may be defined later on ๐ŸŒˆ They could replace this one or sit alongside it. Main character energy for future protocols!

6.1. Mechanisms ๐ŸŒธ

  • In support of data integrity, a message digest algorithm is required ๐Ÿ” A digest gets calculated over an appropriate portion of an SNMP message, and then it's included as part of the message that gets sent to the recipient.
  • In support of data origin authentication and data integrity, a secret value is prepended to the SNMP message before the digest is computed ๐Ÿคซ The digest is then partially inserted into the SNMP message before it's sent, and the prepended value is never transmitted. That secret value is shared by all SNMP engines that are authorized to originate messages on behalf of the appropriate user. Secret sauce, but make it shared with the right crew only ๐Ÿซถ

6.1.1. Digest Authentication Mechanism ๐Ÿ’–

The Digest Authentication Mechanism in this memo gives you two things:

  • verification of the integrity of a received message, i.e., the message received is the message sent ๐Ÿงš

The integrity of the message is protected by computing a digest over an appropriate portion of the message. The originator computes the digest, it gets transmitted with the message, and then the recipient verifies it. Receipts, but for packets โœจ

  • verification of the user on whose behalf the message was generated ๐Ÿ‘‘

A secret value that only SNMP engines authorized to generate messages on behalf of a user know is used in HMAC mode (see [RFC2104]). It also recommends that the hash-function output used as the Message Authentication Code be truncated. Chop chop, babe โœ‚๏ธ

This protocol uses the MD5 [MD5] message digest algorithm ๐Ÿ’œ A 128-bit MD5 digest is calculated in a special (HMAC) way over the designated portion of an SNMP message, and then the first 96 bits of that digest are included as part of the message sent to the recipient. So the digest carried in a message is 12 octets, and the private authentication key (the secret) is 16 octets. For the nitty-gritty details, see section 6.3 ๐Ÿฆ‹

6.2. Elements of the Digest Authentication Protocol ๐Ÿ“

This section has the definitions you need to realize the authentication module defined in this section of this memo. Lots of setup, but it's worth it ๐Ÿ’…

6.2.1. Users ๐ŸŽ€

Authentication using this protocol makes use of a defined set of userNames ๐Ÿงธ For any user on whose behalf a message must be authenticated at a particular SNMP engine, that SNMP engine must have knowledge of that user. An SNMP engine that wants to talk to another SNMP engine also has to know a user that's known to that engine, including the applicable attributes of that user. No stranger danger here ๐Ÿ˜Œ

A user and its attributes are defined as follows:

<userName>
  A string representing the name of the user.
<authKey>
  A user's secret key to be used when calculating a digest.
  It MUST be 16 octets long for MD5.

6.2.2. msgAuthoritativeEngineID ๐ŸŒŸ

The msgAuthoritativeEngineID value in an authenticated message tells you which authoritative SNMP engine is in charge of that particular message (see the definition of SnmpEngineID in the SNMP Architecture document [RFC2271]) ๐Ÿงš

The user's (private) authentication key is normally different at each authoritative SNMP engine, so the snmpEngineID is what gets used to select the right key for the authentication process. Key matchmaking, literally ๐Ÿ’˜

6.2.3. SNMP Messages Using this Authentication Protocol ๐Ÿ’Œ

Messages using this authentication protocol carry a msgAuthenticationParameters field as part of the msgSecurityParameters. For this protocol, the msgAuthenticationParameters field is the serialized OCTET STRING that represents the first 12 octets of the HMAC-MD5-96 output, computed over the wholeMsg โœจ

The digest is calculated over the wholeMsg, so if a message is authenticated, that also means every field in the message is intact and hasn't been tampered with. Full integrity check, periodt ๐Ÿ”’

6.2.4. Services provided by the HMAC-MD5-96 Authentication Module ๐ŸŒˆ

This section describes the inputs and outputs that the HMAC-MD5-96 Authentication module expects and produces when the User-based Security module calls it for services ๐ŸŽ€

6.2.4.1. Services for Generating an Outgoing SNMP Message ๐Ÿ“ค

The HMAC-MD5-96 authentication protocol assumes that the caller does the selection of the authKey, and that the caller passes in the secret key to be used ๐Ÿ—๏ธ

When it's done, the authentication module returns statusInformation and, if the message digest was calculated correctly, the wholeMsg with the digest inserted at the proper place. The abstract service primitive looks like this:

statusInformation =              -- success or failure
  authenticateOutgoingMsg(
  IN   authKey                   -- secret key for authentication
  IN   wholeMsg                  -- unauthenticated complete message
  OUT  authenticatedWholeMsg     -- complete authenticated message
       )

The abstract data elements are:

  • statusInformation: an indication of whether the authentication process was successful. If not, it's an indication of the problem ๐Ÿšจ
  • authKey: the secret key to be used by the authentication algorithm. The length of this key MUST be 16 octets ๐Ÿ”‘
  • wholeMsg: the message to be authenticated ๐Ÿ“จ
  • authenticatedWholeMsg: the authenticated message (including the inserted digest) on output โœจ

Note that the authParameters field is filled in by the authentication module, and this field should already be present in the wholeMsg before the Message Authentication Code (MAC) is generated. Order of operations matters, bestie ๐Ÿ™ˆ

6.2.4.2. Services for Processing an Incoming SNMP Message ๐Ÿ“ฅ

The HMAC-MD5-96 authentication protocol assumes that the caller does the selection of the authKey, and that the caller passes in the secret key to be used ๐Ÿ—๏ธ

When it's done, the authentication module returns statusInformation and, if the message digest was calculated correctly, the wholeMsg as it was processed. The abstract service primitive looks like this:

statusInformation =              -- success or failure
  authenticateIncomingMsg(
  IN   authKey                   -- secret key for authentication
  IN   authParameters            -- as received on the wire
  IN   wholeMsg                  -- as received on the wire
  OUT  authenticatedWholeMsg     -- complete authenticated message
    )

The abstract data elements are:

  • statusInformation: an indication of whether the authentication process was successful. If not, it's an indication of the problem ๐Ÿšจ
  • authKey: the secret key to be used by the authentication algorithm. The length of this key MUST be 16 octets ๐Ÿ”‘
  • authParameters: the authParameters from the incoming message ๐Ÿ“ฌ
  • wholeMsg: the message to be authenticated on input, and the authenticated message on output ๐Ÿ”„
  • authenticatedWholeMsg: the whole message after the authentication check is complete โœ…

6.3. Elements of Procedure ๐Ÿงฉ

This section describes the procedures for the HMAC-MD5-96 authentication protocol. Step-by-step time, bestie ๐Ÿ’…

6.3.1. Processing an Outgoing Message ๐Ÿ“ค

This section describes the procedure an SNMP engine follows whenever it has to authenticate an outgoing message using the usmHMACMD5AuthProtocol ๐Ÿฆ‹

1) The msgAuthenticationParameters field is set to the serialization, according to the rules in [RFC1906], of an OCTET STRING containing 12 zero octets ๐ŸŒธ

2) From the secret authKey, two keys, K1 and K2, get derived:

  • a) extend the authKey to 64 octets by appending 48 zero octets, and save it as extendedAuthKey ๐Ÿง
  • b) obtain IPAD by replicating the octet 0x36 64 times ๐Ÿ”
  • c) obtain K1 by XORing extendedAuthKey with IPAD ๐Ÿ’ซ
  • d) obtain OPAD by replicating the octet 0x5C 64 times ๐Ÿ”
  • e) obtain K2 by XORing extendedAuthKey with OPAD ๐Ÿ’ซ

4) Prepend K1 to the wholeMsg, and calculate the MD5 digest over it according to [MD5] ๐Ÿงฎ

5) Prepend K2 to the result of step 4, and calculate the MD5 digest over it according to [MD5]. Take the first 12 octets of the final digest, which is the Message Authentication Code (MAC) ๐ŸŽฏ

6) Replace the msgAuthenticationParameters field with the MAC obtained in step 5 ๐Ÿ”„

7) The authenticatedWholeMsg is then returned to the caller, together with statusInformation indicating success ๐ŸŽ‰

6.3.2. Processing an Incoming Message โœจ

okay so this is the procedure an SNMP engine follows whenever it has to authenticate an incoming message with the usmHMACMD5AuthProtocol ๐Ÿ’…

  1. if the digest in the msgAuthenticationParameters field isn't exactly 12 octets long, that's a failure ๐Ÿ™…โ€โ™€๏ธ and the engine returns an errorIndication (authenticationError) to the calling module
  2. save the MAC that came in the msgAuthenticationParameters field ๐Ÿ”
  3. replace the digest in the msgAuthenticationParameters field with 12 zero octets ๐Ÿซง
  4. now we derive two keys, K1 and K2, from the secret authKey ๐Ÿ”‘
    • a) extend the authKey to 64 octets by appending 48 zero octets, and save the result as extendedAuthKey
    • b) get IPAD by replicating the octet 0x36 64 times
    • c) get K1 by XORing extendedAuthKey with IPAD
    • d) get OPAD by replicating the octet 0x5C 64 times
    • e) get K2 by XORing extendedAuthKey with OPAD
  5. time to calculate the MAC over the wholeMsg ๐Ÿงฎ
    • a) prepend K1 to the wholeMsg and compute the MD5 digest over that
    • b) prepend K2 to the result of step 5.a and compute the MD5 digest over that
    • c) the first 12 octets of the result from step 5.b is the MAC

Then the msgAuthenticationParameters field gets the MAC value we saved back in step 2 ๐ŸŽ€

  1. compare the newly calculated MAC with the MAC saved in step 2. if they don't match, that's a failure and the engine returns an errorIndication (authenticationFailure) to the calling module ๐Ÿ’€
  2. if everything checks out, the authenticatedWholeMsg and a statusInformation showing success go back to the caller ๐ŸŽ‰

7. HMAC-SHA-96 Authentication Protocol ๐Ÿฆ‹

this section is all about the HMAC-SHA-96 authentication protocol ๐Ÿ’– it uses the SHA hash-function described in [SHA-NIST], in the HMAC mode from [RFC2104], and then truncates the output down to 96 bits โœ‚๏ธ

this protocol is identified by usmHMACSHAAuthProtocol ๐Ÿท๏ธ

Over time, other authentication protocols may be defined, either as a replacement for this one or alongside it. ๐ŸŒธ

7.1. Mechanisms ๐Ÿงš

  • For data integrity, a message digest algorithm is required. A digest gets calculated over an appropriate chunk of an SNMP message, and that digest is included in the message sent to the recipient ๐Ÿ“ฆ
  • For data origin authentication and data integrity, a secret value gets prepended to the SNMP message before the digest is computed. The calculated digest is then partly inserted into the message before it's transmitted. The prepended secret is never transmitted ๐Ÿคซ The secret value is shared by all SNMP engines that are authorized to originate messages on behalf of the appropriate user ๐Ÿ‘‘

7.1.1. Digest Authentication Mechanism ๐Ÿ’…

The Digest Authentication Mechanism defined in this memo gives you two things โœจ

  • Integrity verification: the message you receive is the message that was sent ๐Ÿ” The digest is computed over an appropriate portion of the message, computed by the originator, transmitted along with the message, and verified by the recipient ๐Ÿซถ
  • User verification: we check the user the message was generated for ๐Ÿชช A secret value, known only to SNMP engines authorized to generate messages on behalf of a user, is used in HMAC mode (see [RFC2104]). It also recommends truncating the hash-function output that's used as the Message Authentication Code ๐ŸŽ€

This mechanism uses the SHA [SHA-NIST] message digest algorithm. A 160-bit SHA digest is calculated in a special (HMAC) way over the designated portion of an SNMP message, and the first 96 bits of that digest are included in the message sent to the recipient ๐Ÿ”ฅ The digest carried in a message is 12 octets, and the private authentication key (the secret) is 20 octets. For the details, see section 7.3 ๐Ÿ“–

7.2. Elements of the HMAC-SHA-96 Authentication Protocol ๐Ÿ’œ

this section has the definitions you need to build the authentication module described here ๐Ÿงฉ

7.2.1. Users ๐Ÿ™‹โ€โ™€๏ธ

Authentication with this protocol uses a defined set of userNames ๐Ÿท๏ธ For any user on whose behalf a message must be authenticated at a particular SNMP engine, that engine has to know that user. An SNMP engine that wants to talk to another SNMP engine also has to know a user known to that engine, including that user's applicable attributes ๐Ÿซง

a user and its attributes are defined like this:

  • <userName>: a string representing the name of the user
  • <authKey>: the user's secret key, used when calculating a digest. It MUST be 20 octets long for SHA. ๐Ÿ”‘

7.2.2. msgAuthoritativeEngineID ๐ŸŒˆ

the msgAuthoritativeEngineID value in an authenticated message says which authoritative SNMP engine is responsible for that message (see the definition of SnmpEngineID in the SNMP Architecture document [RFC2271]) ๐Ÿง 

a user's (private) authentication key is usually different at each authoritative SNMP engine, so the snmpEngineID is what picks the right key for the authentication process ๐Ÿ—๏ธ

7.2.3. SNMP Messages Using this Authentication Protocol ๐Ÿ’Œ

messages using this protocol carry a msgAuthenticationParameters field as part of the msgSecurityParameters ๐ŸŽ For this protocol, the msgAuthenticationParameters field is the serialized OCTET STRING holding the first 12 octets of the HMAC-SHA-96 output computed over the wholeMsg ๐Ÿ’–

the digest is calculated over the wholeMsg, so if a message gets authenticated, that also means all of its fields are intact and haven't been tampered with ๐Ÿ›ก๏ธ no cap, that's iconic ๐Ÿ˜ญ

7.2.4. Services provided by the HMAC-SHA-96 Authentication Module ๐Ÿ›Ž๏ธ

this section describes the inputs and outputs the HMAC-SHA-96 Authentication module expects and produces when the User-based Security module calls it for services ๐Ÿ“ž

7.2.4.1. Services for Generating an Outgoing SNMP Message ๐Ÿ“ค

HMAC-SHA-96 authentication assumes the caller picks the authKey and passes in the secret key to use ๐Ÿ”‘

when it's done, the authentication module returns statusInformation and, if the message digest was calculated correctly, the wholeMsg with the digest inserted in the right spot โœจ The abstract service primitive looks like this:

statusInformation =              -- success or failure
  authenticateOutgoingMsg(
  IN   authKey                   -- secret key for authentication
  IN   wholeMsg                  -- unauthenticated complete message
  OUT  authenticatedWholeMsg     -- complete authenticated message
       )

the abstract data elements are:

  • statusInformation: says whether the authentication process worked. If it didn't, it says what the problem was ๐Ÿ™ˆ
  • authKey: the secret key the authentication algorithm uses. The length of this key MUST be 20 octets. ๐Ÿ”
  • wholeMsg: the message to be authenticated ๐Ÿ“จ
  • authenticatedWholeMsg: the authenticated message, including the inserted digest, on output ๐ŸŽ€
the authParameters field gets filled in by the authentication module, but that field should already be present in the wholeMsg before the Message Authentication Code (MAC) is generated. don't skip this bit bestie ๐Ÿšจ

7.2.4.2. Services for Processing an Incoming SNMP Message ๐Ÿ“ฅ

same deal here: HMAC-SHA-96 authentication assumes the caller picks the authKey and passes in the secret key to use ๐Ÿ—๏ธ

when it's done, the authentication module returns statusInformation and, if the message digest was calculated correctly, the wholeMsg as it was processed ๐Ÿ’… The abstract service primitive looks like this:

statusInformation =              -- success or failure
  authenticateIncomingMsg(
  IN   authKey                   -- secret key for authentication
  IN   authParameters            -- as received on the wire
  IN   wholeMsg                  -- as received on the wire
  OUT  authenticatedWholeMsg     -- complete authenticated message
    )

the abstract data elements are:

  • statusInformation: says whether the authentication process worked. If it didn't, it says what the problem was ๐Ÿ™ˆ
  • authKey: the secret key the authentication algorithm uses. The length of this key MUST be 20 octets. ๐Ÿ”
  • authParameters: the authParameters from the incoming message ๐Ÿ“ฌ
  • wholeMsg: the message to be authenticated on input, and the authenticated message on output ๐ŸŽ€
  • authenticatedWholeMsg: the whole message once the authentication check is complete โœจ

7.3. Elements of Procedure ๐ŸŽฌ

this section describes the procedures for the HMAC-SHA-96 authentication protocol ๐Ÿ’–

7.3.1. Processing an Outgoing Message ๐Ÿ“ค

this section describes the procedure an SNMP engine follows whenever it has to authenticate an outgoing message with the usmHMACSHAAuthProtocol ๐Ÿ”ฅ

  1. set the msgAuthenticationParameters field to the serialization, following the rules in [RFC1906], of an OCTET STRING containing 12 zero octets ๐Ÿซง
  2. from the secret authKey, derive two keys, K1 and K2 ๐Ÿ”‘
    • a) extend the authKey to 64 octets by appending 44 zero octets, and save the result as extendedAuthKey
    • b) get IPAD by replicating the octet 0x36 64 times
    • c) get K1 by XORing extendedAuthKey with IPAD
    • d) get OPAD by replicating the octet 0x5C 64 times
    • e) get K2 by XORing extendedAuthKey with OPAD
  3. prepend K1 to the wholeMsg and calculate the SHA digest over it, according to [SHA-NIST] ๐Ÿงฎ
  4. prepend K2 to the result of step 4, and calculate the SHA digest over it, according to [SHA-NIST]. Take the first 12 octets of the final digest, which is the Message Authentication Code (MAC) ๐ŸŽ€
  5. replace the msgAuthenticationParameters field with the MAC obtained in step 5 ๐Ÿ’Œ
  6. the authenticatedWholeMsg goes back to the caller, together with a statusInformation showing success ๐ŸŽ‰

7.3.2. Processing an Incoming Message โœจ

Okay bestie, this is the part where an SNMP engine checks the authentication on an incoming message whenever it has to use usmHMACSHAAuthProtocol ๐Ÿ”. Here's the order it goes in:

  1. If the digest in the msgAuthenticationParameters field is not 12 octets long, it's a failure. An errorIndication (authenticationError) gets sent back to the calling module ๐Ÿšซ
  2. The MAC that came in the msgAuthenticationParameters field gets saved ๐Ÿ’พ
  3. The digest in msgAuthenticationParameters gets replaced with 12 zero octets ๐Ÿซง
  4. Two keys, K1 and K2, get derived from the secret authKey ๐Ÿ—๏ธ
    • a) Extend authKey to 64 octets by appending 44 zero octets, and save the result as extendedAuthKey
    • b) Get IPAD by repeating the octet 0x36 64 times
    • c) Get K1 by XORing extendedAuthKey with IPAD
    • d) Get OPAD by repeating the octet 0x5C 64 times
    • e) Get K2 by XORing extendedAuthKey with OPAD
  5. Calculate the MAC over the wholeMsg ๐Ÿงฎ
    • a) Prepend K1 to wholeMsg and calculate the SHA digest over that
    • b) Prepend K2 to the result of step 5.a and calculate the SHA digest over that
    • c) The first 12 octets of the result of step 5.b is the MAC

Then the msgAuthenticationParameters field gets replaced with the MAC value that was saved in step 2.

  1. Compare the newly calculated MAC with the MAC saved in step 2. If they don't match, it's a failure and an errorIndication (authenticationFailure) goes back to the calling module ๐Ÿ’”
  2. If everything checks out, the authenticatedWholeMsg and a statusInformation showing success get returned to the caller ๐ŸŽ‰

8. CBC-DES Symmetric Encryption Protocol ๐Ÿ”’

This section is all about the CBC-DES Symmetric Encryption Protocol ๐Ÿ’…. It's the first privacy protocol ever defined for the User-based Security Model, so it's kind of a big deal ๐Ÿ‘‘

This protocol is identified by usmDESPrivProtocol ๐Ÿชช

Over time, other privacy protocols may be defined, either to replace this one or to sit alongside it ๐ŸŒˆ

8.1. Mechanisms ๐Ÿงฉ

  • For data confidentiality, an encryption algorithm is required ๐Ÿคซ An appropriate portion of the message gets encrypted before it's sent. The User-based Security Model says the scopedPDU is the part of the message that needs encrypting.
  • A secret value, combined with a timeliness value, is used to create the en/decryption key and the initialization vector ๐Ÿ”‘ That secret value is shared by all SNMP engines that are allowed to send messages on behalf of the right user.

8.1.1. Symmetric Encryption Protocol ๐Ÿ”

The Symmetric Encryption Protocol in this memo gives you data confidentiality ๐Ÿซถ The part of an SNMP message you designate gets encrypted and then included in the message that's sent to the recipient.

Two organizations have published specs for DES: the National Institute of Standards and Technology (NIST) [DES-NIST] and the American National Standards Institute [DES-ANSI]. Each one has a companion Modes of Operation spec ([DESO-NIST] and [DESO-ANSI], respectively) ๐Ÿ“š

NIST has also put out three extra docs that implementers might find useful ๐Ÿค“

  • There's a guidelines document for implementing and using DES, including functional specs for DES and its modes of operation [DESG-NIST].
  • There's a validation test suite for DES [DEST-NIST]. It's built to test every aspect of DES and is super useful for pinpointing specific problems ๐ŸŽฏ
  • There's a maintenance test for DES [DESM-NIST]. It uses a minimal amount of data and processing to test all the components of DES. It gives you a simple yes-or-no answer on whether things are working, and it's handy to run as part of an initialization step, like when a computer reboots ๐Ÿ”„

8.1.1.1. DES key and Initialization Vector. ๐Ÿ—๏ธ

The first 8 octets of the 16-octet secret (private privacy key) are used as the DES key. Since DES only uses 56 bits, the Least Significant Bit in each octet gets ignored ๐Ÿ™ˆ

The Initialization Vector for encryption is obtained with the following procedure ๐Ÿช„

The last 8 octets of the 16-octet secret (private privacy key) are used as the pre-IV.

Now here's the thing ๐Ÿ‘€ If two different packets are encrypted with the same key, their IVs must not be the same (in other words, the IV must never repeat). So we need to "salt" the pre-IV with something unique for each packet. The "salt" is an 8-octet string. Its input is the concatenation of the generating SNMP engine's 32-bit snmpEngineBoots and a local 32-bit integer that the encryption engine maintains. That 32-bit integer gets set to an arbitrary value at boot time ๐Ÿฅน

The 32-bit snmpEngineBoots becomes the first 4 octets of the "salt" (Most Significant Byte first). The 32-bit integer then becomes the last 4 octets of the "salt" (also Most Significant Byte first). The resulting "salt" is XOR-ed with the pre-IV. The 8-octet "salt" then goes into the privParameters field, encoded as an OCTET STRING. After that, the "salt" integer gets modified. We recommend incrementing it by one, and wrapping around when it hits the maximum value โ™ป๏ธ

How exactly the value of the "salt" (and therefore the IV) changes is an implementation issue, as long as you take steps to avoid producing a duplicate IV ๐Ÿ’–

The "salt" must be placed in the privParameters field so the receiving entity can compute the correct IV and decrypt the message ๐Ÿ”“

8.1.1.2. Data Encryption. ๐Ÿ“

The data to be encrypted is treated as a sequence of octets. Its length should be an integral multiple of 8. If it isn't, the data gets padded at the end as needed. The actual pad value doesn't matter ๐Ÿ™Œ

The data is encrypted in Cipher Block Chaining mode ๐Ÿ”—

The plaintext is split into 64-bit blocks ๐Ÿงฑ

The plaintext for each block is XOR-ed with the ciphertext of the previous block. That result gets encrypted, and the output of the encryption is the ciphertext for that block. This keeps going until there are no more plaintext blocks ๐Ÿ”

For the very first block, the Initialization Vector is used instead of the ciphertext of a previous block โœจ

8.1.1.3. Data Decryption ๐Ÿซง

Before decryption, the encrypted data length gets verified. If the length of the OCTET STRING to be decrypted isn't an integral multiple of 8 octets, the decryption process halts and an appropriate exception gets noted ๐Ÿšจ When decrypting, the padding is ignored.

The first ciphertext block is decrypted, the decryption output is XOR-ed with the Initialization Vector, and the result is the first plaintext block ๐Ÿชž

For each block after that, the ciphertext block is decrypted, the decryption output is XOR-ed with the previous ciphertext block, and the result is the plaintext block ๐Ÿ’œ

8.2. Elements of the DES Privacy Protocol ๐Ÿงš

This section has the definitions needed to make the privacy module in this memo work ๐Ÿ› ๏ธ

8.2.1. Users ๐Ÿ‘ฏ

Data en/decryption with this Symmetric Encryption Protocol uses a defined set of userNames. Any user on whose behalf a message has to be en/decrypted at a particular SNMP engine must be known to that engine. An SNMP engine that wants to talk to another SNMP engine also has to know a user known to that other engine, including the applicable attributes of that user ๐Ÿซถ

A user and its attributes are defined like this ๐Ÿ“‹

  • <userName>: An octet string with the name of the user.
  • <privKey>: The user's secret key, used as input for the DES key and IV. The length of this key MUST be 16 octets. ๐Ÿ”‘

8.2.2. msgAuthoritativeEngineID ๐Ÿชช

The msgAuthoritativeEngineID value in an authenticated message says which authoritative SNMP engine handles that message. (Check the definition of SnmpEngineID in the SNMP Architecture document [RFC2271] for more.)

The user's (private) privacy key is usually different at each authoritative SNMP engine, so the snmpEngineID is used to pick the right key for the en/decryption process ๐Ÿ—๏ธ

8.2.3. SNMP Messages Using this Privacy Protocol ๐Ÿ“จ

Messages using this privacy protocol carry a msgPrivacyParameters field as part of msgSecurityParameters. For this protocol, msgPrivacyParameters is the serialized OCTET STRING that represents the "salt" used to create the IV ๐Ÿง‚

8.2.4. Services provided by the DES Privacy Module ๐ŸŽ€

This section describes the inputs and outputs the DES Privacy module expects and produces when the User-based Security module calls it for services ๐Ÿ“ž

8.2.4.1. Services for Encrypting Outgoing Data ๐Ÿ”

This DES privacy protocol assumes the caller picks the privKey and passes in the secret key to be used ๐Ÿ™‹โ€โ™€๏ธ

When it's done, the privacy module returns statusInformation. If the encryption worked, it also returns the encryptedPDU and the msgPrivacyParameters encoded as an OCTET STRING. The abstract service primitive looks like this ๐Ÿ‘‡

statusInformation =              -- success of failure
  encryptData(
  IN    encryptKey               -- secret key for encryption
  IN    dataToEncrypt            -- data to encrypt (scopedPDU)
  OUT   encryptedData            -- encrypted data (encryptedPDU)
  OUT   privParameters           -- filled in by service provider
        )

The abstract data elements are:

  • statusInformation: Says whether the encryption worked or failed. If it failed, it says what the error was.
  • encryptKey: The secret key the encryption algorithm uses. The length of this key MUST be 16 octets. ๐Ÿ—๏ธ
  • dataToEncrypt: The data that must be encrypted.
  • encryptedData: The encrypted data, once it's successfully done.
  • privParameters: The privParameters, encoded as an OCTET STRING.

8.2.4.2. Services for Decrypting Incoming Data ๐Ÿ”“

This DES privacy protocol also assumes the caller picks the privKey and passes in the secret key to use ๐Ÿ’…

When it's done, the privacy module returns statusInformation. If the decryption worked, it also returns the scopedPDU in plain text. The abstract service primitive looks like this ๐Ÿ‘‡

statusInformation =
  decryptData(
  IN    decryptKey               -- secret key for decryption
  IN    privParameters           -- as received on the wire
  IN    encryptedData            -- encrypted data (encryptedPDU)
  OUT   decryptedData            -- decrypted data (scopedPDU)
        )

The abstract data elements are:

  • statusInformation: Says whether the data was decrypted successfully and, if not, what the error was.
  • decryptKey: The secret key the decryption algorithm uses. The length of this key MUST be 16 octets. ๐Ÿ”‘
  • privParameters: The "salt" used to calculate the IV.
  • encryptedData: The data to be decrypted.
  • decryptedData: The decrypted data.

8.3. Elements of Procedure. ๐Ÿ“

This section describes the procedures for the DES privacy protocol ๐ŸŒธ

8.3.1. Processing an Outgoing Message โœจ

okay so this is the procedure an SNMP engine follows any time it needs to encrypt part of an outgoing message using the usmDESPrivProtocol ๐Ÿ” it's giving very ordered recipe energy

  1. The secret cryptKey gets used to build the DES encryption key, the "salt", and the DES pre-IV (see section 8.1.1.1 for the deets) ๐Ÿ”‘
  2. The privParameters field gets set to the serialization of an OCTET STRING representing the "salt" string, serialized by the rules in [RFC1906] ๐Ÿง‚
  3. The scopedPDU gets encrypted (see section 8.1.1.2), and then the encrypted data gets serialized as an OCTET STRING following the rules in [RFC1906] ๐Ÿ”’
  4. The serialized OCTET STRING of the encrypted scopedPDU, together with privParameters and a statusInformation saying success, gets handed back to the calling module ๐ŸŽ€

8.3.2. Processing an Incoming Message ๐Ÿ“ฅ

this part is the same vibe but in reverse. it's the procedure an SNMP engine follows whenever it has to decrypt part of an incoming message using the usmDESPrivProtocol ๐Ÿช„

  1. If the privParameters field isn't an 8-octet OCTET STRING, an error indication (decryptionError) gets returned to the calling module ๐Ÿ™…
  2. The "salt" gets pulled out of the privParameters field ๐Ÿซง
  3. The secret cryptKey and the "salt" then get used to build the DES decryption key and pre-IV (see section 8.1.1.1) ๐Ÿ—๏ธ
  4. The encryptedPDU gets decrypted (see section 8.1.1.3) ๐Ÿ”“
  5. If the encryptedPDU can't be decrypted, an error indication (decryptionError) gets returned to the calling module ๐Ÿ’€
  6. The decrypted scopedPDU and a statusInformation saying success get returned to the calling module ๐Ÿ’…

9. Intellectual Property ๐Ÿง 

okay so the IETF doesn't take a side on whether any intellectual property or other rights might be claimed over the tech in this doc, or on whether you can actually get a license for those rights. it's also not saying it went looking for any of them. if you want info on how the IETF handles rights for standards-track and standards-related docs, check out BCP-11 ๐Ÿ“š claims of rights that were made available for publication, assurances that licenses will be available, or the result of trying to get a general license or permission for implementers or users of this spec can all be obtained from the IETF Secretariat ๐Ÿ“ฌ

the IETF also invites anyone to flag any copyrights, patents, patent applications, or other proprietary rights that might cover tech needed to practice this standard. send that info to the IETF Executive Director ๐Ÿซถ

10. Acknowledgements ๐Ÿ™Œ

this doc is the result of the SNMPv3 Working Group's hard work, and they deserve a huge shoutout ๐Ÿ“ฃ special thanks go to these SNMPv3 WG members:

  • Dave Battle (SNMP Research, Inc.)
  • Uri Blumenthal (IBM T.J. Watson Research Center)
  • Jeff Case (SNMP Research, Inc.)
  • John Curran (BBN)
  • T. Max Devlin (Hi-TECH Connections)
  • John Flick (Hewlett Packard)
  • David Harrington (Cabletron Systems Inc.)
  • N.C. Hien (IBM T.J. Watson Research Center)
  • Dave Levi (SNMP Research, Inc.)
  • Louis A Mamakos (UUNET Technologies Inc.)
  • Paul Meyer (Secure Computing Corporation)
  • Keith McCloghrie (Cisco Systems)
  • Russ Mundy (Trusted Information Systems, Inc.)
  • Bob Natale (ACE*COMM Corporation)
  • Mike O'Dell (UUNET Technologies Inc.)
  • Dave Perkins (DeskTalk)
  • Peter Polkinghorne (Brunel University)
  • Randy Presuhn (BMC Software, Inc.)
  • David Reid (SNMP Research, Inc.)
  • Shawn Routhier (Epilogue)
  • Juergen Schoenwaelder (TU Braunschweig)
  • Bob Stewart (Cisco Systems)
  • Bert Wijnen (IBM T.J. Watson Research Center)

the document is based on recommendations from the IETF Security and Administrative Framework Evolution for SNMP Advisory Team ๐Ÿงฉ the members of that Advisory Team were:

  • David Harrington (Cabletron Systems Inc.)
  • Jeff Johnson (Cisco Systems)
  • David Levi (SNMP Research Inc.)
  • John Linn (Openvision)
  • Russ Mundy (Trusted Information Systems) chair
  • Shawn Routhier (Epilogue)
  • Glenn Waters (Nortel)
  • Bert Wijnen (IBM T. J. Watson Research Center)

as the Advisory Team and the SNMPv3 Working Group Charter recommended, the design pulls in as much as is practical from previous RFCs and drafts ๐Ÿ“ which means big thanks to the authors of the earlier designs known as SNMPv2u and SNMPv2*:

  • Jeff Case (SNMP Research, Inc.)
  • David Harrington (Cabletron Systems Inc.)
  • David Levi (SNMP Research, Inc.)
  • Keith McCloghrie (Cisco Systems)
  • Brian O'Keefe (Hewlett Packard)
  • Marshall T. Rose (Dover Beach Consulting)
  • Jon Saperia (BGS Systems Inc.)
  • Steve Waldbusser (International Network Services)
  • Glenn W. Waters (Bell-Northern Research Ltd.)

11. Security Considerations ๐Ÿšจ

okay this part is SERIOUS bestie. security is literally the whole point ๐Ÿ˜ญ don't skip these, they keep the whole thing from falling apart ๐Ÿ›ก๏ธ

this section covers practices that help the mechanisms defined in this memo run securely and effectively ๐Ÿ’–

  • An SNMP engine must discard SNMP Response messages that do not correspond to any currently outstanding Request message. It is the responsibility of the Message Processing module to take care of this. For example, it can use a msgID for that.

An SNMP Command Generator Application must discard any Response PDU for which there is no currently outstanding Request PDU. For example, for SNMPv2 [RFC1905] PDUs, the request-id component in the PDU can be used to correlate Responses to outstanding Requests.

Even though it would be typical for an SNMP engine and an SNMP Command Generator Application to do this as a matter of course, it's a big deal when you're using these security protocols because of the possibility of message duplication, whether malicious or otherwise ๐Ÿ™ˆ

  • If an SNMP engine uses a msgID for correlating Response messages to outstanding Request messages, then it MUST use different msgIDs in all such Request messages that it sends out during a Time Window (150 seconds) period.

A Command Generator or Notification Originator Application MUST use different request-ids in all Request PDUs that it sends out during a TimeWindow (150 seconds) period.

This has to be done to protect against the possibility of message duplication, whether malicious or otherwise ๐Ÿšซ

For example, starting operations with a msgID and/or request-id value of zero is not a good idea ๐Ÿ™… starting with an unpredictable number (so they don't start out the same after each reboot) and then incrementing by one would be acceptable ๐Ÿงš

  • An SNMP engine should perform time synchronization using authenticated messages to protect against the possibility of message duplication, whether malicious or otherwise ๐Ÿ•ฐ๏ธ
  • When sending state altering messages to a managed authoritative SNMP engine, a Command Generator Application should delay sending successive messages to that managed SNMP engine until a positive acknowledgement is received for the previous message or until the previous message expires.

No message ordering is imposed by SNMP. Messages may be received in any order relative to their time of generation, and each will be processed in the order received. Note that when an authenticated message is sent to a managed SNMP engine, it will be valid for approximately 150 seconds under normal circumstances, and it's subject to replay during that window ๐Ÿ˜ฌ an SNMP engine and SNMP Command Generator Applications have to cope with the loss and re-ordering of messages caused by network anomalies as a matter of course ๐ŸŒช๏ธ

however, a managed object, snmpSetSerialNo [RFC1907], is specifically defined for use with SNMP Set operations. it gives you a mechanism to make sure SNMP messages get processed in a specific order ๐ŸŽฏ

  • The frequency with which the secrets of a User-based Security Model user should be changed is indirectly related to how often those secrets get used โณ

protecting the secrets from disclosure is critical to the overall security of the protocols ๐Ÿ” frequent use of a secret gives a cryptanalyst a steady stream of data they could use to exploit known or perceived weaknesses in an algorithm. frequently changing the secret shuts that down ๐Ÿ”„

changing a secret after every single use is generally seen as the most secure practice, but it can come with a lot of overhead ๐Ÿ˜ฎโ€๐Ÿ’จ

also, in a local environment the threat of disclosure may be less significant, so changing secrets can happen less often. however, when public data networks are used as the communication paths, more caution is wise ๐ŸŒโœจ

11.2. Defining Users ๐ŸŽ€

okay so the whole User-based Security Model is built around the idea of users, the people or things a message gets sent on behalf of. ๐Ÿซถ How you define a user is totally up to your network's security policy. A user could be a person like joe or jane, a role like operator or administrator, or a combo like joe-operator, jane-operator or joe-admin. ๐Ÿ’… A user can even be a logical entity, like an SNMP Application or a set of them, acting for an individual, a role, a set of individuals, a set of roles, or any combination. It's giving flexible ๐Ÿ˜ญ

Appendix A has an algorithm that turns a user "password" into a 16 octet value, which can be used as an authentication key, a privacy key, or both. ngl, using the same password (and therefore the same key) for both authentication and privacy is very poor security practice and should be strongly discouraged ๐Ÿ’€. Human-generated passwords can be shorter than the 16 octets the auth and privacy protocols need, and brute force attacks are pretty easy on a relatively short ASCII character set ๐Ÿ™ˆ. So the Appendix A algorithm performs a transformation on the password. If you use the Appendix A algorithm, SNMP implementations (and SNMP configuration applications) must ensure that passwords are at least 8 characters in length.

Because the Appendix A algorithm uses these passwords (nearly) directly, it is very important that they not be easily guessed ๐Ÿ”ฅ. The suggestion is to mix uppercase and lowercase letters, numbers, and punctuation, and to avoid words or phrases that you'd find in a dictionary. Longer passwords make the system more secure. Users may also want to type in multiword phrases, which makes the password longer while keeping it memorable โœจ.

Here's the tea ๐Ÿต: it's impossible for human users to keep a different password for every SNMP engine, but security requirements strongly discourage using the same key for more than one SNMP engine. So the User-based Security Model uses a compromise proposed in [Localized-key]. It derives the user keys for each SNMP engine from the user's password, in a way that makes it practically impossible to figure out either the user's password or the user's key for another SNMP engine, even from any combination of the user's keys on SNMP engines. big brain energy ๐Ÿง 

Note however, that if the user's password is disclosed, then key localization won't help and network security may be compromised in this case. Therefore a user's password or non-localized key MUST NOT be stored on a managed device/node. Instead the localized key SHALL be stored (if at all), so that, in case a device does get compromised, no other managed or managing devices get compromised ๐Ÿ›ก๏ธ.

11.3. Conformance โœจ

To be termed a "Secure SNMP implementation" based on the User-based Security Model, an SNMP implementation MUST:

  • implement one or more Authentication Protocol(s). The HMAC-MD5-96 and HMAC-SHA-96 Authentication Protocols defined in this memo are examples of such protocols.
  • to the maximum extent possible, prohibit access to the secret(s) of each user about which it maintains information in a Local Configuration Datastore (LCD) under all circumstances except as required to generate and/or validate SNMP messages with respect to that user.
  • implement the key-localization mechanism.
  • implement the SNMP-USER-BASED-SM-MIB.

In addition, an authoritative SNMP engine SHOULD provide initial configuration in accordance with Appendix A.1 ๐ŸŒธ.

Implementation of a Privacy Protocol (the DES Symmetric Encryption Protocol defined in this memo is one such protocol) is optional ๐Ÿฆ‹.


12. References ๐Ÿ“š

[RFC1321] Rivest, R., "Message Digest Algorithm MD5", RFC 1321, April 1992.

[RFC1903] Case, J., McCloghrie, K., Rose, M. and S. Waldbusser, "Textual Conventions for Version 2 of the Simple Network Management Protocol (SNMPv2)", RFC 1903, January 1996.

[RFC1905] Case, J., McCloghrie, K., Rose, M. and S. Waldbusser, "Protocol Operations for Version 2 of the Simple Network Management Protocol (SNMPv2)", RFC 1905, January 1996.

[RFC1906] Case, J., McCloghrie, K., Rose, M. and S. Waldbusser, "Transport Mappings for Version 2 of the Simple Network Management Protocol (SNMPv2)", RFC 1906, January 1996.

[RFC1907] Case, J., McCloghrie, K., Rose, M. and S. Waldbusser, "Management Information Base for Version 2 of the Simple Network Management Protocol (SNMPv2)", RFC 1907 January 1996.

[RFC2104] Krawczyk, H., Bellare, M., and R. Canetti, "HMAC: Keyed-Hashing for Message Authentication", RFC 2104, February 1997.

[RFC2028] Hovey, R., and S. Bradner, "The Organizations Involved in the IETF Standards Process", BCP 11, RFC 2028, October 1996.

[RFC2119] Bradner, S., "Key words for use in RFCs to Indicate Requirement Levels", BCP 14, RFC 2119, March 1997.

[RFC2271] Harrington, D., Presuhn, R., and B. Wijnen, "An Architecture for describing SNMP Management Frameworks", RFC 2271, January 1998.

[RFC2272] Case, J., Harrington, D., Presuhn, R., and B. Wijnen, "Message Processing and Dispatching for the Simple Network Management Protocol (SNMP)", RFC 2272, January 1998.

[Localized-Key] U. Blumenthal, N. C. Hien, B. Wijnen "Key Derivation for Network Management Applications" IEEE Network Magazine, April/May issue, 1997.

[DES-NIST] Data Encryption Standard, National Institute of Standards and Technology. Federal Information Processing Standard (FIPS) Publication 46-1. Supersedes FIPS Publication 46, (January, 1977; reaffirmed January, 1988).

[DES-ANSI] Data Encryption Algorithm, American National Standards Institute. ANSI X3.92-1981, (December, 1980).

[DESO-NIST] DES Modes of Operation, National Institute of Standards and Technology. Federal Information Processing Standard (FIPS) Publication 81, (December, 1980).

[DESO-ANSI] Data Encryption Algorithm - Modes of Operation, American National Standards Institute. ANSI X3.106-1983, (May 1983).

[DESG-NIST] Guidelines for Implementing and Using the NBS Data Encryption Standard, National Institute of Standards and Technology. Federal Information Processing Standard (FIPS) Publication 74, (April, 1981).

[DEST-NIST] Validating the Correctness of Hardware Implementations of the NBS Data Encryption Standard, National Institute of Standards and Technology. Special Publication 500-20.

[DESM-NIST] Maintenance Testing for the Data Encryption Standard, National Institute of Standards and Technology. Special Publication 500-61, (August, 1980).

[SHA-NIST] Secure Hash Algorithm. NIST FIPS 180-1, (April, 1995) http://csrc.nist.gov/fips/fip180-1.txt (ASCII) http://csrc.nist.gov/fips/fip180-1.ps (Postscript)


13. Editors' Addresses ๐ŸŒท

Uri Blumenthal
IBM T. J. Watson Research
30 Saw Mill River Pkwy,
Hawthorne, NY 10532
USA

EMail:      uri@watson.ibm.com
Phone:      +1-914-784-7064
Bert Wijnen
IBM T. J. Watson Research
Schagen 33
3461 GL Linschoten
Netherlands

EMail:      wijnen@vnet.ibm.com
Phone:      +31-348-432-794

APPENDIX A - Installation ๐Ÿงš

A.1. SNMP engine Installation Parameters

During installation, an authoritative SNMP engine SHOULD (in the meaning as defined in [RFC2119]) be configured with several initial parameters. These include:

  1. A security posture

The choice of security posture determines if initial configuration is implemented and if so how. One of three possible choices is selected:

minimum-secure,
semi-secure,
very-secure (i.e., no-initial-configuration)

In the case of a very-secure posture, there is no initial configuration, and so the following steps are irrelevant.

  1. one or more secrets

These are the authentication/privacy secrets for the first user to be configured.

One way to accomplish this is to have the installer enter a "password" for each required secret. The password is then algorithmically converted into the required secret by:

  • forming a string of length 1,048,576 octets by repeating the value of the password as often as necessary, truncating accordingly, and using the resulting string as the input to the MD5 algorithm [MD5]. The resulting digest, termed "digest1", is used in the next step.
  • a second string is formed by concatenating digest1, the SNMP engine's snmpEngineID value, and digest1. This string is used as input to the MD5 algorithm [MD5].

The resulting digest is the required secret (see Appendix A.2).

With these configured parameters, the SNMP engine instantiates the following usmUserEntry in the usmUserTable:

                       no privacy support     privacy support
                       ------------------     ---------------
usmUserEngineID        localEngineID          localEngineID
usmUserName            "initial"              "initial"
usmUserSecurityName    "initial"              "initial"
usmUserCloneFrom       ZeroDotZero            ZeroDotZero
usmUserAuthProtocol    usmHMACMD5AuthProtocol usmHMACMD5AuthProtocol
usmUserAuthKeyChange   ""                     ""
usmUserOwnAuthKeyChange ""                    ""
usmUserPrivProtocol    none                   usmDESPrivProtocol
usmUserPrivKeyChange   ""                     ""
usmUserOwnPrivKeyChange ""                    ""
usmUserPublic          ""                     ""
usmUserStorageType     anyValidStorageType    anyValidStorageType
usmUserStatus          active                 active

A.2. Password to Key Algorithm

A sample code fragment (section A.2.1) demonstrates the password to key algorithm which can be used when mapping a password to an authentication or privacy key using MD5. The reference source code of MD5 is available in [RFC1321].

Another sample code fragment (section A.2.2) demonstrates the password to key algorithm which can be used when mapping a password to an authentication or privacy key using SHA (documented in SHA-NIST).

An example of the results of a correct implementation is provided (section A.3) which an implementor can use to check if his implementation produces the same result ๐Ÿ“.

A.2.1. Password to Key Sample Code for MD5

void password_to_key_md5(
   u_char *password,    /* IN */
   u_int   passwordlen, /* IN */
   u_char *engineID,    /* IN  - pointer to snmpEngineID  */
   u_int   engineLength /* IN  - length of snmpEngineID */
   u_char *key)         /* OUT - pointer to caller 16-octet buffer */
{
   MD5_CTX     MD;
   u_char     *cp, password_buf[64];
   u_long      password_index = 0;
   u_long      count = 0, i;

   MD5Init (&MD);   /* initialize MD5 */
   /**********************************************/
   /* Use while loop until we've done 1 Megabyte */
   /**********************************************/
   while (count < 1048576) {
      cp = password_buf;
      for (i = 0; i < 64; i++) {
          /*************************************************/
          /* Take the next octet of the password, wrapping */
          /* to the beginning of the password as necessary.*/
          /*************************************************/
          *cp++ = password[password_index++ % passwordlen];
      }
      MD5Update (&MD, password_buf, 64);
      count += 64;
   }
   MD5Final (key, &MD);          /* tell MD5 we're done */

   /*****************************************************/
   /* Now localize the key with the engineID and pass   */
   /* through MD5 to produce final key                  */
   /* May want to ensure that engineLength <= 32,       */
   /* otherwise need to use a buffer larger than 64     */
   /*****************************************************/
   memcpy(password_buf, key, 16);
   memcpy(password_buf+16, engineID, engineLength);
   memcpy(password_buf+engineLength, key, 16);

   MD5Init(&MD);
   MD5Update(&MD, password_buf, 32+engineLength);
   MD5Final(key, &MD);

   return;
}

A.2.2. Password to Key Sample Code for SHA

void password_to_key_sha(
   u_char *password,    /* IN */
   u_int   passwordlen, /* IN */
   u_char *engineID,    /* IN  - pointer to snmpEngineID  */
   u_int   engineLength /* IN  - length of snmpEngineID */
   u_char *key)         /* OUT - pointer to caller 20-octet buffer */
{
   SHA_CTX     SH;
   u_char     *cp, password_buf[72];
   u_long      password_index = 0;
   u_long      count = 0, i;
   SHAInit (&SH);   /* initialize SHA */

   /**********************************************/
   /* Use while loop until we've done 1 Megabyte */
   /**********************************************/
   while (count < 1048576) {
      cp = password_buf;
      for (i = 0; i < 64; i++) {
          /*************************************************/
          /* Take the next octet of the password, wrapping */
          /* to the beginning of the password as necessary.*/
          /*************************************************/
          *cp++ = password[password_index++ % passwordlen];
      }
      SHAUpdate (&SH, password_buf, 64);
      count += 64;
   }
   SHAFinal (key, &SH);          /* tell SHA we're done */

   /*****************************************************/
   /* Now localize the key with the engineID and pass   */
   /* through SHA to produce final key                  */
   /* May want to ensure that engineLength <= 32,       */
   /* otherwise need to use a buffer larger than 72     */
   /*****************************************************/
   memcpy(password_buf, key, 20);
   memcpy(password_buf+20, engineID, engineLength);
   memcpy(password_buf+engineLength, key, 20);

   SHAInit(&SH);
   SHAUpdate(&SH, password_buf, 40+engineLength);
   SHAFinal(key, &SH);

   return;
}

A.3. Password to Key Sample Results

A.3.1. Password to Key Sample Results using MD5

Here's a sample of what the password to key algorithm spits out for a 16-octet key using MD5. ๐Ÿ’–

With a password of "maplesyrup", the output of the password to key algorithm before the key gets localized with the SNMP engine's snmpEngineID looks like this:

'9f af 32 83 88 4e 92 83 4e bc 98 47 d8 ed d9 63'H

After that intermediate key (shown above) is localized with the snmpEngineID value of:

'00 00 00 00 00 00 00 00 00 00 00 02'H

the final output of the password to key algorithm is:

'52 6f 5e ed 9f cc e2 6f 89 64 c2 93 07 87 d8 2b'H

A.3.2. Password to Key Sample Results using SHA

Same vibe, but now for a 20-octet key using SHA. ๐ŸŒธ

With a password of "maplesyrup", the output before localization with the SNMP engine's snmpEngineID is:

'f1 be a9 ae 66 7f 4f b6 34 1e 51 af 06 80 7e 91 e4 3b 01 ac'H

After the intermediate key (shown above) is localized with the snmpEngineID value of:

'00 00 00 00 00 00 00 00 00 00 00 02'H

the final output of the password to key algorithm is:

'8a a3 d9 9e 3e 30 56 f2 bf e3 a9 ee f3 45 d5 39 54 91 12 be'H

A.4. Sample encoding of msgSecurityParameters

Okay so msgSecurityParameters in an SNMP message is represented as an OCTET STRING, and that OCTET STRING should be treated as opaque outside a specific Security Model. Hands off, everyone else ๐Ÿ™ˆ

The User-based Security Model is the one that defines what's inside that OCTET STRING: it's a SEQUENCE (see section 2.4). ๐Ÿงš

Put those two things together and you get an example of msgSecurityParameters for the User-based Security Model, encoded as an OCTET STRING:

  04 <length>
  30 <length>
  04 <length> <msgAuthoritativeEngineID>
  02 <length> <msgAuthoritativeEngineBoots>
  02 <length> <msgAuthoritativeEngineTime>
  04 <length> <msgUserName>
  04 0c       <HMAC-MD5-96-digest>
  04 08       <salt>

And here's that same example again, but now with real values. The only things left as placeholders are the digest in msgAuthenticationParameters and the salt in msgPrivacyParameters, since those depend on variable data we haven't defined here. ๐ŸŽ€

  Hex Data                         Description
  --------------  -----------------------------------------------
  04 39           OCTET STRING,                  length 57
  30 37           SEQUENCE,                      length 55
  04 0c 80000002  msgAuthoritativeEngineID:      IBM
        01                                       IPv4 address
        09840301                                 9.132.3.1
  02 01 01        msgAuthoritativeEngineBoots:   1
  02 02 0101      msgAuthoritativeEngineTime:    257
  04 04 62657274  msgUserName:                   bert
  04 0c 01234567  msgAuthenticationParameters:   sample value
        89abcdef
        fedcba98
  04 08 01234567  msgPrivacyParameters:          sample value
        89abcdef

Copyright (C) The Internet Society (1998). All Rights Reserved. ๐ŸŒˆ

Okay bestie, time for the legal bit ๐Ÿ’… You're allowed to copy this document and share it with anyone. You can also write derivative works that comment on it, explain it, or help people implement it, and publish and distribute those in whole or in part with no restrictions, as long as the copyright notice and this paragraph stay on every copy and derivative work.

BUT the document itself can't be modified in any way. That means no removing the copyright notice or the references to the Internet Society or other Internet organizations. The only exceptions are developing Internet standards (in which case the Internet Standards process copyright procedures must be followed) or translating it into languages other than English. ๐Ÿซถ

These permissions are perpetual, and the Internet Society or its successors or assigns won't revoke them. ๐Ÿฆ‹

And the fine print, which is very serious and very not fun ๐Ÿ˜ญ

This document and the information contained herein is provided on an "AS IS" basis and THE INTERNET SOCIETY AND THE INTERNET ENGINEERING TASK FORCE DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
๐Ÿ“ฆ where this page comes from