Re: [Ietf-dkim] Question regarding RFC 6376
"Murray S. Kucherawy" <superuser@gmail.com> Mon, 11 March 2024 15:55 UTC
Return-Path: <superuser@gmail.com>
X-Original-To: ietf-dkim@ietfa.amsl.com
Delivered-To: ietf-dkim@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 4A9C4C14F6AC for <ietf-dkim@ietfa.amsl.com>; Mon, 11 Mar 2024 08:55:20 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -7.107
X-Spam-Level:
X-Spam-Status: No, score=-7.107 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, RCVD_IN_DNSWL_HI=-5, RCVD_IN_ZEN_BLOCKED_OPENDNS=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01] 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 5YCMlfygW-_v for <ietf-dkim@ietfa.amsl.com>; Mon, 11 Mar 2024 08:55:19 -0700 (PDT)
Received: from mail-ej1-x630.google.com (mail-ej1-x630.google.com [IPv6:2a00:1450:4864:20::630]) (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 D7806C14F5FB for <ietf-dkim@ietf.org>; Mon, 11 Mar 2024 08:55:07 -0700 (PDT)
Received: by mail-ej1-x630.google.com with SMTP id a640c23a62f3a-a28cfca3c45so171980066b.1 for <ietf-dkim@ietf.org>; Mon, 11 Mar 2024 08:55:07 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1710172506; x=1710777306; darn=ietf.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=IAvjF5pdYSUfTTjOCRcAN6fAQwk68Xlrn3Mc7+jOQtI=; b=dsK9sg4XBr6lnH/VmyoSKs9GXTmPpK17Mnwcq3e8tk0HG/+7o/myy8LhFZE0rrVcSD Zylx+qhELOBxzIT53xKYHW1i+zKuxwnf8FBKeBdGeukEioCZMizz2efzMPwwfgTh2rsm sUW9oGzKN1pgUc+CKZcXGTW9RWnOP71dPgODFBI/hIQu1Mt0yZh8JR8KuoQk8qpA4cz6 3sns17raqUqKeEd9u/6q4PT8/wHYXG1qza8rz6Mbkk5Z7zKdjBAmMTmbq6ehMB9L7IcW 7mvgYznJux8zqFV7x9ssPXkxA8xcF6neG5vlRyxOCyiBJn/swEjCQY5wPAFRThunS1wg Rg/Q==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710172506; x=1710777306; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=IAvjF5pdYSUfTTjOCRcAN6fAQwk68Xlrn3Mc7+jOQtI=; b=BzFG8sHXcCmoTzwv6DhZ38a3I+m2f5zVPZrR/AUZH4gZWpJc4BDJc9CzAmdsGgDYQ2 vrzpdAx6pGpYiqWzphaiaKIGVe1UE5LgmLLnIxP5JjVN/gH6qwSQl2jlamCiTmjYTl4o cmVizClfAcP7/MeJwW9IDL6M9p75QBbZNYcbu8Qa4V0BQ2Nma5scPwf9ar4Bd2Svx5KH T85nzHWpQS18bjh1bpUKTb/QyBxZDdkjFUPqXjr6o33GgWou5DRnxwjUtzF9L3AsOk/8 eLk6McgGlr/VaOjQ4aFHK20EiH8K2mDTUtj7mliLOB6NYApdxtuA6Uy/r629FlfuX3L0 Vb+g==
X-Gm-Message-State: AOJu0YzZ4imn5wj7fsfLgcpcES1FaXdslBJFmERCfiBu/NOaLfEYg4Vw XE14hDxX64tFNfCCLQFj/CbwxaoxQi75jfU+sdFwFMq25+bXOKM1LdcNNrGz8Guo0dtllvJzjT8 uju1kNhI+ct+KbV3cXVTXGjV8tHGVs0lshdg=
X-Google-Smtp-Source: AGHT+IH0/HltZHkG2eZooApWIH2nBBZ6MsEydA5FLCm9hEUyHMrI4zf+e6XV9tWJRiohi3mRfq1mk+/zD2wnHF8x1p4=
X-Received: by 2002:a17:906:53d5:b0:a3b:b215:6edb with SMTP id p21-20020a17090653d500b00a3bb2156edbmr4499449ejo.6.1710172505461; Mon, 11 Mar 2024 08:55:05 -0700 (PDT)
MIME-Version: 1.0
References: <65EF0B08.26692.1826077F@David.Harris.pmail.gen.nz>
In-Reply-To: <65EF0B08.26692.1826077F@David.Harris.pmail.gen.nz>
From: "Murray S. Kucherawy" <superuser@gmail.com>
Date: Mon, 11 Mar 2024 08:54:53 -0700
Message-ID: <CAL0qLwZyf6oL-JDEeCiV=MWEDH8usF5cfrDQMOc=qFwKGGjFgw@mail.gmail.com>
To: David Harris <David.Harris@pmail.gen.nz>
Cc: ietf-dkim@ietf.org
Content-Type: multipart/alternative; boundary="000000000000b15a34061364903b"
Archived-At: <https://mailarchive.ietf.org/arch/msg/ietf-dkim/MCbr_IoM_4-N_JzqytRPAt9x5OY>
Subject: Re: [Ietf-dkim] Question regarding RFC 6376
X-BeenThere: ietf-dkim@ietf.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: IETF DKIM List <ietf-dkim.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/ietf-dkim>, <mailto:ietf-dkim-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/ietf-dkim/>
List-Post: <mailto:ietf-dkim@ietf.org>
List-Help: <mailto:ietf-dkim-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/ietf-dkim>, <mailto:ietf-dkim-request@ietf.org?subject=subscribe>
X-List-Received-Date: Mon, 11 Mar 2024 15:55:20 -0000
On Mon, Mar 11, 2024 at 6:50 AM David Harris <David.Harris@pmail.gen.nz> wrote: > Question 1: > > My first question is the exact meaning of this piece of pseudocode: > > body-hash = hash-alg (canon-body, l-param) > > Does this mean: > > 1: Pass the canonicalized body to the hash algorithm, then pass the value > of > any l= tag to the hash algorithm as well. > > -- or -- > > 2: Pass the canonicalized body to the hash algorithm, restricting the > amount > passed to the value of any "l=" tag. > > >From the way the other two pseudocode items are written, (A) would seem > to > be the correct interpretation, but that raises the question of what should > be > passed - a binary form of the l= value? Or a string representation? And > what > should be done if there is no l= tag at all? > (2) It's a pseudocode function to which the value of the "l=" tag (if present) is a parameter. The result is a hash of canon-body; digest all of it if l-param is not present, otherwise digest the first l-param bytes only. > Question 2: > > I am puzzled by the reference to an item called "a-hash-alg" in the NOTE > part at the end of this section: "a-hash-alg" does not appear anywhere > else in > the document, and since it has not been mentioned in an erratum anywhere > (as far as I could see), I assume it must have some specific meaning > defined > somewhere else. Could someone direct me to a reference explaining this > term? > Looks like this is a typo, perhaps warranting an erratum of its own. It should be just "hash-alg". > Question 3: > > The main problem I am having is understanding exactly how the signing > process is meant to be handled: traditionally, you would either use your > hash > algorithm (SHA-256 in this case) to generate a digest of the content, then > have your crypto library (OpenSSL in my case) generate a signature for > that > digest. There are also "streaming" APIs available that perform the hashing > and signing as a combined task. > > I would have assumed from the pseudocode that the intended action here > was to do one of the following: > > * Pass d-domain, selector, and data-hash in that order to an SHA-256 hash > algorithm, then generate an RSA signature using the hash generated by that > process as its digest. > > * Call a streaming RSA-SHA256 API passing each of the three items in the > correct order then finalizing the signature. > > Either of these approaches *should* generate the same signature. The > problem comes from the NOTE section, where it says: > > -------------------------- Cut here ---------------------------- > When using such an API, the last two steps in the > algorithm would probably be combined into a single call that would > perform both the "a-hash-alg" and the "sig-alg". > -------------------------- Cut here ---------------------------- > > It is difficult to interpret this without knowing what "a-hash-alg" means, > but on > the assumption that it is a typo, that suggests that the pseudocode > sections > "data-hash" and "sig-alg" would be rolled into one step -- but I can't see > how > that could work, since "sig-alg" requires "data-hash" (which I understand > to > be an actual hash result) as its input. The NOTE comment seems so at odds > with the two intended actions I described above that I am not sure which > approach is the one I need to take. > > I have spent quite some time trying to perform internet searches to > clarify this > section, but it's historically something I do quite poorly, so if there is > a nice > clean explanation of this somewhere, I'd be really grateful if someone > could > send me a link to it. > > I'm sorry to send such a long message, but hope someone will feel > charitable > enough to help me out on these issues. > The signature is the result of base64-encoding the RSA encryption of the data-hash. The data-hash is the result of passing the canonicalized headers, in order, to the SHA algorithm. The canonicalized headers include, at the end, the incomplete DKIM-Signature field that's under construction. You then append the base64-encoded form of that signature to the incomplete DKIM-Signature field and attach it to the message. In some cases (e.g., OpenSSL) , the call sequence would be: * create a digest object (one API call) * feed it the header fields and so forth, as described (N API calls, depending on how you do the work) * finalize the digest (one API call) * encrypt the digest using the specified key (one API call) Some APIs (e.g., GNUTLS, as I recall) provide a different interface, allowing you to do all of that in a single call. I believe the NOTE you're citing is just emphasizing that the four-step method and the one-step method are equivalent as far as DKIM is concerned; as long as what you end up with is an RSA encryption of the SHA digest, you have what you need. -MSK
- [Ietf-dkim] Question regarding RFC 6376 David Harris
- Re: [Ietf-dkim] Question regarding RFC 6376 Murray S. Kucherawy
- Re: [Ietf-dkim] Question regarding RFC 6376 David Harris
- Re: [Ietf-dkim] Question regarding RFC 6376 Murray S. Kucherawy