Files
simple_crypto/src/ssh/errors.rs

55 lines
1.3 KiB
Rust

use base64::DecodeError;
use simple_asn1::ASN1DecodeErr;
use std::io;
#[derive(Debug)]
pub enum SSHKeyParseError
{
ASN1Error(ASN1DecodeErr),
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
}
impl From<ASN1DecodeErr> for SSHKeyParseError {
fn from(e: ASN1DecodeErr) -> SSHKeyParseError {
println!("asn1 error: {:?}", e);
SSHKeyParseError::ASN1Error(e)
}
}
impl From<DecodeError> for SSHKeyParseError {
fn from(e: DecodeError) -> SSHKeyParseError {
SSHKeyParseError::DecodeError(e)
}
}
impl From<io::Error> for SSHKeyParseError {
fn from(e: io::Error) -> SSHKeyParseError {
SSHKeyParseError::IOError(e)
}
}
#[derive(Debug)]
pub enum SSHKeyRenderError {
IOError(io::Error),
StringTooLong,
BufferTooLarge
}
impl From<io::Error> for SSHKeyRenderError {
fn from(e: io::Error) -> SSHKeyRenderError {
SSHKeyRenderError::IOError(e)
}
}