/* @(#)WhirlpoolMD_64Test.java	3.0	2005-03-01
 * This file was freely contributed to the LimeWire project and is covered
 * by its existing GPL licence, but it may be used individually as a public
 * domain implementation of a published engine (see below for references).
 * It was also freely contributed to the Bitzi public domain sources.
 * @author Philippe Verdy
 */
package org.rodage.pub.tests.security;

import java.security.DigestException;

import junit.framework.Test;

import org.rodage.pub.java.security.WhirlpoolMD_64;

public class WhirlpoolMD_64Test extends WhirlpoolMD_AbstractTest {
    
    public static void main(String[] args) {
        junit.textui.TestRunner.run(suite());
    }              

    public static Test suite() {
        return WhirlpoolMD_AbstractTest.buildTestSuite(WhirlpoolMD_64Test.class);
    }
    
    /**
     * Constructor for WhirlpoolMD_32Test.
     * @param name
     */
    public WhirlpoolMD_64Test(String name) {
        super(name);
        engine = new Engine();
    }
    
    public void testVectorsForISO() throws Exception {
        WhirlpoolMD_AbstractTest.testVectorsForISO(engine);
    }

    public void testVectorsForNESSIE() throws Exception {
        WhirlpoolMD_AbstractTest.testVectorsForNESSIE(engine);
    }
    
    public void testPerformance() throws Exception {
        WhirlpoolMD_AbstractTest.testPerformance(engine);
        // Java 1.5.0_01-b08, on Pentium M 1600MHz:
        // java -client: 7.8431373 MegaBytes/s (194.550 CPU cycles per byte).
        // java -server: 11.389522 MegaBytes/s (133.972 CPU cycles per byte).
    }

    /**
     * This class just redeclares the protected methods of the abstract
     * MessageDigestSpi class into public abstract methods that can be
     * referenced in lightweight tests.<p>
     */
    private static class Engine extends WhirlpoolMD_64
    implements MessageDigestSpiTestable {
        
        // only changes the visibility to implement MessageDigestSpiTestable
        public void engineReset() {
            super.engineReset();
        }

        // only changes the visibility to implement MessageDigestSpiTestable
        public int engineGetDigestLength() {
            return super.engineGetDigestLength();
        }

        // only changes the visibility to implement MessageDigestSpiTestable
        public void engineUpdate(byte input) {
            super.engineUpdate(input);
        }

        // only changes the visibility to implement MessageDigestSpiTestable
        public void engineUpdate(byte[] input, int offset, int len) {
            super.engineUpdate(input, offset, len);
        }

        // only changes the visibility to implement MessageDigestSpiTestable
        public int engineDigest(byte[] hashvalue, int offset, int len)
                throws DigestException {
            return super.engineDigest(hashvalue, offset, len);
        }

        // only changes the visibility to implement MessageDigestSpiTestable
        public byte[] engineDigest() {
            return super.engineDigest();
        }
    }

    private Engine engine;
}

