Package io.levysworks.utilities
Class KeyGenerator
java.lang.Object
io.levysworks.utilities.KeyGenerator
Utility class for generating SSH key pairs and hashing keys.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classProvides hashing functionality for SSH keys.static classRepresents a pair of SSH keys: private and public. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic KeyGenerator.SSHKeyPairGenerates an ECDSA SSH key pair with 256 bits key size.static KeyGenerator.SSHKeyPairGenerates an Ed25519 SSH key pair.static KeyGenerator.SSHKeyPairgenerateKeyPair(String keyType, int keySize) Generates an SSH key pair using the system's ssh-keygen command.static KeyGenerator.SSHKeyPairgenerateRSAKeyPair(int keySize) Generates an RSA SSH key pair with the specified size.static KeyGenerator.SSHKeyPairGenerates an Ed25519 SSH key pair.
-
Constructor Details
-
KeyGenerator
public KeyGenerator()
-
-
Method Details
-
RegisterKeypair
Generates an Ed25519 SSH key pair.- Returns:
- an
KeyGenerator.SSHKeyPaircontaining the private and public keys - Throws:
IOException- if key generation failsInterruptedException- if the process is interrupted
-
generateKeyPair
public static KeyGenerator.SSHKeyPair generateKeyPair(String keyType, int keySize) throws IOException, InterruptedException Generates an SSH key pair using the system's ssh-keygen command.- Parameters:
keyType- the type of keykeySize- the size of the key in bits- Returns:
- generated
KeyGenerator.SSHKeyPair - Throws:
IOException- if an I/O error occursInterruptedException- if the process is interrupted
-
generateRSAKeyPair
public static KeyGenerator.SSHKeyPair generateRSAKeyPair(int keySize) throws IOException, InterruptedException Generates an RSA SSH key pair with the specified size.- Parameters:
keySize- key size in bits- Returns:
- generated RSA
KeyGenerator.SSHKeyPair - Throws:
IOException- if key generation failsInterruptedException- if process interrupted
-
generateECDSAKeyPair
public static KeyGenerator.SSHKeyPair generateECDSAKeyPair() throws IOException, InterruptedExceptionGenerates an ECDSA SSH key pair with 256 bits key size.- Returns:
- generated ECDSA
KeyGenerator.SSHKeyPair - Throws:
IOException- if key generation failsInterruptedException- if process interrupted
-
generateEd25519KeyPair
public static KeyGenerator.SSHKeyPair generateEd25519KeyPair() throws IOException, InterruptedExceptionGenerates an Ed25519 SSH key pair.- Returns:
- generated Ed25519
KeyGenerator.SSHKeyPair - Throws:
IOException- if key generation failsInterruptedException- if process interrupted
-