Re: [TLS] New Cached info draft

Stefan Santesson <stefan@aaa-sec.com> Tue, 30 March 2010 01:20 UTC

Return-Path: <stefan@aaa-sec.com>
X-Original-To: tls@core3.amsl.com
Delivered-To: tls@core3.amsl.com
Received: from localhost (localhost [127.0.0.1]) by core3.amsl.com (Postfix) with ESMTP id 4E9373A682E for <tls@core3.amsl.com>; Mon, 29 Mar 2010 18:20:48 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -0.819
X-Spam-Level:
X-Spam-Status: No, score=-0.819 tagged_above=-999 required=5 tests=[AWL=1.300, BAYES_00=-2.599, DNS_FROM_OPENWHOIS=1.13, HELO_EQ_SE=0.35, RCVD_IN_DNSWL_LOW=-1]
Received: from mail.ietf.org ([64.170.98.32]) by localhost (core3.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id kD+8DlYlsmOf for <tls@core3.amsl.com>; Mon, 29 Mar 2010 18:20:45 -0700 (PDT)
Received: from s87.loopia.se (s87.loopia.se [194.9.95.115]) by core3.amsl.com (Postfix) with ESMTP id A81C83A63EC for <tls@ietf.org>; Mon, 29 Mar 2010 18:20:44 -0700 (PDT)
Received: from s24.loopia.se (s34.loopia.se [194.9.94.70]) by s87.loopia.se (Postfix) with ESMTP id 8A47E378DB7 for <tls@ietf.org>; Tue, 30 Mar 2010 03:21:21 +0200 (CEST)
Received: (qmail 7372 invoked from network); 30 Mar 2010 01:21:10 -0000
Received: from 213-64-142-247-no153.business.telia.com (HELO [192.168.1.16]) (stefan@fiddler.nu@[213.64.142.247]) (envelope-sender <stefan@aaa-sec.com>) by s24.loopia.se (qmail-ldap-1.03) with DES-CBC3-SHA encrypted SMTP for <marsh@extendedsubset.com>; 30 Mar 2010 01:21:10 -0000
User-Agent: Microsoft-Entourage/12.24.0.100205
Date: Tue, 30 Mar 2010 03:21:09 +0100
From: Stefan Santesson <stefan@aaa-sec.com>
To: Marsh Ray <marsh@extendedsubset.com>
Message-ID: <C7D71EA5.9B22%stefan@aaa-sec.com>
Thread-Topic: [TLS] New Cached info draft
Thread-Index: AcrPp0bu9xASmRQcT02d9K7CRsnVWQ==
In-Reply-To: <4BB0CB91.9060306@extendedsubset.com>
Mime-version: 1.0
Content-type: text/plain; charset="US-ASCII"
Content-transfer-encoding: 7bit
Cc: Adam Langley <agl@imperialviolet.org>, "tls@ietf.org" <tls@ietf.org>
Subject: Re: [TLS] New Cached info draft
X-BeenThere: tls@ietf.org
X-Mailman-Version: 2.1.9
Precedence: list
List-Id: "This is the mailing list for the Transport Layer Security working group of the IETF." <tls.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/listinfo/tls>, <mailto:tls-request@ietf.org?subject=unsubscribe>
List-Archive: <http://www.ietf.org/mail-archive/web/tls>
List-Post: <mailto:tls@ietf.org>
List-Help: <mailto:tls-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/tls>, <mailto:tls-request@ietf.org?subject=subscribe>
X-List-Received-Date: Tue, 30 Mar 2010 01:20:48 -0000

Thanks Marsh,

I implemented the pseudocode in Java and and obtained matching output.

Here is the simple code I wrote for both FNV-1 and FNV-1a;

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

 
    public BigInteger fNV1(String inpString) {

        BigInteger digest = fnvOffsetBasis;

        for (int i = 0; i < inpString.length(); i++) {
            digest = digest.multiply(fnvPrime).mod(m);
            digest = digest.xor(BigInteger.valueOf((int)
                     inpString.charAt(i)));
        }
        return (digest);
    }

    public BigInteger fNV1a(String inpString) {

        BigInteger digest = fnvOffsetBasis;

        for (int i = 0; i < inpString.length(); i++) {
            digest = digest.xor(BigInteger.valueOf((int)
                     inpString.charAt(i)));
            digest = digest.multiply(fnvPrime).mod(m);
        }
        return (digest);
    }

I'm considering including this code sample in the draft.
I would gratefully receive a matching C sample.

/Stefan



On 10-03-29 4:47 PM, "Marsh Ray" <marsh@extendedsubset.com>; wrote:

> On 3/29/2010 5:36 AM, Stefan Santesson wrote:
>> Marsh and all,
>> 
>> I would like to switch to FNV-1a.
>> The reason being that FNV-1 has the downside that the last octet only flips
>> bits in the lowest 8 bits of the digest value, while FNV-1a influence all 64
>> bits (by changing the order of multiplication and XOR).
>> 
>> See also:
>> http://sites.google.com/site/murmurhash/avalanche
>> 
>> The pseudocode for FNV-1a is:
>> 
>>       digest = FNV_offset_basis
>>       for each octet_of_data to be digested {
>>              digest = digest XOR octet_of_data
>>              digest = digest * FNV_prime }
>>       return digest
>> 
>> Could you run some test vectors also for FNV-1a?
> 
> Sure, here's what I get from the new pseudocode.
> 
> For input data:
> 0 bytes
> Digest is: CB F2 9C E4 84 22 23 25
> 8 bytes
> 
> For input data:
> 0000  61                                                a
> 1 bytes
> Digest is: AF 63 DC 4C 86 01 EC 8C
> 8 bytes
> 
> For input data:
> 0000  FF 00 00 01                                       ....
> 4 bytes
> Digest is: 69 61 19 64 91 CC 68 2D
> 8 bytes
> 
> For input data:
> 0000  68 74 74 70 3A 2F 2F 65 6E 2E 77 69 6B 69 70 65   http://en.wikipe
> 0010  64 69 61 2E 6F 72 67 2F 77 69 6B 69 2F 46 6F 77   dia.org/wiki/Fow
> 0020  6C 65 72 5F 4E 6F 6C 6C 5F 56 6F 5F 68 61 73 68   ler_Noll_Vo_hash
> 48 bytes
> Digest is: D9 B9 57 FB 7F E7 94 C5
> 8 bytes
> 
> - Marsh