Module org.snmp4j

Class DHOperations

  • public class DHOperations
    extends java.lang.Object
    Implementation of Diffie Hellman operations for SNMP as defined by RFC 2786.
    Frank Fock
    • Field Detail


        public static final java.lang.String DH_KICKSTART_SEC_NAME
        See Also:
        Constant Field Values

        public static final java.lang.String DH_KICKSTART_VIEW_NAME
        See Also:
        Constant Field Values
      • oidUsmDHKickstartMyPublic

        public static final OID oidUsmDHKickstartMyPublic
      • oidUsmDHKickstartMgrPublic

        public static final OID oidUsmDHKickstartMgrPublic
      • oidUsmDHKickstartSecurityName

        public static final OID oidUsmDHKickstartSecurityName

        public static final java.lang.String DH_PRIVATE_KEY_PROPERTY
        Property name for private keys of Diffie Hellman key exchange property files.
        See Also:
        Constant Field Values

        public static final java.lang.String DH_PUBLIC_KEY_PROPERTY
        Property name for public keys of Diffie Hellman key exchange property files.
        See Also:
        Constant Field Values

        public static final java.lang.String DH_AUTH_PROTOCOL_PROPERTY
        Property name for authentication protocol OID of the kickstart user entry.
        See Also:
        Constant Field Values

        public static final java.lang.String DH_PRIV_PROTOCOL_PROPERTY
        Property name for privacy protocol OID of the kickstart user entry.
        See Also:
        Constant Field Values

        public static final java.lang.String DH_VACM_ROLE_PROPERTY
        Property name for VACM role of the kickstart user entry.
        See Also:
        Constant Field Values

        public static final java.lang.String DH_RESET_PROPERTY
        Property name to reset an USM user with a kickstart user entry.
        See Also:
        Constant Field Values
    • Constructor Detail

      • DHOperations

        public DHOperations()
    • Method Detail

      • computeSharedKey

        public static byte[] computeSharedKey​(javax.crypto.KeyAgreement keyAgreement,
                                              byte[] publicKey,
                                              DHParameters dhParameters)
      • bytesToBigInteger

        public static java.math.BigInteger bytesToBigInteger​(byte[] bytes)
        Convert a byte array to a BigInteger. Adds a leading zero-byte to ensure a positive BigInteger.
        bytes - The byte array to convert.
        the BigInteger containing the provided bytes as unsigned integer.
      • keyToBytes

        public static byte[] keyToBytes​( key)
        Convert a Key to a byte array. Uses X or Y values of a key depending on key type (private or public). Cut off a leading zero-byte if key length is not divisible by 8.
        key - The Key to convert.
        the byte array representation of the key or null.
      • derivePublicKey

        public static OctetString derivePublicKey​( keyPair)
      • derivePrivateKey

        public static OctetString derivePrivateKey​( keyPair)
      • generatePublicKey

        public static generatePublicKey​(DHParameters dhParameters)
      • getInitializedKeyAgreement

        public static javax.crypto.KeyAgreement getInitializedKeyAgreement​( keyPair)
      • deriveKey

        public static byte[] deriveKey​(byte[] sharedKey,
                                       int keyLength)
        Derive the USM key from the Diffie Hellman key exchange.
        sharedKey - the shared key (z).
        keyLength - the key length of the resulting key in bytes.
        the USM key as byte array of length keyLength.
      • getDHKickstartPublicKeys

        public static java.util.Map<OctetString,OctetString[]> getDHKickstartPublicKeys​(Session session,
                                                                                        PDUFactory pduFactory,
                                                                                        Target<?> target,
                                                                                        java.util.Set<OctetString> managerPublic)
        Get the public keys of the agent's kickstart table that match the local public keys provided from a remote agent.
        session - the SNMP Session to use.
        pduFactory - the PDUFactory to be used to create SNMP PDUs for requesting the data.
        target - the SNMP agent target.
        managerPublic - a set of public keys of this manager for which public keys of the agent should be retrieved.
        a map that maps the manager's public keys for which an agent public key has been found, to a two-element array with the first element being the agent public key and the second the associated user/security name.
        Throws: - if the SNMP communication fails.