Re: [IPsec] DH keys calculation performance

Yaron Sheffer <yaronf.ietf@gmail.com> Tue, 26 July 2011 11:17 UTC

Return-Path: <yaronf.ietf@gmail.com>
X-Original-To: ipsec@ietfa.amsl.com
Delivered-To: ipsec@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 44CDF21F8C54 for <ipsec@ietfa.amsl.com>; Tue, 26 Jul 2011 04:17:34 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -102.141
X-Spam-Level:
X-Spam-Status: No, score=-102.141 tagged_above=-999 required=5 tests=[BAYES_00=-2.599, HTML_MESSAGE=0.001, MIME_HTML_ONLY=1.457, RCVD_IN_DNSWL_LOW=-1, USER_IN_WHITELIST=-100]
Received: from mail.ietf.org ([64.170.98.30]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id XWhtYY2EXVHL for <ipsec@ietfa.amsl.com>; Tue, 26 Jul 2011 04:17:33 -0700 (PDT)
Received: from mail-ww0-f42.google.com (mail-ww0-f42.google.com [74.125.82.42]) by ietfa.amsl.com (Postfix) with ESMTP id 884AA21F8C50 for <ipsec@ietf.org>; Tue, 26 Jul 2011 04:17:33 -0700 (PDT)
Received: by wwg11 with SMTP id 11so2176337wwg.1 for <ipsec@ietf.org>; Tue, 26 Jul 2011 04:17:32 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=LB79WW0B1wUUAoPt3sowaWfE0adA/VEioWaJ08dbyz4=; b=HByF9tEnlkmOgW5Z9D6ja5/hONG8MnCnGO68pOMnwd2MAOfTkReNDzDpKbYD2uibwE kD4MVJOLbLy/tZvj0YW6K8sYxwHBpU4ZeksDlqR2DIk/TZpSIpoJiVFqdsqwK7bcBkEY z0Ob/8XHrOEu6H7LqYZSzP/zI3/DzAr032PAk=
Received: by 10.227.24.68 with SMTP id u4mr4799261wbb.43.1311679052620; Tue, 26 Jul 2011 04:17:32 -0700 (PDT)
Received: from [10.0.0.6] (93-173-6-225.bb.netvision.net.il [93.173.6.225]) by mx.google.com with ESMTPS id 20sm333432wbw.36.2011.07.26.04.17.31 (version=SSLv3 cipher=OTHER); Tue, 26 Jul 2011 04:17:31 -0700 (PDT)
Message-ID: <4E2EA248.70708@gmail.com>
Date: Tue, 26 Jul 2011 14:17:28 +0300
From: Yaron Sheffer <yaronf.ietf@gmail.com>
User-Agent: Mozilla/5.0 (X11; Linux i686; rv:5.0) Gecko/20110627 Thunderbird/5.0
MIME-Version: 1.0
To: Yoav Nir <ynir@checkpoint.com>
References: <20013.29623.491247.654466@fireball.kivinen.iki.fi> <B97B134FACB2024DB45F524AB0A7B7F203ED2B05@XMB-BGL-419.cisco.com> <90AEF529-7273-4695-BA31-4F221A4ACF45@checkpoint.com>
In-Reply-To: <90AEF529-7273-4695-BA31-4F221A4ACF45@checkpoint.com>
Content-Type: text/html; charset="windows-1252"
Content-Transfer-Encoding: 8bit
Cc: "ipsec@ietf.org" <ipsec@ietf.org>, "Prashant Batra (prbatra)" <prbatra@cisco.com>
Subject: Re: [IPsec] DH keys calculation performance
X-BeenThere: ipsec@ietf.org
X-Mailman-Version: 2.1.12
Precedence: list
List-Id: Discussion of IPsec protocols <ipsec.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/ipsec>, <mailto:ipsec-request@ietf.org?subject=unsubscribe>
List-Archive: <http://www.ietf.org/mail-archive/web/ipsec>
List-Post: <mailto:ipsec@ietf.org>
List-Help: <mailto:ipsec-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/ipsec>, <mailto:ipsec-request@ietf.org?subject=subscribe>
X-List-Received-Date: Tue, 26 Jul 2011 11:17:34 -0000

You might want to review http://tools.ietf.org/html/rfc5996#section-2.12" rel="nofollow">http://tools.ietf.org/html/rfc5996#section-2.12.

Also, session resumption (http://tools.ietf.org/html/rfc5723" rel="nofollow">http://tools.ietf.org/html/rfc5723) reduces the computational costs of renewing an IKE SA when a client needs to reconnect to a gateway a second time after some failure.

Thanks,
    Yaron

On 07/26/2011 01:40 PM, Yoav Nir wrote:
On Jul 25, 2011, at 11:29 PM, Prashant Batra (prbatra) wrote:

Hello,

The DH exchange (Calculation of Public/Private key and the Secret) in
IKEV2 Initial exchange 
seems to be very expensive. This is slowing down the overall IKEv2
tunnel establishment.
Is there a way to optimize it?
Hi Prashant.

I know of three ways to optimize the D-H exchange.

First, note that each peer has to perform two operations: 
 1. Generate: create a random x and calculate X=2^x mod p
 2. Derive: calculate the shared secret S=Y^x mod p
The "Derive" operation has to be done during the exchange, but the "Generate" operation can be done long before the exchange. If your problem is degraded performance at some peak, you can pre-generate some values. This has a high cost in memory, but can be useful for dealing with peaks.

Second, note that 2^73 mod p = ((2^64 mod p) * (2^8 mod p) * (2^1 mod p)) mod p
If you're using a 2048-bit D-H group, you can pre-calculate 2^x mod p for 0<=x<=2048 and store these values. After that, both the generate and derive operations become simple multiplications of the resulting values. This has a fixed cost in memory, but can accelerate things.

Third, you may want to look at the EC groups. The EC operations require less computation.

Hope this helps

Yoav



_______________________________________________
IPsec mailing list
IPsec@ietf.org
https://www.ietf.org/mailman/listinfo/ipsec" rel="nofollow">https://www.ietf.org/mailman/listinfo/ipsec