Module org.snmp4j

Interface PrivacyProtocol

    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      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.
      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.
      int getDecryptParamsLength​()
      Gets the length of the decryption parameters used by this security protocol.
      int getEncryptedLength​(int scopedPDULength)
      Gets the length of a scoped PDU when encrypted with this security protocol.
      OID getID​()
      Gets the OID uniquely identifying the privacy protocol.
      int getMaxKeyLength​()
      Gets the maximum key size for this privacy protocol.
      int getMinKeyLength​()
      Gets the minimum key size for this privacy protocol.
    • Method Detail

      • encrypt

        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.
        Parameters:
        unencryptedData - the unencrypted data. This byte array may contain leading and trailing bytes that will not be encrypted.
        offset - the offset into the unencryptedData where to start encryption.
        length - the length of the substring starting at offset to 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

        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 crypted data. This byte array may contain leading and trailing bytes that will not be decrypted.
        offset - the offset into the cryptedData where to start encryption.
        length - the length of the substring starting at offset to decrypt.
        decryptionKey - the key to be used for decryption.
        engineBoots - the engine boots counter to use.
        engineTime - the engine time to use.
        decryptParams - contains the decryption parameters.
        Returns:
        the decrypted data, or null if decryption failed.
      • getID

        OID getID​()
        Gets the OID uniquely identifying the privacy protocol.
        Specified by:
        getID in interface SecurityProtocol
        Returns:
        an OID instance.
      • getEncryptedLength

        int getEncryptedLength​(int scopedPDULength)
        Gets 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

        int getMinKeyLength​()
        Gets the minimum key size for this privacy protocol.
        Returns:
        the minimum key size for this privacy protocol.
      • getMaxKeyLength

        int getMaxKeyLength​()
        Gets the maximum key size for this privacy protocol.
        Specified by:
        getMaxKeyLength in interface SecurityProtocol
        Returns:
        the minimum key size for this privacy protocol.
      • getDecryptParamsLength

        int getDecryptParamsLength​()
        Gets 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.
      • extendShortKey

        byte[] extendShortKey​(byte[] shortKey,
                              OctetString password,
                              byte[] engineID,
                              AuthenticationProtocol authProtocol)
        Extend 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 using AuthenticationProtocol.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 shortKey if no extension is needed.
        Since:
        1.9