Re: [IPsec] [CFRG] Use of AEAD algorithms as pure encryption algorithms

Valery Smyslov <smyslov.ietf@gmail.com> Mon, 24 April 2023 17:58 UTC

Return-Path: <smyslov.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 E48E0C14CEFD; Mon, 24 Apr 2023 10:58:58 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.994
X-Spam-Level:
X-Spam-Status: No, score=-1.994 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, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, HTTPS_HTTP_MISMATCH=0.1, RCVD_IN_ZEN_BLOCKED_OPENDNS=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=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 (2048-bit key) header.d=gmail.com
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 B0XYXoz-P_22; Mon, 24 Apr 2023 10:58:54 -0700 (PDT)
Received: from mail-ej1-x633.google.com (mail-ej1-x633.google.com [IPv6:2a00:1450:4864:20::633]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 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 76E31C14CE45; Mon, 24 Apr 2023 10:58:54 -0700 (PDT)
Received: by mail-ej1-x633.google.com with SMTP id a640c23a62f3a-94f6c285d92so872312866b.3; Mon, 24 Apr 2023 10:58:54 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1682359132; x=1684951132; h=content-language:thread-index:mime-version:message-id:date:subject :in-reply-to:references:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=VoSeF56ZwtGGJuPVIctpx8Fve3AwFC7K251BDEHP8Ko=; b=Stb/ZLjQQZMOP8sJze8Te3+H5pQDBaLV7IHPfsgI40o/kAXcn6kTNMfd2cLTxgryGq MCg732uk40THQG7p6YXOT90pEherdC4uHiZdbPBXEEYm+a6lVLgDJPPhCZyxFKmAP0b5 CzF0iAxzaxHx7MXFKn6+e1MYB3OUDuL/qnE9JVmG/9iG/JvcyTP53ggoaNFN0K65Msoi kQSNs4hQzIdgytjddXhRv2bq9UNwmSNkRkSd4dAKzSAz+iBWUvrd2aR72O7cXN++pOdx jaWl6PfkMMKn1mFChPcB9myQTfHs21CboMMQoevhLstiwaSBvAk7mjJOYYOdjf31ZwPe ruWQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682359132; x=1684951132; h=content-language:thread-index:mime-version:message-id:date:subject :in-reply-to:references:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=VoSeF56ZwtGGJuPVIctpx8Fve3AwFC7K251BDEHP8Ko=; b=jGp6VsBqNW30d32POJ0y3DOX7oACTQiBHEciqlwbvpG54Y5K5bfhAEJkdVgbJvEOIr SHYdVIe+A/LR4oLTu+lLft1v2/TCf+gdXCSH6Bd2+kHPnubJh1faqsIn+kqU9TICBMUD xfazr7NNA+i7iT9bBo/wlrhB6j24WQ0zJP8tRMtmt/zMu+Ephl7EvSl03yorc6ADmdqC c3N+YPmiB82fZ5kwobk/FqNYASaAWOPfrxt/LqvuItFUkgHQ1sf2FR6RonyzU5yC7Gvg l/FqN1b+FJhyPO+kQqC1r7t0DR1liObTW4tYI2d0Lkaawc371Bc39Vro8nBYEK2iMLCZ RbnA==
X-Gm-Message-State: AAQBX9furpXfXrWtlbH5xBx/XOnIkL65awQcGjsugjbNGlZSPCgeUQ7s +zD23VOnAG60T1OnLsXWcQV5RTpOpu0=
X-Google-Smtp-Source: AKy350brxy6Ui90uiFIEgpQFpvkRRc/XGqpA2PRc6ZKMZ36Pkx9wEhIWmhRqx3s+WVN5054EKFNLPw==
X-Received: by 2002:a17:906:90c8:b0:92b:e1ff:be30 with SMTP id v8-20020a17090690c800b0092be1ffbe30mr8632913ejw.4.1682359132406; Mon, 24 Apr 2023 10:58:52 -0700 (PDT)
Received: from svannotebook ([192.162.250.9]) by smtp.gmail.com with ESMTPSA id wz13-20020a170906fe4d00b00959c6b9dac8sm847467ejb.197.2023.04.24.10.58.50 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 24 Apr 2023 10:58:51 -0700 (PDT)
From: Valery Smyslov <smyslov.ietf@gmail.com>
To: 'John Mattsson' <john.mattsson@ericsson.com>, 'Natanael' <natanael.l@gmail.com>
Cc: cfrg@ietf.org, 'IPsecME WG' <ipsec@ietf.org>
References: <083b01d9735b$97767000$c6635000$@gmail.com> <CAAt2M1_rMBKoEZENQuz8FzJYZTp-3K=dEXaptYEkqfSjs_WnJA@mail.gmail.com> <090901d97424$fd80c660$f8825320$@gmail.com> <GVXPR07MB9678D4283BB499A153728DEA89619@GVXPR07MB9678.eurprd07.prod.outlook.com>
In-Reply-To: <GVXPR07MB9678D4283BB499A153728DEA89619@GVXPR07MB9678.eurprd07.prod.outlook.com>
Date: Mon, 24 Apr 2023 20:58:44 +0300
Message-ID: <00a501d976d6$6a7c4bf0$3f74e3d0$@gmail.com>
MIME-Version: 1.0
Content-Type: multipart/alternative; boundary="----=_NextPart_000_00A6_01D976EF.8FC983F0"
X-Mailer: Microsoft Outlook 16.0
Thread-Index: AQH6YJbH8RagVNfyVENz5YpoDjl7TAEqWe3mAgbzoFQCL2REEK7NNJcg
Content-Language: ru
Archived-At: <https://mailarchive.ietf.org/arch/msg/ipsec/VyBxsBUbAGwQBLXcNPxDuoBy-fI>
Subject: Re: [IPsec] [CFRG] Use of AEAD algorithms as pure encryption algorithms
X-BeenThere: ipsec@ietf.org
X-Mailman-Version: 2.1.39
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: <https://mailarchive.ietf.org/arch/browse/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: Mon, 24 Apr 2023 17:58:59 -0000

Hi John,

 

thank you for the comments, please see inline.

 

 

Hi Valery,

 

Some quick commments.

 

- If the G-IKEv2 engine is not trusted to access information inside the messages,

it should probably not be trusted to modify the keys. Chaning the keys would

get however is in control of the G-IKEv2 engine access to information

encrypted with the keys. (The G-IKEv2 can force key reuse as Natanael writes).

 

            G-IKEv2 engine is trusted to the extent that it will not voluntarily do any bad thing.

            There are basically two reasons to not expose keys in clear to the G-IKEv2 engine.

            First, despite the fact that we trust it, generally the engine may be more vulnerable

            to some side-channel attacks compared to crypto engine. For example,

            its memory may not be as protected as crypto engine's memory,

            there may be some electromagnetic emission issues, not existent 

in crypto engine which may be a specially designed HSM, and the like.

            Second, usually all the keys reside in crypto engine and never leave it in clear, only in wrapped (encrypted) form

            (I think that most crypto API don't even allow to export keys in clear, but I may be wrong).

 

            So, you can imagine the situation that we have two crypto engines -

            one on a Group Controller and the other on a Group Member and

            we want to transfer a key from the former to the latter.

            In this situation we usually wrap the key, transfer it (even via a protected channel)

            and unwrap on receiver. The idea was to use IKEv2 encryption transforms

            (which in many cases are in fact AEAD transforms these days) to also

            wrap/unwrap the keys, but since we know that the channel is protected,

            only use an encryption/decryption service of these transforms.

            

Maybe sending two UDP datagrams is the solution? Or sending less keys and use

a KDF to derive some of the keys?

 

            Sending multiple UDP datagrams is possible, but would complicate the protocol.

            Currently it is assumed that rekey is done with a single UDP datagram.

            Using KDF looks less desirable, it is assumed that all keys are independent

            and there is no correlation between them.

 

- I don't think "pure encryption algorithms" is a good term. Authenticated

encryption is "pure encryption" for IND-CCA confidentiality. I.e., confidentiality

against active attackers.

 

            It was an "ad hoc" term, I'm sure it is far from perfect.

 

- I think is it very good to have a discussion on IND-CPA encryption and APIs for that.

While AEAD has a standardized interface C = E(K, N, P, A) in RFC 5116, IND-CPA

encryption do not. The lack of IND-CPA encryption without message expansion and

the lack of a common API are problems. We discussed this in a paper we just

submitted to the NIST LWC workshop.

 

https://github.com/emanjon/Publications/blob/main/Proposals%20for%20Standardization%20of%20the%20Ascon%20Family.pdf

 

The DTLS 1.3 and QUIC specifications use AES-ECB which is secure in their case as the plaintext is a single block, but

I have met people believing that AES-ECB is now ok in general as DTLS and QUIC use it. It would have been easier if each AEAD algorithm had an IND-CPA mode. But people using IND-CPA when they should not are also a big problem…

 

            I understand.

 

How should a general interface for IND-CPA look like? Should it be

 

C = E(K, N, P)

 

or should it be a special case of the AEAD interface with a zero length tag and A = ""?

 

C = E(K, N, P, "")

 

            Or with a NULL (if we map this to C++)?

 

            C = E(K, N, P, NULL)

 

            Regards,

            Valery.

 

Cheers,

John

 

From: CFRG <cfrg-bounces@irtf.org <mailto:cfrg-bounces@irtf.org> > on behalf of Valery Smyslov <smyslov.ietf@gmail.com <mailto:smyslov.ietf@gmail.com> >
Date: Friday, 21 April 2023 at 09:44
To: 'Natanael' <natanael.l@gmail.com <mailto:natanael.l@gmail.com> >
Cc: cfrg@ietf.org <mailto:cfrg@ietf.org>  <cfrg@ietf.org <mailto:cfrg@ietf.org> >, 'IPsecME WG' <ipsec@ietf.org <mailto:ipsec@ietf.org> >
Subject: Re: [CFRG] Use of AEAD algorithms as pure encryption algorithms

Hi Natanael,

 

thank you for your response, please see inline.

 

Den tors 20 apr. 2023 09:42Valery Smyslov < <mailto:smyslov.ietf@gmail.com> smyslov.ietf@gmail.com> skrev:

Hi,

I have a question to the crypto community regarding the use of AEAD algorithms as pure
encryption algorithms. The use case is as follows.

In G-IKEv2 ( <https://datatracker.ietf.org/doc/draft-ietf-ipsecme-g-ikev2/> https://datatracker.ietf.org/doc/draft-ietf-ipsecme-g-ikev2/) we have a situation
where keys are transferred inside the G-IKEv2 message. The message itself is encrypted and
integrity protected. In addition, each of individual keys inside this message is encrypted too
with a different key(s) (it can be the same key for all encrypted keys or different key for each encrypted key,
but in any case these keys are different from the key protecting the message).
The reason for this construction is to prevent the G-IKEv2 engine which forms and parses 
messages from accessing any sensitive information inside the messages.

The algorithm for protecting the message itself and individual keys inside the message is the same - 
it is one of IKEv2 Encryption transforms 
 <https://www.iana.org/assignments/ikev2-parameters/ikev2-parameters.xhtml#ikev2-parameters-5> https://www.iana.org/assignments/ikev2-parameters/ikev2-parameters.xhtml#ikev2-parameters-5
The reason for this is to simplify implementations - the algorithm for protecting the message will be 
supported anyway, so there seems to be no reason to negotiate another one.
In many cases this algorithm will be an AEAD algorithm (like AES-GCM).

The problem is that there may be quite a lot of encrypted keys inside a single message,
and since G-IKEv2 operates over UDP (and over multicast!), the size of the message matters - 
large messages will be fragmented by IP level and due to known issues with firewalls
might not get through, so we want to make the message small. And for each protected key 
the authentication tags would consume almost the same space, as the encrypted content.

So, the design is that even when using an AEAD algorithm, the individual
keys inside the protected message are only encrypted and their authentication tags produced by the AEAD algorithm,
are not transmitted. On a receiving side it must be possible to decrypt keys without performing an integrity check.
Note, that the message itself is encrypted and integrity protected, so we are sure that all message content, 
including all encrypted keys, is not altered.

My questions to the crypto community:
1. Is it generally OK to use AEAD algorithms as pure ciphers.
2. Do existing APIs to AEAD algorithms allow to decrypt an encrypted blob without checking its integrity.

Regards,
Valery.

 

1: No, in the general case. It's not a good idea. But there's options (see below).

 

Especially given that many common AEAD ciphers are built on stream ciphers they are trivially malleable if you don't check the authentication, so if an adversary knows a single plaintext block they can modify it to decrypt to anything they wish. You get none of the guarantees they're intended to give if you don't use them as intended.

 

          Yes, I’m aware of this.

 

In the context of your example this allows the adversary to eg. resend old keys, possibly forcing key reuse elsewhere.

 

          No, it is not possible in my use case. The message, which contains encrypted keys, is always

          encrypted and authenticated using the same AEAD algorithm, and G-IKEv2 provides replay protection,

          so no external adversary can either see or manipulate the keys.

 

*Even if* the individual keys have their own layer of authenticated encryption inside the encrypted stream, the authentication should bind to the session to prevent replays and more.

 

          As I’ve already said, replays are not possible. And there is a binding of these keys to a session too.

 

2: I think most APIs prevent it - in addition some algorithms makes it impossible, intentionally. See SCRAM;

 

 <https://protect2.fireeye.com/v1/url?k=31323334-501cfaf3-313273af-454445554331-86146c33258534f8&q=1&e=1376b3f0-373e-43c7-a61f-75309f93706a&u=https%3A%2F%2Fgithub.com%2Faws%2Fs2n-tls%2Ftree%2Fmain%2Fscram> https://github.com/aws/s2n-tls/tree/main/scram

 

          Thank you for the pointer.

 

You do have other options. If you prepend a signed/authenticated Merkle Tree hash which cover the set of encrypted keys then they can be individually verified against the Merkle root without decrypting the entire message. This signature can then also bind the key bundle to the session. The size overhead can be some kilobytes. If this is worth it depends on what you mean with "quite a lot of keys". Several hundreds or more? Could be worth doing. Just some dozen? Not really.

 

          Well, let me be more specific. G-IKEv2 operates over UDP, so the message size should be less than path MTU to avoid IP fragmentation.

          In most cases it is 1500 bytes, but can be smaller, say 576 bytes. There are some other stuff in the message besides keys,

          so it is generally about from 300 to 1250 bytes are available for keys. To exclude a user from the group using LKH algorithm (RFC 2627)

          we have to send as many keys, as the height of the key tree, which is determined by the group size. Let us assume 

          that we limit group size to say 16M users (really big value), then we have to send 24 keys. If we assume that the  size of each key is 256 bits

          (32 bytes) and it must be accompanied with some metadata (key ID etc.) which is 8 bytes and IV (say 8 bytes), then the size of each individual

          encrypted key is no less than 48 bytes. Which makes it barely fit in our optimistic case (with PMTU 1500).

          If we add an authentication tag to each key (16 bytes for AES-GCM), then that many keys won’t fit in any case.

          We should either decrease the size of the keys or limit the group size or complicate protocol to split these messages into many.

 

          Regards,

          Valery.