Subject: [saag] Link to the TLS draft including description and code for FNV-1a

From: Stefan Santesson <[email-masked]>
Date: Thu, 31 Mar 2011 14:38:43 +0100

As discussed at the Saag meeting

http://tools.ietf.org/html/draft-ietf-tls-cached-info-08

/Stefan

---

From: Stefan Santesson <[email-masked]>
Date: Thu, 31 Mar 2011 14:53:53 +0100

OK, I see now that this draft contains the somewhat flawed java code.

The XOR operation is only an 8 bit operation and thus it is not suitable
to feed the algorithm with a string of characters potentially holding more
than 8 bits.
The example in the draft works for a pure ASCII string only.

The following code is however correct for the general case

/**
 * Java code sample, implementing 64 bit FNV-1a
 * By Stefan Santesson
 */

import java.math.BigInteger;

public class FNV {

    static public BigInteger getFNV1aToByte(byte[] inp) {

        BigInteger m = new BigInteger("2").pow(64);
        BigInteger fnvPrime = new BigInteger("1099511628211");
        BigInteger fnvOffsetBasis =
                new BigInteger("14695981039346656037");

        BigInteger digest = fnvOffsetBasis;

        for (byte b : inp) {
            digest = digest.xor(BigInteger.valueOf((int) b & 255));
            digest = digest.multiply(fnvPrime).mod(m);
        }
        return digest;

    }
}

This is a copy of implemented and tested code which produce the test
vector results in the draft.

/Stefan

From:  Stefan Santesson <[email-masked]>
Date:  Thu, 31 Mar 2011 14:38:43 +0100
To:  "[email-masked]" <[email-masked]>
Subject:  [saag] Link to the TLS draft including description and code for
FNV-1a

>_______________________________________________
>saag mailing list
>[email-masked]://www.ietf.org/mailman/listinfo/saag

---

From: Donald Eastlake <[email-masked]>
Date: Thu, 31 Mar 2011 15:01:17 +0200

Thanks for the pointer.

Little of the information in
http://tools.ietf.org/html/draft-eastlake-fnv-00
is in the TLS draft and it is planned to have a fairly complete suite
of FNV code in the next version of the fnv draft covering all
currently specified hash sizes of FNV, etc. I see no reason to remove
or change the code in the TLS draft.

I plan to add an informational reference to the fnv draft pointing at
the tls draft. You may wish to add an informational reference the
other way. I am hopeful that the fnv draft will go through fairly
quickly.

Thanks,
Donald
=============================
 Donald E. Eastlake 3rd   +1-508-333-2270 (cell)
 155 Beaver Street
 Milford, MA 01757 USA
 [email-masked]

On Thu, Mar 31, 2011 at 3:38 PM, Stefan Santesson <[email-masked]> wrote:
> [email-masked]
> https://www.ietf.org/mailman/listinfo/saag
>
>