fix: verify_oneshot, maybe makes a difference?
This commit is contained in:
parent
652af15771
commit
5d3c222774
2 changed files with 6 additions and 3 deletions
|
@ -17,6 +17,9 @@ pub enum UpubError {
|
||||||
|
|
||||||
#[error("fetch error: {0}")]
|
#[error("fetch error: {0}")]
|
||||||
Reqwest(#[from] reqwest::Error),
|
Reqwest(#[from] reqwest::Error),
|
||||||
|
|
||||||
|
#[error("invalid base64 string: {0}")]
|
||||||
|
Base64(#[from] base64::DecodeError),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl UpubError {
|
impl UpubError {
|
||||||
|
|
|
@ -89,9 +89,9 @@ where
|
||||||
|
|
||||||
fn verify_control_text(txt: &str, key: &str, control: &str) -> crate::Result<bool> {
|
fn verify_control_text(txt: &str, key: &str, control: &str) -> crate::Result<bool> {
|
||||||
let pubkey = PKey::public_key_from_pem(key.as_bytes())?;
|
let pubkey = PKey::public_key_from_pem(key.as_bytes())?;
|
||||||
let mut verifier = Verifier::new(MessageDigest::sha256(), &pubkey).unwrap();
|
let mut verifier = Verifier::new(MessageDigest::sha256(), &pubkey)?;
|
||||||
verifier.update(txt.as_bytes())?;
|
let signature = base64::prelude::BASE64_URL_SAFE.decode(control)?;
|
||||||
Ok(verifier.verify(&base64::prelude::BASE64_URL_SAFE.decode(control).unwrap_or_default())?)
|
Ok(verifier.verify_oneshot(&signature, txt.as_bytes())?)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue