diff options
author | Daniel Mueller <deso@posteo.net> | 2017-03-28 20:06:42 -0700 |
---|---|---|
committer | Daniel Mueller <deso@posteo.net> | 2017-03-28 20:06:42 -0700 |
commit | a0c6480aa6b1c6dad45b67e5bc7c29c5f0a4bb0e (patch) | |
tree | b8698743b3d77b23147a49fd15a8d313340c1a8b /nitrocli/src/pinentry.rs | |
parent | fdd34d1ac10e37b3e0683a3c716665f50684596b (diff) | |
download | nitrocli-a0c6480aa6b1c6dad45b67e5bc7c29c5f0a4bb0e.tar.gz nitrocli-a0c6480aa6b1c6dad45b67e5bc7c29c5f0a4bb0e.tar.bz2 |
Send HID feature report to open/close the encrypted volume
With this change we assemble a HID feature report and send it to the
nitrokey device. Feature reports are the objects used for sending
commands to the nitrokey. We create two different reports for
opening and closing of the encrypted volume.
Diffstat (limited to 'nitrocli/src/pinentry.rs')
-rw-r--r-- | nitrocli/src/pinentry.rs | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/nitrocli/src/pinentry.rs b/nitrocli/src/pinentry.rs index eabf598..3fb533a 100644 --- a/nitrocli/src/pinentry.rs +++ b/nitrocli/src/pinentry.rs @@ -17,7 +17,7 @@ // * along with this program. If not, see <http://www.gnu.org/licenses/>. * // ************************************************************************* -use error::Error as Error; +use error::Error; use std::process; @@ -50,14 +50,11 @@ fn parse_pinentry_passphrase(response: Vec<u8>) -> Result<Vec<u8>, Error> { pub fn inquire_passphrase() -> Result<Vec<u8>, Error> { - const PINENTRY_DESCR: &'static str = "+"; - const PINENTRY_TITLE: &'static str = "Please+enter+user+PIN"; + const PINENTRY_DESCR: &'static str = "+"; + const PINENTRY_TITLE: &'static str = "Please+enter+user+PIN"; const PINENTRY_PASSWD: &'static str = "PIN"; - let args = vec![CACHE_ID, - PINENTRY_DESCR, - PINENTRY_PASSWD, - PINENTRY_TITLE].join(" "); + let args = vec![CACHE_ID, PINENTRY_DESCR, PINENTRY_PASSWD, PINENTRY_TITLE].join(" "); let command = "GET_PASSPHRASE --data ".to_string() + &args; // We could also use the --data parameter here to have a more direct // representation of the passphrase but the resulting response was @@ -65,10 +62,9 @@ pub fn inquire_passphrase() -> Result<Vec<u8>, Error> { // reported for the GET_PASSPHRASE command does not actually cause // gpg-connect-agent to exit with a non-zero error code, we have to // evaluate the output to determine success/failure. - let output = process::Command::new("gpg-connect-agent") - .arg(command) - .arg("/bye") - .output()?; + let output = process::Command::new("gpg-connect-agent").arg(command) + .arg("/bye") + .output()?; return parse_pinentry_passphrase(output.stdout); } |