RFC 2574
User-based Security Model (USM) for version 3 of the Simple Network Management Protocol (SNMPv3)
RFC 2574: User-based Security Model (USM) for SNMPv3 ๐
okay bestie, this is the one that tells SNMPv3 how to figure out WHO is talking and keep their messages safe ๐โจ
RFC number: 2574 Title: User-based Security Model (USM) for version 3 of the Simple Network Management Protocol (SNMPv3) Authors: U. Blumenthal and B. Wijnen, both from IBM T. J. Watson Research ๐ง Category: Standards Track ๐ Date: April 1999 ๐ธ Obsoletes: RFC 2274 (it replaces that one, so new girlie, new rules) ๐ Updates: none listed
Status of This Memo ๐
This document describes an Internet standards track protocol for the Internet community, and it's asking everyone for discussion and suggestions for improvements ๐ฆ If you want to know where this protocol stands officially, check the current edition of the "Internet Official Protocol Standards" (STD 1). Distribution of this memo is unlimited, so share it with everyone ๐
Copyright Notice ยฉ๏ธ
Copyright (C) The Internet Society (1999). All Rights Reserved. ๐ซถ
Abstract โจ
Okay so this doc describes the User-based Security Model (USM) for SNMP version 3, the one used in the SNMP architecture [RFC2571] ๐ It spells out the Elements of Procedure for giving SNMP messages security at the message level. It also includes a MIB, which is basically a way to remotely watch and manage the configuration settings for this security model. Iconic. ๐
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 msgAuthoritativeEngineTime14
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 50
6.1. Mechanisms 50
6.1.1. Digest Authentication Mechanism 50
6.2. Elements of the Digest Authentication Protocol 51
6.2.1. Users 51
6.2.2. msgAuthoritativeEngineID 51
6.2.3. SNMP Messages Using this Authentication Protocol 51
6.2.4. Services provided by the HMAC-MD5-96 Authentication Module52
6.2.4.1. Services for Generating an Outgoing SNMP Message 52
6.2.4.2. Services for Processing an Incoming SNMP Message 53
6.3. Elements of Procedure 53
6.3.1. Processing an Outgoing Message 54
6.3.2. Processing an Incoming Message 54
7. HMAC-SHA-96 Authentication Protocol 55
7.1. Mechanisms 55
7.1.1. Digest Authentication Mechanism 56
7.2. Elements of the HMAC-SHA-96 Authentication Protocol 56
7.2.1. Users 56
7.2.2. msgAuthoritativeEngineID 57
7.2.3. SNMP Messages Using this Authentication Protocol 57
7.2.4. Services provided by the HMAC-SHA-96 Authentication Module57
7.2.4.1. Services for Generating an Outgoing SNMP Message 57
7.2.4.2. Services for Processing an Incoming SNMP Message 58
7.3. Elements of Procedure 59
7.3.1. Processing an Outgoing Message 59
7.3.2. Processing an Incoming Message 60
8. CBC-DES Symmetric Encryption Protocol 61
8.1. Mechanisms 61
8.1.1. Symmetric Encryption Protocol 61
8.1.1.1. DES key and Initialization Vector. 62
8.1.1.2. Data Encryption. 63
8.1.1.3. Data Decryption 63
8.2. Elements of the DES Privacy Protocol 63
8.2.1. Users 63
8.2.2. msgAuthoritativeEngineID 64
8.2.3. SNMP Messages Using this Privacy Protocol 64
8.2.4. Services provided by the DES Privacy Module 64
8.2.4.1. Services for Encrypting Outgoing Data 64
8.2.4.2. Services for Decrypting Incoming Data 65
8.3. Elements of Procedure. 66
8.3.1. Processing an Outgoing Message 66
8.3.2. Processing an Incoming Message 66
9. Intellectual Property 67
10. Acknowledgements 67
11. Security Considerations 69
11.1. Recommended Practices 69
11.2. Defining Users 71
11.3. Conformance 72
11.4. Use of Reports 72
11.5. Access to the SNMP-USER-BASED-SM-MIB 72
12. References 73
13. Editors' Addresses 75
A.1. SNMP engine Installation Parameters 76
A.2. Password to Key Algorithm 78
A.2.1. Password to Key Sample Code for MD5 79
A.2.2. Password to Key Sample Code for SHA 80
A.3. Password to Key Sample Results 81
A.3.1. Password to Key Sample Results using MD5 81
A.3.2. Password to Key Sample Results using SHA 81
A.4. Sample encoding of msgSecurityParameters 82
A.5. Sample keyChange Results 83
A.5.1. Sample keyChange Results using MD5 83
A.5.2. Sample keyChange Results using SHA 84
B. Change Log 85
C. Full Copyright Statement 86
1. Introduction ๐
The Architecture for describing Internet Management Frameworks [RFC2571] 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 borrow the services of these subsystems, so they're like the VIP section of the engine ๐
It's super important to get the SNMP architecture and its vocabulary down so you can see where the Security Model in this doc fits in and how it hangs out with the other subsystems. The reader is expected to have already read and understood the SNMP architecture description in [RFC2571], so go catch up first if you haven't ๐
This memo [RFC2274] describes the User-based Security Model the way it's used inside the SNMP Architecture. The big idea is simple: we use the classic concept of a user, identified by a userName, and attach security information to that user ๐ซถ
This memo describes HMAC-MD5-96 and HMAC-SHA-96 as the authentication protocols, and CBC-DES as the privacy protocol. BUT the User-based Security Model lets other protocols be used instead of these, or alongside them ๐ฆ That's why HMAC-MD5-96, HMAC-SHA-96 and CBC-DES each get their own section. They're self-contained, and that setup means they can be swapped out or added to 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 interpreted as described in [RFC2119]. Those are the official BCP 14 vibes, so read them as the RFC 2119 meanings, periodt ๐ฅ
โจ more parts are coming, bestie, so stay tuned ๐ง๐
1.1. Threats ๐ฅ
Okay so, some of the classic network protocol threats totally apply to network management, which means they'd also apply to any SNMP Security Model ๐ญ. Other threats just don't apply to network management at all. This section goes through the principal threats, the secondary ones, and the ones that matter less. ๐
The principal threats this SNMP Security Model should provide protection 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 principal 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. ๐ญ
There are also two secondary threats ๐. 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:
- Provide for verification that each received SNMP message has not been modified during its transmission through the network. ๐
- Provide for verification of the identity of the user on whose behalf a received SNMP message claims to have been generated. ๐ชช
- Provide for detection of received SNMP messages, which request or contain management information, whose time of generation was not recent. โฐ
- Provide, when necessary, that the contents of each received SNMP message are protected from disclosure. ๐
Supporting secure network management is the main goal, but the design of this SNMP Security Model is also shaped by these constraints:
- When the requirements of effective management in times of network stress are inconsistent with those of security, the design should prefer the former. ๐ช๏ธ
- 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). ๐ โโ๏ธ
- 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:
- Data Integrity 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 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 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 This 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 obtain data integrity without data origin authentication, nor is it possible to obtain data origin authentication without data integrity. Further, there is no provision for data confidentiality without both data integrity and data origin authentication. ๐
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 specific responsibilities, so that together they realize the goals and security services described above ๐:
- 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 ๐ .
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 (those messages that contain a Confirmed Class PDU [RFC2571]), then the receiver of such messages is authoritative. When an SNMP message contains a payload which does not expect a response (those messages that contain an Unconfirmed Class PDU [RFC2571]), then the sender of such a message is authoritative. โจ
1.5.2. Mechanisms โจ
okay so here's how the security model actually protects against sneaky messages ๐
1) To guard against message delay or replay (to an extent greater than can happen through normal operation), each message generated includes a set of timeliness indicators for the authoritative SNMP engine. An SNMP engine checks those indicators to decide whether a received message is recent ๐ฐ๏ธ. It may also check that a received message is at least as recent as the last message it got from the same source. A non-authoritative SNMP engine uses authentic messages it receives to move forward its idea of the timeliness indicators at the remote authoritative source ๐ .
An SNMP engine MUST also use a mechanism to match incoming Responses to outstanding Requests, and it MUST drop any Responses that do not match an outstanding request ๐ซถ. For example, a msgID can be put in every message to handle this job.
These mechanisms let you detect authenticated messages whose generation time wasn't recent. Lowkey a glow-up for security ๐ธ.
This protection against delay or replay does not imply or provide any protection against unauthorized deletion or suppression of messages, so don't get it twisted ๐. Also, an SNMP engine may not be able to detect message reordering if all the messages involved are sent within the Time Window interval. Other mechanisms defined independently of the security protocol can also be used to detect the re-ordering, replay, deletion, or suppression of messages containing Set operations (for example, the MIB variable snmpSetSerialNo [RFC1907]) โจ.
2) Verification that a message sent to or from one authoritative SNMP engine cannot be replayed to, or as if from, another authoritative SNMP engine ๐ฆ.
Each message includes an identifier that is unique to the authoritative SNMP engine associated with the sender or intended recipient of the message ๐.
A message containing an Unconfirmed Class PDU, sent by an authoritative SNMP engine to one non-authoritative SNMP engine, can potentially be replayed to another non-authoritative SNMP engine. That second engine might (if it knows the same userName with the same secrets at the authoritative SNMP engine) update its idea of the authoritative SNMP engine's timeliness indicators as a result, but that is not considered a threat ๐. In this case, a Report or Response message will be discarded by the Message Processing Model, because there should not be an outstanding Request message. A Trap will possibly be accepted. Again, that's not considered a threat, because the communication was authenticated and timely ๐. It's as if the authoritative SNMP engine were configured to start sending Traps to the second SNMP engine, which can theoretically happen without the second engine knowing anyway ๐ง. Anyway, the second SNMP engine may not expect to receive this Trap, but it is allowed to see the management information in it ๐.
3) Detection of messages which were not recently generated ๐ฅ.
A set of time indicators is included in the message, showing the time of generation. Messages without recent time indicators are not considered authentic ๐. In addition, an SNMP engine MUST drop any Responses that do not match an outstanding request. This, however, is the responsibility of the Message Processing Model ๐.
This memo allows the same user to be defined on multiple SNMP engines. Each SNMP engine maintains a value, snmpEngineID, which uniquely identifies the SNMP engine. This value is included in each message sent to or from the SNMP engine that is authoritative (see section 1.5.1). On receipt of a message, an authoritative SNMP engine checks the value to make sure it is the intended recipient, and a non-authoritative SNMP engine uses the value to make sure the message is processed using the correct state information ๐ธ.
Each SNMP engine maintains two values, snmpEngineBoots and snmpEngineTime, which together give an indication of time at that SNMP engine โฐ. Both values are included in an authenticated message sent to or received from that SNMP engine. On receipt, the values are checked to make sure the indicated timeliness value is within a Time Window of the current time. The Time Window is an administrative upper bound on acceptable delivery delay for protocol messages ๐ฆ.
For an SNMP engine to generate a message that an authoritative SNMP engine will accept as authentic, and to verify that a message received from that authoritative SNMP engine is authentic, the SNMP engine must first achieve timeliness synchronization with the authoritative SNMP engine. See section 2.3 ๐ซถ.
1.6. Abstract Service Interfaces ๐งฉ
Abstract service interfaces are defined to describe the conceptual interfaces between the various subsystems within an SNMP entity. Similarly, a set of abstract service interfaces is defined within the User-based Security Model (USM) to 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 that describe the services provided and the abstract data elements that must be passed when the services are 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 provides the following internal primitives to pass 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 provides the following internal primitives to pass 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 contains the definitions required to realize the security model defined by this memo ๐.
2.1. User-based Security Model Users ๐ค
Management operations using this Security Model make use of a defined set of user identities. For any user on whose behalf management operations are authorized at a particular SNMP engine, that SNMP engine must have knowledge of that user. An SNMP engine that wishes to communicate with another SNMP engine must also have knowledge of a user known to that engine, including knowledge of the applicable attributes of that user ๐ท.
A user and its attributes are defined as follows:
userName: A string representing the name of the user.
securityName: A human-readable string representing the user in a format that is Security Model independent.
authProtocol: An indication of whether messages sent on behalf of this user can be authenticated and, if so, the type of authentication protocol which is used. Two such protocols are defined in this memo:
- the HMAC-MD5-96 authentication protocol.
- the HMAC-SHA-96 authentication protocol.
authKey: If messages sent on behalf of this user can be authenticated, the (private) authentication key for use with the authentication protocol. Note that a user's authentication key will normally be different at different authoritative SNMP engines. The authKey is not accessible via SNMP. The length requirements of the authKey are defined by the authProtocol in use ๐.
authKeyChange and authOwnKeyChange: The only way to remotely update the authentication key. It does so in a secure manner, so the update can be completed without the need to employ privacy protection ๐ก๏ธ.
privProtocol: An indication of whether messages sent on behalf of this user can be protected from disclosure and, if so, the type of privacy protocol which is used. One such protocol is defined in this memo: the CBC-DES Symmetric Encryption Protocol ๐.
privKey: If messages sent on behalf of this user can be en/decrypted, the (private) privacy key for use with the privacy protocol. Note that a user's privacy key will normally be different at different authoritative SNMP engines. The privKey is not accessible via SNMP. The length requirements of the privKey are defined by the privProtocol in use ๐ฆ.
privKeyChange and privOwnKeyChange: The only way to remotely update the encryption key. It does that in a secure manner, so the update can be completed without the need to employ 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 is a count of the number of times the SNMP engine has re-booted or re-initialized sincesnmpEngineIDwas last configured; and,snmpEngineTime, which is the number of seconds since thesnmpEngineBootscounter was last incremented.
Each SNMP engine is always authoritative with respect to these objects in its own SNMP entity. It is 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 contained in an authenticated message is used to defeat attacks in which messages from one SNMP engine to another SNMP engine are replayed to a different SNMP engine. It represents the snmpEngineID at the authoritative SNMP engine involved in the exchange of the message ๐ซถ.
When an authoritative SNMP engine is first installed, it sets its local value of snmpEngineID according to an enterprise-specific algorithm (see the definition of the Textual Convention for SnmpEngineID in the SNMP Architecture document [RFC2571]) ๐.
2.2.2. msgAuthoritativeEngineBoots and msgAuthoritativeEngineTime โฐ
okay so msgAuthoritativeEngineBoots and msgAuthoritativeEngineTime are the anti-replay duo ๐ฏโโ๏ธ. they're in every authenticated message to stop attackers from replaying old messages that aren't valid anymore ๐
โโ๏ธ. they basically copy the snmpEngineBoots and snmpEngineTime values from the authoritative SNMP engine that's part of the exchange ๐
here's the lowkey genius part ๐ง โจ an SNMP engine doesn't need a clock that keeps ticking even when it's powered off ๐ญ instead, every time the engine reboots, it grabs snmpEngineBoots, adds one to it, saves it back into non-volatile storage, and resets snmpEngineTime to zero ๐ no stress, no clock needed ๐
when an SNMP engine is brand new, it sets its local snmpEngineBoots and snmpEngineTime to zero ๐ธ and if snmpEngineTime ever hits its max value (2147483647), then snmpEngineBoots gets incremented like the engine rebooted, snmpEngineTime goes back to zero, and it starts counting up again ๐ it's giving odometer rollover energy ๐๐จ
every time an authoritative SNMP engine reboots, any SNMP engines that are holding its snmpEngineBoots and snmpEngineTime values need to re-synchronize before they send correctly authenticated messages to it ๐ซถ (see Section 2.3 for the (re-)synchronization procedures). BUT, and this is a very big but ๐, the procedures still let a receiving SNMP engine accept a notification as authentic when it came from an authoritative SNMP engine that rebooted since the receiver last (re-)synchronized. so it's not a total lockout, which is iconic ๐
if an authoritative SNMP engine is ever unable to figure out its latest snmpEngineBoots value, then it must set snmpEngineBoots to 2147483647. ๐
whenever the local value of snmpEngineBoots is 2147483647, it latches at that value. and any authenticated message will always cause a notInTimeWindow authentication failure. no exceptions, bestie ๐ซ
to reset an SNMP engine whose snmpEngineBoots has reached 2147483647, you need manual intervention ๐ ๏ธ 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 SNMP engine. also, even if an SNMP engine reboots once a second, it would still take about 68 years to reach the max value of 2147483647 ๐คฏ so honestly, it's not happening to you ๐
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 says the exact same Time Window, 150 seconds, is used for every user, so there's no VIP treatment here ๐
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 when the non-authoritative engine has gotten a local notion of the authoritative engine's snmpEngineBoots and snmpEngineTime values from that authoritative engine ๐ซง those values must be (and remain) within the authoritative SNMP engine's Time Window, so the local copy has to stay loosely synchronized with what's stored at the authoritative engine ๐ค
the non-authoritative engine also keeps one extra local variable, latestReceivedEngineTime ๐ this one records the highest snmpEngineTime value the non-authoritative engine has ever received from the authoritative engine, and it's what stops someone from replaying messages to freeze the non-authoritative engine's notion of snmpEngineTime so it can't move forward ๐ก๏ธ that's some serious protection energy ๐ค
a non-authoritative SNMP engine must keep its local notions of snmpEngineBoots, snmpEngineTime and latestReceivedEngineTime for each authoritative SNMP engine it wants to talk to ๐ each authoritative engine is uniquely and unambiguously identified by its snmpEngineID, so the non-authoritative engine can use that value as the key to cache these values ๐๏ธ very organized, very slay ๐
time synchronization happens as part of the procedure for receiving an SNMP message (Section 3.2, step 7b) ๐ so no separate, explicit time synchronization procedure is needed for a non-authoritative SNMP engine โจ also, whenever the local snmpEngineID changes (for example through discovery), or when secure communications are first set up with an authoritative SNMP engine, the local values of snmpEngineBoots and latestReceivedEngineTime should be set to zero ๐ that forces time synchronization to happen when the next authentic message arrives ๐ฌ
2.4. SNMP Messages Using this Security Model ๐จ
an SNMP message using this Security Model follows the message format defined in the version-specific Message Processing Model document (for example [RFC2572]) ๐
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(0..32)),
-- authentication protocol specific parameters
msgAuthenticationParameters OCTET STRING,
-- privacy protocol specific parameters
msgPrivacyParameters OCTET STRING
}
END
here's what each field in that sequence does ๐
msgAuthoritativeEngineIDspecifies the snmpEngineID of the authoritative SNMP engine involved in the exchange of the message. ๐ทmsgAuthoritativeEngineBootsspecifies the snmpEngineBoots value at the authoritative SNMP engine involved in the exchange of the message. ๐ทmsgAuthoritativeEngineTimespecifies the snmpEngineTime value at the authoritative SNMP engine involved in the exchange of the message. ๐ทmsgUserNamespecifies the user (principal) on whose behalf the message is being exchanged. note that a zero-length userName won't match any user, but it can be used for snmpEngineID discovery ๐msgAuthenticationParametersare defined by the authentication protocol in use for the message, as defined by the usmUserAuthProtocol column in the user's entry in the usmUserTable. ๐msgPrivacyParametersare 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 the field msgSecurityParameters ๐งฉ
2.5. Services provided by the User-based Security Model ๐
this section is all about the services the User-based Security Model provides, including 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 get passed in these abstract service primitives ๐ฆ
2.5.1. Services for Generating an Outgoing SNMP Message โจ
okay bestie, so when the Message Processing (MP) Subsystem asks the User-based Security module to lock down an outgoing SNMP message ๐, it has to use the right service the Security module provides. there are literally two of them and they're both iconic ๐
- A service to generate a Request message. The abstract service primitive is:
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
)
- A service to generate a Response message. The abstract service primitive is:
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
)
so the data elements passed into these primitives are the following ๐
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, which is the admin info. also not used by the User-based Security module ๐งmaxMessageSize: the max message size, as included in the message, from the sending SNMP entity. not used by the User-based Security module ๐securityParameters: the security parameters themselves. the User-based Security module fills these in ๐securityModel: the securityModel in use, which should be the User-based Security Model. not used by the User-based Security module ๐ฆ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 insteadsecurityLevel: the Level of Security. the User-based Security module uses it to figure out whether the message needs protection from disclosure and whether it needs to be authenticated ๐ซถ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 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 vibes ๐securityStateReference: a handle/reference to cachedSecurityData, used when securing an outgoing Response message. it's the exact same handle that the User-based Security module generated when it processed the incoming Request message 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 finishes, the User-based Security module returns statusInformation. if it worked, you get the completed message with privacy and authentication applied, as long as the specified securityLevel asked for them ๐ if it didn't work, 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 has to use the service 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
and here's what those data elements mean ๐ง
statusInformation: whether the process succeeded. 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. not used by the User-based Security module ๐maxMessageSize: the max message size as included in the message. the User-based Security module uses this value to calculate the maxSizeResponseScopedPDU ๐งฎsecurityParameters: the security parameters, exactly as received in the message ๐securityModel: the securityModel in use, which should be the User-based Security Model. not used by the User-based Security module ๐securityLevel: the Level of Security. the User-based Security module uses it to decide whether the message needs protection from disclosure and whether it needs to be authenticated ๐ก๏ธwholeMsg: the whole message, as it was received ๐ฆwholeMsgLength: the length of the message as it was received (wholeMsg) ๐securityEngineID: the snmpEngineID that got pulled out of the field msgAuthoritativeEngineID. it's 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. the format doesn't depend on the Security Model ๐scopedPDU: the message payload. opaque to the User-based Security Model, again ๐ซงmaxSizeResponseScopedPDU: the largest scopedPDU that could fit in a possible Response message. the User-based Security module works this out from the msgMaxSize (as received in the message) and the space needed for the Response message's header, including the securityParameters ๐securityStateReference: a handle/reference to cachedSecurityData, for securing an outgoing Response message later. when the Message Processing Subsystem calls the User-based Security module to generate a response to this incoming message, it has to pass this handle/reference back in ๐
when the process is done, the User-based Security module returns statusInformation and, if it worked, the extra data elements the Message Processing Subsystem needs to keep going ๐ฆ if it didn't work, you get an errorIndication, which might come with an OID and value pair for whichever error counter got incremented ๐
2.6. Key Localization Algorithm. ๐
okay so a localized key is a secret key shared between a user U and one authoritative SNMP engine E ๐ซถ here's the thing: a user might only have one password, which means one key for the whole network, but 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, then that password gets converted 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 of user U at the authoritative SNMP engine E, you append the snmpEngineID of that authoritative SNMP engine to the key Ku, and then you append the key Ku to the result. basically the snmpEngineID gets wrapped inside two copies of the user's key Ku ๐ then you run a secure hash function on that. which hash function depends on the authentication protocol defined for user U at authoritative SNMP engine E. this document defines two authentication protocols with their 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 an SNMP engine follows when it processes SNMP messages according to the User-based Security Model ๐
3.1. Generating an Outgoing SNMP Message โจ
okay bestie, this section is the recipe an SNMP engine follows whenever it cooks up a message with a management operation in it (a request, a response, a notification, or a report) on behalf of a user at a particular securityLevel. ๐ let's go step by step!
- a) If any
securityStateReferenceis passed (Response or Report message), then the user's info gets pulled from thecachedSecurityData. ThecachedSecurityDatacan now be discarded ๐๏ธ. ThesecurityEngineIDis set to the localsnmpEngineID, and thesecurityLevelis set to whatever value the calling module specified.
Otherwise,
b) based on the securityName, the info about the user at the destination snmpEngineID (that's the securityEngineID) gets pulled from the Local Configuration Datastore (LCD, usmUserTable). If the user isn't in the LCD at all, then an error indication (unknownSecurityName) gets returned to the calling module. ๐
- If the
securityLevelsays 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. - If the
securityLevelsays the message has to be authenticated, but the user doesn't support an authentication protocol, then the message can't be sent. An error indication (unsupportedSecurityLevel) gets returned to the calling module. ๐ - a) If the
securityLevelsays the message has to be protected from disclosure, then the octet sequence representing the serializedscopedPDUgets encrypted using the user's privacy protocol. To do that, a call goes to 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 you 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 gets 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, then the message can't be sent and an error indication (encryptionError) gets returned to the calling module. ๐ญ
If the privacy module says success, then the returned privParameters go 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 a zero-length OCTET STRING gets encoded into the msgPrivacyParameters field of the securityParameters, and the plaintext scopedPDU becomes the payload of the message being prepared.
- The
securityEngineIDgets encoded as an OCTET STRING into themsgAuthoritativeEngineIDfield of thesecurityParameters. Here's the tea โ: an empty (zero length)securityEngineIDis totally OK for a Request message, because the remote (authoritative) SNMP engine will send back a Report PDU with the propersecurityEngineIDin themsgAuthoritativeEngineIDof that returned Report PDU'ssecurityParameters. ๐ฆ - a) If the
securityLevelsays the message has to be authenticated, then the current values ofsnmpEngineBootsandsnmpEngineTimethat match thesecurityEngineIDfrom the LCD get used.
Otherwise,
b) if this is a Response or Report message, then the current values of snmpEngineBoots and snmpEngineTime that match the local snmpEngineID from the LCD get used.
Otherwise,
c) if this is a Request message, then a zero value is used for both snmpEngineBoots and snmpEngineTime. That zero value also gets used if snmpEngineID is empty.
The values get encoded as INTEGER, respectively, into the msgAuthoritativeEngineBoots and msgAuthoritativeEngineTime fields of the securityParameters. ๐
- The
userNamegets encoded as an OCTET STRING into themsgUserNamefield of thesecurityParameters. - a) If the
securityLevelsays the message has to be authenticated, then the message gets authenticated using the user's authentication protocol. To do that, a call goes to 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 you whether the 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 to be authenticated. authenticatedWholeMsg is the same as the input given to the authenticateOutgoingMsg service, but with msgAuthenticationParameters properly filled in.
If the authentication module says failure, then the message can't be sent and an error indication (authenticationFailure) gets returned to the calling module.
If the authentication module says success, then the msgAuthenticationParameters field goes into the securityParameters, and the authenticatedWholeMsg represents the serialization of the authenticated message being prepared. ๐ฅ
Otherwise,
b) if the securityLevel says the message does NOT need to be authenticated, then a zero-length OCTET STRING gets encoded into the msgAuthenticationParameters field of the securityParameters. The wholeMsg is now serialized and represents the unauthenticated message being prepared.
- The completed message, along with its length, gets returned to the calling module with
statusInformationset to success. ๐
3.2. Processing an Incoming SNMP Message ๐
okay, now the flip side! This section is the procedure an SNMP engine follows whenever it receives a message with a management operation on behalf of a user at a particular securityLevel. Let's see how it sorts the good from the sketchy ๐
Quick heads-up before we start: the release of state information isn't always spelled out in every step, to keep things tidy. The general rule is that if state information exists when a message gets discarded, that state information should also be released. An error indication can also return an OID and value for an incremented counter, and optionally a value for securityLevel, plus values for contextEngineID or contextName for the counter. And the securityStateReference data gets returned if any such info is available where the error gets detected. ๐ง
- If the received
securityParametersis not the serialization (according to the conventions of [RFC1906]) of an OCTET STRING formatted according to theUsmSecurityParametersdefined in section 2.4, then thesnmpInASNParseErrscounter [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 in this case there isn't enough info to generate a Report PDU. ๐ - The values of the security parameter fields get extracted from the
securityParameters. ThesecurityEngineIDto be returned to the caller is the value of themsgAuthoritativeEngineIDfield. ThecachedSecurityDatagets prepared, and asecurityStateReferencegets prepared to reference this data. The values to be cached are:
msgUserName
- If the value of the
msgAuthoritativeEngineIDfield in thesecurityParametersis 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 on processing;
or
b) the usmStatsUnknownEngineIDs counter gets incremented, and an error indication (unknownEngineID) together with the OID and value of the incremented counter gets returned to the calling module.
Note that if a zero-length, or otherwise illegally sized, msgAuthoritativeEngineID is received, b) should be chosen to facilitate engineID discovery. Otherwise, the choice between a) and b) is an implementation issue. ๐ธ
- Info about the values of the
msgUserNameandmsgAuthoritativeEngineIDfields gets extracted from the Local Configuration Datastore (LCD,usmUserTable). If there's no info available for the user, then theusmStatsUnknownUserNamescounter gets incremented, and an error indication (unknownSecurityName) together with the OID and value of the incremented counter gets returned to the calling module. ๐ - If the info about the user says it doesn't support the
securityLevelthe caller asked for, then theusmStatsUnsupportedSecLevelscounter gets incremented, and an error indication (unsupportedSecurityLevel) together with the OID and value of the incremented counter gets returned to the calling module. - If the
securityLevelsays the message has to be authenticated, then the message gets authenticated using the user's authentication protocol. To do that, a call goes to the authentication module that implements the user's authentication 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 you whether the 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 to be authenticated. authenticatedWholeMsg is the same as the input given to the authenticateIncomingMsg service, but after authentication has been checked. ๐
If the authentication module returns failure, then the message cannot be trusted ๐. So the usmStatsWrongDigests counter gets incremented, and an error indication (authenticationFailure) goes back to the calling module, along with the OID and value of that counter ๐ญ.
If the authentication module returns success, then the message is authentic and can be trusted, so processing keeps going ๐ซถโจ.
7) Okay, time check โฐ. If the securityLevel says the message is authenticated, then we pull the local values of snmpEngineBoots, snmpEngineTime, and latestReceivedEngineTime out of the Local Configuration Datastore. We match them up using the msgAuthoritativeEngineID field.
a) If the extracted msgAuthoritativeEngineID is the same as the snmpEngineID of the processing SNMP engine, meaning this is the authoritative SNMP engine, then the message is considered outside of the Time Window if any of these are true:
- the local value of snmpEngineBoots is 2147483647;
- the value of the msgAuthoritativeEngineBoots field differs from the local value of snmpEngineBoots; or,
- the value of the msgAuthoritativeEngineTime field differs from the local notion of snmpEngineTime by more than +/- 150 seconds.
If the message is outside the Time Window, then the usmStatsNotInTimeWindows counter gets incremented. An error indication (notInTimeWindow) goes back to the calling module, together with the OID, the value of the incremented counter, and an indication that the error must be reported with a securityLevel of authNoPriv.
b) If the extracted msgAuthoritativeEngineID is not the same as the snmpEngineID of the processing SNMP engine, meaning this is not the authoritative SNMP engine, then:
1) If at least one of these conditions is true:
- the extracted value of the msgAuthoritativeEngineBoots field is greater than the local notion of the value of snmpEngineBoots; or,
- the extracted value of the msgAuthoritativeEngineBoots field is equal to the local notion of the value of snmpEngineBoots, and the extracted value of the msgAuthoritativeEngineTime field is greater than the value of latestReceivedEngineTime,
then the LCD entry for the extracted msgAuthoritativeEngineID gets updated by setting:
- the local notion of the value of snmpEngineBoots to the value of the msgAuthoritativeEngineBoots field,
- the local notion of the value of snmpEngineTime to the value of the msgAuthoritativeEngineTime field, and
- the latestReceivedEngineTime to the value of the msgAuthoritativeEngineTime field.
2) If any of these conditions is true, then the message is considered outside of the Time Window:
- the local notion of the value of snmpEngineBoots is 2147483647;
- the value of the msgAuthoritativeEngineBoots field is less than the local notion of the value of snmpEngineBoots; or,
- the value of the msgAuthoritativeEngineBoots field is equal to the local notion of the value of snmpEngineBoots, and the value of the msgAuthoritativeEngineTime field is more than 150 seconds less than the local notion of the value of snmpEngineTime.
If the message is outside the Time Window, then an error indication (notInTimeWindow) goes back to the calling module.
Note that this means a too old (possibly replayed) message has been detected, and it is deemed unauthentic. ๐จ
Also note that this procedure allows the value of msgAuthoritativeEngineBoots in the message to be greater than the local notion of the value of snmpEngineBoots. That way, messages can still be accepted as authentic when they come from an authoritative SNMP engine that rebooted since the receiving SNMP engine last (re-)synchronized. Main character reboot arc, honestly ๐โจ.
8) a) If the securityLevel says the message was protected from disclosure, then the OCTET STRING representing the encryptedPDU gets decrypted according to the user's privacy protocol. This turns it into an unencrypted serialized scopedPDU value. To do that, we call 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, bestie ๐:
- statusInformation indicates whether the decryption process was successful or not.
- decryptKey is the user's localized private privKey. It's the secret key the decryption algorithm can use.
- privParameters is the msgPrivacyParameters, encoded as an OCTET STRING.
- encryptedData is the encryptedPDU, which represents the encrypted scopedPDU, encoded as an OCTET STRING.
- decryptedData is the serialized scopedPDU, if decryption works.
If the privacy module returns failure, then the message can not be processed. So the usmStatsDecryptionErrors counter gets incremented, and an error indication (decryptionError) goes back to the calling module, together with the OID and value of that counter ๐.
If the privacy module returns success, then the decrypted scopedPDU is the message payload that gets returned to the calling module ๐.
Otherwise,
b) The scopedPDU component is assumed to be in plain text, and it is the message payload that gets returned to the calling module.
9) The maxSizeResponseScopedPDU gets calculated. This is the maximum size allowed for a scopedPDU in a possible Response message. It leaves room for a message header that allows the same securityLevel as the received Request ๐.
10) The securityName for the user gets retrieved from the usmUserTable ๐.
11) The security data gets cached as cachedSecurityData, so that a possible response to this message can and will use the same authentication and privacy secrets. The information to be saved or cached is:
- msgUserName,
- usmUserAuthProtocol, usmUserAuthKey,
- usmUserPrivProtocol, usmUserPrivKey.
12) The statusInformation is set to success, and a return is made to the calling module. The OUT parameters get passed back as specified in the processIncomingMsg primitive ๐.
4. Discovery ๐โจ
The User-based Security Model requires that a discovery process gets enough information about other SNMP engines to communicate with them. Discovery requires a non-authoritative SNMP engine to learn the authoritative SNMP engine's snmpEngineID value before communication can proceed. This can be done by generating a Request message with a securityLevel of noAuthNoPriv, a msgUserName of zero-length, a msgAuthoritativeEngineID value of zero length, and the varBindList left empty. The response will be a Report message that contains the snmpEngineID of the authoritative SNMP engine as the value of the msgAuthoritativeEngineID field, inside the msgSecurityParameters field. It also has a Report PDU with the usmStatsUnknownEngineIDs counter in the varBindList ๐งฉ.
If authenticated communication is required, then the discovery process should also set up time synchronization with the authoritative SNMP engine. This can be done by sending an authenticated Request message, with msgAuthoritativeEngineID set to the newly learned snmpEngineID, and with msgAuthoritativeEngineBoots and msgAuthoritativeEngineTime both set to zero. For an authenticated Request message, a valid userName must be used in the msgUserName field. The response will be a Report message with the up-to-date values of the authoritative SNMP engine's snmpEngineBoots and snmpEngineTime, given back as the values of the msgAuthoritativeEngineBoots and msgAuthoritativeEngineTime fields. It also contains the usmStatsNotInTimeWindows counter in the varBindList of the Report PDU. The time synchronization then happens automatically as part of the procedures in section 3.2 step 7b. See also section 2.3 โฑ๏ธ๐.
5. Definitions ๐๐
Here's the MIB module, bestie. Don't worry, it's all copied exactly ๐ซถ:
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 "9901200000Z" -- 20 Jan 1999, midnight
ORGANIZATION "SNMPv3 Working Group"
CONTACT-INFO "WG-email: snmpv3@lists.tislabs.com
Subscribe: majordomo@lists.tislabs.com
In msg body: subscribe snmpv3
Chair: Russ Mundy
Trusted Information Systems
postal: 3060 Washington Rd
Glenwood MD 21738
USA
email: mundy@tislabs.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.
"
-- Revision history
REVISION "9901200000Z" -- 20 Jan 1999, midnight
DESCRIPTION "Clarifications, published as RFC2574"
REVISION "9711200000Z" -- 20 Nov 1997, midnight
DESCRIPTION "Initial version, published as RFC2274"
::= { snmpModules 15 }
-- Administrative assignments ****************************************
usmMIBObjects OBJECT IDENTIFIER ::= { snmpUsmMIB 1 }
usmMIBConformance OBJECT IDENTIFIER ::= { snmpUsmMIB 2 }
-- Identification of Authentication and Privacy Protocols ************
Okay so we're picking up with the protocol identities, bestie ๐ฆ Auth first, then privacy, then the KeyChange textual convention, which is seriously the most intense part of this whole module ๐
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 }
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 }
Next up is the textual conventions bit ๐ This KeyChange thing is literally the main character of the whole module. It's how you change a secret key without ever sending the actual key over the wire, and the math is giving full cryptography drama ๐ฅ๐ง
-- 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 requester 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 keyNew 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 recipient 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
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.
Note that the keyOld and keyNew are the localized keys.
Note that it is probably wise that when an SNMP entity sends
a SetRequest to change a key, that it keeps a copy of the old
key until it has confirmed that the key change actually
succeeded.
"
SYNTAX OCTET STRING
-- 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 }
-- 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 }
Okay bestie, the usmUserTable is where the magic happens โจ It's the list of every user the engine knows about, and the table's description walks you through how to make a brand-new user step by step ๐
-- 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).
To create a new user (i.e., to instantiate a new
conceptual row in this table), it is recommended to
follow this procedure:
1) GET(usmUserSpinLock.0) and save in sValue.
2) SET(usmUserSpinLock.0=sValue,
usmUserCloneFrom=templateUser,
usmUserStatus=createAndWait)
You should use a template user to clone from
which has the proper auth/priv protocol defined.
If the new user is to use privacy:
3) generate the keyChange value based on the secret
privKey of the clone-from user and the secret key
to be used for the new user. Let us call this
pkcValue.
4) GET(usmUserSpinLock.0) and save in sValue.
5) SET(usmUserSpinLock.0=sValue,
usmUserPrivKeyChange=pkcValue
usmUserPublic=randomValue1)
6) GET(usmUserPulic) and check it has randomValue1.
If not, repeat steps 4-6.
If the new user will never use privacy:
7) SET(usmUserPrivProtocol=usmNoPrivProtocol)
If the new user is to use authentication:
8) generate the keyChange value based on the secret
authKey of the clone-from user and the secret key
to be used for the new user. Let us call this
akcValue.
9) GET(usmUserSpinLock.0) and save in sValue.
10) SET(usmUserSpinLock.0=sValue,
usmUserAuthKeyChange=akcValue
usmUserPublic=randomValue2)
11) GET(usmUserPulic) and check it has randomValue2.
If not, repeat steps 9-11.
If the new user will never use authentication:
12) SET(usmUserAuthProtocol=usmNoAuthProtocol)
Finally, activate the new user:
13) SET(usmUserStatus=active)
The new user should now be available and ready to be
used for SNMPv3 communication. Note however that access
to MIB data must be provided via configuration of the
SNMP-VIEW-BASED-ACM-MIB.
The use of usmUserSpinlock is to avoid conflicts with
another SNMP command responder application which may
also be acting on the usmUserTable.
"
::= { usmUser 2 }
Ngl, the steps are a whole little choreography ๐ฉฐ You grab the spin lock, set up the row with a clone-from template, then do the privacy dance (steps 3 to 6) and the authentication dance (steps 8 to 11) only if your new user actually needs them. Anyone who's never going to use privacy just gets the usmNoPrivProtocol shortcut in step 7, and same vibe for auth in step 12. Then step 13 flips the row to active and she's ready to go ๐
Now let's look at the row itself ๐ฆ
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
}
So each row is identified by its usmUserEngineID plus its usmUserName, and the SEQUENCE lists every column that hangs off that row ๐ Pretty iconic index situation, honestly.
Next up, the engine ID column ๐ธ
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 }
So for a simple agent it's just its own engine ID, but it can also point at a remote engine the user talks to. It's giving flexibility ๐ง
And the human-readable name ๐
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 }
Notice the size limit, 1 to 32 characters, and the fact that this is the USM-dependent security ID ๐
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 }
Lowkey iconic: by default the securityName is just the userName, same tea, different cup โ It's read-only, so you can look but not touch ๐
Now the cloning column, which is a whole mood ๐
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 must be
cloned from its clone-from user. These parameters are:
- authentication protocol (usmUserAuthProtocol)
- privacy protocol (usmUserPrivProtocol)
They will be copied regardless of what the current
value is.
Cloning also causes the initial values of the secret
authentication key (authKey) and the secret encryption
key (privKey) of the new user to be set to the same
value as the corresponding secret of the 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 does not exist or is not in an active
state when the cloning process is invoked.
When this object is read, the ZeroDotZero OID
is returned.
"
::= { usmUserEntry 4 }
Okay so cloning copies the auth and priv protocols no matter what, and it also copies the authKey and privKey secrets over ๐ซถ The clone only happens on the first write, every write after that is a successful no-op. And if the clone-from row isn't there or isn't active, you get an 'inconsistentName' error ๐ Reading it just gives you ZeroDotZero back.
Last but definitely not least, the auth protocol column ๐ฅ
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).
If an initial set operation (i.e. at row creation time)
tries to set a value for an unknown or unsupported
protocol, then a 'wrongValue' error must be returned.
The value will be overwritten/set when a set operation
is performed on the corresponding instance of
usmUserCloneFrom.
Once instantiated, the value of such an instance of
this object can only be changed via a set operation to
the value of the usmNoAuthProtocol.
If a set operation tries to change the value of an
existing instance of this object to any value other
than usmNoAuthProtocol, then an 'inconsistentValue'
error must be returned.
If a set operation tries to set the value to the
usmNoAuthProtocol while the usmUserPrivProtocol value
in the same row is not equal to usmNoPrivProtocol,
then an 'inconsistentValue' error must be returned.
That means that an SNMP command generator application
must first ensure that the usmUserPrivProtocol is set
to the usmNoPrivProtocol value before it can set
the usmUserAuthProtocol value to usmNoAuthProtocol.
"
DEFVAL { usmNoAuthProtocol }
::= { usmUserEntry 5 }
This one has the most drama ๐ญ A bad protocol on row creation gets a 'wrongValue' error, and once it's set, the only move allowed is switching to usmNoAuthProtocol, and even that only works if privacy is already turned off ๐ So the command generator has to drop privacy first, then auth. The default value is usmNoAuthProtocol, so it starts out as no-auth unless you say otherwise ๐ธ
Okay, bestie, now we get to the key-change columns ๐โจ These are the objects that let a user swap out their secret keys without the whole thing falling apart ๐
usmUserAuthKeyChange OBJECT-TYPE
SYNTAX KeyChange -- typically (SIZE (0 | 32)) for HMACMD5
-- typically (SIZE (0 | 40)) for HMACSHA
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 instance
of usmUserCloneFrom.
When the value of the corresponding usmUserAuthProtocol
is usmNoAuthProtocol, then a set is successful, but
effectively is a no-op.
When this object is read, the zero-length (empty)
string is returned.
The recommended way to do a key change is as follows:
1) GET(usmUserSpinLock.0) and save in sValue.
2) generate the keyChange value based on the old
(existing) secret key and the new secret key,
let us call this kcValue.
If you do the key change on behalf of another user:
3) SET(usmUserSpinLock.0=sValue,
usmUserAuthKeyChange=kcValue
usmUserPublic=randomValue)
If you do the key change for yourself:
4) SET(usmUserSpinLock.0=sValue,
usmUserOwnAuthKeyChange=kcValue
usmUserPublic=randomValue)
If you get a response with error-status of noError,
then the SET succeeded and the new key is active.
If you do not get a response, then you can issue a
GET(usmUserPublic) and check if the value is equal
to the randomValue you did send in the SET. If so, then
the key change succeeded and the new key is active
(probably the response got lost). If not, then the SET
request probably never reached the target and so you
can start over with the procedure above.
"
DEFVAL { ''H } -- the empty string
::= { usmUserEntry 6 }
So usmUserAuthKeyChange is the one you use to change somebody else's authKey ๐ It's basically a one-way-function situation: the object gets modified, and the secret authentication key used for messages to and from that engine gets changed. The hash algorithm is whatever the user's usmUserAuthProtocol is, and reading it always gives you back an empty string ๐
Creating a brand-new user is a little picky. A set that refers to this object gets an inconsistentName error unless usmUserCloneFrom is set first (or in the same set). And if the auth protocol is usmNoAuthProtocol, the set still works, it just does absolutely nothing ๐
The full dance has a few steps. You read usmUserSpinLock.0 to get sValue, then cook up kcValue from the old and new keys. After that you SET the spin lock, the key change, and a random usmUserPublic value all together. Obviously, changing a key for yourself uses usmUserOwnAuthKeyChange instead. If you get a noError back, the new key is live ๐ If the response goes missing, you can GET usmUserPublic and check whether it matches your random value. If it does, the change worked and only the reply got lost. If not, the SET probably never arrived, so start over from the top ๐
usmUserOwnAuthKeyChange OBJECT-TYPE
SYNTAX KeyChange -- typically (SIZE (0 | 32)) for HMACMD5
-- typically (SIZE (0 | 40)) for HMACSHA
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.
In addition, the USM security model must be
used for 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).
Note that this can only be done once the row is active.
When a set is received and the usmUserName of the
requester is not the same as the umsUserName that
indexes the row which is targeted by this operation,
then a 'noAccess' error must be returned.
When a set is received and the security model in use
is not USM, then a 'noAccess' error must be returned.
"
DEFVAL { ''H } -- the empty string
::= { usmUserEntry 7 }
usmUserOwnAuthKeyChange works exactly like its sibling, with one big twist: your usmUserName has to match the name on the row you're touching ๐ช It also only works under USM, and only once the row is active. That's why it can be public-access, since all it lets you do is change your own authKey ๐ Anything else gets a noAccess error, whether the names don't match or the security model isn't USM.
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).
If an initial set operation (i.e. at row creation time)
tries to set a value for an unknown or unsupported
protocol, then a 'wrongValue' error must be returned.
The value will be overwritten/set when a set operation
is performed on the corresponding instance of
usmUserCloneFrom.
Once instantiated, the value of such an instance of
this object can only be changed via a set operation to
the value of the usmNoPrivProtocol.
If a set operation tries to change the value of an
existing instance of this object to any value other
than usmNoPrivProtocol, then an 'inconsistentValue'
error must be returned.
Note that if any privacy protocol is used, then you
must also use an authentication protocol. In other
words, if usmUserPrivProtocol is set to anything else
than usmNoPrivProtocol, then the corresponding instance
of usmUserAuthProtocol cannot have a value of
usmNoAuthProtocol. If it does, then an
'inconsistentValue' error must be returned.
"
DEFVAL { usmNoPrivProtocol }
::= { usmUserEntry 8 }
usmUserPrivProtocol says whether messages to and from that engine can be kept secret, and if so, which privacy protocol is in use ๐ต๏ธโโ๏ธ It gets created at the same time as the rest of the row. If your initial set asks for a protocol that's unknown or unsupported, you get a wrongValue error ๐ฌ Cloning overwrites it, and once it's set, the only change you can make is going back to usmNoPrivProtocol. Anything else gets an inconsistentValue.
Also, privacy can't exist without authentication. If usmUserPrivProtocol is set to anything other than usmNoPrivProtocol while usmUserAuthProtocol is usmNoAuthProtocol, you get an inconsistentValue error, no exceptions ๐ซ
usmUserPrivKeyChange OBJECT-TYPE
SYNTAX KeyChange -- typically (SIZE (0 | 32)) for DES
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 instance
of usmUserCloneFrom.
When the value of the corresponding usmUserPrivProtocol
is usmNoPrivProtocol, then a set is successful, but
effectively is a no-op.
When this object is read, the zero-length (empty)
string is returned.
See the description clause of usmUserAuthKeyChange for
a recommended procedure to do a key change.
"
DEFVAL { ''H } -- the empty string
::= { usmUserEntry 9 }
usmUserPrivKeyChange is the privacy-key cousin of the auth one ๐ It changes the secret encryption key (privKey) through the same kind of one-way function, and the protocol it's tied to is usmUserPrivProtocol. The hash algorithm, though, comes from usmUserAuthProtocol, which is a fun little plot twist โจ Creation rules are the same as before, and if the privacy protocol is usmNoPrivProtocol, the set succeeds and does nothing. Reading it returns an empty string, and for the recommended key-change procedure, you just go look at usmUserAuthKeyChange.
usmUserOwnPrivKeyChange OBJECT-TYPE
SYNTAX KeyChange -- typically (SIZE (0 | 32)) for DES
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.
In addition, the USM security model must be
used for 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).
Note that this can only be done once the row is active.
When a set is received and the usmUserName of the
requester is not the same as the umsUserName that
indexes the row which is targeted by this operation,
then a 'noAccess' error must be returned.
When a set is received and the security model in use
is not USM, then a 'noAccess' error must be returned.
"
DEFVAL { ''H } -- the empty string
::= { usmUserEntry 10 }
usmUserOwnPrivKeyChange is the self-service version for privKey ๐
Same rules as usmUserOwnAuthKeyChange: the requester's usmUserName has to match the row, the security model has to be USM, and the row has to be active. Get any of that wrong and you get a noAccess error ๐
โโ๏ธ
usmUserPublic OBJECT-TYPE
SYNTAX OCTET STRING (SIZE(0..32))
MAX-ACCESS read-create
STATUS current
DESCRIPTION "A publicly-readable value which can be 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 }
Last one for this batch: usmUserPublic is the publicly readable value you write during a key change and read back afterwards to see whether the change actually went through ๐ฆ It's an OCTET STRING of up to 32 bytes, and its default is the empty string ๐ธ
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'.
If an initial set operation tries to set the value to
'readOnly' for a user who employs authentication or
privacy, then an 'inconsistentValue' error must be
returned. Note that if the value has been previously
set (implicit or explicit) to any value, then the rules
as defined in the StorageType Textual Convention apply.
It is an implementation issue to decide if a SET for
a readOnly or permanent row is accepted at all. In some
contexts this may make sense, in others it may not. If
a SET for a readOnly or permanent row is not accepted
at all, then a 'wrongValue' error must be returned.
"
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 for a user who
employs authentication, cannot be made active until the
corresponding usmUserCloneFrom and usmUserAuthKeyChange
have been set.
Further, a newly created row for a user who also
employs privacy, cannot be made active until the
usmUserPrivKeyChange has been set.
The RowStatus TC [RFC2579] 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,
except for usmUserOwnAuthKeyChange and
usmUserOwnPrivKeyChange. For these 2 objects, the
value of usmUserStatus MUST be active.
"
::= { usmUserEntry 13 }
-- 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, and it's giving foundational ๐ง. It was the very first one defined for the User-based Security Model, so it's kind of the OG. It uses the MD5 hash function described in [MD5], in HMAC mode as described in [RFC2104], and the output gets truncated to 96 bits. Iconic. ๐
This protocol is identified by usmHMACMD5AuthProtocol. ๐ฆ
Over time, other authentication protocols may be defined, either to replace this one or to sit alongside it. Growth arc unlocked ๐ฑ
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 gets included as part of the message that's sent to the recipient. ๐
- In support of 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 partially inserted into the SNMP message before it's transmitted, and the prepended value is never transmitted. The secret value is shared by all SNMP engines that are authorized to originate messages on behalf of the appropriate user. It's giving secret-handshake energy ๐คซ๐ซถ
6.1.1. Digest Authentication Mechanism
The Digest Authentication Mechanism defined in this memo provides for:
- 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 digest is computed by the originator of the message, transmitted with the message, and verified by the recipient of the message. Bestie, it's a full loop ๐
- verification of the user on whose behalf the message was generated.
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 that the hash function output used as the Message Authentication Code be truncated. Main character energy for the truncation, honestly ๐
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 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 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. Lowkey the setup chapter ๐ธ
6.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 about that user. An SNMP engine that wants to talk to another SNMP engine must also know about a user that's known to that engine, including the applicable attributes of that user. The guest list has to be on file, periodt ๐
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 contained in an authenticated message specifies the authoritative SNMP engine for that particular message (see the definition of SnmpEngineID in the SNMP Architecture document [RFC2571]). Basically it tells you who's in charge of this message ๐
The user's (private) authentication key is normally different at each authoritative SNMP engine, so the snmpEngineID is used to select the proper key for the authentication process. Different engine, different key, no mix-ups ๐ง
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 representing the first 12 octets of the HMAC-MD5-96 output done over the wholeMsg. ๐
The digest is calculated over the wholeMsg, so if a message is authenticated, that also means all the fields in the message are intact and haven't been tampered with. Zero tampering, full slay ๐
โจ
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. It's the handshake between the two modules, and honestly it's kind of iconic ๐ฆ
6.2.4.1. Services for Generating an Outgoing SNMP Message
The HMAC-MD5-96 authentication protocol assumes that the caller selects the authKey, and that the caller passes in the secret key to be used. The caller's the boss here ๐
Upon completion, the authentication module returns statusInformation and, if the message digest was correctly calculated, 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 is 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 inserted digest) on output.
Note, theauthParametersfield is filled in by the authentication module, and this module and this field should already be present in thewholeMsgbefore the Message Authentication Code (MAC) is generated. Order of operations matters, bestie, don't skip this step ๐
6.2.4.2. Services for Processing an Incoming SNMP Message ๐ฅ
Okay so, same deal as before: the caller picks the authKey ๐ and hands over the secret key to use. HMAC-MD5-96 doesn't choose it for you, bestie.
When it's done, the module gives back statusInformation. If the message digest was correctly calculated, it also gives back 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 worked. If it didn't, it tells you what went wrong. ๐authKey: the secret key the authentication algorithm uses. The length of this key MUST be 16 octets. ๐authParameters: the authParameters from the incoming message. ๐ฆwholeMsg: the message being authenticated on the way in, and the authenticated message on the way out. โจauthenticatedWholeMsg: the whole message once the authentication check is finished. ๐
6.3. Elements of Procedure ๐งพ
This section walks through the procedures for the HMAC-MD5-96 authentication protocol, step by step. Let's go, periodt ๐
6.3.1. Processing an Outgoing Message ๐ค
This part covers what an SNMP engine does whenever it needs to authenticate an outgoing message with usmHMACMD5AuthProtocol.
- The msgAuthenticationParameters field gets set to the serialization, following the rules in [RFC1906], of an OCTET STRING holding 12 zero octets. 0๏ธโฃ
- Two keys, K1 and K2, get derived 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.
- Prepend K1 to the wholeMsg, then calculate an MD5 digest over it according to [MD5]. ๐ง
- Prepend K2 to the result of step 4, then calculate an MD5 digest over that according to [MD5]. Take the first 12 octets of the final digest. This is the Message Authentication Code (MAC). ๐ฅ
- Replace the msgAuthenticationParameters field with the MAC from step 4. ๐
- The authenticatedWholeMsg goes back to the caller together with statusInformation saying success. ๐
6.3.2. Processing an Incoming Message ๐ฅ
This part covers what an SNMP engine does whenever it needs to authenticate an incoming message with usmHMACMD5AuthProtocol. Pay attention, because it's giving detective ๐ต๏ธโโ๏ธ
- If the digest in the msgAuthenticationParameters field is not 12 octets long, it's a failure. An errorIndication (authenticationError) goes back to the calling module. โ
- The MAC received in the msgAuthenticationParameters field gets saved. ๐พ
- The digest in the msgAuthenticationParameters field gets replaced with 12 zero octets. 0๏ธโฃ
- Two keys, K1 and K2, get derived 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.
- Calculate the MAC over the wholeMsg:
- a) Prepend K1 to the wholeMsg, then calculate the MD5 digest over it.
- b) Prepend K2 to the result of step 5.a, then calculate the MD5 digest over it.
- c) The first 12 octets of the result of step 5.b are the MAC.
The msgAuthenticationParameters field then gets replaced with the MAC value that was saved in step 2. ๐ช
- Compare the newly calculated MAC with the MAC saved in step 2. If they don't match, it's a failure. An errorIndication (authenticationFailure) goes back to the calling module. ๐จ
- The authenticatedWholeMsg and statusInformation saying success go back to the caller. ๐
7. HMAC-SHA-96 Authentication Protocol ๐ฆ
This section covers the HMAC-SHA-96 authentication protocol. It uses the SHA hash function, which is described in [SHA-NIST], in the HMAC mode described in [RFC2104], with the output truncated to 96 bits. ๐
This protocol is identified by usmHMACSHAAuthProtocol.
Over time, other authentication protocols might get defined. They could replace this one, or show up alongside it. ๐
7.1. Mechanisms โ๏ธ
- For data integrity, you need a message digest algorithm. A digest is calculated over an appropriate portion of an SNMP message and gets included as part of 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 partially inserted into the message before it's sent. The prepended secret never gets transmitted. It's shared by all SNMP engines that are allowed to send messages on behalf of the right user. ๐คซ
7.1.1. Digest Authentication Mechanism ๐
The Digest Authentication Mechanism in this memo gives you two things:
- Integrity checking for a received message, so you can be sure 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, sends it along with the message, and the recipient verifies it. ๐ฌ
- Verification of the user the message was generated on behalf of. ๐
A secret value, known only to SNMP engines allowed to generate messages on behalf of a user, is used in HMAC mode (see [RFC2104]). It also recommends that the hash function output used as the Message Authentication Code be truncated. โ๏ธ
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 as part of the message sent to the recipient. The digest carried in a message is 12 octets long. The private authentication key (the secret) is 20 octets long. For the details, see Section 7.3. ๐ง
7.2. Elements of the HMAC-SHA-96 Authentication Protocol ๐ง
This section has the definitions needed to make the authentication module in this section of this memo work. ๐
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 about that user. An SNMP engine that wants to talk to another SNMP engine also has to know about a user known to that engine, including the applicable attributes of that user. ๐ซถ
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 names the authoritative SNMP engine for that particular message. (Check the definition of SnmpEngineID in the SNMP Architecture document, [RFC2571].) ๐
The user's (private) authentication key is normally different at each authoritative SNMP engine. That's why the snmpEngineID is used to pick 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 gets calculated over the wholeMsg. So if a message is authenticated, that also means all the fields in the message are intact and haven't been tampered with. ๐ก๏ธ
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 ๐ค
The HMAC-SHA-96 authentication protocol assumes the caller picks the authKey and passes in the secret key to use. ๐
When it's done, the authentication module returns statusInformation. If the message digest was correctly calculated, it also returns the wholeMsg with the digest inserted in 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: says whether the authentication worked. If it didn't, it tells you the problem. ๐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 on output, including the inserted digest. โจ
Note: 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. ๐
7.2.4.2. Services for Processing an Incoming SNMP Message ๐ฅ
The HMAC-SHA-96 authentication protocol assumes the caller picks the authKey and passes in the secret key to use. Same energy as always, bestie ๐ซถ
When it's done, the authentication module returns statusInformation. If the message digest was correctly calculated, it also returns 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 worked. If it didn't, it tells you the problem. ๐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 the way in, and the authenticated message on the way out. โจauthenticatedWholeMsg: the whole message once the authentication check is done. ๐
7.3. Elements of Procedure ๐ฅ
Okay so this part is the actual recipe for HMAC-SHA-96, bestie. Let's get into it ๐
This section describes the procedures for the HMAC-SHA-96 authentication protocol ๐ฆ
7.3.1. Processing an Outgoing Message
This is what an SNMP engine does whenever it has to authenticate an outgoing message using usmHMACSHAAuthProtocol โจ
- The
msgAuthenticationParametersfield gets set to the serialization (following the rules in [RFC1906]) of an OCTET STRING holding 12 zero octets. ๐ซถ - From the secret
authKey, we derive two keys, K1 and K2 ๐- a) extend the
authKeyto 64 octets by appending 44 zero octets; save it asextendedAuthKey - b) get IPAD by replicating the octet
0x3664 times; - c) get K1 by XORing
extendedAuthKeywith IPAD; - d) get OPAD by replicating the octet
0x5C64 times; - e) get K2 by XORing
extendedAuthKeywith OPAD.
- a) extend the
- Prepend K1 to the
wholeMsgand calculate the SHA digest over it according to [SHA-NIST] ๐ธ - Prepend K2 to the result of the step 4 and calculate the SHA digest over it according to [SHA-NIST]. Take the first 12 octets of the final digest, and that's your Message Authentication Code (MAC) ๐
- Replace the
msgAuthenticationParametersfield with the MAC obtained in the step 5 ๐ - The
authenticatedWholeMsgis then returned to the caller together withstatusInformationindicating success ๐
7.3.2. Processing an Incoming Message
This is the reverse vibe: what an SNMP engine does whenever it has to authenticate an incoming message using usmHMACSHAAuthProtocol ๐ง
- If the digest received in the
msgAuthenticationParametersfield is not 12 octets long, then a failure happens and anerrorIndication(authenticationError) is returned to the calling module. ๐ - The MAC received in the
msgAuthenticationParametersfield is saved ๐ - The digest in the
msgAuthenticationParametersfield is replaced by the 12 zero octets ๐ - From the secret
authKey, we derive two keys, K1 and K2 ๐- a) extend the
authKeyto 64 octets by appending 44 zero octets; save it asextendedAuthKey - b) get IPAD by replicating the octet
0x3664 times; - c) get K1 by XORing
extendedAuthKeywith IPAD; - d) get OPAD by replicating the octet
0x5C64 times; - e) get K2 by XORing
extendedAuthKeywith OPAD.
- a) extend the
- The MAC is calculated over the
wholeMsgโญ- a) prepend K1 to the
wholeMsgand calculate the SHA digest over it; - b) prepend K2 to the result of step 5.a and calculate the SHA digest over it;
- c) the first 12 octets of the result of step 5.b is the MAC.
- a) prepend K1 to the
The msgAuthenticationParameters field is replaced with the MAC value that was saved in step 2.
- The newly calculated MAC is compared with the MAC saved in step 2. If they do not match, then a failure happens and an
errorIndication(authenticationFailure) is returned to the calling module. ๐ญ - The
authenticatedWholeMsgandstatusInformationindicating success are then returned to the caller ๐ซง
8. CBC-DES Symmetric Encryption Protocol ๐
This section describes the CBC-DES Symmetric Encryption Protocol. This protocol is the first privacy protocol defined for the User-based Security Model, so it's the OG of the privacy crew ๐
This protocol is identified by usmDESPrivProtocol ๐
Over time, other privacy protocols may be defined either as a replacement of this protocol or in addition to this protocol. Ooo, more options coming, babe ๐ธ
8.1. Mechanisms
- In support of data confidentiality, an encryption algorithm is required. An appropriate portion of the message is encrypted prior to being transmitted. The User-based Security Model specifies that the
scopedPDUis the portion of the message that needs to be encrypted ๐ - A secret value in combination with a timeliness value is used to create the en/decryption key and the initialization vector. The secret value is shared by all SNMP engines authorized to originate messages on behalf of the appropriate user ๐๏ธ
8.1.1. Symmetric Encryption Protocol
The Symmetric Encryption Protocol defined in this memo provides support for data confidentiality. The designated portion of an SNMP message is encrypted and included as part of the message sent to the recipient ๐
Two organizations have published specifications defining the DES: the National Institute of Standards and Technology (NIST) [DES-NIST] and the American National Standards Institute [DES-ANSI]. There is a companion Modes of Operation specification for each definition ([DESO-NIST] and [DESO-ANSI], respectively). ๐
The NIST has also published three additional documents that implementors may find useful ๐ง
- There is a document with guidelines for implementing and using the DES, including functional specifications for the DES and its modes of operation [DESG-NIST].
- There is a specification of a validation test suite for the DES [DEST-NIST]. The suite is designed to test all aspects of the DES and is useful for pinpointing specific problems ๐
- There is a specification of a maintenance test for the DES [DESM-NIST]. The test utilizes a minimal amount of data and processing to test all components of the DES. It provides a simple yes-or-no indication of correct operation and is useful to run as part of an initialization step, e.g., when a computer re-boots ๐
8.1.1.1. DES key and Initialization Vector.
The first 8 octets of the 16-octet secret (private privacy key) are used as a DES key. Since DES uses only 56 bits, the Least Significant Bit in each octet is disregarded ๐ซถ
The Initialization Vector for encryption is obtained using the following procedure. The last 8 octets of the 16-octet secret (private privacy key) are used as pre-IV ๐
Now here's the tricky-but-iconic bit: in order to ensure that the IV for two different packets encrypted by the same key are not the same (i.e., the IV does not repeat), we need to "salt" the pre-IV with something unique per packet. An 8-octet string is used as the "salt". The concatenation of the generating SNMP engine's 32-bit snmpEngineBoots and a local 32-bit integer, that the encryption engine maintains, is input to the "salt". The 32-bit integer is initialized to an arbitrary value at boot time โฐ
The 32-bit snmpEngineBoots is converted to the first 4 octets (Most Significant Byte first) of our "salt". The 32-bit integer is then converted to the last 4 octets (Most Significant Byte first) of our "salt". The resulting "salt" is then XOR-ed with the pre-IV to obtain the IV. The 8-octet "salt" is then put into the privParameters field encoded as an OCTET STRING. The "salt" integer is then modified. We recommend that it be incremented by one and wrap when it reaches the maximum value ๐
How exactly the value of the "salt" (and thus of the IV) varies is an implementation issue, as long as the measures are taken to avoid producing a duplicate IV โจ
The "salt" must be placed in the privParameters field to enable the receiving entity to compute the correct IV and to 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, and if it is not, the data is padded at the end as necessary. The actual pad value is irrelevant ๐
The data is encrypted in Cipher Block Chaining mode ๐
The plaintext is divided into 64-bit blocks ๐งฉ
The plaintext for each block is XOR-ed with the ciphertext of the previous block, the result is encrypted, and the output of the encryption is the ciphertext for the block. This procedure is repeated until there are no more plaintext blocks ๐
For the very first block, the Initialization Vector is used instead of the ciphertext of the previous block ๐ธ
8.1.1.3. Data Decryption
Before decryption, the encrypted data length is verified. If the length of the OCTET STRING to be decrypted is not an integral multiple of 8 octets, the decryption process is halted and an appropriate exception 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 subsequent block, 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 contains the definitions required to realize the privacy module defined by this memo ๐ฆ
8.2.1. Users
Data en/decryption using this Symmetric Encryption Protocol makes use of a defined set of userNames. For any user on whose behalf a message must be en/decrypted at a particular SNMP engine, that SNMP engine must have knowledge of that user. An SNMP engine that wishes to communicate with another SNMP engine must also have knowledge of a user known to that SNMP engine, including knowledge of the applicable attributes of that user ๐งโ๐คโ๐ง
A user and its attributes are defined as follows:
<userName>
An octet string representing the name of the user.
<privKey>
A user's secret key to be 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 contained in an authenticated message specifies the authoritative SNMP engine for that particular message (see the definition of SnmpEngineID in the SNMP Architecture document [RFC2571]) ๐๏ธ
The user's (private) privacy key is normally different at each authoritative SNMP engine, so the snmpEngineID is used to select the proper 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 the msgSecurityParameters. For this protocol, the msgPrivacyParameters field is the serialized OCTET STRING representing the "salt" that was used to create the IV ๐ง
8.2.4. Services provided by the DES Privacy Module
This section describes the inputs and outputs that the DES Privacy module expects and produces when the User-based Security module invokes the DES Privacy module for services ๐
8.2.4.1. Services for Encrypting Outgoing Data
This DES privacy protocol assumes that the selection of the privKey is done by the caller, and that the caller passes the secret key to be used ๐
Upon completion, the privacy module returns statusInformation and, if the encryption process was successful, the encryptedPDU and the msgPrivacyParameters encoded as an OCTET STRING. The abstract service primitive is:
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: An indication of the success or failure of the encryption process. In case of failure, it is an indication of the error. โencryptKey: The secret key to be used by the encryption algorithm. The length of this key MUST be 16 octets. ๐๏ธdataToEncrypt: The data that must be encrypted. ๐encryptedData: The encrypted data upon successful completion. ๐privParameters: TheprivParametersencoded as an OCTET STRING. ๐ธ
8.2.4.2. Services for Decrypting Incoming Data ๐โจ
Okay bestie, this part is all about the decrypt side ๐. This DES privacy protocol assumes the caller is the one choosing the privKey ๐, and the caller is the one who passes in the secret key to use.
When the privacy module finishes, it hands back a statusInformation and, if decryption worked, 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)
)
Here are the abstract data elements, and they're giving very organized energy ๐:
statusInformation: An indication whether the data was successfully decrypted and if not an indication of the error.decryptKey: The secret key to be used by the decryption algorithm. The length of this key MUST be 16 octets.privParameters: The "salt" to be used to calculate the IV.encryptedData: The data to be decrypted.decryptedData: The decrypted data.
8.3. Elements of Procedure. ๐ง
This section is where the step-by-step procedures for the DES privacy protocol live, so grab a snack ๐.
8.3.1. Processing an Outgoing Message ๐ค
This part covers what an SNMP engine does whenever it needs to encrypt part of an outgoing message using the usmDESPrivProtocol ๐.
- The secret cryptKey is used to construct the DES encryption key, the "salt" and the DES pre-IV (from which the IV is computed as described in section 8.1.1.1).
- The privParameters field is set to the serialization according to the rules in [RFC1906] of an OCTET STRING representing the the "salt" string.
- The scopedPDU is encrypted (as described in section 8.1.1.2) and the encrypted data is serialized according to the rules in [RFC1906] as an OCTET STRING.
- The serialized OCTET STRING representing the encrypted scopedPDU together with the privParameters and statusInformation indicating success is returned to the calling module.
8.3.2. Processing an Incoming Message ๐ฅ
Now the reverse ๐ช. This part describes what an SNMP engine does whenever it needs to decrypt part of an incoming message using the usmDESPrivProtocol.
- If the privParameters field is not an 8-octet OCTET STRING, then an error indication (decryptionError) is returned to the calling module.
- The "salt" is extracted from the privParameters field.
- The secret cryptKey and the "salt" are then used to construct the DES decryption key and pre-IV (from which the IV is computed as described in section 8.1.1.1).
- The encryptedPDU is then decrypted (as described in section 8.1.1.3).
- If the encryptedPDU cannot be decrypted, then an error indication (decryptionError) is returned to the calling module.
- The decrypted scopedPDU and statusInformation indicating success are returned to the calling module.
9. Intellectual Property ๐
The IETF doesn't take a side on whether any intellectual property or other rights that someone might claim over the technology in this document are valid or in scope, and it doesn't say whether a license for those rights is available or not. It also doesn't claim it has tried to find any of those rights. If you want the details on how the IETF handles rights for standards-track and standards-related documents, check out BCP-11 ๐. Copies of claimed rights that were made available for publication, plus any assurances that licenses will be made available, or the result of an attempt to get a general license or permission for implementors or users to use those proprietary rights, can be obtained from the IETF Secretariat ๐ฌ.
The IETF invites any interested party to bring to its attention any copyrights, patents or patent applications, or other proprietary rights which may cover technology that may be required to practice this standard. Please send that information to the IETF Executive Director ๐ซถ.
10. Acknowledgements ๐ธ
This document is the result of the efforts of the SNMPv3 Working Group ๐. Some special thanks are in order to the following SNMPv3 WG members, who absolutely ate:
- Harald Tveit Alvestrand (Maxware)
- Dave Battle (SNMP Research, Inc.)
- Alan Beard (Disney Worldwide Services)
- Paul Berrevoets (SWI Systemware/Halcyon Inc.)
- Martin Bjorklund (Ericsson)
- Uri Blumenthal (IBM T.J. Watson Research Center)
- Jeff Case (SNMP Research, Inc.)
- John Curran (BBN)
- Mike Daniele (Compaq Computer Corporation))
- T. Max Devlin (Eltrax Systems)
- John Flick (Hewlett Packard)
- Rob Frye (MCI)
- Wes Hardaker (U.C.Davis, Information Technology - D.C.A.S.)
- David Harrington (Cabletron Systems Inc.)
- Lauren Heintz (BMC Software, Inc.)
- N.C. Hien (IBM T.J. Watson Research Center)
- Michael Kirkham (InterWorking Labs, Inc.)
- Dave Levi (SNMP Research, Inc.)
- Louis A Mamakos (UUNET Technologies Inc.)
- Joe Marzot (Nortel Networks)
- Paul Meyer (Secure Computing Corporation)
- Keith McCloghrie (Cisco Systems)
- Bob Moore (IBM)
- Russ Mundy (TIS Labs at Network Associates)
- Bob Natale (ACE*COMM Corporation)
- Mike O'Dell (UUNET Technologies Inc.)
- Dave Perkins (DeskTalk)
- Peter Polkinghorne (Brunel University)
- Randy Presuhn (BMC Software, Inc.)
- David Reeder (TIS Labs at Network Associates)
- David Reid (SNMP Research, Inc.)
- Aleksey Romanov (Quality Quorum)
- Shawn Routhier (Epilogue)
- Juergen Schoenwaelder (TU Braunschweig)
- Bob Stewart (Cisco Systems)
- Mike Thatcher (Independent Consultant)
- Bert Wijnen (IBM T.J. Watson Research Center)
The document is based on recommendations of the IETF Security and Administrative Framework Evolution for SNMP Advisory Team. 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 recommended by the Advisory Team and the SNMPv3 Working Group Charter, the design incorporates as much as practical from previous RFCs and drafts. As a result, special thanks are due to the authors of previous 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 one is serious, so listen up ๐จ.
11.1. Recommended Practices ๐ก๏ธ
This section describes practices that contribute to the secure, effective operation of the mechanisms defined in this memo. Think of these as the glow-up routine for keeping your SNMP setup safe ๐.
- 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 Class PDU for which there is no currently outstanding Confirmed Class PDU; for example for SNMPv2 [RFC1905] PDUs, the request-id component in the PDU can be used to correlate Responses to outstanding Requests.
Although it would be typical for an SNMP engine and an SNMP Command Generator Application to do this as a matter of course, when using these security protocols it is significant due to the possibility of message duplication (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 must be done to protect against the possibility of message duplication (malicious or otherwise).
For example, starting operations with a msgID and/or request-id value of zero is not a good idea. Initializing them with an unpredictable number (so they do not 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 in order to protect against the possibility of message duplication (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 the SNMP. Messages may be received in any order relative to their time of generation and each will be processed in the ordered received. Note that when an authenticated message is sent to a managed SNMP engine, it will be valid for a period of time of approximately 150 seconds under normal circumstances, and is subject to replay during this period. Indeed, an SNMP engine and SNMP Command Generator Applications must cope with the loss and re-ordering of messages resulting from anomalies in the network as a matter of course.
However, a managed object, snmpSetSerialNo [RFC1907], is specifically defined for use with SNMP Set operations in order to provide a mechanism to ensure that the processing of SNMP messages occurs in a specific order. ๐งฉ
- The frequency with which the secrets of a User-based Security Model user should be changed is indirectly related to the frequency of their use.
Protecting the secrets from disclosure is critical to the overall security of the protocols. Frequent use of a secret provides a continued source of data that may be useful to a cryptanalyst in exploiting known or perceived weaknesses in an algorithm. Frequent changes to the secret avoid this vulnerability.
Changing a secret after each use is generally regarded as the most secure practice, but a significant amount of overhead may be associated with that approach.
Note, too, in a local environment the threat of disclosure may be less significant, and as such the changing of secrets may be less frequent. However, when public data networks are used as the communication paths, more caution is prudent. ๐
11.2. Defining Users ๐ซถ
okay so this whole doc is built around users, the people (or things) that messages get sent on behalf of ๐. How "users" get defined is totally up to the network admin's security policy ๐. Users could be individuals (e.g., "joe" or "jane"), a role (e.g., "operator" or "administrator"), or a combo (e.g., "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, or a set of roles (including combos) ๐งโโ๏ธ
Appendix A has an algorithm that turns a user "password" into a 16/20 octet value, which you can use as an authentication key, a privacy key, or both ๐. ngl, using the same password (and therefore the same key) for auth AND privacy is very poor security practice and should be strongly discouraged ๐
Passwords are usually made, remembered, and typed in by a human ๐. Human passwords can be shorter than the 16/20 octets the protocols need, and brute force attacks can be pretty easy on a short ASCII character set ๐ญ. That's why the Appendix A algorithm transforms the password. If the Appendix A algorithm is used, SNMP implementations (and SNMP configuration applications) must ensure that passwords are at least 8 characters in length. Also, heads up: longer passwords with repetitive strings may end up with exactly the same key. For example, the password 'bertbert' will result in exactly the same key as 'bertbertbert'. Iykyk ๐
Since the Appendix A algorithm uses these passwords (nearly) directly, it is very important that they can't be easily guessed ๐ฅ. The suggestion is to mix uppercase and lowercase letters, numbers, and punctuation, and to avoid words or phrases you'd find in a dictionary. Longer passwords make the system more secure โจ. Users can also try multiword phrases, which make the string longer and still stay memorable ๐
It's not realistic for humans to keep a different password for every SNMP engine ๐ฅฒ, but security requirements strongly discourage using the same key on more than one SNMP engine. So the User-based Security Model uses a compromise proposed in [Localized-key]. It derives each user's keys for the SNMP engines from the user's password, in a way that makes it practically impossible to either work out the user's password, or the user's key for another SNMP engine, from any combination of the user's keys on SNMP engines ๐
โ ๏ธ Note however: if a user's password is disclosed, key localization won't help, and network security may be compromised in this case. So 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 if a device does get compromised, no other managed or managing devices get compromised too ๐ก๏ธ
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 ๐
Implementing a Privacy Protocol is optional (the DES Symmetric Encryption Protocol defined in this memo is one such protocol) ๐
11.4. Use of Reports ๐จ
Sending unsecure reports (i.e. sending them with a securityLevel of noAuthNoPriv) can potentially expose a non-authoritative SNMP engine to some form of attack ๐ฌ. Some people consider these denial of service attacks, and others don't ๐คทโโ๏ธ. An installation should evaluate the risk involved before deploying unsecure Report PDUs โ๏ธ
11.5. Access to the SNMP-USER-BASED-SM-MIB ๐
The objects in this MIB may be considered sensitive in many environments ๐. Specifically, the objects in the usmUserTable contain information about users and their authentication and privacy protocols. It's important to closely control (both read and write) access to these MIB objects by using appropriately configured Access Control models, for example the View-based Access Control Model specified in [RFC2575] ๐
12. References ๐
[RFC1321] Rivest, R., "Message Digest Algorithm MD5", RFC
1321, April 1992.
[RFC2579] McCloghrie, K., Perkins, D. and J. Schoenwaelder,
"Textual Conventions for SMIv2", STD 58, RFC 2579,
April 1999.
[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.
[RFC2119] Bradner, S., "Key words for use in RFCs to Indicate
Requirement Levels", BCP 14, RFC 2119, March 1997.
[RFC2571] Harrington, D., Presuhn, R. and B. Wijnen, "An
Architecture for describing SNMP Management
Frameworks", RFC 2571, April 1999.
[RFC2572] Case, J., Harrington, D., Presuhn, R. and B. Wijnen,
"Message Processing and Dispatching for the Simple
Network Management Protocol (SNMP)", RFC 2572, April
1999.
[RF2575] Wijnen, B., Presuhn, R. and K. McCloghrie, "View-
based Access Control Model for the Simple Network
Management Protocol (SNMP)", RFC 2575, April 1999.
[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
Phone: +1-914-784-7064
EMail: uri@watson.ibm.com
Bert Wijnen
IBM T. J. Watson Research
Schagen 33
3461 GL Linschoten
Netherlands
Phone: +31-348-432-794
EMail: wijnen@vnet.ibm.com
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:
- A security posture
The choice of security posture determines whether 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, so the following steps are irrelevant ๐
- one or more secrets ๐
These are the authentication and privacy secrets for the first user to be configured, so the first user gets their own keys โจ
One way to do this is to have the installer type in a "password" for each required secret. That password then gets turned into the required secret in two steps:
- Make a string that's exactly 1,048,576 octets long by repeating the password as many times as needed and chopping off the extra. Feed that string into the MD5 algorithm [MD5]. The resulting digest, called "digest1", gets used in the next step.
- Make a second string by sticking together digest1, the SNMP engine's snmpEngineID value, and digest1 again. Feed this string into MD5 [MD5] too.
The resulting digest is the required secret (see Appendix A.2).
With those configured parameters, the SNMP engine creates 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
It is recommended to also set up a few template usmUserEntries that can be used as clone-from users for newly created usmUserEntries ๐ง There are two suggested entries:
no privacy support privacy support
------------------ ---------------
usmUserEngineID localEngineID localEngineID
usmUserName "templateMD5" "templateMD5"
usmUserSecurityName "templateMD5" "templateMD5"
usmUserCloneFrom ZeroDotZero ZeroDotZero
usmUserAuthProtocol usmHMACMD5AuthProtocol usmHMACMD5AuthProtocol
usmUserAuthKeyChange "" ""
usmUserOwnAuthKeyChange "" ""
usmUserPrivProtocol none usmDESPrivProtocol
usmUserPrivKeyChange "" ""
usmUserOwnPrivKeyChange "" ""
usmUserPublic "" ""
usmUserStorageType permanent permanent
usmUserStatus active active
no privacy support privacy support
------------------ ---------------
usmUserEngineID localEngineID localEngineID
usmUserName "templateSHA" "templateSHA"
usmUserSecurityName "templateSHA" "templateSHA"
usmUserCloneFrom ZeroDotZero ZeroDotZero
usmUserAuthProtocol usmHMACSHAAuthProtocol usmHMACSHAAuthProtocol
usmUserAuthKeyChange "" ""
usmUserOwnAuthKeyChange "" ""
usmUserPrivProtocol none usmDESPrivProtocol
usmUserPrivKeyChange "" ""
usmUserOwnPrivKeyChange "" ""
usmUserPublic "" ""
usmUserStorageType permanent permanent
usmUserStatus active active
A.2. Password to Key Algorithm โจ
Here's a sample code fragment (section A.2.1) showing the password to key algorithm, which you can use to map a password to an authentication or privacy key using MD5. The reference source code of MD5 is available in [RFC1321] ๐
There's also another sample code fragment (section A.2.2) showing the password to key algorithm for mapping a password to an authentication or privacy key using SHA (documented in SHA-NIST).
And there's an example of correct results (section A.3), so an implementor can check whether their implementation gives the same answer ๐
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+16+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+20+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
The following shows a sample output of the password to key algorithm for a 16-octet key using MD5.
With a password of "maplesyrup", the output of the password to key algorithm before the key is localized with the SNMP engine's snmpEngineID is:
'9f af 32 83 88 4e 92 83 4e bc 98 47 d8 ed d9 63'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:
'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
The following shows a sample output of the password to key algorithm for a 20-octet key using SHA.
With a password of "maplesyrup", the output of the password to key algorithm before the key is localized with the SNMP engine's snmpEngineID is:
'9f b5 cc 03 81 49 7b 37 93 52 89 39 ff 78 8d 5d 79 14 52 11'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:
'66 95 fe bc 92 88 e3 62 82 23 5f c7 15 1f 12 84 97 b3 8f 3f'H
A.4. Sample encoding of msgSecurityParameters ๐
The msgSecurityParameters in an SNMP message are represented as an OCTET STRING. This OCTET STRING should be considered opaque outside a specific Security Model.
The User-based Security Model defines the contents of the OCTET STRING as a SEQUENCE (see section 2.4).
Given these two properties, here's an example of the 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>
Here is the example once more, but now with real values (except for the digest in msgAuthenticationParameters and the salt in msgPrivacyParameters, which depend on variable data that we have not 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
A.5. Sample keyChange Results โจ
A.5.1. Sample keyChange Results using MD5 ๐
okay so let's say a user has the current password "maplesyrup" (same setup as section A.3.1.) and the snmpEngineID is 12 octets:
'00 00 00 00 00 00 00 00 00 00 00 02'H
now we wanna change the password to "newsyrup" โจ first we calculate the key for the new password, and it comes out like this:
'01 ad d2 73 10 7c 4e 59 6b 4b 00 f8 2b 1d 42 a7'H
then we localize it for that same snmpEngineID, and the localized new key becomes:
'87 02 1d 7b d9 d1 01 ba 05 ea 6e 3b f9 d9 bd 4a'H
next we pick a random value. it's not the most secure choice, but it's super easy to test ๐ so we use:
'00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00'H
and then the value we must send for keyChange is:
'00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
88 05 61 51 41 67 6c c9 19 61 74 e7 42 a3 25 51'H
if this were for the privacy key, it would be exactly the same ๐ซถ
A.5.2. Sample keyChange Results using SHA ๐งช
same vibe here: a user with the current password "maplesyrup" (as in section A.3.2.) and an snmpEngineID of 12 octets:
'00 00 00 00 00 00 00 00 00 00 00 02'H
we wanna change the password to "newsyrup" ๐ so first up is the key for the new password:
'3a 51 a6 d7 36 aa 34 7b 83 dc 4a 87 e3 e5 5e e4 d6 98 ac 71'H
localize it for that snmpEngineID and the localized new key becomes:
'78 e2 dc ce 79 d5 94 03 b5 8c 1b ba a5 bf f4 63 91 f1 cd 25'H
random value time (again, not so good, but easy to test ๐):
'00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00'H
so the value we must send for keyChange is:
'00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
9c 10 17 f4 fd 48 3d 2d e8 d5 fa db f8 43 92 cb 06 45 70 51'
now for the key used for privacy ๐ the new nonlocalized key would be:
'3a 51 a6 d7 36 aa 34 7b 83 dc 4a 87 e3 e5 5e e4 d6 98 ac 71'H
and the new localized key for privacy would be (heads up, the localized key gets truncated to 16 octets for DES โ ๏ธ):
'78 e2 dc ce 79 d5 94 03 b5 8c 1b ba a5 bf f4 63'H
we use another (not so good, but easy to test) random value of:
'00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00'H
and then the value we must send for keyChange for the privacy key is:
'00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
'7e f8 d8 a4 c9 cd b2 6b 47 59 1c d8 52 ff 88 b5'H
B. Change Log ๐
Changes made since RFC2274:
- Fixed
msgUserNameto allow size of zero and explain that this can be used for snmpEngineID discovery. - Clarified section 3.1 steps 4.b, 5, 6 and 8.b.
- Clarified section 3.2 paragraph 2.
- Clarified section 3.2 step 7.a last paragraph, step 7.b.1 second bullet and step 7.b.2 third bullet.
- Clarified section 4 to indicate that discovery can use a userName of zero length in unAuthenticated messages, whereas a valid userName must be used in authenticated messages.
- Added REVISION clauses to
MODULE-IDENTITY. - Clarified
KeyChange TCby adding a note that localized keys must be used when calculating a KeyChange value. - Added clarifying text to the
DESCRIPTIONclause ofusmUserTable. Added text describes a recommended procedure for adding a new user. - Clarified the use of
usmUserCloneFromobject. - Clarified how and under which conditions the
usmUserAuthProtocolandusmUserPrivProtocolcan be initialized and/or changed. - Added comment on typical sizes for
usmUserAuthKeyChangeandusmUserPrivKeyChange. Also forusmUserOwnAuthKeyChangeandusmUserOwnPrivKeyChange. - Added clarifications to the
DESCRIPTIONclauses ofusmUserAuthKeyChange,usmUserOwnAuthKeychange,usmUserPrivKeyChangeandusmUserOwnPrivKeychange. - Added clarification to
DESCRIPTIONclause ofusmUserStorageType. - Added clarification to
DESCRIPTIONclause ofusmUserStatus. - Clarified IV generation procedure in section 8.1.1.1 and in addition clarified section 8.3.1 step 1 and section 8.3.2. step 3.
- Clarified section 11.2 and added a warning that different size passwords with repetitive strings may result in same key.
- Added template users to appendix A for cloning process.
- Fixed C-code examples in Appendix A.
- Fixed examples of generated keys in Appendix A.
- Added examples of KeyChange values to Appendix A.
- Used PDU Classes instead of RFC1905 PDU types.
- Added text in the security section about Reports and Access Control to the MIB.
- Removed a incorrect note at the end of section 3.2 step 7.
- Added a note in section 3.2 step 3.
- Corrected various spelling errors and typos.
- Corrected procedure for 3.2 step 2.a).
- various clarifications.
- Fixed references to new/revised documents.
- Change to no longer cache data that is not used.
C. Full Copyright Statement ยฉ๏ธ
Copyright (C) The Internet Society (1999). All Rights Reserved.
This document and translations of it may be copied and furnished to others, and derivative works that comment on or otherwise explain it or assist in its implementation may be prepared, copied, published and distributed, in whole or in part, without restriction of any kind, provided that the above copyright notice and this paragraph are included on all such copies and derivative works. However, this document itself may not be modified in any way, such as by removing the copyright notice or references to the Internet Society or other Internet organizations, except as needed for the purpose of developing Internet standards in which case the procedures for copyrights defined in the Internet Standards process must be followed, or as required to translate it into languages other than English.
The limited permissions granted above are perpetual and will not be revoked by the Internet Society or its successors or assigns.
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.
Acknowledgement ๐ซถ
Funding for the RFC Editor function is currently provided by the Internet Society. ๐
๐ฆ where this page comes from
- ietf: rfc2574 1999-04
- ๐ girlified by claude-haiku-5-5 on : a language model's rewrite of the original, under its terms