C# Class SnmpSharpNet.PrivacyAES

AES privacy protocol implementation class.
Inheritance: IPrivacyProtocol
Show file Open project: griffina/SnmpSharpNet

Protected Properties

Property Type Description
_keyBytes int
_salt System.Int64

Public Methods

Method Description
Decrypt ( byte cryptedData, int offset, int length, byte key, int engineBoots, int engineTime, byte privacyParameters ) : byte[]

Decrypt ScopedPdu BER encoded byte array.

Encrypt ( byte unencryptedData, int offset, int length, byte key, int engineBoots, int engineTime, byte &privacyParameters, IAuthenticationDigest authDigest ) : byte[]

Encrypt ScopedPdu data BER encoded in a byte array.

ExtendShortKey ( byte shortKey, byte password, byte engineID, IAuthenticationDigest authProtocol ) : byte[]

Some protocols support a method to extend the encryption or decryption key when supplied key is too short.

GetEncryptedLength ( int scopedPduLength ) : int

Calculates and returns length of the buffer that is the result of the encryption method.

PasswordToKey ( byte secret, byte engineId, IAuthenticationDigest authProtocol ) : byte[]

Convert privacy password into encryption key using packet authentication hash.

PrivacyAES ( int keyBytes ) : System

Standard constructor.

Protected Methods

Method Description
NextSalt ( ) : System.Int64

Get next salt Int64 value. Used internally to encrypt data.

Method Details

Decrypt() public method

Decrypt ScopedPdu BER encoded byte array.
public Decrypt ( byte cryptedData, int offset, int length, byte key, int engineBoots, int engineTime, byte privacyParameters ) : byte[]
cryptedData byte Encrypted data byte array
offset int Offset within the buffer to start decryption process from
length int Length of data to decrypt
key byte Decryption key
engineBoots int Authoritative engine boots value. Retrieved as part of SNMP v3 discovery procedure
engineTime int Authoritative engine time value. Retrieved as part of SNMP v3 discovery procedure
privacyParameters byte Privacy parameters parsed from the incoming packet.
return byte[]

Encrypt() public method

Encrypt ScopedPdu data BER encoded in a byte array.
public Encrypt ( byte unencryptedData, int offset, int length, byte key, int engineBoots, int engineTime, byte &privacyParameters, IAuthenticationDigest authDigest ) : byte[]
unencryptedData byte BER encoded byte array that needs to be encrypted
offset int Offset within the BER encoded byte array to start encryption operation from.
length int Length of data to encrypt
key byte Encryption key
engineBoots int Authoritative engine boots value. Retrieved as part of SNMP v3 discovery process.
engineTime int Authoritative engine time value. Retrieved as part of SNMP v3 discovery process.
privacyParameters byte Byte array that will receive privacy parameters information that is the result of the /// encryption procedure.
authDigest IAuthenticationDigest Authentication digest reference. Not used by AES protocol and can be null
return byte[]

ExtendShortKey() public method

Some protocols support a method to extend the encryption or decryption key when supplied key is too short.
public ExtendShortKey ( byte shortKey, byte password, byte engineID, IAuthenticationDigest authProtocol ) : byte[]
shortKey byte Key that needs to be extended
password byte Privacy password as configured on the SNMP agent.
engineID byte Authoritative engine id. Value is retrieved as part of SNMP v3 discovery procedure
authProtocol IAuthenticationDigest Authentication protocol class instance cast as
return byte[]

GetEncryptedLength() public method

Calculates and returns length of the buffer that is the result of the encryption method.
public GetEncryptedLength ( int scopedPduLength ) : int
scopedPduLength int Length of the buffer that is needs to be encrypted.
return int

NextSalt() protected method

Get next salt Int64 value. Used internally to encrypt data.
protected NextSalt ( ) : System.Int64
return System.Int64

PasswordToKey() public method

Convert privacy password into encryption key using packet authentication hash.
Thrown when key size is shorter then MinimumKeyLength
public PasswordToKey ( byte secret, byte engineId, IAuthenticationDigest authProtocol ) : byte[]
secret byte Privacy user secret
engineId byte Authoritative engine id of the snmp agent
authProtocol IAuthenticationDigest Authentication protocol
return byte[]

PrivacyAES() public method

Standard constructor.
public PrivacyAES ( int keyBytes ) : System
keyBytes int Key size in bytes. Acceptable values are /// 16 = 128-bit key size, 24 = 192-bit key size, or 32 = 256-bit key size.
return System

Property Details

_keyBytes protected property

AES protocol key bytes. Valid values are 16 (for AES128), 24 (AES192) or 32 (AES256).
protected int _keyBytes
return int

_salt protected property

Salt value
protected Int64,System _salt
return System.Int64