[OAUTH-WG] Query on correct approach of calculating the "x5t#S256" parameter in the JWKS response

Thamindu Dilshan Jayawickrama <thamindudill071@gmail.com> Wed, 10 January 2024 04:11 UTC

Return-Path: <thamindudill071@gmail.com>
X-Original-To: oauth@ietfa.amsl.com
Delivered-To: oauth@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 4F6C2C18DBB4 for <oauth@ietfa.amsl.com>; Tue, 9 Jan 2024 20:11:08 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -6.855
X-Spam-Level:
X-Spam-Status: No, score=-6.855 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_ENVFROM_END_DIGIT=0.25, 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, 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 6WRQg62Ebj10 for <oauth@ietfa.amsl.com>; Tue, 9 Jan 2024 20:11:04 -0800 (PST)
Received: from mail-ed1-x52e.google.com (mail-ed1-x52e.google.com [IPv6:2a00:1450:4864:20::52e]) (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 795DAC18DBAC for <oauth@ietf.org>; Tue, 9 Jan 2024 20:11:04 -0800 (PST)
Received: by mail-ed1-x52e.google.com with SMTP id 4fb4d7f45d1cf-5585fe04266so13683a12.1 for <oauth@ietf.org>; Tue, 09 Jan 2024 20:11:04 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1704859862; x=1705464662; darn=ietf.org; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=EtXpn+tGg9fu2k5TrFflBsgDzc3AdIW9VkyAVXq54j4=; b=gaAOwUhGRvdOCb+Mlc5SeTfieUpBpKiY1buBjRIZiJ+prH6tVCk6sfcekpLMfo7Z2r k5S9N3PHSo2Z6PyM5ABlYedxrsZRTtXfu3X4xA6DXjLV3LSBKbxxdj5bwMiUzCcaMt/T IsUvXXPSb1MUzY/9TNZq23oJVZ792aLZvs9E3tJXwtFLtCacsK/elqmAvYHP3aU2/1af HYJAHl6V3Ka7iR6cc3yWP7QhRO9LJbBeJNniQGwGz+94BvQizOKHhLg4wnseM58Q3Ze8 FJ2MutTp90efevy40mrDlr0Cx4FcuLURBod49mYVvt5gGYhf4I03sOWvy0AvHK3lqyfX ye0A==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704859862; x=1705464662; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=EtXpn+tGg9fu2k5TrFflBsgDzc3AdIW9VkyAVXq54j4=; b=LgX9fBJny3B8yJ692HyJRWfNoi3ecJcbT8tr1C35f9ol6DQ/GdDlNaJAkj6qgHZwDq zCK2GcQ/5CuNGzwz5SpdHzIU8TYQ9nDy231Wn0if3EqZC0JWogRm+nKAUiFd3Nc3tS+g GTM3TlJpp5Dzxj0ToGo5F8EhFruFmpJWVQ8tL557vPYvpMceUvnallTjh7sUtjRFLbmm R3ynOhc8x6LRIDWbYqlhCzkdIxP27ihY2rNAdfYQy0W3+pci7v2V1mYPl0vWsQssFFfo vC7BBd1n4zGFR93Ft0ceS3JfQLmoMoG2qZR0WoAGHauLJTmRbrqlsVXJAYedbotzAqIh RwFg==
X-Gm-Message-State: AOJu0YxeI1T/fHfHLu1wYurzeDkJGPiaXLiPWeAVYgjk8WjWxB73Qklk DznGBxkDn4mskQg0yN03hjKGfBGEIjM21M8U3gpq8IoqGnM=
X-Google-Smtp-Source: AGHT+IGwo1HQTlTvRu4LzvFTBzhplqMFILPFX+5GKe4x1aDptB5qaC3SjxMFbMhXL/0Cot3de6sn7fufPBQnfsS0lmY=
X-Received: by 2002:a17:906:a259:b0:a28:b71d:ac5b with SMTP id bi25-20020a170906a25900b00a28b71dac5bmr186445ejb.131.1704859862355; Tue, 09 Jan 2024 20:11:02 -0800 (PST)
MIME-Version: 1.0
From: Thamindu Dilshan Jayawickrama <thamindudill071@gmail.com>
Date: Wed, 10 Jan 2024 09:40:50 +0530
Message-ID: <CAHv-d+8eMYy7p_Px-dua4of=Y6wd=SyVxF3uyOi_citASskcPQ@mail.gmail.com>
To: oauth@ietf.org
Content-Type: multipart/alternative; boundary="0000000000007cd205060e8f9e27"
Archived-At: <https://mailarchive.ietf.org/arch/msg/oauth/ruo__tJgL077MpnMIMYJecs_1Kk>
Subject: [OAUTH-WG] Query on correct approach of calculating the "x5t#S256" parameter in the JWKS response
X-BeenThere: oauth@ietf.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: OAUTH WG <oauth.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/oauth>, <mailto:oauth-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/oauth/>
List-Post: <mailto:oauth@ietf.org>
List-Help: <mailto:oauth-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/oauth>, <mailto:oauth-request@ietf.org?subject=subscribe>
X-List-Received-Date: Wed, 10 Jan 2024 04:13:36 -0000

Hi all,

I have initiated this mail thread to get your opinion on the correct
approach of calculating the "x5t#S256" parameter in the JWKS response. JWS
specification [1
<https://datatracker.ietf.org/doc/html/rfc7515#section-4.1.8>] defines the
"x5t#S256" parameter as follows.

"""
The "x5t#S256" (X.509 certificate SHA-256 thumbprint) Header
Parameter is a base64url-encoded SHA-256 thumbprint (a.k.a. digest)
of the DER encoding of the X.509 certificate [RFC5280] corresponding
to the key used to digitally sign the JWS.
"""

Different parties seem to be using two different methods when calculating
this field.

*Method 1:*

1. Take DER encoding of the certificate which produces a 32 byte array
2. Take the base64 url encoding

In this method, we compute this "x5t#S256" parameter by directly url
encoding the 32 byte array without taking the hex string. Example given at
appendix A of the MTLS token spec [2
<https://datatracker.ietf.org/doc/html/rfc8705#section-appendix.a>] appears
to be following this method.

*Method 2:*

1. Take DER encoding of the certificate which produces a 32 byte array
2. Convert it into a hexadecimal string and transform it into a 64 byte
array
3. Take the base64 url encoding

In some places I have seen the following approach is used to obtain a value
equal to the "x5t#S256" field.

1. Display the certificate with a tool like Keytool Explorer and copy the
SHA 256 fingerprint.
2. Remove colons (":"s) and convert it to all lowercase.
3. Base64url encode the value.

This approach requires the above hexifing step (method 2) in order to
produce a similar result when computing the "x5t#S256" field.

Hence I would like to query about the correct approach to follow when
calculating the "x5t#S256" parameter. Or can we accept both these forms as
correct methods to calculate the mentioned field?

Thanks in advance.

[1] https://datatracker.ietf.org/doc/html/rfc7515#section-4.1.8
[2] https://datatracker.ietf.org/doc/html/rfc8705#section-appendix.a

Best Regards,
Thamindu Jayawickrama