Table of Contents

Class TripleDESPrivacyProvider

Namespace
Lextm.SharpSnmpLib.Security
Assembly
SharpSnmpLib.dll

Privacy provider for 3DES.

[Obsolete("3DES is no longer secure. Please use a more secure provider.")]
public sealed class TripleDESPrivacyProvider : IPrivacyProvider
Inheritance
TripleDESPrivacyProvider
Implements
Inherited Members
Extension Methods

Remarks

Ported from SNMP#NET Privacy3DES class.

Originally defined in a draft https://datatracker.ietf.org/doc/html/draft-reeder-snmpv3-usm-3desede-00

Constructors

TripleDESPrivacyProvider(OctetString, IAuthenticationProvider)

Initializes a new instance of the DESPrivacyProvider class.

public TripleDESPrivacyProvider(OctetString phrase, IAuthenticationProvider auth)

Parameters

phrase OctetString

The phrase.

auth IAuthenticationProvider

The authentication provider.

Properties

AuthenticationProvider

Corresponding IAuthenticationProvider.

public IAuthenticationProvider AuthenticationProvider { get; }

Property Value

IAuthenticationProvider

EngineIds

Engine IDs.

public ICollection<OctetString>? EngineIds { get; set; }

Property Value

ICollection<OctetString>

Remarks

This is an optional field, and only used by TRAP v2 authentication.

MaximumKeyLength

Return maximum encryption/decryption key length. For 3DES, returned value is 32.

3DES protocol itself requires an 24 byte key. Additional 8 bytes are used for generating the encryption IV. For encryption itself, first 24 bytes of the key are used.

public static int MaximumKeyLength { get; }

Property Value

int

MinimumKeyLength

Returns minimum encryption/decryption key length. For 3DES, returned value is 32.

3DES protocol itself requires an 24 byte key. Additional 8 bytes are used for generating the encryption IV. For encryption itself, first 24 bytes of the key are used.

public static int MinimumKeyLength { get; }

Property Value

int

PrivacyParametersLength

Returns the length of privacyParameters USM header field. For 3DES, field length is 8.

public static int PrivacyParametersLength { get; }

Property Value

int

Salt

Gets the salt.

public OctetString Salt { get; }

Property Value

OctetString

The salt.

UseLegacy

Flag to force using legacy encryption/decryption code on .NET 6.

public static bool UseLegacy { get; set; }

Property Value

bool

Methods

Decrypt(ISnmpData, SecurityParameters)

Decrypts the specified data.

public ISnmpData Decrypt(ISnmpData data, SecurityParameters parameters)

Parameters

data ISnmpData

The data.

parameters SecurityParameters

The parameters.

Returns

ISnmpData

Decrypt(byte[], byte[], byte[])

Decrypt DES encrypted scoped PDU.

public static byte[] Decrypt(byte[] encryptedData, byte[] key, byte[] privacyParameters)

Parameters

encryptedData byte[]

Source data buffer

key byte[]

Decryption key. Key length has to be 32 bytes in length or longer (bytes beyond 32 bytes are ignored).

privacyParameters byte[]

Privacy parameters extracted from USM header

Returns

byte[]

Decrypted byte array

Exceptions

ArgumentNullException

Thrown when encrypted data is null or length == 0

ArgumentOutOfRangeException

Thrown when encryption key length is less then 32 byte or if privacy parameters argument is null or length other then 8 bytes

Encrypt(ISnmpData, SecurityParameters)

Encrypts the specified scope.

public ISnmpData Encrypt(ISnmpData data, SecurityParameters parameters)

Parameters

data ISnmpData

The scope data.

parameters SecurityParameters

The parameters.

Returns

ISnmpData

Encrypt(byte[], byte[], byte[])

Encrypt scoped PDU using DES encryption protocol

public static byte[] Encrypt(byte[] unencryptedData, byte[] key, byte[] privacyParameters)

Parameters

unencryptedData byte[]

Unencrypted scoped PDU byte array

key byte[]

Encryption key. Key has to be at least 32 bytes is length

privacyParameters byte[]

Privacy parameters out buffer. This field will be filled in with information required to decrypt the information. Output length of this field is 8 bytes and space has to be reserved in the USM header to store this information

Returns

byte[]

Encrypted byte array

Exceptions

ArgumentOutOfRangeException

Thrown when encryption key is null or length of the encryption key is too short.

PasswordToKey(byte[], byte[])

Passwords to key.

public byte[] PasswordToKey(byte[] secret, byte[] engineId)

Parameters

secret byte[]

The secret.

engineId byte[]

The engine identifier.

Returns

byte[]

ToString()

Returns a string that represents this object.

public override string ToString()

Returns

string