wala-rust

Unnamed repository; edit this file 'description' to name the repository.
Info | Log | Files | Refs | README | LICENSE

commit 3273d86ab4b211eeffa4ecd4a0cab58f92119a2c
parent 7b9c7b0d40f511ca9286f87ed2a8b86878fa145c
Author: lash <dev@holbrook.no>
Date:   Fri, 24 Jun 2022 10:44:45 +0000

Add pubsig auth scheme specifier

Diffstat:
Msrc/auth/mod.rs | 21++++++++++++++++++++-
Msrc/auth/pgp.rs | 6+++---
2 files changed, 23 insertions(+), 4 deletions(-)

diff --git a/src/auth/mod.rs b/src/auth/mod.rs @@ -55,7 +55,26 @@ impl FromStr for AuthSpec { type Err = AuthSpecError; fn from_str(s: &str) -> Result<AuthSpec, AuthSpecError> { - let mut auth_fields = s.split(":"); + let mut auth_kv = s.split(" "); + match auth_kv.next() { + Some(v) => { + if v != "PUBSIG" { + return Err(AuthSpecError{}); + } + }, + _ => {}, + }; + + let ss = match auth_kv.next() { + Some(v) => { + v + }, + _ => { + return Err(AuthSpecError{}); + }, + }; + + let mut auth_fields = ss.split(":"); if auth_fields.clone().count() != 3 { return Err(AuthSpecError{}) } diff --git a/src/auth/pgp.rs b/src/auth/pgp.rs @@ -186,7 +186,7 @@ mod tests { let sig_foo_single = hex::decode(&sig_foo_single_hex).unwrap(); let sig_foo_single_base64 = base64::encode(&sig_foo_single); - let auth_spec_str = format!("pgp:{}:{}", key_single_base64, sig_foo_single_base64); + let auth_spec_str = format!("PUBSIG pgp:{}:{}", key_single_base64, sig_foo_single_base64); let auth_spec = AuthSpec::from_str(&auth_spec_str).unwrap(); let data = b"foo"; @@ -241,7 +241,7 @@ mod tests { let sig_foo_single = hex::decode(&sig_foo_single_hex).unwrap(); let sig_foo_single_base64 = base64::encode(&sig_foo_single); - let auth_spec_str = format!("pgp:{}:{}", key_single_base64, sig_foo_single_base64); + let auth_spec_str = format!("PUBSIG pgp:{}:{}", key_single_base64, sig_foo_single_base64); let auth_spec = AuthSpec::from_str(&auth_spec_str).unwrap(); let data = b"foo"; @@ -266,7 +266,7 @@ mod tests { let sig_foo_bundle = hex::decode(&sig_foo_bundle_hex).unwrap(); let sig_foo_bundle_base64 = base64::encode(&sig_foo_bundle); - let auth_spec_str = format!("pgp:{}:{}", key_bundle_base64, sig_foo_bundle_base64); + let auth_spec_str = format!("PUBSIG pgp:{}:{}", key_bundle_base64, sig_foo_bundle_base64); let auth_spec = AuthSpec::from_str(&auth_spec_str).unwrap(); let data = b"foo";