Package org.snmp4j.security
Class PrivDES
java.lang.Object
org.snmp4j.security.PrivacyGeneric
org.snmp4j.security.PrivDES
- All Implemented Interfaces:
 Serializable,PrivacyProtocol,SecurityProtocol
Privacy protocol class for DES.
 This class uses DES in CBC mode to encrypt the data. The protocol
 is defined in the IETF standard "User-based Security Model (USM)
 for SNMPv3".
- Version:
 - 2.5.0
 - Author:
 - Jochen Katz
 - See Also:
 
- 
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final OIDUnique ID of this privacy protocol.protected org.snmp4j.security.SaltFields inherited from class org.snmp4j.security.PrivacyGeneric
cipherPool, initVectorLength, keyBytes, protocolClass, protocolId - 
Constructor Summary
Constructors - 
Method Summary
Modifier and TypeMethodDescriptionbyte[]decrypt(byte[] cryptedData, int offset, int length, byte[] decryptionKey, long engineBoots, long engineTime, DecryptParams decryptParams) Decrypts a message using a given decryption key, engine boots count, and engine ID.byte[]encrypt(byte[] unencryptedData, int offset, int length, byte[] encryptionKey, long engineBoots, long engineTime, DecryptParams decryptParams) Encrypts a message using a given encryption key, engine boots count, and engine ID.byte[]extendShortKey(byte[] shortKey, OctetString password, byte[] engineID, AuthenticationProtocol authProtocol) Extend a localized key that is too short.intGets the length of the decryption parameters used by this security protocol.intgetEncryptedLength(int scopedPDULength) Gets the length of a scoped PDU when encrypted with this security protocol.getID()Gets the OID uniquely identifying the privacy protocol.intGets the maximum key size for this privacy protocol.intGets the minimum key size for this privacy protocol.booleanChecks whether this security protocol is actually supported by this Java runtime environment.Methods inherited from class org.snmp4j.security.PrivacyGeneric
doDecrypt, doFinal, doFinalWithPadding, doInit 
- 
Field Details
- 
ID
Unique ID of this privacy protocol. - 
salt
protected org.snmp4j.security.Salt salt 
 - 
 - 
Constructor Details
- 
PrivDES
public PrivDES() 
 - 
 - 
Method Details
- 
encrypt
public byte[] encrypt(byte[] unencryptedData, int offset, int length, byte[] encryptionKey, long engineBoots, long engineTime, DecryptParams decryptParams) Description copied from interface:PrivacyProtocolEncrypts a message using a given encryption key, engine boots count, and engine ID.- Parameters:
 unencryptedData- the unencrypted data. This byte array may contain leading and trailing bytes that will not be encrypted.offset- the offset into theunencryptedDatawhere to start encryption.length- the length of the substring starting atoffsetto encrypt.encryptionKey- the key to be used for encryption.engineBoots- the engine boots counter to use.engineTime- the engine time to use.decryptParams- returns the decryption parameters needed to decrypt the data that has been encrypted by this method.- Returns:
 - the encrypted copy of 
unencryptedData. 
 - 
decrypt
public byte[] decrypt(byte[] cryptedData, int offset, int length, byte[] decryptionKey, long engineBoots, long engineTime, DecryptParams decryptParams) Decrypts a message using a given decryption key, engine boots count, and engine ID.- Parameters:
 cryptedData- the data to decrypt.offset- the offset intocryptedDatato start decryption.length- the length of the data to decrypt.decryptionKey- the decryption key.engineBoots- the engine boots counter.engineTime- the engine time value.decryptParams- contains the decryption parameters.- Returns:
 - the decrypted data, or 
nullif decryption failed. 
 - 
getID
Gets the OID uniquely identifying the privacy protocol.- Returns:
 - an 
OIDinstance. 
 - 
isSupported
public boolean isSupported()Description copied from interface:SecurityProtocolChecks whether this security protocol is actually supported by this Java runtime environment.- Specified by:
 isSupportedin interfaceSecurityProtocol- Overrides:
 isSupportedin classPrivacyGeneric- Returns:
 trueif this security protocol is supported,falseotherwise.
 - 
getEncryptedLength
public int getEncryptedLength(int scopedPDULength) Description copied from interface:PrivacyProtocolGets the length of a scoped PDU when encrypted with this security protocol.- Parameters:
 scopedPDULength- the length of the (unencrypted) scoped PDU.- Returns:
 - the length of the encrypted scoped PDU.
 
 - 
getMinKeyLength
public int getMinKeyLength()Description copied from interface:PrivacyProtocolGets the minimum key size for this privacy protocol.- Returns:
 - the minimum key size for this privacy protocol.
 
 - 
getDecryptParamsLength
public int getDecryptParamsLength()Description copied from interface:PrivacyProtocolGets the length of the decryption parameters used by this security protocol.- Returns:
 - a positive integer denoting the length of decryption parameters returned by this security protocol.
 
 - 
getMaxKeyLength
public int getMaxKeyLength()Description copied from interface:PrivacyProtocolGets the maximum key size for this privacy protocol.- Returns:
 - the minimum key size for this privacy protocol.
 
 - 
extendShortKey
public byte[] extendShortKey(byte[] shortKey, OctetString password, byte[] engineID, AuthenticationProtocol authProtocol) Description copied from interface:PrivacyProtocolExtend a localized key that is too short. Some privacy protocols require a key that is longer than the key generated by the password-to-key algorithm of the authentication protocol. This function extends a short key to the required length.- Parameters:
 shortKey- the short key that was generated usingAuthenticationProtocol.passwordToKey(org.snmp4j.smi.OctetString, byte[])function.password- the password to use for key extension.engineID- the SNMP engine ID of the authoritative engine.authProtocol- the authentication protocol that should be used.- Returns:
 - the extended key or 
shortKeyif no extension is needed. 
 
 -