head	1.17;
access;
symbols
	TIGRIS_1_1_0RC2:1.16
	TIGRIS_1_1_0RC1:1.16
	TIGRIS_1_1:1.16.0.4
	TIGRIS_1_0_8:1.16
	TIGRIS_1_0_8RC3:1.16
	TIGRIS_1_0_8RC2:1.16
	TIGRIS_1_0_8RC1:1.16
	TIGRIS_1_0_7:1.16
	TIGRIS_1_0_7RC3:1.16
	TIGRIS_1_0_7RC2:1.16
	TIGRIS_1_0_7RC1:1.16
	TIGRIS_1_0_6:1.16
	TIGRIS_1_0_6RC5:1.16
	TIGRIS_1_0_6RC4:1.16
	TIGRIS_1_0_6RC3:1.16
	TIGRIS_1_0_6RC2:1.16
	TIGRIS_1_0_6RC1:1.16
	TIGRIS_1_0_5:1.16
	TIGRIS_1_0_5RC6:1.16
	TIGRIS_1_0_5RC5:1.16
	TIGRIS_1_0_5RC4:1.16
	TIGRIS_1_0_5RC3:1.16
	TIGRIS_1_0_5RC2:1.16
	TIGRIS_1_0_5RC1:1.16
	TIGRIS_1_0_4:1.16
	TIGRIS_1_0_3:1.16
	TIGRIS_1_0_2:1.16
	TIGRIS_1_0_1:1.16
	TIGRIS_1_0:1.16.0.6
	TIGRIS_1_0_0:1.16
	TIGRIS_1_0_0_RC1:1.16.0.2
	dlr:1.1.1
	TIGRIS_0_9_2_4:1.13.4.1
	TIGRIS_0_9_2_3:1.13
	HELM_PEER_PORT_BRANCH:1.1.1.1
	TURBINE_PEER:1.15
	TIGRIS_0_9_2_1:1.15
	TIGRIS_0_9_2:1.13.0.4
	TIGRIS_0_9_0:1.13.0.2
	TIGRIS_0_8_4:1.10.0.2;
locks; strict;
comment	@# @;


1.17
date	2001.08.07.20.53.11;	author leonardr;	state Exp;
branches;
next	1.16;

1.16
date	2001.02.21.01.08.25;	author dlr;	state Exp;
branches;
next	1.15;

1.15
date	2001.01.26.18.29.09;	author edk;	state Exp;
branches
	1.15.2.1;
next	1.14;

1.14
date	2001.01.26.05.24.08;	author edk;	state dead;
branches;
next	1.13;

1.13
date	2000.12.12.02.34.04;	author dlr;	state Exp;
branches
	1.13.4.1;
next	1.12;

1.12
date	2000.12.06.17.24.07;	author dlr;	state Exp;
branches;
next	1.11;

1.11
date	2000.12.05.00.27.33;	author dlr;	state Exp;
branches;
next	1.10;

1.10
date	2000.11.29.21.35.11;	author dlr;	state Exp;
branches;
next	1.9;

1.9
date	2000.11.21.04.14.47;	author dlr;	state Exp;
branches;
next	1.8;

1.8
date	2000.11.20.21.15.11;	author dlr;	state Exp;
branches;
next	1.7;

1.7
date	2000.11.20.20.14.55;	author dlr;	state Exp;
branches;
next	1.6;

1.6
date	2000.11.20.20.13.38;	author dlr;	state Exp;
branches;
next	1.5;

1.5
date	2000.11.20.20.11.14;	author dlr;	state Exp;
branches;
next	1.4;

1.4
date	2000.11.20.19.55.54;	author dlr;	state Exp;
branches;
next	1.3;

1.3
date	2000.11.19.22.01.28;	author dlr;	state Exp;
branches;
next	1.2;

1.2
date	2000.11.19.21.57.20;	author dlr;	state Exp;
branches;
next	1.1;

1.1
date	2000.11.18.09.38.08;	author dlr;	state Exp;
branches
	1.1.1.1;
next	;

1.1.1.1
date	2001.02.21.00.35.22;	author dlr;	state Exp;
branches;
next	;

1.13.4.1
date	2001.02.01.18.49.25;	author jrobbins;	state Exp;
branches;
next	;

1.15.2.1
date	2001.01.28.01.02.19;	author dlr;	state dead;
branches;
next	1.15.2.2;

1.15.2.2
date	2001.02.14.00.41.07;	author elicia;	state Exp;
branches;
next	1.15.2.3;

1.15.2.3
date	2001.02.15.20.50.44;	author leonardr;	state Exp;
branches;
next	;


desc
@@


1.17
log
@Got rid of lingering Webmacro dependencies.
@
text
@/* ================================================================
 * Copyright (c) 2000-2001 CollabNet.  All rights reserved.
 * 
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are
 * met:
 * 
 * 1. Redistributions of source code must retain the above copyright
 * notice, this list of conditions and the following disclaimer.
 * 
 * 2. Redistributions in binary form must reproduce the above copyright
 * notice, this list of conditions and the following disclaimer in the
 * documentation and/or other materials provided with the distribution.
 * 
 * 3. The end-user documentation included with the redistribution, if
 * any, must include the following acknowlegement: "This product includes
 * software developed by CollabNet (http://www.collab.net/)."
 * Alternately, this acknowlegement may appear in the software itself, if
 * and wherever such third-party acknowlegements normally appear.
 * 
 * 4. The hosted project names must not be used to endorse or promote
 * products derived from this software without prior written
 * permission. For written permission, please contact info@@collab.net.
 * 
 * 5. Products derived from this software may not use the "Tigris" name
 * nor may "Tigris" appear in their names without prior written
 * permission of CollabNet.
 * 
 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
 * IN NO EVENT SHALL COLLABNET OR ITS CONTRIBUTORS BE LIABLE FOR ANY
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 * ====================================================================
 * 
 * This software consists of voluntary contributions made by many
 * individuals on behalf of CollabNet.
 */


package org.tigris.helm.tool;

import java.util.StringTokenizer;
import java.net.InetAddress;
import java.security.MessageDigest;

import org.apache.turbine.util.Log;

/**
 * Computes MDA using the Cryptix libs.  Direct port of
 * <a href="http://frogdot.de/mod_auth_mda/">Frogdot's mod_auth_mda</a> code.
 *
 * @@author <a href="heinz.richter@@frogdot.de">Heinz Richter</a>
 * @@author <a href="mailto:dlr@@collab.net">Daniel Rall</a>
 * @@version $Id: MDA.java,v 1.16 2001/02/21 01:08:25 dlr Exp $
 */
public class MDA
{
    /**
     * length IP
     */
    public static final int IP_TI = 8;

    /**
     * length digest
     */
    public static final int DIGEST = 32;

    /**
     * Whether to write to the log file.
     */
    private static final boolean debug = true;

    /**
     * The error message used if the JCE provider addition fails.
     */
    private static final String CRYPTO_RETRIEVAL_ERR = "Cannot retrieve " + 
        CryptoProviderService.CRYPTIX_PROVIDER + " instance";

    /**
     * The JCE message digest implementation.
     */
    private MessageDigest md;

    /**
     * Available after calling <code>compute()</code>.
     */
    private String timestamp;

    /**
     * Creates a new instance of the message digest.
     */
    public MDA () throws Exception
    {
        try
        {
            md = MessageDigest.getInstance
                (CryptoProviderService.MD5, 
                 CryptoProviderService.CRYPTIX_PROVIDER);
            timestamp = null;
        }
        catch (Throwable t)
        {
            Log.error(CRYPTO_RETRIEVAL_ERR);
            throw new Exception(CRYPTO_RETRIEVAL_ERR + ": " + t.getMessage());
        }
    }

    /**
     * Computes a digital signature.
     *
     * @@param ip    The IP address of the client to compute the signature for.
     * @@param key   The shared secret.
     * @@param email The email address of the person computing.
     * @@param realm The MDA realm mask.
     * @@param cargo What to get the checksum of.
     * @@param ti    The [?] time in [?]
     */
    public String compute (String ip, String key, String email, String realm,
                           String cargo, long ti)
    {
        // Dump the parameters.
        if (debug)
        {
            Log.info("ip=" + ip);
            Log.info("key=" + key);
            Log.info("email=" + email);
            Log.info("realm=" + realm);
            Log.info("cargo=" + cargo);
            Log.info("ti=" + ti);
        }

        int len = IP_TI + key.length()
            + email.length()
            + realm.length()
            + cargo.length() ;
        byte bbuf[] = new byte[len];
        byte tbuf[] = new byte[4];

        // IP addess
        StringTokenizer tokenizer = new StringTokenizer(ip, ".");
        bbuf[0] = readByte(tokenizer);
        bbuf[1] = readByte(tokenizer);
        bbuf[2] = readByte(tokenizer);
        bbuf[3] = readByte(tokenizer);
        // time stamp
        tbuf[0] =
            bbuf[4] = (byte) ((ti & 0xff000000) >> 24);
        tbuf[1] =
            bbuf[5] = (byte) ((ti & 0xff0000) >> 16);
        tbuf[2] =
            bbuf[6] = (byte) ((ti & 0xff00) >> 8);
        tbuf[3] =
            bbuf[7] = (byte) ((ti & 0xff));

        timestamp = ByteToHex.transform(tbuf);

        String sbuf    = key + email + realm + cargo;
        byte   sbbuf[] = sbuf.getBytes();

        int i;
        for (i = IP_TI; i < len; i++) bbuf[i] = sbbuf[i - IP_TI];

        //System.out.println("IP + timestamp");
        //for (i=0; i< 8; i++) System.out.print("["+bbuf[i]+"]");
        //System.out.println("\nkey email realm cargo");
        //for (i=8; i<len; i++) System.out.print("["+(char)(bbuf[i])+"]");
        //System.out.println();

        // compute first hash
        byte[] out = md.digest(bbuf);

        String sout = ByteToHex.transform(out) + key;
        bbuf = sout.getBytes();
        // second hash
        out = md.digest(bbuf);

        //System.out.println("");
        //for (i=0; i<out.length; i++) System.out.print("["+out[i]+"]");
        //System.out.println();
        //for (i=0; i<out.length; i++) System.out.print("["+(char)(out[i])+"]");
        //System.out.println("\n "+ByteToHex.transform(out)+" "+out.length);

        return ByteToHex.transform(out);
    }

    /**
     * Returns the timestamp of a <code>compute()</code>'d digest.
     */
    public String getTimestamp ()
    {
        return timestamp;
    }

    /**
     * Try to read a number of radix 10.
     *
     * @@param tokenizer From String input command.
     * @@return          The parsed number, or <code>0</code> if no number.
     */
    private final byte readByte (StringTokenizer tokenizer)
    {
        byte b = 0;
        if (tokenizer.hasMoreElements())
        {
            String token = "";
            try
            {
                token = tokenizer.nextToken();
                // Read in as integer, then force to byte.
                int i = Integer.valueOf(token).intValue();
                b = (byte) i;
            }
            catch (NumberFormatException e)
            {
                Log.warn("Couldn't parse number from: " + token);
            }
        }
        else
        {
            Log.warn("Unparsable input");
        }
        return b;
    }
}
@


1.16
log
@This is the highest revision from the HELM_PEER_PORT_BRANCH.  The previous import caused too many conflicts to resolve manually
@
text
@d17 1
a17 1
 * software developed by Collab.Net (http://www.collab.net/)."
d27 1
a27 1
 * permission of Collab.Net.
d32 1
a32 1
 * IN NO EVENT SHALL COLLAB.NET OR ITS CONTRIBUTORS BE LIABLE FOR ANY
d54 1
a54 1
import org.webmacro.util.Log;
d62 1
a62 1
 * @@version $Id: MDA.java,v 1.15.2.3 2001/02/15 20:50:44 leonardr Exp $
a76 5
     * The log file.
     */
    private static final Log log = new Log("mda", "MDA");

    /**
d111 1
a111 1
            log.error(CRYPTO_RETRIEVAL_ERR);
d132 6
a137 6
            log.info("ip=" + ip);
            log.info("key=" + key);
            log.info("email=" + email);
            log.info("realm=" + realm);
            log.info("cargo=" + cargo);
            log.info("ti=" + ti);
d223 1
a223 1
                log.warning("Coudn't parse number from: " + token);
d228 1
a228 1
            log.warning("Unparsable input");
@


1.15
log
@readding all the files as part of the process of returning to the way
things were as of tuesday
@
text
@d2 1
a2 1
 * Copyright (c) 2000 CollabNet.  All rights reserved.
d62 1
a62 1
 * @@version $Id: MDA.java,v 1.13 2000/12/12 02:34:04 dlr Exp $
@


1.15.2.1
log
@Porting to the Turbine Peer system.  -dlr and leonardr
@
text
@d62 1
a62 1
 * @@version $Id: MDA.java,v 1.15 2001/01/26 18:29:09 edk Exp $
@


1.15.2.2
log
@ported to turbine
@
text
@@


1.15.2.3
log
@Normalized copyright dates.
@
text
@d2 1
a2 1
 * Copyright (c) 2000-2001 CollabNet.  All rights reserved.
d62 1
a62 1
 * @@version $Id: MDA.java,v 1.15.2.2 2001/02/14 00:41:07 elicia Exp $
@


1.14
log
@revert this stuff to its state as of 2001/01/24 12:42:00 GMT -- with
the following exceptions, which have some different modifications so
they'll work with changes which have happened in joist:

ProjectNewsEdit.java
SkinManager.java
SkinStyleElementValueManager.java
StyleElementManager.java
StyleManager.java

it compiles.  i dunno if it works, though.
@
text
@@


1.13
log
@Moved byte[] to hex string transform into ByteToHex utility class.
@
text
@d62 1
a62 1
 * @@version $Id: MDA.java,v 1.12 2000/12/06 17:24:07 dlr Exp $
@


1.13.4.1
log
@moved changed from HEAD for ProjectDocuments and ProjectDownloads
@
text
@d62 1
a62 1
 * @@version $Id: MDA.java,v 1.15 2001/01/26 18:29:09 edk Exp $
@


1.12
log
@Provide the correct error message.
@
text
@d62 1
a62 1
 * @@version $Id: MDA.java,v 1.11 2000/12/05 00:27:33 dlr Exp $
a76 5
     * List of hex characters.
     */
    private static final String HEX_DIGIT ="0123456789abcdef";

    /**
d168 1
a168 1
        timestamp = byte2hex(tbuf);
d185 1
a185 1
        String sout = byte2hex(out) + key;
d194 1
a194 1
        //System.out.println("\n "+byte2hex(out)+" "+out.length);
d196 1
a196 1
        return byte2hex(out);
a235 16
    }

    /**
     * Fast routine to go from byte to hex.
     */
    private final String byte2hex(byte[] c)
    {
        String out = "";
        int len = c.length, i, k;
        for (i = 0; i < len; i++)
        {
            k = c[i];
            out = out + HEX_DIGIT.charAt((k >> 4) & 0x0f) +
                HEX_DIGIT.charAt(k & 0x0f);
        }
        return out;
@


1.11
log
@Migrated to new CryptoProvderService.
@
text
@d62 1
a62 1
 * @@version $Id: MDA.java,v 1.10 2000/11/29 21:35:11 dlr Exp $
d87 1
a87 1
     * The log file.
d94 3
a96 2
    private static final String PROVIDER_ADD_ERR =
        "Cryptix cryptography provider addition failed";
d121 2
a122 2
            log.warning(PROVIDER_ADD_ERR);
            throw new Exception(PROVIDER_ADD_ERR + ": " + t.getMessage());
@


1.10
log
@Streamlined like a dolphin.
@
text
@d17 1
a17 1
 * software developed by Collab.Net (http://www.Collab.Net/)."
a51 1
import java.security.Security;
a53 2
import cryptix.provider.Cryptix;

d62 1
a62 1
 * @@version $Id: MDA.java,v 1.9 2000/11/21 04:14:47 dlr Exp $
a91 10
     * The JCE provider name.
     */
    private static final String PROVIDER_NAME = "Cryptix";

    /**
     * The message digest algorithm.
     */
    private static final String MD_ALGORITHM = "MD5";

    /**
a105 6
    static
    {
        Security.addProvider(new Cryptix());
        if (debug) log.info("Cryptix cryptography provider loaded");
    }

d113 3
a115 1
            md = MessageDigest.getInstance(MD_ALGORITHM, PROVIDER_NAME);
d128 1
a128 1
     * @@param ip    The IP address of [?].
@


1.9
log
@Brought comment up to date.
@
text
@d65 1
a65 1
 * @@version $Id: MDA.java,v 1.8 2000/11/20 21:15:11 dlr Exp $
d82 1
a82 1
    private static final String HEXDIGIT ="0123456789abcdef";
d95 15
d119 6
d132 1
a132 3
            Security.addProvider(new Cryptix());
            //log.info("Cryptix cryptography provider loaded");
            md = MessageDigest.getInstance("MD5", "Cryptix");
d137 2
a138 3
            String errMsg = "Cryptix cryptography provider addition failed";
            log.warning(errMsg);
            throw new Exception(errMsg + ": " + t.getMessage());
d269 2
a270 2
            out = out + HEXDIGIT.charAt((k >> 4) & 0x0f) +
                HEXDIGIT.charAt(k & 0x0f);
@


1.8
log
@Renamed from MD5 to MDA since it does more than just compute a MD5
checksum.  Moved in repository to preserve history.
@
text
@d65 1
a65 1
 * @@version $Id: MDA.java,v 1.7 2000/11/20 20:14:55 dlr Exp $
d80 1
a80 1
     * Not yet used.
@


1.7
log
@Correct URL.
@
text
@d60 1
a60 1
 * Computes MD5 using the Cryptix libs.  Direct port of
d65 1
a65 1
 * @@version $Id: MD5.java,v 1.6 2000/11/20 20:13:38 dlr Exp $
d67 1
a67 1
public class MD5
d87 1
a87 1
    private static final Log log = new Log("md5", "MD5");
d107 1
a107 1
    public MD5 () throws Exception
@


1.6
log
@Creditted orginal author.
@
text
@d61 1
a61 1
 * <a href="http://http://frogdot.de/mod_auth_mda/">Frogdot</a> code.
d65 1
a65 1
 * @@version $Id: MD5.java,v 1.5 2000/11/20 20:11:14 dlr Exp $
@


1.5
log
@Dump the params for testing.
@
text
@d60 2
a61 1
 * Computes MD5 using the Cryptix libs.
d63 1
d65 1
a65 1
 * @@version $Id: MD5.java,v 1.4 2000/11/20 19:55:54 dlr Exp $
@


1.4
log
@Added documentation.
@
text
@d63 1
a63 1
 * @@version $Id: MD5.java,v 1.3 2000/11/19 22:01:28 dlr Exp $
d88 5
d135 11
@


1.3
log
@Initialize timestamp to null explicitly.
@
text
@d63 1
a63 1
 * @@version $Id: MD5.java,v 1.2 2000/11/19 21:57:20 dlr Exp $
d124 1
a124 1
     * @@param cargo [?]
@


1.2
log
@First stab at integration of Frogdot's digest class MD5-based digital signature algorithm.
@
text
@d63 1
a63 1
 * @@version $Id: MD5.java,v 1.1 2000/11/18 09:38:08 dlr Exp $
d107 1
a107 1

@


1.1
log
@A stub for a MD5 message digest computation routine.
@
text
@d50 1
d52 1
d55 4
d62 2
a63 2
 * @@author <a href="mailto:dlr@@collab.net>Daniel Rall</a>
 * @@version $Id: $
d68 50
d119 106
d226 1
a226 3
    public static String compute (String ip, String sharedSecret,
                                  String email, String realm, String cargo,
                                  long time)
d228 9
a236 2
        // TODO
        return null;
@


1.1.1.1
log
@Replacing the HEAD with the HELM_PEER_PORT_BRANCH.
@
text
@d2 1
a2 1
 * Copyright (c) 2000-2001 CollabNet.  All rights reserved.
d17 1
a17 1
 * software developed by Collab.Net (http://www.collab.net/)."
a49 1
import java.util.StringTokenizer;
a52 2
import org.webmacro.util.Log;

d54 1
a54 2
 * Computes MDA using the Cryptix libs.  Direct port of
 * <a href="http://frogdot.de/mod_auth_mda/">Frogdot's mod_auth_mda</a> code.
d56 2
a57 3
 * @@author <a href="heinz.richter@@frogdot.de">Heinz Richter</a>
 * @@author <a href="mailto:dlr@@collab.net">Daniel Rall</a>
 * @@version $Id: MDA.java,v 1.15.2.3 2001/02/15 20:50:44 leonardr Exp $
d59 1
a59 1
public class MDA
a61 55
     * length IP
     */
    public static final int IP_TI = 8;

    /**
     * length digest
     */
    public static final int DIGEST = 32;

    /**
     * The log file.
     */
    private static final Log log = new Log("mda", "MDA");

    /**
     * Whether to write to the log file.
     */
    private static final boolean debug = true;

    /**
     * The error message used if the JCE provider addition fails.
     */
    private static final String CRYPTO_RETRIEVAL_ERR = "Cannot retrieve " + 
        CryptoProviderService.CRYPTIX_PROVIDER + " instance";

    /**
     * The JCE message digest implementation.
     */
    private MessageDigest md;

    /**
     * Available after calling <code>compute()</code>.
     */
    private String timestamp;

    /**
     * Creates a new instance of the message digest.
     */
    public MDA () throws Exception
    {
        try
        {
            md = MessageDigest.getInstance
                (CryptoProviderService.MD5, 
                 CryptoProviderService.CRYPTIX_PROVIDER);
            timestamp = null;
        }
        catch (Throwable t)
        {
            log.error(CRYPTO_RETRIEVAL_ERR);
            throw new Exception(CRYPTO_RETRIEVAL_ERR + ": " + t.getMessage());
        }
    }

    /**
a62 89
     *
     * @@param ip    The IP address of the client to compute the signature for.
     * @@param key   The shared secret.
     * @@param email The email address of the person computing.
     * @@param realm The MDA realm mask.
     * @@param cargo What to get the checksum of.
     * @@param ti    The [?] time in [?]
     */
    public String compute (String ip, String key, String email, String realm,
                           String cargo, long ti)
    {
        // Dump the parameters.
        if (debug)
        {
            log.info("ip=" + ip);
            log.info("key=" + key);
            log.info("email=" + email);
            log.info("realm=" + realm);
            log.info("cargo=" + cargo);
            log.info("ti=" + ti);
        }

        int len = IP_TI + key.length()
            + email.length()
            + realm.length()
            + cargo.length() ;
        byte bbuf[] = new byte[len];
        byte tbuf[] = new byte[4];

        // IP addess
        StringTokenizer tokenizer = new StringTokenizer(ip, ".");
        bbuf[0] = readByte(tokenizer);
        bbuf[1] = readByte(tokenizer);
        bbuf[2] = readByte(tokenizer);
        bbuf[3] = readByte(tokenizer);
        // time stamp
        tbuf[0] =
            bbuf[4] = (byte) ((ti & 0xff000000) >> 24);
        tbuf[1] =
            bbuf[5] = (byte) ((ti & 0xff0000) >> 16);
        tbuf[2] =
            bbuf[6] = (byte) ((ti & 0xff00) >> 8);
        tbuf[3] =
            bbuf[7] = (byte) ((ti & 0xff));

        timestamp = ByteToHex.transform(tbuf);

        String sbuf    = key + email + realm + cargo;
        byte   sbbuf[] = sbuf.getBytes();

        int i;
        for (i = IP_TI; i < len; i++) bbuf[i] = sbbuf[i - IP_TI];

        //System.out.println("IP + timestamp");
        //for (i=0; i< 8; i++) System.out.print("["+bbuf[i]+"]");
        //System.out.println("\nkey email realm cargo");
        //for (i=8; i<len; i++) System.out.print("["+(char)(bbuf[i])+"]");
        //System.out.println();

        // compute first hash
        byte[] out = md.digest(bbuf);

        String sout = ByteToHex.transform(out) + key;
        bbuf = sout.getBytes();
        // second hash
        out = md.digest(bbuf);

        //System.out.println("");
        //for (i=0; i<out.length; i++) System.out.print("["+out[i]+"]");
        //System.out.println();
        //for (i=0; i<out.length; i++) System.out.print("["+(char)(out[i])+"]");
        //System.out.println("\n "+ByteToHex.transform(out)+" "+out.length);

        return ByteToHex.transform(out);
    }

    /**
     * Returns the timestamp of a <code>compute()</code>'d digest.
     */
    public String getTimestamp ()
    {
        return timestamp;
    }

    /**
     * Try to read a number of radix 10.
     *
     * @@param tokenizer From String input command.
     * @@return          The parsed number, or <code>0</code> if no number.
d64 3
a66 1
    private final byte readByte (StringTokenizer tokenizer)
d68 2
a69 21
        byte b = 0;
        if (tokenizer.hasMoreElements())
        {
            String token = "";
            try
            {
                token = tokenizer.nextToken();
                // Read in as integer, then force to byte.
                int i = Integer.valueOf(token).intValue();
                b = (byte) i;
            }
            catch (NumberFormatException e)
            {
                log.warning("Coudn't parse number from: " + token);
            }
        }
        else
        {
            log.warning("Unparsable input");
        }
        return b;
@


