From: "Shannon Sterz" <s.sterz@proxmox.com>
To: "Mark Atwood" <mark@wolfssl.com>, <pve-devel@lists.proxmox.com>
Subject: Re: [PATCH common v2 2/2] ticket: allow signing RSA tickets with SHA-256
Date: Tue, 17 Nov 2026 17:05:24 +0100 [thread overview]
Message-ID: <DMXM4ET1THGM.2OI5FZYFSA0KY@proxmox.com> (raw)
In-Reply-To: <20261113030639.3514-3-mark@wolfssl.com>
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 <mark@wolfssl.com>
> ---
> 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) = @_;
> + my ($rsa_priv, $prefix, $data, $secret_data, $hash) = @_;
> +
> + $hash //= 'sha1';
> + die "unsupported ticket signature hash '$hash'\n" if $hash ne 'sha1' && $hash ne 'sha256';
>
> my $timestamp = sprintf("%08X", time());
>
> @@ -66,6 +72,12 @@ sub assemble_rsa_ticket {
>
> my $full = defined($secret_data) ? "$plain:$secret_data" : $plain;
>
> + if ($hash eq 'sha256') {
> + $rsa_priv->use_sha256_hash();
> + } else {
> + $rsa_priv->use_sha1_hash();
> + }
> +
> my $ticket = $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 noerr");
>
> +# which digest was used when signing, checked by verifying with the digest forced
> +my sub signed_with($ticket, $hash) {
> + my $pub = 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) = $ticket =~ m/^(\S+)::(\S+)$/;
> + return $pub->verify($plain, decode_base64($sig)) ? 1 : 0;
> +}
> +
> +my $sha1_ticket = PVE::Ticket::assemble_rsa_ticket($rsa_priv, 'PVE', 'root@pam');
> +my $default_ticket = 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<--
prev parent reply other threads:[~2026-11-17 16:05 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-13 3:06 [PATCH common v2 0/2] ticket: sign RSA tickets with SHA-256, opt-in Mark Atwood
2026-11-13 3:06 ` [PATCH common v2 1/2] ticket: accept RSA tickets signed with SHA-256 Mark Atwood
2026-11-17 16:05 ` Shannon Sterz
2026-11-13 3:06 ` [PATCH common v2 2/2] ticket: allow signing RSA tickets " Mark Atwood
2026-11-17 16:05 ` Shannon Sterz [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=DMXM4ET1THGM.2OI5FZYFSA0KY@proxmox.com \
--to=s.sterz@proxmox.com \
--cc=mark@wolfssl.com \
--cc=pve-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox