com.maverick.ssh2
Class SshHmac

java.lang.Object
  extended bycom.maverick.ssh2.SshHmac

public class SshHmac
extends java.lang.Object

Data integrity is provided by the SSH Transport Protocol by including with each packet a message authentication code (MAC) that is computed from a shared secret, packet sequence number, and the contents of the packet. This class implements a wrapper around the digests so additional implementations need only concern themselves with the actual digest implementation.

Author:
Lee David Painter

Constructor Summary
SshHmac(java.lang.String name, com.maverick.crypto.digests.HMac mac)
          Construct an uninitialized MAC
 
Method Summary
 void generate(long sequenceNo, byte[] data, int offset, int len, byte[] output, int start)
          Generate a MAC from the data supplied.
 java.lang.String getAlgorithm()
          Get the algorithm name
 int getMacLength()
          Get the length of the MAC.
 void init(byte[] keydata)
          Initialize the MAC
 boolean verify(long sequenceNo, byte[] data, int start, int len, byte[] mac, int offset)
          Verify a MAC.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SshHmac

public SshHmac(java.lang.String name,
               com.maverick.crypto.digests.HMac mac)
Construct an uninitialized MAC

Parameters:
name - the name of the algorithm, for example "hmac-sha1"
Method Detail

getAlgorithm

public java.lang.String getAlgorithm()
Get the algorithm name

Returns:
the name supplied during creation of this object.

getMacLength

public int getMacLength()
Get the length of the MAC.

Returns:
the length of the digest.

generate

public void generate(long sequenceNo,
                     byte[] data,
                     int offset,
                     int len,
                     byte[] output,
                     int start)
Generate a MAC from the data supplied.

Parameters:
sequenceNo - the sequence no of the transport protocol message
data - the data to generate a MAC from
offset - the offset in the data to start
len - the length of data to process
Returns:
the generated MAC

init

public void init(byte[] keydata)
          throws SshException
Initialize the MAC

Parameters:
keydata - the key data
Throws:
java.io.IOException
SshException

verify

public boolean verify(long sequenceNo,
                      byte[] data,
                      int start,
                      int len,
                      byte[] mac,
                      int offset)
               throws SshException
Verify a MAC.

Parameters:
sequenceNo - the sequence no of the transport protocol message
data - the data including the mac to verify
start - the start of the data
len - the length of the data
Returns:
true if the MAC is corrent, otherwise false
Throws:
java.io.IOException
SshException


Copyright © 2003 3SP LTD. All Rights Reserved.