|
|
@ -62,12 +62,9 @@ pub fn extract_public_key(content: &str) -> SnekcloudResult<PublicKey> {
|
|
|
|
|
|
|
|
|
|
|
|
/// Extracts a base64 encoded key between the prefix and suffix
|
|
|
|
/// Extracts a base64 encoded key between the prefix and suffix
|
|
|
|
fn extract_key(content: &str, prefix: &str, suffix: &str) -> SnekcloudResult<[u8; 32]> {
|
|
|
|
fn extract_key(content: &str, prefix: &str, suffix: &str) -> SnekcloudResult<[u8; 32]> {
|
|
|
|
let mut content = content
|
|
|
|
if !content.starts_with(prefix) || !content.ends_with(suffix) {}
|
|
|
|
.strip_prefix(prefix)
|
|
|
|
let mut content = content.trim_start_matches(prefix);
|
|
|
|
.ok_or(SnekcloudError::InvalidKey)?;
|
|
|
|
content = content.trim_end_matches(suffix);
|
|
|
|
content = content
|
|
|
|
|
|
|
|
.strip_suffix(suffix)
|
|
|
|
|
|
|
|
.ok_or(SnekcloudError::InvalidKey)?;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let key = base64::decode(content)?;
|
|
|
|
let key = base64::decode(content)?;
|
|
|
|
if key.len() != 32 {
|
|
|
|
if key.len() != 32 {
|
|
|
|