use base64::DecodeError; use ed25519::ED25519PublicImportError; use std::io; #[derive(Debug)] pub enum SSHKeyParseError { DecodeError(DecodeError), IOError(io::Error), NoBeginBannerFound, NoEndBannerFound, NoOpenSSHMagicHeader, UnknownKeyCipher(String), UnknownKDF(String), UnexpectedKDFOptions, InvalidNumberOfKeys(u32), UnknownTrailingData, UnknownKeyType(String), InvalidPublicKeyMaterial, PrivateKeyCorruption, InconsistentKeyTypes(String,String), InconsistentPublicKeyValue, InvalidPrivateKeyValue, InvalidPadding, InvalidPublicKeyType, BrokenPublicKeyLine, UnknownECDSACurve(String), InvalidECPointCompression } impl From for SSHKeyParseError { fn from(e: DecodeError) -> SSHKeyParseError { SSHKeyParseError::DecodeError(e) } } impl From for SSHKeyParseError { fn from(e: io::Error) -> SSHKeyParseError { SSHKeyParseError::IOError(e) } } impl From for SSHKeyParseError { fn from(e: ED25519PublicImportError) -> SSHKeyParseError { match e { ED25519PublicImportError::WrongNumberOfBytes(_) => SSHKeyParseError::InvalidPublicKeyMaterial, ED25519PublicImportError::InvalidPublicPoint => SSHKeyParseError::InvalidPublicKeyMaterial, } } } #[derive(Debug)] pub enum SSHKeyRenderError { IOError(io::Error), StringTooLong, BufferTooLarge, IllegalECDSAKeyType(String) } impl From for SSHKeyRenderError { fn from(e: io::Error) -> SSHKeyRenderError { SSHKeyRenderError::IOError(e) } }