com.sun.management.snmp.usm
Class SnmpUsmHmacAlgorithm

java.lang.Object
  extended by com.sun.management.snmp.usm.SnmpUsmHmacAlgorithm
All Implemented Interfaces:
SnmpUsmAlgorithm, SnmpUsmAuthAlgorithm
Direct Known Subclasses:
SnmpUsmHmacMd5, SnmpUsmHmacSha

public abstract class SnmpUsmHmacAlgorithm
extends Object
implements SnmpUsmAuthAlgorithm

FOR INTERNAL USE ONLY. This is the default implementation of the Hmac + Message Digest algorithms. It is based on the standard java.security packages.

Since:
Java DMK 5.1

Constructor Summary
protected SnmpUsmHmacAlgorithm(String algoName, String mdName)
           
 
Method Summary
 byte[] calculateAuthDelta(byte[] oldKey, byte[] newKey, byte[] random)
          Calculate the delta parameter needed when processing key change.
 byte[] calculateNewAuthKey(byte[] oldKey, byte[] randomdelta)
          Compute the new key and return it.
 byte[] calculateNewPrivKey(byte[] oldKey, byte[] randomdelta, int deltaSize)
          Compute the new key and return it.
 byte[] calculatePrivDelta(byte[] oldKey, byte[] newKey, byte[] random, int deltaSize)
          Calculate the delta parameter needed when processing key change for a privacy algorithm.
 String getAlgorithm()
          Gets the unique algorithm name.
abstract  int getDeltaSize()
          Gets the delta used for key change algorithm (see RFC 2574).
 byte[] localizeAuthKey(byte[] key, SnmpEngineId engineId)
          Translate a global key to a local one (RFC 2574 KUL).
 byte[] localizePrivKey(byte[] key, SnmpEngineId engineId, int keysize)
          Translate a global privacy key to a local one (RFC 2574 KUL).
 byte[] password_to_key(String password)
          Translate a password to a key according to the right algorithm (RFC 2574 algorithm).
 byte[] sign(byte[] key, byte[] data, int length)
          Sign the passed data and returns the corresponding Hmac.
 String toString(byte[] signature)
          Translate a signature to a displayable string.
 boolean verify(byte[] key, byte[] data, int length, byte[] signature)
          Verify that the passed signature is compliant with the passed data.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.sun.management.snmp.usm.SnmpUsmAlgorithm
getAlgorithm, getOid
 

Constructor Detail

SnmpUsmHmacAlgorithm

protected SnmpUsmHmacAlgorithm(String algoName,
                               String mdName)
Method Detail

getDeltaSize

public abstract int getDeltaSize()
Description copied from interface: SnmpUsmAlgorithm
Gets the delta used for key change algorithm (see RFC 2574).

Specified by:
getDeltaSize in interface SnmpUsmAlgorithm
Returns:
The delta value.

sign

public byte[] sign(byte[] key,
                   byte[] data,
                   int length)
Sign the passed data and returns the corresponding Hmac.

Specified by:
sign in interface SnmpUsmAuthAlgorithm
Parameters:
key - The key to use.
data - The data to sign.
length - The data length.
Returns:
The Hmac.

verify

public boolean verify(byte[] key,
                      byte[] data,
                      int length,
                      byte[] signature)
Verify that the passed signature is compliant with the passed data.

Specified by:
verify in interface SnmpUsmAuthAlgorithm
Parameters:
key - The key to use.
data - The data to sign.
length - The data length.
signature - The signature (Hmac).
Returns:
true means signature OK, false means bad signature.

toString

public String toString(byte[] signature)
Translate a signature to a displayable string.

Parameters:
signature - The Hmac
Returns:
The displayable string representing the signature.

password_to_key

public byte[] password_to_key(String password)
Translate a password to a key according to the right algorithm (RFC 2574 algorithm).

Specified by:
password_to_key in interface SnmpUsmAuthAlgorithm
Parameters:
password - The password.
Returns:
The key.

localizeAuthKey

public byte[] localizeAuthKey(byte[] key,
                              SnmpEngineId engineId)
Translate a global key to a local one (RFC 2574 KUL). The parameter used to localize a key is the authoritative engine Id.

Specified by:
localizeAuthKey in interface SnmpUsmAuthAlgorithm
Parameters:
key - The key to use.
engineId - The engine Id to use.
Returns:
The localized key.

localizePrivKey

public byte[] localizePrivKey(byte[] key,
                              SnmpEngineId engineId,
                              int keysize)
Translate a global privacy key to a local one (RFC 2574 KUL). The parameter used to localize a key is the authoritative engine Id. The returned key size is equal to key size parameter.

Specified by:
localizePrivKey in interface SnmpUsmAuthAlgorithm
Parameters:
key - The key to use.
engineId - The engine Id to use.
keysize - The privacy algorithm key size.
Returns:
The localized key.

calculateAuthDelta

public byte[] calculateAuthDelta(byte[] oldKey,
                                 byte[] newKey,
                                 byte[] random)
Calculate the delta parameter needed when processing key change. This computation is done by the key change initiator. It MUST be compliant to RFC 2574 description.

Specified by:
calculateAuthDelta in interface SnmpUsmAuthAlgorithm
Parameters:
oldKey - The old key.
newKey - The new key.
random - The random value.
Returns:
The delta.

calculatePrivDelta

public byte[] calculatePrivDelta(byte[] oldKey,
                                 byte[] newKey,
                                 byte[] random,
                                 int deltaSize)
Calculate the delta parameter needed when processing key change for a privacy algorithm. This computation is done by the key change initiator. It MUST be compliant to RFC 2574 description.

Specified by:
calculatePrivDelta in interface SnmpUsmAuthAlgorithm
Parameters:
oldKey - The old key.
newKey - The new key.
random - The random value.
deltaSize - The algorithm delta size.
Returns:
The delta.

calculateNewAuthKey

public byte[] calculateNewAuthKey(byte[] oldKey,
                                  byte[] randomdelta)
Compute the new key and return it. It MUST be compliant to RFC 2574 description. This is done mainly in the agent side.

Specified by:
calculateNewAuthKey in interface SnmpUsmAuthAlgorithm
Parameters:
oldKey - The old key.
randomdelta - Random and received delta concatenation.

calculateNewPrivKey

public byte[] calculateNewPrivKey(byte[] oldKey,
                                  byte[] randomdelta,
                                  int deltaSize)
Compute the new key and return it. It MUST be compliant to RFC 2574 description. This is done mainly in the agent side.

Specified by:
calculateNewPrivKey in interface SnmpUsmAuthAlgorithm
Parameters:
oldKey - The old key.
randomdelta - Random and received delta concatenation.
deltaSize - The algorithm deltaSize

getAlgorithm

public String getAlgorithm()
Description copied from interface: SnmpUsmAlgorithm
Gets the unique algorithm name.

Specified by:
getAlgorithm in interface SnmpUsmAlgorithm
Returns:
Algorithm name.

Open Source build 02
opendmk-1.0-b02 2007.10.01_19:17:46_MEST

Copyright 1998-2007 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms.