JXTA

jxta.security.impl.mac
Class MACAlgorithm

java.lang.Object
  |
  +--jxta.security.impl.mac.MACAlgorithm

public class MACAlgorithm
extends java.lang.Object
implements jxta.security.mac.MAC


Fields inherited from interface jxta.security.mac.MAC
ALG_NULL, ALG_RC4_MD5, ALG_RC4_SHA1, MODE_ENCRYPT, MODE_VERIFY, name
 
Constructor Summary
MACAlgorithm(jxta.security.cipher.Cipher cipherAlg, byte theType, jxta.security.hash.Hash theDigest)
          constructor
 
Method Summary
 void clearDebug()
          turn off debugging
 int encrypt(byte[] inbuf, int offset, int inLength, byte[] macBuf, int macOffset)
          Signs the hash generated from the last(only) buffer of data.
 byte getAlgorithm()
          // Algorithm type
 java.lang.String getAlgorithmName()
          // Algorithm name
 int getLength()
          get the length of the signature
 void init(byte theMode, jxta.security.cipher.Key theKey, byte[] privateKey)
          initialize the Signature mode - sign or verify
 void setDebug()
          turn on debugging
 void update(byte[] inbuf, int offset, int length)
          updates data to be encrypted.
 boolean verify(byte[] inBuf, int inOffset, int inLength, byte[] macBuf, int macOffset, int macLength)
          Verifies a MAC after updating last/only inBuf against the MAC in macBuf.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MACAlgorithm

public MACAlgorithm(jxta.security.cipher.Cipher cipherAlg,
                    byte theType,
                    jxta.security.hash.Hash theDigest)
             throws jxta.security.exceptions.CryptoException
constructor
Method Detail

getAlgorithmName

public java.lang.String getAlgorithmName()
// Algorithm name
Specified by:
getAlgorithmName in interface jxta.security.mac.MAC

getAlgorithm

public byte getAlgorithm()
// Algorithm type
Specified by:
getAlgorithm in interface jxta.security.mac.MAC

setDebug

public void setDebug()
turn on debugging

clearDebug

public void clearDebug()
turn off debugging

getLength

public int getLength()
get the length of the signature
Specified by:
getLength in interface jxta.security.mac.MAC

init

public void init(byte theMode,
                 jxta.security.cipher.Key theKey,
                 byte[] privateKey)
          throws jxta.security.exceptions.CryptoException
initialize the Signature mode - sign or verify
Specified by:
init in interface jxta.security.mac.MAC

update

public void update(byte[] inbuf,
                   int offset,
                   int length)
            throws jxta.security.exceptions.CryptoException
updates data to be encrypted. Here, the data in inbuf is hashed with the digest.
Specified by:
update in interface jxta.security.mac.MAC

encrypt

public int encrypt(byte[] inbuf,
                   int offset,
                   int inLength,
                   byte[] macBuf,
                   int macOffset)
            throws jxta.security.exceptions.CryptoException
Signs the hash generated from the last(only) buffer of data.
Specified by:
encrypt in interface jxta.security.mac.MAC

verify

public boolean verify(byte[] inBuf,
                      int inOffset,
                      int inLength,
                      byte[] macBuf,
                      int macOffset,
                      int macLength)
               throws jxta.security.exceptions.CryptoException
Verifies a MAC after updating last/only inBuf against the MAC in macBuf. One can use update as with encrypt().
Specified by:
verify in interface jxta.security.mac.MAC

JXTA