Import identities whose private key starts with zero bytes

The identity tests failed now and then: one key in 256 has a private
scalar below 2^248, the TeamSpeak export stores it as a DER integer
without the leading zero bytes, and EccKeyPrivP256::from_tomcrypt passed
those fewer than 32 bytes to from_short, which refused them. Such an
identity from the official client could not be imported at all ("no
identity in this file"). The scalar is padded to 32 bytes now; a test
round-trips keys with one, two and 31 leading zero bytes through both
export forms. Local patch 12 in UPSTREAM.md.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
selikhovandClaude Opus 5.5 committed 2026-10-04 04:50:44 +03:00
1 parent a8b0609618
commit 20cc18b556
2 files changed
+32 -2

No files matched your search

+6
View File
@@ -100,3 +100,9 @@ against or offered back to upstream.
(RFC 2782 order). A CNAME among the SRV answers no longer panics. The lookups
are injectable inside the module, and the tests use a fake TSDNS server and
fake names; the upstream tests that need DNS and the internet are `#[ignore]`d.
12. **Private keys with leading zero bytes** (`tsproto-types/src/crypto.rs`,
"Voelin patch"). The TeamSpeak export stores the private scalar as a DER
integer, which drops leading zero bytes, and `EccKeyPrivP256::from_tomcrypt`
handed those fewer than 32 bytes to `from_short`, which refused them: one
identity in 256 (the official client's ones included) could not be imported.
The scalar is padded to 32 bytes now; a test round-trips such keys.