Re: [openpgp] Partial review of the crypto refresh

Marcus Brinkmann <marcus.brinkmann@rub.de> Fri, 25 November 2022 14:05 UTC

Return-Path: <marcus.brinkmann@rub.de>
X-Original-To: openpgp@ietfa.amsl.com
Delivered-To: openpgp@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 283DCC14CE4C for <openpgp@ietfa.amsl.com>; Fri, 25 Nov 2022 06:05:03 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -7.096
X-Spam-Level:
X-Spam-Status: No, score=-7.096 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_HI=-5, RCVD_IN_ZEN_BLOCKED_OPENDNS=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_DBL_BLOCKED_OPENDNS=0.001, URIBL_ZEN_BLOCKED_OPENDNS=0.001] autolearn=ham autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (1024-bit key) header.d=rub.de
Received: from mail.ietf.org ([50.223.129.194]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 9FK4jxWAT_Yv for <openpgp@ietfa.amsl.com>; Fri, 25 Nov 2022 06:04:58 -0800 (PST)
Received: from out3.mail.ruhr-uni-bochum.de (out3.mail.ruhr-uni-bochum.de [IPv6:2a05:3e00:8:1001::8693:359b]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 2BCBFC14CE46 for <openpgp@ietf.org>; Fri, 25 Nov 2022 06:04:58 -0800 (PST)
Received: from mx3.mail.ruhr-uni-bochum.de (localhost [127.0.0.1]) by out3.mail.ruhr-uni-bochum.de (Postfix mo-ext) with ESMTP id 4NJc7V2nnhz8Sdh; Fri, 25 Nov 2022 15:04:54 +0100 (CET)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=rub.de; s=mail-2017; t=1669385094; bh=t8Zvc3Ndj1Ssb82c7AMcNKo/geq9U+oNwtN8jrHaTz8=; h=From:Subject:Date:In-Reply-To:Cc:To:References:From; b=RMkgKcrRDoW9lQPy5zcu+qIS16GmbUBwy+CUPGHZBN088CMqDo2o9G/E5b+IoYKOf btJ+a0+VvljoywxqTNjNW89vFSZo45nOqdmZGlHkzy2Z12shNIdVgeaq2UMbA5TALQ jFnS2c13aTecYiPhPpBZkrGdEJ9hZQjpfT39PIbM=
Received: from out3.mail.ruhr-uni-bochum.de (localhost [127.0.0.1]) by mx3.mail.ruhr-uni-bochum.de (Postfix idis) with ESMTP id 4NJc7V20Yxz8SBQ; Fri, 25 Nov 2022 15:04:54 +0100 (CET)
X-RUB-Notes: Internal origin=134.147.42.236
X-Envelope-Sender: <marcus.brinkmann@rub.de>
Received: from mail2.mail.ruhr-uni-bochum.de (mail2.mail.ruhr-uni-bochum.de [134.147.42.236]) by out3.mail.ruhr-uni-bochum.de (Postfix mi-int) with ESMTP id 4NJc7T14Sgz8Sl7; Fri, 25 Nov 2022 15:04:52 +0100 (CET)
X-Virus-Status: Clean
X-Virus-Scanned: clamav-milter 0.103.7 at mx3.mail.ruhr-uni-bochum.de
Received: from smtpclient.apple (dyn-7001789eac61920fc5001000.eduroam.ipv6.ruhr-uni-bochum.de [IPv6:2a05:3e00:1:5c:f029:16ca:e987:1007]) by mail2.mail.ruhr-uni-bochum.de (Postfix) with ESMTPSA id 4NJc7S4cQbzDh1s; Fri, 25 Nov 2022 15:04:52 +0100 (CET)
X-Virus-Status: Clean
X-Virus-Scanned: clamav-milter 0.105.0 at mail2.mail.ruhr-uni-bochum.de
From: Marcus Brinkmann <marcus.brinkmann@rub.de>
Message-Id: <3E09FE42-EA91-4F43-804C-2718B8383F53@rub.de>
Content-Type: multipart/alternative; boundary="Apple-Mail=_E20CB100-5542-4F27-A7AF-306CC01B6522"
Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.120.41.1.1\))
Date: Fri, 25 Nov 2022 15:04:51 +0100
In-Reply-To: <HniDSkOrqQhzJeIb0B_7yLgQjsIDVZZdGPnwttTdfpk4LCN7B4Nh1J6xzv1eZIV-OR6UemykSEdao4pWe5gFfr5BUWhEfHX8mdj6Jhla6xg=@protonmail.com>
Cc: IETF OpenPGP WG <openpgp@ietf.org>
To: Daniel Huigens <d.huigens=40protonmail.com@dmarc.ietf.org>
References: <HniDSkOrqQhzJeIb0B_7yLgQjsIDVZZdGPnwttTdfpk4LCN7B4Nh1J6xzv1eZIV-OR6UemykSEdao4pWe5gFfr5BUWhEfHX8mdj6Jhla6xg=@protonmail.com>
X-Mailer: Apple Mail (2.3696.120.41.1.1)
Archived-At: <https://mailarchive.ietf.org/arch/msg/openpgp/KJX-3z-HbGGP7KV4luokoCQOtyc>
Subject: Re: [openpgp] Partial review of the crypto refresh
X-BeenThere: openpgp@ietf.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: "Ongoing discussion of OpenPGP issues." <openpgp.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/openpgp>, <mailto:openpgp-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/openpgp/>
List-Post: <mailto:openpgp@ietf.org>
List-Help: <mailto:openpgp-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/openpgp>, <mailto:openpgp-request@ietf.org?subject=subscribe>
X-List-Received-Date: Fri, 25 Nov 2022 14:05:03 -0000

Hi,

> Am 24.11.2022 um 14:53 schrieb Daniel Huigens <d.huigens=40protonmail.com@dmarc.ietf.org>:
>> 3.2.  Multiprecision Integers
>>   (...)
>>   Also note that when an MPI is encrypted, the length refers to the
>>   plaintext MPI.  It may be ill-formed in its ciphertext.
> 
> This note has always confused me. Does someone know what it means?

It means what you understood it to mean, that encryption for MPIs is not format-preserving. And yes, it is obvious to us today.

>> 3.7.2.  String-to-Key Usage
> 
> I think what is potentially missing from this section is some guidance
> about "Iterated and Salted S2K", e.g. hinting that it is not very
> strong, or at least that a high octet count should be used. For
> example, we could append to this section:
> 
>   If Argon2 is not available, Iterated and Salted S2K MAY be used if
>   care is taken to use a sufficiently high octet count. However, this
>   method does not provide memory-hardness, unlike Argon2.

There is no octet count representable in any variant of S2K that I would consider safe to use. I agree that there should be guidance, but I would suggest that the guidance should be that S2K should only to be used with a strong passphrase. If a sufficiently strong passphrase is chosen, the variant of S2K chosen does not matter anymore. To give some concrete numbers:

The count consists of a "mantisse" between 16 and 31, and an exponent (to basis 2) between 6 and 21. The total count is mantisse*2^exponent, which is a number between 1024 and 65,011,712. With a blocksize of 512 bits (SHA-1, SHA-2), we have to divide by 64, giving an iteration count of up to approx. 1M. Computing SHA-1 can be done very quickly using standard CPUs (~100MH/s), GPUs (~20 GH/s), and dedicated ASICs (such as used for Bitcoin mining, total network capacity ~160 Million TeraHash/s!). We can now compute how hard it is to brute-force a PGP password. With a single GPU (such as an RTX3090 with 23 GH/s) and 1M H/Password, we are looking at 2.3M password guesses per second. A stronger hash function only reduces this by a small factor (SHA-256: Faktor 2.3, SHA-512: Faktor 7), but really the only viable option here is a much stronger password. Using a uniformly distributed random password from a 64-letter alphabet (a-zA-Z0-9+/) and a password length of 14 characters (= 2^84 passwords), you can pretty much ignore the PGP S2K settings for now (ignoring QC).

Suggestion:

  If Argon2 is not available, Iterated and Salted S2K MAY be used if
  care is taken to use a high octet count and a strong passphrase.
  However, this method does not provide memory-hardness, unlike Argon2.

Thanks,
Marcus

—
Dipl.-Math. Marcus Brinkmann

Lehrstuhl für Netz- und Datensicherheit
Ruhr Universität Bochum
Universitätsstr. 150, Geb. ID 2/461
D-44780 Bochum

Telefon: +49 (0) 234 / 32-25030
http://www.nds.rub.de/chair/people/mbrinkmann