public class DHOperations extends Object
Modifier and Type | Class and Description |
---|---|
static class |
DHOperations.DHKeyInfo
The
DHSharedKeyInfo provides DH key exchange information that associates a user name with a key
(private or shared) and authentication and privacy protocol OIDs necessary to create an USM user
during a DH kick-start operation. |
static class |
DHOperations.KeyType |
Modifier and Type | Field and Description |
---|---|
static String |
DH_AUTH_PROTOCOL_PROPERTY
Property name for authentication protocol OID of the kickstart user entry.
|
static String |
DH_KICKSTART_SEC_NAME |
static String |
DH_KICKSTART_VIEW_NAME |
static String |
DH_PARAMS_PROPERTY
Property name with the
DHParameters used for the kickstart. |
static String |
DH_PRIV_PROTOCOL_PROPERTY
Property name for privacy protocol OID of the kickstart user entry.
|
static String |
DH_PRIVATE_KEY_PROPERTY
Property name for private keys of Diffie Hellman key exchange property files.
|
static String |
DH_PUBLIC_KEY_PROPERTY
Property name for public keys of Diffie Hellman key exchange property files.
|
static String |
DH_RESET_PROPERTY
Property name to reset an USM user with a kickstart user entry.
|
static String |
DH_VACM_ROLE_PROPERTY
Property name for VACM role of the kickstart user entry.
|
static String |
DIFFIE_HELLMAN |
static OID |
oidUsmDHKickstartMgrPublic |
static OID |
oidUsmDHKickstartMyPublic |
static OID |
oidUsmDHKickstartSecurityName |
static String |
PBKDF2 |
Constructor and Description |
---|
DHOperations() |
Modifier and Type | Method and Description |
---|---|
static BigInteger |
bytesToBigInteger(byte[] bytes)
Convert a byte array to a
BigInteger . |
static byte[] |
computeSharedKey(KeyAgreement keyAgreement,
byte[] publicKey,
DHParameters dhParameters) |
static KeyPair |
createKeyPair(OctetString publicKeyOctets,
OctetString privateKeyOctets,
DHParameters dhParameters) |
static byte[] |
deriveKey(byte[] sharedKey,
int keyLength)
Derive the USM key from the Diffie Hellman key exchange.
|
static byte[] |
deriveKeyPBKDF2(byte[] shareKey,
int keyLength,
SecurityProtocols.SecurityProtocolType securityProtocolType) |
static OctetString |
derivePrivateKey(KeyPair keyPair) |
static OctetString |
derivePublicKey(KeyPair keyPair) |
static KeyPair |
generatePublicKey(DHParameters dhParameters) |
static Map<OctetString,OctetString[]> |
getDHKickstartPublicKeys(Session session,
PDUFactory pduFactory,
Target target,
Set<OctetString> managerPublic)
Get the public keys of the agent's kickstart table that match the local public keys provided from a remote agent.
|
static KeyAgreement |
getInitializedKeyAgreement(KeyPair keyPair) |
static byte[] |
keyToBytes(Key key)
Convert a
Key to a byte array. |
public static final String DIFFIE_HELLMAN
public static final String PBKDF2
public static final String DH_KICKSTART_SEC_NAME
public static final String DH_KICKSTART_VIEW_NAME
public static final OID oidUsmDHKickstartMyPublic
public static final OID oidUsmDHKickstartMgrPublic
public static final OID oidUsmDHKickstartSecurityName
public static final String DH_PRIVATE_KEY_PROPERTY
public static final String DH_PUBLIC_KEY_PROPERTY
public static final String DH_AUTH_PROTOCOL_PROPERTY
public static final String DH_PRIV_PROTOCOL_PROPERTY
public static final String DH_VACM_ROLE_PROPERTY
public static final String DH_RESET_PROPERTY
public static final String DH_PARAMS_PROPERTY
DHParameters
used for the kickstart.public static byte[] computeSharedKey(KeyAgreement keyAgreement, byte[] publicKey, DHParameters dhParameters)
public static BigInteger bytesToBigInteger(byte[] bytes)
BigInteger
.
Adds a leading zero-byte to ensure a positive BigInteger
.bytes
- The byte array to convert.BigInteger
containing the provided bytes as unsigned integer.public static byte[] keyToBytes(Key key)
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.null
.public static KeyPair createKeyPair(OctetString publicKeyOctets, OctetString privateKeyOctets, DHParameters dhParameters)
public static OctetString derivePublicKey(KeyPair keyPair)
public static OctetString derivePrivateKey(KeyPair keyPair)
public static KeyPair generatePublicKey(DHParameters dhParameters) throws NoSuchAlgorithmException, InvalidAlgorithmParameterException
public static KeyAgreement getInitializedKeyAgreement(KeyPair keyPair)
public static byte[] deriveKey(byte[] sharedKey, int keyLength)
sharedKey
- the shared key (z).keyLength
- the key length of the resulting key in bytes.keyLength
.public static byte[] deriveKeyPBKDF2(byte[] shareKey, int keyLength, SecurityProtocols.SecurityProtocolType securityProtocolType)
public static Map<OctetString,OctetString[]> getDHKickstartPublicKeys(Session session, PDUFactory pduFactory, Target target, Set<OctetString> managerPublic) throws IOException
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.IOException
- if the SNMP communication fails.Copyright © 2020 SNMP4J.org. All rights reserved.