Skip to main content

generate

Function generate 

Source
pub fn generate(
    kind: KeyType,
    bits: Option<u32>,
    comment: &str,
) -> Result<PrivateKey, GitwayError>
Expand description

Generates a new keypair of the requested type.

For ECDSA, the curve is selected by the KeyType variant; bits is ignored. For RSA, bits defaults to 3072 (the OpenSSH minimum recommended value as of 2025). Ed25519 always produces a 256-bit key.

ยงErrors

Returns GitwayError::signing on RNG failure or on an invalid bits value (for RSA: below 2048 or above 16384).