From 7719078d467777d4784af04086a1e4fc8d4af29e Mon Sep 17 00:00:00 2001 From: David Drysdale Date: Tue, 8 Jun 2021 11:26:24 +0100 Subject: [PATCH] cbor: rename crate to sk-cbor In anticipation of publishing to crates.io, which already has a `cbor` crate. --- Cargo.toml | 2 +- fuzz/fuzz_helper/Cargo.toml | 2 +- fuzz/fuzz_helper/src/lib.rs | 1 + libraries/cbor/Cargo.toml | 2 +- libraries/cbor/fuzz/Cargo.toml | 4 ++-- libraries/cbor/fuzz/fuzz_targets/fuzz_target_cbor.rs | 1 + libraries/cbor/src/macros.rs | 10 +++++----- libraries/crypto/Cargo.toml | 1 - src/ctap/command.rs | 3 ++- src/ctap/config_command.rs | 1 + src/ctap/credential_management.rs | 1 + src/ctap/data_formats.rs | 3 ++- src/ctap/mod.rs | 3 ++- src/ctap/response.rs | 5 ++++- src/ctap/storage.rs | 3 ++- 15 files changed, 26 insertions(+), 16 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 3ed2531..34ae47a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,7 +13,7 @@ edition = "2018" libtock_core = { path = "third_party/libtock-rs/core" } libtock_drivers = { path = "third_party/libtock-drivers" } lang_items = { path = "third_party/lang-items" } -cbor = { path = "libraries/cbor" } +sk-cbor = { path = "libraries/cbor" } crypto = { path = "libraries/crypto" } persistent_store = { path = "libraries/persistent_store" } byteorder = { version = "1", default-features = false } diff --git a/fuzz/fuzz_helper/Cargo.toml b/fuzz/fuzz_helper/Cargo.toml index eccf972..9d4c1d1 100644 --- a/fuzz/fuzz_helper/Cargo.toml +++ b/fuzz/fuzz_helper/Cargo.toml @@ -9,6 +9,6 @@ edition = "2018" arrayref = "0.3.6" libtock_drivers = { path = "../../third_party/libtock-drivers" } crypto = { path = "../../libraries/crypto", features = ['std'] } -cbor = { path = "../../libraries/cbor" } +sk-cbor = { path = "../../libraries/cbor" } ctap2 = { path = "../..", features = ['std'] } lang_items = { path = "../../third_party/lang-items", features = ['std'] } diff --git a/fuzz/fuzz_helper/src/lib.rs b/fuzz/fuzz_helper/src/lib.rs index 1553f65..f7107d2 100644 --- a/fuzz/fuzz_helper/src/lib.rs +++ b/fuzz/fuzz_helper/src/lib.rs @@ -29,6 +29,7 @@ use ctap2::ctap::hid::{ChannelID, CtapHid, HidPacket, Message}; use ctap2::ctap::status_code::Ctap2StatusCode; use ctap2::ctap::CtapState; use libtock_drivers::timer::{ClockValue, Timestamp}; +use sk_cbor as cbor; const COMMAND_INIT: u8 = 0x06; const CHANNEL_BROADCAST: ChannelID = [0xFF, 0xFF, 0xFF, 0xFF]; diff --git a/libraries/cbor/Cargo.toml b/libraries/cbor/Cargo.toml index 913a9fd..5726615 100644 --- a/libraries/cbor/Cargo.toml +++ b/libraries/cbor/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "cbor" +name = "sk-cbor" version = "0.1.0" authors = [ "Fabian Kaczmarczyck ", diff --git a/libraries/cbor/fuzz/Cargo.toml b/libraries/cbor/fuzz/Cargo.toml index e1374e6..150e2a4 100644 --- a/libraries/cbor/fuzz/Cargo.toml +++ b/libraries/cbor/fuzz/Cargo.toml @@ -1,6 +1,6 @@ [package] -name = "cbor-fuzz" +name = "sk-cbor-fuzz" version = "0.0.0" authors = ["Automatically generated"] publish = false @@ -12,7 +12,7 @@ cargo-fuzz = true [dependencies] libfuzzer-sys = "0.3" -[dependencies.cbor] +[dependencies.sk-cbor] path = ".." # Prevent this from interfering with workspaces diff --git a/libraries/cbor/fuzz/fuzz_targets/fuzz_target_cbor.rs b/libraries/cbor/fuzz/fuzz_targets/fuzz_target_cbor.rs index 2f7e870..2bacc55 100644 --- a/libraries/cbor/fuzz/fuzz_targets/fuzz_target_cbor.rs +++ b/libraries/cbor/fuzz/fuzz_targets/fuzz_target_cbor.rs @@ -3,6 +3,7 @@ extern crate alloc; use alloc::vec::Vec; use libfuzzer_sys::fuzz_target; +use sk_cbor as cbor; fuzz_target!(|data: &[u8]| { if let Ok(value) = cbor::read(data) { diff --git a/libraries/cbor/src/macros.rs b/libraries/cbor/src/macros.rs index 3cde9f5..d8a4726 100644 --- a/libraries/cbor/src/macros.rs +++ b/libraries/cbor/src/macros.rs @@ -36,7 +36,7 @@ use core::iter::Peekable; /// /// ```rust /// # extern crate alloc; -/// # use cbor::destructure_cbor_map; +/// # use sk_cbor::destructure_cbor_map; /// # /// # fn main() { /// # let map = alloc::vec::Vec::new(); @@ -143,7 +143,7 @@ macro_rules! assert_sorted_keys { /// /// ```rust /// # extern crate alloc; -/// # use cbor::cbor_map; +/// # use sk_cbor::cbor_map; /// let map = cbor_map! { /// 0x01 => false, /// "02" => -3, @@ -182,7 +182,7 @@ macro_rules! cbor_map { /// /// ```rust /// # extern crate alloc; -/// # use cbor::cbor_map_options; +/// # use sk_cbor::cbor_map_options; /// let missing_value: Option = None; /// let map = cbor_map_options! { /// 0x01 => Some(false), @@ -232,7 +232,7 @@ macro_rules! cbor_map_collection { /// /// ```rust /// # extern crate alloc; -/// # use cbor::cbor_array; +/// # use sk_cbor::cbor_array; /// let array = cbor_array![1, "2"]; /// ``` #[macro_export] @@ -339,7 +339,7 @@ macro_rules! cbor_bytes { /// /// ```rust /// # extern crate alloc; -/// # use cbor::cbor_bytes_lit; +/// # use sk_cbor::cbor_bytes_lit; /// let byte_array = cbor_bytes_lit!(b"foo"); /// ``` #[macro_export] diff --git a/libraries/crypto/Cargo.toml b/libraries/crypto/Cargo.toml index a73b694..7c0a45f 100644 --- a/libraries/crypto/Cargo.toml +++ b/libraries/crypto/Cargo.toml @@ -11,7 +11,6 @@ edition = "2018" [dependencies] libtock_drivers = { path = "../../third_party/libtock-drivers" } -cbor = { path = "../cbor" } arrayref = "0.3.6" subtle = { version = "2.2.3", default-features = false, features = ["nightly"] } byteorder = { version = "1", default-features = false } diff --git a/src/ctap/command.rs b/src/ctap/command.rs index 387a687..db4b07c 100644 --- a/src/ctap/command.rs +++ b/src/ctap/command.rs @@ -26,8 +26,9 @@ use super::status_code::Ctap2StatusCode; use alloc::string::String; use alloc::vec::Vec; use arrayref::array_ref; -use cbor::destructure_cbor_map; use core::convert::TryFrom; +use sk_cbor as cbor; +use sk_cbor::destructure_cbor_map; // This constant is a consequence of the structure of messages. const MIN_LARGE_BLOB_LEN: usize = 17; diff --git a/src/ctap/config_command.rs b/src/ctap/config_command.rs index bdedc6b..943366a 100644 --- a/src/ctap/config_command.rs +++ b/src/ctap/config_command.rs @@ -20,6 +20,7 @@ use super::response::ResponseData; use super::status_code::Ctap2StatusCode; use super::storage::PersistentStore; use alloc::vec; +use sk_cbor as cbor; /// Processes the subcommand enableEnterpriseAttestation for AuthenticatorConfig. fn process_enable_enterprise_attestation( diff --git a/src/ctap/credential_management.rs b/src/ctap/credential_management.rs index b81648a..e99e86e 100644 --- a/src/ctap/credential_management.rs +++ b/src/ctap/credential_management.rs @@ -30,6 +30,7 @@ use alloc::vec::Vec; use crypto::sha256::Sha256; use crypto::Hash256; use libtock_drivers::timer::ClockValue; +use sk_cbor as cbor; /// Generates a set with all existing RP IDs. fn get_stored_rp_ids( diff --git a/src/ctap/data_formats.rs b/src/ctap/data_formats.rs index be76b65..bd1d74c 100644 --- a/src/ctap/data_formats.rs +++ b/src/ctap/data_formats.rs @@ -16,11 +16,12 @@ use super::status_code::Ctap2StatusCode; use alloc::string::String; use alloc::vec::Vec; use arrayref::array_ref; -use cbor::{cbor_array_vec, cbor_map, cbor_map_options, destructure_cbor_map}; use core::convert::TryFrom; use crypto::{ecdh, ecdsa}; #[cfg(test)] use enum_iterator::IntoEnumIterator; +use sk_cbor as cbor; +use sk_cbor::{cbor_array_vec, cbor_map, cbor_map_options, destructure_cbor_map}; // Used as the identifier for ECDSA in assertion signatures and COSE. const ES256_ALGORITHM: i64 = -7; diff --git a/src/ctap/mod.rs b/src/ctap/mod.rs index eaca021..c1f069b 100644 --- a/src/ctap/mod.rs +++ b/src/ctap/mod.rs @@ -68,7 +68,6 @@ use alloc::vec; use alloc::vec::Vec; use arrayref::array_ref; use byteorder::{BigEndian, ByteOrder}; -use cbor::cbor_map_options; use core::convert::TryFrom; #[cfg(feature = "debug_ctap")] use core::fmt::Write; @@ -80,6 +79,8 @@ use crypto::Hash256; use libtock_drivers::console::Console; use libtock_drivers::crp; use libtock_drivers::timer::{ClockValue, Duration}; +use sk_cbor as cbor; +use sk_cbor::cbor_map_options; pub const INITIAL_SIGNATURE_COUNTER: u32 = 1; // Our credential ID consists of diff --git a/src/ctap/response.rs b/src/ctap/response.rs index 765403d..4661a37 100644 --- a/src/ctap/response.rs +++ b/src/ctap/response.rs @@ -19,7 +19,10 @@ use super::data_formats::{ }; use alloc::string::String; use alloc::vec::Vec; -use cbor::{cbor_array_vec, cbor_bool, cbor_int, cbor_map_collection, cbor_map_options, cbor_text}; +use sk_cbor as cbor; +use sk_cbor::{ + cbor_array_vec, cbor_bool, cbor_int, cbor_map_collection, cbor_map_options, cbor_text, +}; #[derive(Debug, PartialEq)] pub enum ResponseData { diff --git a/src/ctap/storage.rs b/src/ctap/storage.rs index 084cc1b..77afb46 100644 --- a/src/ctap/storage.rs +++ b/src/ctap/storage.rs @@ -32,11 +32,12 @@ use alloc::string::String; use alloc::vec; use alloc::vec::Vec; use arrayref::array_ref; -use cbor::cbor_array_vec; use core::cmp; use core::convert::TryInto; use crypto::rng256::Rng256; use persistent_store::{fragment, StoreUpdate}; +use sk_cbor as cbor; +use sk_cbor::cbor_array_vec; /// Wrapper for master keys. pub struct MasterKeys {