Re: [Cfrg] One question about MODP: the structure of DLP prime in a finite field

Wang Guilin <Wang.Guilin@huawei.com> Tue, 19 November 2019 05:49 UTC

Return-Path: <Wang.Guilin@huawei.com>
X-Original-To: cfrg@ietfa.amsl.com
Delivered-To: cfrg@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 49ED5120152 for <cfrg@ietfa.amsl.com>; Mon, 18 Nov 2019 21:49:41 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -4.2
X-Spam-Level:
X-Spam-Status: No, score=-4.2 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
Received: from mail.ietf.org ([4.31.198.44]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id j86FA8p2pDk5 for <cfrg@ietfa.amsl.com>; Mon, 18 Nov 2019 21:49:36 -0800 (PST)
Received: from huawei.com (szxga03-in.huawei.com [45.249.212.189]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id B2FCE120B79 for <cfrg@irtf.org>; Mon, 18 Nov 2019 21:49:35 -0800 (PST)
Received: from DGGEMM401-HUB.china.huawei.com (unknown [172.30.72.54]) by Forcepoint Email with ESMTP id 9D773B27124957792DC7; Tue, 19 Nov 2019 13:49:30 +0800 (CST)
Received: from sineml704-chm.china.huawei.com (10.223.161.111) by DGGEMM401-HUB.china.huawei.com (10.3.20.209) with Microsoft SMTP Server (TLS) id 14.3.439.0; Tue, 19 Nov 2019 13:49:30 +0800
Received: from sineml702-chm.china.huawei.com (10.223.161.109) by sineml704-chm.china.huawei.com (10.223.161.111) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Tue, 19 Nov 2019 13:49:29 +0800
Received: from sineml702-chm.china.huawei.com ([10.223.161.109]) by sineml702-chm.china.huawei.com ([10.223.161.109]) with mapi id 15.01.1713.004; Tue, 19 Nov 2019 13:49:29 +0800
From: Wang Guilin <Wang.Guilin@huawei.com>
To: "Scott Fluhrer (sfluhrer)" <sfluhrer@cisco.com>, "cfrg@irtf.org" <cfrg@irtf.org>
CC: Wang Guilin <Wang.Guilin@huawei.com>
Thread-Topic: One question about MODP: the structure of DLP prime in a finite field
Thread-Index: AdWegtVJxKWRMLE+TymcwM5ykoxhwQACbuuwAAKbMAA=
Date: Tue, 19 Nov 2019 05:49:29 +0000
Message-ID: <883cbcc55ee04a268f7eace336ad818e@huawei.com>
References: <0d62d07932d44b53ab30b1cdb47db8ee@huawei.com> <BN8PR11MB3666349CA819D2B251FCCAC8C14C0@BN8PR11MB3666.namprd11.prod.outlook.com>
In-Reply-To: <BN8PR11MB3666349CA819D2B251FCCAC8C14C0@BN8PR11MB3666.namprd11.prod.outlook.com>
Accept-Language: en-US
Content-Language: en-US
X-MS-Has-Attach:
X-MS-TNEF-Correlator:
x-originating-ip: [10.215.37.163]
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0
X-CFilter-Loop: Reflected
Archived-At: <https://mailarchive.ietf.org/arch/msg/cfrg/kJhH-5ayYy2r2QOYxtGiTDLqfLc>
Subject: Re: [Cfrg] One question about MODP: the structure of DLP prime in a finite field
X-BeenThere: cfrg@irtf.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Crypto Forum Research Group <cfrg.irtf.org>
List-Unsubscribe: <https://www.irtf.org/mailman/options/cfrg>, <mailto:cfrg-request@irtf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/cfrg/>
List-Post: <mailto:cfrg@irtf.org>
List-Help: <mailto:cfrg-request@irtf.org?subject=help>
List-Subscribe: <https://www.irtf.org/mailman/listinfo/cfrg>, <mailto:cfrg-request@irtf.org?subject=subscribe>
X-List-Received-Date: Tue, 19 Nov 2019 05:49:41 -0000

Dear Scott, 

Thank you very much for your detailed reply. Here, let me summarize your comments and give a little more feedback. 

1) > The prime factors of p-1 are known to be 2 and q = (p-1)/2.

So, for group ID 14, this means that p is a safe prime. I guess all the prime numbers for other groups specified in RFC 3526 are safe primes. If this is true, for anyone who is responsible to update RFC 3526, it seems better to state this info specifically in the documents. Otherwise, p being a prime number is just like a back side story. 

2) > Actually, the length of q is 2047 bits; it's not obvious to me what a large q would be an issue in this situation...

In textbook and also crypto research papers for DLP in finite fields (e.g., Schnorr signature, DH, SPEKE), they almost always use q, the order of g,  which has a medium bit length (say around 256) due to efficiency and also security considerations. Also, in this case, given x1, x2, ...., xn, we can calculate g^{x1x2...xn} in a fast way: 

(**) Firstly, compute x=x1x2...xn mod q, and then compute g^x mod p, where x is a 256 bit exponent. 

However, if q is 2047 bits, to use algorithm (**) the x can be as long as 2047 bit even though each xi is only 256 bits. [However, luckily, in SPEKE scenario, we do not have this issue really, as we have two xi's only. And the client needs to compute g^x1 first, and then to compute a session K=(g^y)^x when the client received g^y from the server, while both x and y are 256 bits. But still, some potential pre-computation with fixed base may be not applicable anymore, as the base in computing K is (g^y), a random value, not the fixed base g.]

About security, I also feel it looks secure if we only select short exponents, say 256 bit strings for x and y in SPEKE, even though q is 2047 bits. However, to my best knowledge, it seems that this has not been confirmed by any academic research [I may be wrong on this]. Security is subtle and tricky...

Thanks,

Guilin





-----Original Message-----
From: Scott Fluhrer (sfluhrer) [mailto:sfluhrer@cisco.com] 
Sent: Tuesday, November 19, 2019 12:04 PM
To: Wang Guilin <Wang.Guilin@huawei.com>; cfrg@irtf.org
Subject: RE: One question about MODP: the structure of DLP prime in a finite field

> -----Original Message-----
> From: Cfrg <cfrg-bounces@irtf.org> On Behalf Of Wang Guilin
> Sent: Monday, November 18, 2019 9:46 PM
> To: cfrg@irtf.org
> Cc: Wang Guilin <Wang.Guilin@huawei.com>
> Subject: [Cfrg] One question about MODP: the structure of DLP prime in 
> a finite field
> 
> Dear everyone,
> 
> Highly appreciate if anyone can help on the following question.
> 
> RFC 3526 (https://tools.ietf.org/html/rfc3526) offers a number of DLP 
> parameters in a finite field. An example is group ID 14, detailed 
> specification copied below.
> 
> =========================
> This group is assigned id 14.
> 
>    This prime is: 2^2048 - 2^1984 - 1 + 2^64 * { [2^1918 pi] + 124476 
> }
> 
>    Its hexadecimal value is:
>       FFFFFFFF FFFFFFFF C90FDAA2 2168C234 C4C6628B 80DC1CD1
>       29024E08 8A67CC74 020BBEA6 3B139B22 514A0879 8E3404DD
>       EF9519B3 CD3A431B 302B0A6D F25F1437 4FE1356D 6D51C245
>       E485B576 625E7EC6 F44C42E9 A637ED6B 0BFF5CB6 F406B7ED
>       EE386BFB 5A899FA5 AE9F2411 7C4B1FE6 49286651 ECE45B3D
>       C2007CB8 A163BF05 98DA4836 1C55D39A 69163FA8 FD24CF5F
>       83655D23 DCA3AD96 1C62F356 208552BB 9ED52907 7096966D
>       670C354E 4ABC9804 F1746C08 CA18217C 32905E46 2E36CE3B
>       E39E772C 180E8603 9B2783A2 EC07A28F B5C55DF0 6F4C52C9
>       DE2BCBF6 95581718 3995497C EA956AE5 15D22618 98FA0510
>       15728E5A 8AACAA68 FFFFFFFF FFFFFFFF
> 
>    The generator is: 2.
> =========================
> 
> The question is: What is the structure or factors of prime p-1, where 
> the value of p is given above?

The prime factors of p-1 are known to be 2 and q = (p-1)/2.

> Also, if we do not know the factors of p-1, it is risky to just use 
> g=2 as a generator as the order of 2 could be quite small.

The order of g=2 is known to be q

>  In FRC
> 3526, the suggested exponent size for group ID 14 is 220 bits or more.

Yes; the reasoning is that there are two style of attacks to solve the discrete log problem:

- A NFS attack against the group (which is estimated to take approximately 2**110 effort
- A Giant-step-baby-step attack against the exponent; if the exponent is N bits, this takes about 2**(N/2) effort

Selecting an exponent size of 220 makes these two attacks approximately the same effort; selecting an exponent from a smaller range would actively decrease security, while selecting from a significantly larger range would increase the work required without increasing security.

Personally, I'd use a slightly larger range (perhaps 256 bits); our estimates for NFS might be a bit off, and increasing the exponent size modestly doesn't increase time that much...

> 
> My real reason to ask this question is: We want to test SPEKE (a PAKE
> protocol) by using group ID 14. However, to run SPEKE, we need to know 
> a prime factor q of p-1, i.e. (p-1)=qk, where k is an integer. 
> Ideally, the bit length of q is between 220-256.

Actually, the length of q is 2047 bits; it's not obvious to me what a large q would be an issue in this situation...

>  Once we know such a prime factor q for p-1, then both client and 
> server in SPEKE can calculate a generator something like g=(H(pw, 
> salt))^k. Then, they can run DH key exchange normally by using g.
> 
> So, the difficulty here is: Without knowing the factors of p-1 in 
> group ID 14, it seems not possible to generate such a generator g in SPEKE.

As above, that's not an issue...

> 
> Thanks in advance,
> 
> Guilin
> 
> _______________________________________________
> Cfrg mailing list
> Cfrg@irtf.org
> https://www.irtf.org/mailman/listinfo/cfrg