add non existing token
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
shimun 2020-06-19 20:08:32 +02:00
parent ddfd24a098
commit 5f107cd337
Signed by: shimun
GPG Key ID: E81D8382DC2F971B
3 changed files with 10 additions and 6 deletions

2
Cargo.lock generated
View File

@ -369,7 +369,7 @@ dependencies = [
[[package]] [[package]]
name = "fido2luks" name = "fido2luks"
version = "0.2.8" version = "0.2.9"
dependencies = [ dependencies = [
"ctap_hmac", "ctap_hmac",
"failure", "failure",

View File

@ -1,6 +1,6 @@
[package] [package]
name = "fido2luks" name = "fido2luks"
version = "0.2.8" version = "0.2.9"
authors = ["shimunn <shimun@shimun.net>"] authors = ["shimunn <shimun@shimun.net>"]
edition = "2018" edition = "2018"

View File

@ -235,11 +235,15 @@ pub fn replace_key<P: AsRef<Path>>(
if let Some(id) = credential_id { if let Some(id) = credential_id {
if check_luks2(&mut device).is_ok() { if check_luks2(&mut device).is_ok() {
let token = find_token(&mut device, slot)?.map(|(t, _)| t); let token = find_token(&mut device, slot)?.map(|(t, _)| t);
let json = serde_json::to_value(&Fido2LuksToken::new(id, slot)).unwrap();
if let Some(token) = token { if let Some(token) = token {
device.token_handle().json_set(TokenInput::ReplaceToken( device
token, .token_handle()
&serde_json::to_value(&Fido2LuksToken::new(id, slot)).unwrap(), .json_set(TokenInput::ReplaceToken(token, &json))?;
))?; } else {
device
.token_handle()
.json_set(TokenInput::AddToken(&json))?;
} }
} }
} }