Re: [Cfrg] Unknown order DH groups, e.g. as in RFC3526.

Markku-Juhani Olavi Saarinen <mjos@iki.fi> Fri, 08 March 2019 23:30 UTC

Return-Path: <mjos.crypto@gmail.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 E5F8412796B for <cfrg@ietfa.amsl.com>; Fri, 8 Mar 2019 15:30:48 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.649
X-Spam-Level:
X-Spam-Status: No, score=-1.649 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=no 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 AQ6j8BlYzRLC for <cfrg@ietfa.amsl.com>; Fri, 8 Mar 2019 15:30:47 -0800 (PST)
Received: from mail-ed1-f44.google.com (mail-ed1-f44.google.com [209.85.208.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 2CB92130F63 for <cfrg@irtf.org>; Fri, 8 Mar 2019 15:30:47 -0800 (PST)
Received: by mail-ed1-f44.google.com with SMTP id x7so17677545eds.8 for <cfrg@irtf.org>; Fri, 08 Mar 2019 15:30:47 -0800 (PST)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=38LkHz8UD8O7gg/8eo5ND9yyDouRB2vaaQKMZNgrKqQ=; b=Ne3jUmakuzwR6KYzH3ZRScu28tAEu87xXo+Ui3yZY+CYU2KnCAOS5zHrA0xbddEbUY FtXPJRFhvCSVxIYP6UhxzcIO1p1oKoUezj3KOa2QEVWHj/Mxa4sqNUbVxMcdJ9EzBgf6 N8R38kN1rxutNHzNc8/lWXrTsy4qqek5XWNukgCy4hUiz/1u9UrwhE0HPf6H9bgdwQaS 0rmtonIkEng4SwDVftl9ACrAfaP6nEox6FXn4IJUdtwqImeLRvXh/h6yloWMUkScPUSS M10i9lrx9ZZWeGwII2OnwYJYirYp+DUDseJ4VylsVUmcI56niI4f9AdAVGJlR8T70VC9 bt2A==
X-Gm-Message-State: APjAAAX+ktYErCZFO/qjB81fw0qzCBm+YVjJggjq5JoB5m/aRQI+FEg+ qhuFQXyB3tUhxh+/85roI8y7HNnGNIUNnKLROETl9iju
X-Google-Smtp-Source: APXvYqx+K++LOpifUTxz677guVwOcW3SgnToOE6SvsO6L+ue2aIiVXiATav06Q3kLtk6NobuuQAPeqPMpt4vX32h4O4=
X-Received: by 2002:a17:906:c9d5:: with SMTP id hk21mr13448393ejb.122.1552087845515; Fri, 08 Mar 2019 15:30:45 -0800 (PST)
MIME-Version: 1.0
References: <CAKUk3buNuoFk0BnhqkefrGezPJiAcqkwNi35TOB_QZwEaQ8ycw@mail.gmail.com> <875074e405cb4fa08917e6e7ba96e022@XCH-RTP-006.cisco.com> <CAKUk3bvY_tnfTQnx3XSBjM4zAJz5V_9T3Dm3Q=bLPN-LhEut_Q@mail.gmail.com>
In-Reply-To: <CAKUk3bvY_tnfTQnx3XSBjM4zAJz5V_9T3Dm3Q=bLPN-LhEut_Q@mail.gmail.com>
From: Markku-Juhani Olavi Saarinen <mjos@iki.fi>
Date: Fri, 08 Mar 2019 23:30:34 +0000
Message-ID: <CA+iU_qmdDrO5=WOXF0-3spbV0VoYtAiZtv2u-HZM3s2QwGXttA@mail.gmail.com>
To: Andrey Jivsov <crypto@brainhub.org>
Cc: "cfrg@irtf.org" <cfrg@irtf.org>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Archived-At: <https://mailarchive.ietf.org/arch/msg/cfrg/_xKxEeMc-KV9oHs8h5JTrUvf1qc>
Subject: Re: [Cfrg] Unknown order DH groups, e.g. as in RFC3526.
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: Fri, 08 Mar 2019 23:30:49 -0000

Hi Andrey,

It is true that RFC 3526 does not explicitly give out the group orders
-- these are safe primes. I recall when my late colleague at SSH, Mika
Kojo computed (or "found") them some 20 years ago -- they were
published posthumously and that's probably why such mathematical
details are missing. You can run a primality test of your choosing on
each (p-1)/2 to verify this if you like.

All of this, including Diffie-Hellman in a basically any group, is of
course of historical interest only.. but let me expand on this for
posteriority:

It is (or at least used to be) "common knowledge" that the MODP groups
(including RFC3526) were based on Sophie Germain primes, i.e. primes
of type p=2q+1 where q is also a prime. Therefore the group order of
any element x that is coprime with p can only be one of {1, 2, q,
2*q}. The latter two classes correspond to quadratic residues and
quadratic non-residues. There are O(log a log b) algorithms for
Legendre/Jacobi symbol so the group order of any element can be
efficiently evaluated if you accept that p is a "S.G." prime. In most
cases it is sufficient to check that x mod p is not one of { 0, 1, p-1
}, meaning that the group order is at least q -- the quadratic residue
check will only reveal the least significant bit of a secret exponent
-- if the generator happens to be a q.n.r.

Cheers,
- markku

Dr. Markku-Juhani O. Saarinen <mjos@iki.fi>

On Fri, Mar 8, 2019 at 11:17 PM Andrey Jivsov <crypto@brainhub.org> wrote:
>
> Sorry, a correction: https://tools.ietf.org/html/rfc7919 is the RFC that defines safe primes, and thus the group order is (p-1)/2 for each of them.
>
> What's the group order for random primes in https://tools.ietf.org/html/rfc3526 ? Do you mean the composite group order p-1 with potentially unpleasant many-small-factors factorization?
>
> On Fri, Mar 8, 2019 at 2:59 PM Scott Fluhrer (sfluhrer) <sfluhrer@cisco..com> wrote:
>>
>> I suspect you mistyped the RFC number you meant; instead of saying that the groups listed in RFC3526 didn’t specify an order (they do), you meant to talk about the groups in some other RFC…
>>
>>
>>
>> From: Cfrg <cfrg-bounces@irtf.org> On Behalf Of Andrey Jivsov
>> Sent: Friday, March 08, 2019 5:44 PM
>> To: cfrg@irtf.org
>> Subject: [Cfrg] Unknown order DH groups, e.g. as in RFC3526.
>>
>>
>>
>> Greetings.
>>
>>
>>
>> A quick question on DH primes.
>>
>>
>>
>> The IKE DH groups document didn't specify the group order https://tools.ietf.org/html/rfc3526 .
>>
>>
>>
>> This is in contrast to https://tools.ietf.org/html/rfc3526 that uses safe primes.
>>
>>
>>
>> Is my understanding correct that, as a general rule, these primes should not be used, e.g. where a contributory behaviour of DH is needed? The issue here is that a random element, received from a peer, can be in any subgroup, possibly in a subroup with lower security than 128 bits, and there is no way to verify this efficiently.
>>
>>
>>
>> Thank you.
>
> _______________________________________________
> Cfrg mailing list
> Cfrg@irtf.org
> https://www.irtf.org/mailman/listinfo/cfrg