Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

"unknown algorithm" error

Open
#334 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
42/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
rust
Domain
cryptography

Research direction

Start with the Algorithm enum and the PrivateKey::random entry point, using the Cargo.toml and main.rs example to reproduce the runtime error. Trace how algorithm features are defined and gated, then verify that an unavailable algorithm cannot compile or is otherwise rejected before the current "unknown algorithm" runtime failure.

Written by the indexing model from the issue text.

Description

Using ssh-key to create a new PrivateKey using an algorithm which doesn't have the correct crate feature enabled results in a runtime error (unknown algorithm).

The following code compiles fine but panics with an error at runtime.

# Cargo.toml
[dependencies]
ssh-key = "0.6"
// main.rs
use ssh_key::rand_core::OsRng;
use ssh_key::{Algorithm, PrivateKey};

fn main() {
    let private_key = PrivateKey::random(&mut OsRng, Algorithm::Ed25519).unwrap();
    dbg!(&private_key);
}

This is not very rusty. It would be much less surprising if the enum variant Ed25519 of the Algorithm enum would also be guarded by the feature that enables the algorithm.

Dominant language
Rust
Stars
246
Forks
65
Avg merge
3d 2h
Merged PRs (30d)
1

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from RustCrypto/SSH

All issues in RustCrypto/SSH

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.