Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package org.bouncycastle.crypto.macs;
  
Implementation of the Skein parameterised MAC function in 256, 512 and 1024 bit block sizes, based on the Threefish tweakable block cipher.

This is the 1.3 version of Skein defined in the Skein hash function submission to the NIST SHA-3 competition in October 2010.

Skein was designed by Niels Ferguson - Stefan Lucks - Bruce Schneier - Doug Whiting - Mihir Bellare - Tadayoshi Kohno - Jon Callas - Jesse Walker.

 
 public class SkeinMac
     implements Mac
 {
    
256 bit block size - Skein MAC-256
 
     public static final int SKEIN_256 = .;
    
512 bit block size - Skein MAC-512
 
     public static final int SKEIN_512 = .;
    
1024 bit block size - Skein MAC-1024
 
     public static final int SKEIN_1024 = .;
 
     private SkeinEngine engine;

    
Constructs a Skein MAC with an internal state size and output size.

Parameters:
stateSizeBits the internal state size in bits - one of SKEIN_256, SKEIN_512 or SKEIN_1024.
digestSizeBits the output/MAC size to produce in bits, which must be an integral number of bytes.
 
     public SkeinMac(int stateSizeBitsint digestSizeBits)
     {
         this. = new SkeinEngine(stateSizeBitsdigestSizeBits);
     }
 
     public SkeinMac(SkeinMac mac)
     {
         this. = new SkeinEngine(mac.engine);
     }
 
     public String getAlgorithmName()
     {
         return "Skein-MAC-" + (.getBlockSize() * 8) + "-" + (.getOutputSize() * 8);
     }

    
Initialises the Skein digest with the provided parameters.
See org.bouncycastle.crypto.params.SkeinParameters for details on the parameterisation of the Skein hash function.

 
     public void init(CipherParameters params)
         throws IllegalArgumentException
     {
         SkeinParameters skeinParameters;
         if (params instanceof SkeinParameters)
         {
             skeinParameters = (SkeinParameters)params;
         }
         else if (params instanceof KeyParameter)
         {
             skeinParameters = new SkeinParameters.Builder().setKey(((KeyParameter)params).getKey()).build();
         }
         else
         {
             throw new IllegalArgumentException("Invalid parameter passed to Skein MAC init - "
                 + params.getClass().getName());
         }
         if (skeinParameters.getKey() == null)
         {
             throw new IllegalArgumentException("Skein MAC requires a key parameter.");
         }
         .init(skeinParameters);
     }
 
     public int getMacSize()
     {
         return .getOutputSize();
     }
 
     public void reset()
     {
        .reset();
    }
    public void update(byte in)
    {
        .update(in);
    }
    public void update(byte[] inint inOffint len)
    {
        .update(ininOfflen);
    }
    public int doFinal(byte[] outint outOff)
    {
        return .doFinal(outoutOff);
    }
New to GrepCode? Check out our FAQ X