Drop use of "anyhow".
This commit is contained in:
parent
986094fac8
commit
56d03ffca6
16 changed files with 12 additions and 32 deletions
|
@ -16,7 +16,6 @@ blanket = "0.2.0"
|
|||
nom = "6"
|
||||
hex-literal = "0.3"
|
||||
hex-slice = "0.1"
|
||||
anyhow = "1"
|
||||
thiserror = "1"
|
||||
env_logger = "0.8"
|
||||
log = "0.4"
|
||||
|
|
|
@ -13,7 +13,6 @@ use crate::card_do::ApplicationRelatedData;
|
|||
use crate::crypto_data::EccType;
|
||||
use crate::{keys, Error, KeyType};
|
||||
|
||||
use anyhow::{anyhow, Result};
|
||||
use std::convert::TryFrom;
|
||||
use std::fmt;
|
||||
|
||||
|
@ -32,9 +31,9 @@ pub enum AlgoSimple {
|
|||
}
|
||||
|
||||
impl TryFrom<&str> for AlgoSimple {
|
||||
type Error = anyhow::Error;
|
||||
type Error = crate::Error;
|
||||
|
||||
fn try_from(algo: &str) -> Result<Self, anyhow::Error> {
|
||||
fn try_from(algo: &str) -> Result<Self, Self::Error> {
|
||||
use AlgoSimple::*;
|
||||
|
||||
Ok(match algo {
|
||||
|
@ -46,7 +45,7 @@ impl TryFrom<&str> for AlgoSimple {
|
|||
"NIST384" => NIST384,
|
||||
"NIST521" => NIST521,
|
||||
"Curve25519" => Curve25519,
|
||||
_ => return Err(anyhow!("unexpected algo {}", algo)),
|
||||
_ => return Err(Error::UnsupportedAlgo(format!("unexpected algo {}", algo))),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,6 @@ pub(crate) mod command;
|
|||
pub(crate) mod commands;
|
||||
pub mod response;
|
||||
|
||||
use anyhow::Result;
|
||||
use std::convert::TryFrom;
|
||||
|
||||
use crate::apdu::command::Expect;
|
||||
|
|
|
@ -4,8 +4,6 @@
|
|||
//! Data structure for APDU Commands
|
||||
//! (Commands get sent to the card, which will usually send back a `Response`)
|
||||
|
||||
use anyhow::Result;
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
pub enum Expect {
|
||||
Empty,
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
|
||||
use std::convert::TryFrom;
|
||||
|
||||
use anyhow::Result;
|
||||
use nom::branch::alt;
|
||||
use nom::bytes::complete::tag;
|
||||
use nom::combinator::map;
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
|
||||
use std::convert::TryFrom;
|
||||
|
||||
use anyhow::Result;
|
||||
use nom::branch::alt;
|
||||
use nom::combinator::map;
|
||||
use nom::{branch, bytes::complete as bytes, combinator, multi, sequence};
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
|
||||
//! 4.2.1 Application Identifier (AID)
|
||||
|
||||
use anyhow::Result;
|
||||
use nom::{bytes::complete as bytes, number::complete as number};
|
||||
use std::convert::TryFrom;
|
||||
|
||||
|
|
|
@ -5,8 +5,6 @@
|
|||
|
||||
use std::convert::TryFrom;
|
||||
|
||||
use anyhow::Result;
|
||||
|
||||
use crate::card_do::{CardholderRelatedData, Lang, Sex};
|
||||
use crate::tlv::{value::Value, Tlv};
|
||||
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
//! 4.1.3.1 Extended length information
|
||||
//! (Introduced in V3.0)
|
||||
|
||||
use anyhow::Result;
|
||||
use nom::{bytes::complete::tag, number::complete as number, sequence};
|
||||
|
||||
use crate::card_do::{complete, ExtendedLengthInfo};
|
||||
|
|
|
@ -198,7 +198,6 @@ impl TryFrom<&[u8]> for HistoricalBytes {
|
|||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::*;
|
||||
use anyhow::Result;
|
||||
use std::convert::TryInto;
|
||||
|
||||
#[test]
|
||||
|
@ -210,7 +209,7 @@ mod test {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn test_gnuk() -> Result<()> {
|
||||
fn test_gnuk() -> Result<(), Error> {
|
||||
// gnuk 1.2 stable
|
||||
let data: &[u8] = &[0x0, 0x31, 0x84, 0x73, 0x80, 0x1, 0x80, 0x5, 0x90, 0x0];
|
||||
let hist: HistoricalBytes = data.try_into()?;
|
||||
|
@ -240,7 +239,7 @@ mod test {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn test_floss34() -> Result<()> {
|
||||
fn test_floss34() -> Result<(), Error> {
|
||||
// floss shop openpgp smartcard 3.4
|
||||
let data: &[u8] = &[0x0, 0x31, 0xf5, 0x73, 0xc0, 0x1, 0x60, 0x5, 0x90, 0x0];
|
||||
let hist: HistoricalBytes = data.try_into()?;
|
||||
|
@ -270,7 +269,7 @@ mod test {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn test_yk5() -> Result<()> {
|
||||
fn test_yk5() -> Result<(), Error> {
|
||||
// yubikey 5
|
||||
let data: &[u8] = &[0x0, 0x73, 0x0, 0x0, 0xe0, 0x5, 0x90, 0x0];
|
||||
let hist: HistoricalBytes = data.try_into()?;
|
||||
|
@ -293,7 +292,7 @@ mod test {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn test_yk4() -> Result<()> {
|
||||
fn test_yk4() -> Result<(), Error> {
|
||||
// yubikey 4
|
||||
let data: &[u8] = &[0x0, 0x73, 0x0, 0x0, 0x80, 0x5, 0x90, 0x0];
|
||||
let hist: HistoricalBytes = data.try_into()?;
|
||||
|
@ -316,7 +315,7 @@ mod test {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn test_yk_neo() -> Result<()> {
|
||||
fn test_yk_neo() -> Result<(), Error> {
|
||||
// yubikey neo
|
||||
let data: &[u8] = &[
|
||||
0x0, 0x73, 0x0, 0x0, 0x80, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||
|
@ -341,7 +340,7 @@ mod test {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn test_ledger_nano_s() -> Result<()> {
|
||||
fn test_ledger_nano_s() -> Result<(), Error> {
|
||||
let data: &[u8] = &[
|
||||
0x0, 0x31, 0xc5, 0x73, 0xc0, 0x1, 0x80, 0x7, 0x90, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||
];
|
||||
|
|
|
@ -5,8 +5,6 @@
|
|||
//! Private key data, public key data, cryptograms for decryption, hash
|
||||
//! data for signing.
|
||||
|
||||
use anyhow::Result;
|
||||
|
||||
use crate::algorithm::Algo;
|
||||
use crate::card_do::{Fingerprint, KeyGenerationTime};
|
||||
use crate::Error;
|
||||
|
|
|
@ -37,7 +37,6 @@ mod tlv;
|
|||
pub use crate::errors::{Error, SmartcardError, StatusBytes};
|
||||
pub use crate::openpgp::{OpenPgp, OpenPgpTransaction};
|
||||
|
||||
use anyhow::Result;
|
||||
use std::convert::TryInto;
|
||||
use std::ops::{Deref, DerefMut};
|
||||
|
||||
|
|
|
@ -5,7 +5,6 @@ pub(crate) mod length;
|
|||
pub(crate) mod tag;
|
||||
pub(crate) mod value;
|
||||
|
||||
use anyhow::Result;
|
||||
use nom::{bytes::complete as bytes, combinator};
|
||||
use std::convert::TryFrom;
|
||||
|
||||
|
@ -81,11 +80,11 @@ impl TryFrom<&[u8]> for Tlv {
|
|||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use anyhow::Result;
|
||||
use hex_literal::hex;
|
||||
use std::convert::TryFrom;
|
||||
|
||||
use super::{Tlv, Value};
|
||||
use crate::Error;
|
||||
|
||||
#[test]
|
||||
fn test_tlv0() {
|
||||
|
@ -102,7 +101,7 @@ mod test {
|
|||
);
|
||||
}
|
||||
#[test]
|
||||
fn test_tlv() -> Result<()> {
|
||||
fn test_tlv() -> Result<(), Error> {
|
||||
// From OpenPGP card spec § 7.2.6
|
||||
let data = hex!("5B0B546573743C3C54657374695F2D0264655F350131").to_vec();
|
||||
|
||||
|
@ -127,7 +126,7 @@ mod test {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn test_tlv_yubi5() -> Result<()> {
|
||||
fn test_tlv_yubi5() -> Result<(), Error> {
|
||||
// 'Yubikey 5 NFC' output for GET DATA on "Application Related Data"
|
||||
let data = hex!("6e8201374f10d27600012401030400061601918000005f520800730000e00590007f740381012073820110c00a7d000bfe080000ff0000c106010800001100c206010800001100c306010800001100da06010800001100c407ff7f7f7f030003c5500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c6500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000cd1000000000000000000000000000000000de0801000200030081027f660802020bfe02020bfed6020020d7020020d8020020d9020020");
|
||||
let tlv = Tlv::try_from(&data[..])?;
|
||||
|
|
|
@ -3,8 +3,6 @@
|
|||
|
||||
//! Value in a TLV data structure
|
||||
|
||||
use anyhow::Result;
|
||||
|
||||
use crate::card_do::complete;
|
||||
use crate::tlv::Tlv;
|
||||
|
||||
|
|
|
@ -15,5 +15,4 @@ documentation = "https://docs.rs/crate/openpgp-card-pcsc"
|
|||
openpgp-card = { path = "../openpgp-card", version = "0.1" }
|
||||
iso7816-tlv = "0.4"
|
||||
pcsc = "2.7"
|
||||
anyhow = "1"
|
||||
log = "0.4"
|
||||
|
|
|
@ -15,7 +15,6 @@ documentation = "https://docs.rs/crate/openpgp-card-scdc"
|
|||
openpgp-card = { path = "../openpgp-card", version = "0.1" }
|
||||
sequoia-ipc = "0.26"
|
||||
hex = "0.4"
|
||||
anyhow = "1"
|
||||
futures = "0.3"
|
||||
tokio = "0.2"
|
||||
lazy_static = "1.4"
|
||||
|
|
Loading…
Reference in a new issue