Skip to content

tests: rename a test and keys to match the actual format - #2479

Closed
vszakats wants to merge 1 commit into
libssh2:masterfrom
vszakats:fixname
Closed

vszakats wants to merge 1 commit into
libssh2:masterfrom
vszakats:fixname

Conversation

@vszakats

@vszakats vszakats commented Aug 2, 2026

Copy link
Copy Markdown
Member

The committed key was in reality rsa-sha2-512, not rsa-sha2-256, as
the filenames suggested.

Also set the type explicitly to rsa-sha2-512, to avoid relying on
ssh-keygen's default (rsa-sha2-512).

$ grep -E -o ' .+ ' id_rsa_sha2_512_signed-cert.pub | base64 -d | strings | grep -i rsa

Bug: #2474
Follow-up to 3a6ab70 #1314

The committed key was in reality `rsa-sha2-512`, not `rsa-sha2-256`, as
the filenames suggested.

Also set the type explicitly to `rsa-sha2-512`, to avoid relying on
ssh-keygen's default (`rsa-sha2-512`).

```shell
$ grep -E -o ' .+ ' id_rsa_sha2_512_signed-cert.pub | base64 -d | strings | grep -i rsa
```

Bug: libssh2#2474
Follow-up to 3a6ab70 libssh2#1314

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Not ready to approve

The newly added private key fixture still embeds the old key_rsa_sha2_256_signed identifier internally, which undermines the rename’s consistency and should be regenerated to match sha2_512.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

This review doesn't count toward merge requirements. Sign up for the private preview to control whether Copilot approvals count.

Pull request overview

This PR aligns the RSA-SHA2 signed certificate test fixtures with the actual signature type used in the committed keys (rsa-sha2-512), avoiding misleading sha2_256 naming and reducing reliance on ssh-keygen defaults when regenerating fixtures.

Changes:

  • Updates the RSA-SHA2 signed-cert auth test to use the id_rsa_sha2_512_signed* keypair paths.
  • Renames test target references and packaged test key artifacts from sha2_256 to sha2_512.
  • Adjusts keys-generate.sh to explicitly request rsa-sha2-512 for the signed cert generation step.
File summaries
File Description
tests/test_auth_pubkey_ok_rsa_sha2_512_signed.c Switches the test to use the id_rsa_sha2_512_signed key/cert fixtures.
tests/Makefile.inc Renames the test binary in DOCKER_TESTS and updates EXTRA_DIST key artifact entries to sha2_512.
tests/keys/id_rsa_sha2_512_signed.pub Updates the public key comment to match the sha2_512 naming.
tests/keys/id_rsa_sha2_512_signed-cert.pub Updates the certificate comment to match the sha2_512 naming.
tests/keys/id_rsa_sha2_512_signed Adds the corresponding OpenSSH private key fixture for the sha2_512 variant.
tests/keys-generate.sh Updates key generation commands to generate/sign the sha2_512 fixture explicitly.
tests/.gitignore Renames the ignored test binary from sha2_256 to sha2_512.
Review details
  • Files reviewed: 6/7 changed files
  • Comments generated: 0
  • Review effort level: Lite

We're testing this review assessment. Please use 👍 or 👎 to tell us if it's correct.

@vszakats vszakats closed this in 7392dc9 Aug 2, 2026
@vszakats
vszakats deleted the fixname branch August 2, 2026 10:20
@vszakats

vszakats commented Aug 2, 2026 •

Copy link
Copy Markdown
Member Author

Thought: storing keys in repo looks more and more like a bad idea
to me, because of issues like the one fixed in this PR, and others when:

  1. someone other than the original commiter needs to reverse-engineer
    the command necessary to generate the key committed as-is.
  2. the committed key wasn't in the format it was intented to be,
    only to find out about it later, and requiring a non-trivial to fix.
  3. the generator scripts (we now use only as a sort of documentation)
    gets out of sync with the key actually stored in repo.
  4. it results in opaque binary blobs in the repo, which is strongly
    not desired since the xz hack attempt.

Dynamically generating the key is possible though it needs to
specify key parameters explicitly to avoid regressing when
ssh-keygen changes defaults depending on version. It also
makes it impossible to generate too old or too modern keys
depending on the ssh-keygen version used at generation-time.
E.g. generating ssh-dss fails with modern OpenSSH versions.
(though in this case maybe libssh2 should not really deal with
that particular insecure/obsolete key type anymore.)

Another technical issue is that the generator script needs to be
rewritten in Perl to avoid POSIX shell as a dependency for Docker
tests when using CMake.

vszakats added a commit that referenced this pull request Aug 2, 2026
…ig` to accept it

Explicitly use `-t ssh-rsa` (signature algorithm) to generate
`id_rsa_signed.pub` to match the purpose of the patch it came with. Also
to differenciate this key (and test) from the subsequently merged
`id_rsa_sha2_512_signed-cert.pub`, which used the exact same keys (`-t
rsa-sha2-512`, the default) before this patch, and made these tests
duplicates.

Also:
- update `sshd_config` to actually allow using an obsolete/insecure
  certificate signature `ssh-rsa`, by adding it to `CASignatureAlgorithms`.
- delete recently added entry from `HostKeyAlgorithms`, it was not
  necessary.
  Follow-up to 5b494b0 #2478

Testing obsolete/insecure algs is not time best spent in CI and for
maintainers, so maybe in a next step it'd useful to disable the RSA
SHA1-based ones by default.

Ref: https://superuser.com/questions/1556852/how-to-check-if-your-ssh-keys-are-in-the-ssh-rsa2-format
Ref: 7392dc9 #2479
Follow-up to 4b21e49 #710

Closes #2474
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants