C# 클래스 SnmpSharpNet.Privacy3DES

TripleDES privacy protocol implementation class.
TripleDES privacy implementation is based on the Internet Draft proposal to the SNMPv3 Working Group titled: Extension to the User-Based Security Model (USM) to Support Triple-DES EDE in "Outside" CBC Mode High level, TripleDES privacy in SNMPv3 uses DES-EDE. What this means is that a key is generated that is 24 bytes long. This key is split into 3 * 8 byte keys suitable for use with DES. Keys are then used to perform ecryption, decryption and another encryption using DES. Additionally, each block is XORed with the previous block of encrypted data, or if working on the first block, IV value. For details see draft-reeder-snmpv3-usm-3desede-00.txt. Important: TripleDES privacy protocol is not based on a standard. This extension to the USM standard has been proposed and has expired without approval or move to the standards track. Some vendors have implemented this privacy protocol and for the completeness of the library, it has been included in SnmpSharpNet. Troubleshooting of TripleDES encryption is difficult because of the low availability so if you find problems with the SnmpSharpNet implementation, please try to provide me with as much detail, both about your code and the type/version/mode of the agent you are working with.
상속: IPrivacyProtocol
파일 보기 프로젝트 열기: griffina/SnmpSharpNet

보호된 프로퍼티들

프로퍼티 타입 설명
_salt System.Int32

공개 메소드들

메소드 설명
Decrypt ( byte encryptedData, int offset, int length, byte key, int engineBoots, int engineTime, byte privacyParameters ) : byte[]

Decrypt TripleDES encrypted ScopedPdu

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

Encrypt ScopedPdu using TripleDES encryption protocol

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

Extends the encryption key if key size returned by PasswordToKey is less then minimum required by the encryption protocol.

There is no need to call this method in a user application becuase PasswordToKey() method will make the call if password it generates is too short.

GetEncryptedLength ( int scopedPduLength ) : int

Get final encrypted length

TripleDES performs encryption on 8 byte blocks so the final encrypted size will be a mulitiple of 8 with padding added to the end of the ScopedPdu if required.

NextSalt ( ) : int

Returns next salt value.

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

Convert privacy password into encryption key using packet authentication hash.

Privacy3DES ( ) : System

Standard constructor.

비공개 메소드들

메소드 설명
GetIV ( byte privacyKey, byte salt ) : byte[]

Generate IV from the privacy key and salt value returned by GetSalt method.

GetSalt ( int engineBoots ) : byte[]

Get TripleDES encryption salt value.

Salt value is generated by concatenating engineBoots value with the random integer value.

메소드 상세

Decrypt() 공개 메소드

Decrypt TripleDES encrypted ScopedPdu
Thrown when encrypted data is null or length == 0 Thrown when encryption key length is less then 32 byte or if privacy parameters /// argument is null or length other then 8 bytes
public Decrypt ( byte encryptedData, int offset, int length, byte key, int engineBoots, int engineTime, byte privacyParameters ) : byte[]
encryptedData byte Source data buffer
offset int Offset within the buffer to start decryption process
length int Length of data to decrypt
key byte Decryption key. Key length has to be 32 bytes in length or longer (bytes beyond 32 bytes are ignored).
engineBoots int Authoritative engine boots value
engineTime int Authoritative engine time value
privacyParameters byte Privacy parameters extracted from USM header
리턴 byte[]

Encrypt() 공개 메소드

Encrypt ScopedPdu using TripleDES encryption protocol
Thrown when encryption key is null or length of the encryption key is too short.
public Encrypt ( byte unencryptedData, int offset, int length, byte key, int engineBoots, int engineTime, byte &privacyParameters, IAuthenticationDigest authDigest ) : byte[]
unencryptedData byte Unencrypted ScopedPdu byte array
offset int Offset to start encryption
length int Length of data to encrypt
key byte Encryption key. Key has to be at least 32 bytes is length
engineBoots int Authoritative engine boots value
engineTime int Authoritative engine time value.
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
authDigest IAuthenticationDigest Authentication digest class reference. Used by TripleDES.
리턴 byte[]

ExtendShortKey() 공개 메소드

Extends the encryption key if key size returned by PasswordToKey is less then minimum required by the encryption protocol.
There is no need to call this method in a user application becuase PasswordToKey() method will make the call if password it generates is too short.
public ExtendShortKey ( byte shortKey, byte password, byte engineID, IAuthenticationDigest authProtocol ) : byte[]
shortKey byte Encryption key
password byte Privacy password
engineID byte Authoritative engine id
authProtocol IAuthenticationDigest Authentication protocol class instance
리턴 byte[]

GetEncryptedLength() 공개 메소드

Get final encrypted length
TripleDES performs encryption on 8 byte blocks so the final encrypted size will be a mulitiple of 8 with padding added to the end of the ScopedPdu if required.
public GetEncryptedLength ( int scopedPduLength ) : int
scopedPduLength int BER encoded ScopedPdu data length
리턴 int

NextSalt() 공개 메소드

Returns next salt value.
public NextSalt ( ) : int
리턴 int

PasswordToKey() 공개 메소드

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

Privacy3DES() 공개 메소드

Standard constructor.
public Privacy3DES ( ) : System
리턴 System

프로퍼티 상세

_salt 보호되어 있는 프로퍼티

Internal salt value
protected Int32,System _salt
리턴 System.Int32