From 7d6d4f4a68cccc65895b03bacf197c99d92b55ed Mon Sep 17 00:00:00 2001 From: Jaro Fietz Date: Tue, 30 Aug 2022 06:26:03 +0200 Subject: [PATCH] Add no_std support (#7) * Add no_std support * Don't depend on dependencies' std features in std --- Cargo.toml | 4 +++- src/lib.rs | 6 ++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index f399b52..d1a2978 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,11 +13,13 @@ keywords = ["encryption", "xts"] exclude = ["test_files"] [features] +default = ["std"] +std = [] openssl_tests = ["openssl"] [dependencies] cipher = "0.4" -byteorder = "1" +byteorder = { version = "1", default-features = false } # Is actually a dev-dependency enabled only for/by openssl_tests, but dev-dependencies can't be # optional openssl = { version = "0.10", optional = true } diff --git a/src/lib.rs b/src/lib.rs index 6abc39c..07870af 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,3 +1,5 @@ +#![cfg_attr(not(feature = "std"), no_std)] + /*! [XTS block mode](https://en.wikipedia.org/wiki/Disk_encryption_theory#XEX-based_tweaked-codebook_mode_with_ciphertext_stealing_(XTS)) implementation in Rust. @@ -122,8 +124,8 @@ xts.decrypt_area(&mut buffer[0x400..0xC00], 0x200, 2, get_nintendo_tweak); ``` */ -use std::convert::TryFrom; -use std::convert::TryInto; +use core::convert::TryFrom; +use core::convert::TryInto; use byteorder::{ByteOrder, LittleEndian}; use cipher::generic_array::typenum::Unsigned;