[CHECKPOINT] Starting to parse these things.

This commit is contained in:
2019-03-28 18:23:38 -07:00
parent 47fae77a4f
commit 69cef498f2
6 changed files with 241 additions and 1 deletions

42
src/ssh/errors.rs Normal file
View File

@@ -0,0 +1,42 @@
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
}
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)
}
}
pub enum SSHKeyRenderError {
IOError(io::Error),
}
impl From<io::Error> for SSHKeyRenderError {
fn from(e: io::Error) -> SSHKeyRenderError {
SSHKeyRenderError::IOError(e)
}
}