[Hipsec] How much for that hash?

Tero Kivinen <kivinen@iki.fi> Wed, 09 June 2010 11:50 UTC

Return-Path: <kivinen@iki.fi>
X-Original-To: hipsec@core3.amsl.com
Delivered-To: hipsec@core3.amsl.com
Received: from localhost (localhost [127.0.0.1]) by core3.amsl.com (Postfix) with ESMTP id 63B053A6972 for <hipsec@core3.amsl.com>; Wed, 9 Jun 2010 04:50:15 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: 0.001
X-Spam-Level:
X-Spam-Status: No, score=0.001 tagged_above=-999 required=5 tests=[BAYES_50=0.001]
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 DTDHlqYYGLIF for <hipsec@core3.amsl.com>; Wed, 9 Jun 2010 04:50:10 -0700 (PDT)
Received: from mail.kivinen.iki.fi (fireball.acr.fi [83.145.195.1]) by core3.amsl.com (Postfix) with ESMTP id 8D4713A68E7 for <hipsec@ietf.org>; Wed, 9 Jun 2010 04:50:09 -0700 (PDT)
Received: from fireball.kivinen.iki.fi (localhost [127.0.0.1]) by mail.kivinen.iki.fi (8.14.3/8.14.3) with ESMTP id o59Bo2Zj018128 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 9 Jun 2010 14:50:02 +0300 (EEST)
Received: (from kivinen@localhost) by fireball.kivinen.iki.fi (8.14.3/8.12.11) id o59Bo1V0002806; Wed, 9 Jun 2010 14:50:01 +0300 (EEST)
X-Authentication-Warning: fireball.kivinen.iki.fi: kivinen set sender to kivinen@iki.fi using -f
MIME-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Message-ID: <19471.32745.911822.490184@fireball.kivinen.iki.fi>
Date: Wed, 09 Jun 2010 14:50:01 +0300
From: Tero Kivinen <kivinen@iki.fi>
To: Robert Moskowitz <rgm@htt-consult.com>
In-Reply-To: <4C0E9CBD.20600@htt-consult.com>
References: <4C0E9CBD.20600@htt-consult.com>
X-Mailer: VM 7.19 under Emacs 21.4.1
X-Edit-Time: 14 min
X-Total-Time: 79 min
X-Mailman-Approved-At: Wed, 16 Jun 2010 23:41:20 -0700
Cc: HIP WG <hipsec@ietf.org>
Subject: [Hipsec] How much for that hash?
X-BeenThere: hipsec@ietf.org
X-Mailman-Version: 2.1.9
Precedence: list
List-Id: "This is the official IETF Mailing List for the HIP Working Group." <hipsec.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/listinfo/hipsec>, <mailto:hipsec-request@ietf.org?subject=unsubscribe>
List-Archive: <http://www.ietf.org/mail-archive/web/hipsec>
List-Post: <mailto:hipsec@ietf.org>
List-Help: <mailto:hipsec-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/hipsec>, <mailto:hipsec-request@ietf.org?subject=subscribe>
X-List-Received-Date: Wed, 09 Jun 2010 11:50:15 -0000

Robert Moskowitz writes:
> It is really being driven home to me how important a cryptographic hash 
> is to a total security solution.  Trying to design around this is really 
> hard!
> 
> So since the argument for not using a hash is the code cost, can anyone 
> supply me with a good value for the amount of code (in Kb) for SHA-1?  
> For SHA-256?

Checking our crypto library the sha1 is from 1331 bytes to 8471 bytes
depending how much the round functions are unrolled.

Sha256 function is 2869 bytes of object code. These are c-source
compiled with gcc -Os on i386 architecture and only using memcpy and
memset from external libraries. The interface is normal higher level
interface meaning reset_context, update, final taking variable length
of data in.

If using assembler optimizations would most likely make those even
smaller, especially if the cpu has round function instructions or
similar crypto-optimized instructions, so I would assume it would be
possible to make those even smaller. If you do not need to worry about
getting partial blocks to update or padding for the final data etc
then that would also remove some code (few hundred bytes).
-- 
kivinen@iki.fi