From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [IPv6:2a0f:8001:1:32::40]) by lore.proxmox.com (Postfix) with ESMTPS id 0D8251FF0AA for ; Tue, 17 Nov 2026 17:05:38 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 3AD25216B2; Tue, 17 Nov 2026 17:05:28 +0100 (CET) Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Tue, 17 Nov 2026 17:05:24 +0100 Message-Id: Subject: Re: [PATCH common v2 2/2] ticket: allow signing RSA tickets with SHA-256 To: "Mark Atwood" , X-Mailer: aerc 0.20.0 References: <20261113030639.3514-1-mark@wolfssl.com> <20261113030639.3514-3-mark@wolfssl.com> In-Reply-To: <20261113030639.3514-3-mark@wolfssl.com> From: "Shannon Sterz" X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1794931524381 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.574 Adjusted score from AWL reputation of From: address DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment (newer systems) RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: EVDAAABETLSMJ5ACXXYV2ERIRX56WOLR X-Message-ID-Hash: EVDAAABETLSMJ5ACXXYV2ERIRX56WOLR X-MailFrom: s.sterz@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: On Fri Nov 13, 2026 at 4:06 AM CET, Mark Atwood wrote: > Add an optional hash parameter to assemble_rsa_ticket(), either 'sha1' > or 'sha256'. It defaults to 'sha1', so existing callers get the same > tickets as before. Callers that need SHA-256 signatures, like for > running with providers that refuse SHA-1, can opt in. This also > affects Proxmox Mail Gateway, which uses PVE::Ticket too, but only for > callers that pass the parameter. > > Nodes that do not accept SHA-256 tickets yet, i.e. without the previous > patch, reject them, so callers should only pass 'sha256' once all > nodes that verify the tickets accept them. > > The digest is set on the private key object explicitly on every call, > as it is state of the object that earlier calls would otherwise leak > into later ones. > > The tests check the digest that was used by verifying the signatures > with a public key that only accepts a single one. > > Signed-off-by: Mark Atwood > --- > src/PVE/Ticket.pm | 14 +++++++++++++- > test/ticket_test.pl | 36 ++++++++++++++++++++++++++++++++++++ > 2 files changed, 49 insertions(+), 1 deletion(-) > > diff --git a/src/PVE/Ticket.pm b/src/PVE/Ticket.pm > index f20ab5d..a4a593b 100644 > --- a/src/PVE/Ticket.pm > +++ b/src/PVE/Ticket.pm > @@ -50,8 +50,14 @@ sub verify_csrf_prevention_token { > } > > # Note: data may not contain white spaces (verify fails in that case) > +# > +# $hash selects the digest of the RSA signature, either 'sha1' (default)= or 'sha256'. The digest is > +# set explicitly on every call, as it is state of the $rsa_priv object. > sub assemble_rsa_ticket { > - my ($rsa_priv, $prefix, $data, $secret_data) =3D @_; > + my ($rsa_priv, $prefix, $data, $secret_data, $hash) =3D @_; > + > + $hash //=3D 'sha1'; > + die "unsupported ticket signature hash '$hash'\n" if $hash ne 'sha1'= && $hash ne 'sha256'; > > my $timestamp =3D sprintf("%08X", time()); > > @@ -66,6 +72,12 @@ sub assemble_rsa_ticket { > > my $full =3D defined($secret_data) ? "$plain:$secret_data" : $plain; > > + if ($hash eq 'sha256') { > + $rsa_priv->use_sha256_hash(); > + } else { > + $rsa_priv->use_sha1_hash(); > + } > + > my $ticket =3D $plain . "::" . encode_base64($rsa_priv->sign($full),= ''); > > return $ticket; > diff --git a/test/ticket_test.pl b/test/ticket_test.pl > index ee4212a..eb495b8 100755 > --- a/test/ticket_test.pl > +++ b/test/ticket_test.pl > @@ -92,6 +92,42 @@ for my $hash ('sha1', 'sha256') { > is(eval { verify_fixed('sha256', $rsa_pub, 0) }, undef, "ticket of other= key is rejected"); > like($@, qr/invalid PVE ticket/, "ticket of other key raises without noe= rr"); > > +# which digest was used when signing, checked by verifying with the dige= st forced > +my sub signed_with($ticket, $hash) { > + my $pub =3D Crypt::OpenSSL::RSA->new_public_key($rsa_pub->get_public= _key_string()); > + $hash eq 'sha256' ? $pub->use_sha256_hash() : $pub->use_sha1_hash(); > + my ($plain, $sig) =3D $ticket =3D~ m/^(\S+)::(\S+)$/; > + return $pub->verify($plain, decode_base64($sig)) ? 1 : 0; > +} > + > +my $sha1_ticket =3D PVE::Ticket::assemble_rsa_ticket($rsa_priv, 'PVE', '= root@pam'); > +my $default_ticket =3D PVE::Ticket::assemble_rsa_ticket($rsa_priv, 'PVE'= , 'root@pam', undef, undef); nit: maybe the first should be `$default_ticket` and the second `$undef_ticket` so that the variable name reflects the parameters passed to `assemble_rsa_ticket()`. it would also allow to call `$sha1_again` `$sha1_ticket`. -->8 snip 8<--