Switch from subtle-encoding to base16ct (#443)

This commit is contained in:
Tony Arcieri (iqlusion)
2022-11-14 15:26:07 -07:00
committed by GitHub
parent 5c4259023f
commit 0a2e798894
6 changed files with 25 additions and 31 deletions
Generated
+2 -11
View File
@@ -1003,15 +1003,6 @@ version = "2.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601"
[[package]]
name = "subtle-encoding"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7dcb1ed7b8330c5eed5441052651dd7a12c75e2ed88f2ec024ae1fa3a5e59945"
dependencies = [
"zeroize",
]
[[package]]
name = "syn"
version = "1.0.103"
@@ -1270,6 +1261,7 @@ dependencies = [
name = "yubikey"
version = "0.6.0"
dependencies = [
"base16ct",
"chrono",
"cookie-factory",
"der-parser",
@@ -1294,7 +1286,6 @@ dependencies = [
"sha2",
"signature",
"subtle",
"subtle-encoding",
"uuid",
"x509",
"x509-parser",
@@ -1305,12 +1296,12 @@ dependencies = [
name = "yubikey-cli"
version = "0.6.0"
dependencies = [
"base16ct",
"clap",
"env_logger",
"log",
"once_cell",
"sha2",
"subtle-encoding",
"termcolor",
"x509-parser",
"yubikey",
+1 -1
View File
@@ -25,6 +25,7 @@ cookie-factory = "0.3"
der-parser = "8"
des = "0.8"
elliptic-curve = "0.12"
hex = { package = "base16ct", version = "0.1", features = ["alloc"] }
hmac = "0.12"
log = "0.4"
nom = "7"
@@ -41,7 +42,6 @@ secrecy = "0.8"
sha1 = { version = "0.10", features = ["oid"] }
sha2 = { version = "0.10", features = ["oid"] }
subtle = "2"
subtle-encoding = "0.5"
uuid = { version = "1.2", features = ["v4"] }
x509 = "0.2"
x509-parser = "0.14"
+1 -1
View File
@@ -17,10 +17,10 @@ rust-version = "1.56"
[dependencies]
clap = { version = "4", features = ["derive"] }
env_logger = "0.9"
hex = { package = "base16ct", version = "0.1", features = ["alloc"] }
log = "0.4"
once_cell = "1"
sha2 = "0.10"
subtle-encoding = "0.5"
termcolor = "1"
x509-parser = "0.14"
yubikey = { version = "0.6", path = ".." }
+1 -2
View File
@@ -8,7 +8,6 @@ use std::{
str,
sync::Mutex,
};
use subtle_encoding::hex;
use termcolor::{Color, ColorChoice, ColorSpec, StandardStream, StandardStreamLock, WriteColor};
use x509_parser::parse_x509_certificate;
use yubikey::{certificate::Certificate, piv::*, YubiKey};
@@ -200,7 +199,7 @@ pub fn print_cert_info(
print_cert_attr(
stream,
"Fingerprint",
str::from_utf8(hex::encode(fingerprint).as_slice()).unwrap(),
&hex::upper::encode_string(&fingerprint),
)?;
print_cert_attr(
stream,
+10 -8
View File
@@ -32,11 +32,7 @@
use crate::{Error, Result, YubiKey};
use rand_core::{OsRng, RngCore};
use std::{
fmt::{self, Debug, Display},
str,
};
use subtle_encoding::hex;
use std::fmt::{self, Debug, Display};
/// CCCID offset
const CCC_ID_OFFS: usize = 9;
@@ -114,8 +110,14 @@ impl CccId {
}
}
impl Display for CccId {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str(str::from_utf8(&hex::encode(&self.0[..])).unwrap())
impl AsRef<[u8]> for CccId {
fn as_ref(&self) -> &[u8] {
&self.0
}
}
impl Display for CccId {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str(&hex::upper::encode_string(self.as_ref()))
}
}
+10 -8
View File
@@ -31,11 +31,7 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
use crate::{Error, Result, YubiKey};
use std::{
fmt::{self, Debug, Display},
str,
};
use subtle_encoding::hex;
use std::fmt::{self, Debug, Display};
use uuid::Uuid;
/// FASC-N offset
@@ -130,8 +126,14 @@ impl ChuId {
}
}
impl Display for ChuId {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str(str::from_utf8(&hex::encode(&self.0[..])).unwrap())
impl AsRef<[u8]> for ChuId {
fn as_ref(&self) -> &[u8] {
&self.0
}
}
impl Display for ChuId {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str(&hex::upper::encode_string(self.as_ref()))
}
}