Commit 3a9a03c
committed
ssh-key: fix Signature::encode for sk-ecdsa-sha2-nistp256
`Signature`'s `Decode` impl handles the SK signature trailer (flags +
counter) for both `SkEd25519` and `SkEcdsaSha2NistP256`, but the
`Encode` impl only special-cases `SkEd25519`. As a result, an
`sk-ecdsa-sha2-nistp256@openssh.com` signature falls through to the
generic branch, which writes the whole `data` buffer (ECDSA signature
+ flags + counter) as a single length-prefixed string instead of
emitting `string ecdsa_signature || byte flags || uint32 counter`.
Round-tripping such a signature through `Decode` then fails because the
trailer bytes are buried inside the string.
Extend the `Encode` sk-trailer branch to also match
`SkEcdsaSha2NistP256`; the existing trailer-splitting logic is generic
over the trailer size and works unchanged for both algorithms.
Adds `decode_sk_ecdsa_sha2_p256` and `encode_sk_ecdsa_sha2_p256` tests
mirroring the existing sk-ed25519 ones; `encode_sk_ecdsa_sha2_p256`
fails before this change and passes after.1 parent 63e6c1d commit 3a9a03c
1 file changed
Lines changed: 22 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
207 | 207 | | |
208 | 208 | | |
209 | 209 | | |
210 | | - | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
211 | 214 | | |
212 | 215 | | |
213 | 216 | | |
| |||
784 | 787 | | |
785 | 788 | | |
786 | 789 | | |
| 790 | + | |
| 791 | + | |
| 792 | + | |
787 | 793 | | |
788 | 794 | | |
789 | 795 | | |
| |||
857 | 863 | | |
858 | 864 | | |
859 | 865 | | |
| 866 | + | |
| 867 | + | |
| 868 | + | |
| 869 | + | |
| 870 | + | |
| 871 | + | |
860 | 872 | | |
861 | 873 | | |
862 | 874 | | |
| |||
896 | 908 | | |
897 | 909 | | |
898 | 910 | | |
| 911 | + | |
| 912 | + | |
| 913 | + | |
| 914 | + | |
| 915 | + | |
| 916 | + | |
| 917 | + | |
| 918 | + | |
| 919 | + | |
899 | 920 | | |
900 | 921 | | |
901 | 922 | | |
| |||
0 commit comments