Name

MAC

Synopsis

Objects that implement this interface are used to calculate MACs. Classes that implement this interface are obtained from the JXTA crypto suite of the platform; in the standard binding, you can obtain MACs that use RC4 encryption on either an SHA-1 or an MD5 message digest.

A MAC is calculated by passing data to the update( ) method, which can be called any number of times. The last set of data over which the MAC will be calculated is passed to the encrypt( ) data, which obtains the MAC.

Similarly, if you receive a MAC and want to know if it corresponds to a set of data, you pass the data to the update( ) method. In this case, the final set of data is passed to the verify( ) method (along with the MAC), which indicates whether the MAC is valid.

public interface MAC extends jxta.security.util.Description {
// Public Constants
   public static final byte ALG_NULL;                           
// =0
   public static final byte ALG_RC4_MD5;                        
// =2
   public static final byte ALG_RC4_SHA1;                       
// =1
   public static final byte MODE_ENCRYPT;                       
// =1
   public static final byte MODE_VERIFY;                        
// =2
   public static final String name;                             
// ="MAC”
                  // Public Instance Methods
   public abstract int encrypt(byte[ ] inbuff, int offset, int inLength, byte[ ] macBuff, int macOffset) 
       throws jxta.security.exceptions.CryptoException;
   public abstract byte getAlgorithm();  
   public abstract String getAlgorithmName();  
   public abstract int getLength();  
   public abstract void init(byte theMode, jxta.security.cipher.Key theKey, byte[ ] privateKey ...

Get JXTA in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.