diff --git a/Cargo.toml b/Cargo.toml index 6bbc55a..bada9b9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,16 +1,16 @@ [package] name = "libsm" -version = "0.4.1" +version = "0.5.0" authors = [ "Tang Zongxun ", "Niu Junxiang <494521900@qq.com>", "yieazy ", "Rivtower Technologies " ] - description = "A Rust Library of China's Standards of Encryption Algorithms (SM2/3/4)" keywords = ["cipher", "cryptography"] license = "Apache-2.0" +edition = "2021" [dependencies] rand = "0.8" diff --git a/src/sm2/ecc.rs b/src/sm2/ecc.rs index 3a2f024..6f62250 100644 --- a/src/sm2/ecc.rs +++ b/src/sm2/ecc.rs @@ -606,7 +606,7 @@ impl Point { } } -use sm2::error::{Sm2Error, Sm2Result}; +use crate::sm2::error::{Sm2Error, Sm2Result}; use std::fmt; impl fmt::Display for Point { @@ -780,10 +780,11 @@ mod tests { #[cfg(feature = "internal_benches")] mod internal_benches { + use crate::sm2::ecc::EccCtx; + use crate::sm2::field::FieldElem; + use num_bigint::BigUint; use num_traits::Num; - use sm2::ecc::EccCtx; - use sm2::field::FieldElem; extern crate test; diff --git a/src/sm2/encrypt.rs b/src/sm2/encrypt.rs index 3154e94..7e782a6 100644 --- a/src/sm2/encrypt.rs +++ b/src/sm2/encrypt.rs @@ -1,10 +1,9 @@ use num_bigint::BigUint; use num_traits::One; -use crate::{sm2::util::kdf, sm3::hash::Sm3Hash}; - use super::ecc::{EccCtx, Point}; -use sm2::error::{Sm2Error, Sm2Result}; +use crate::sm2::error::{Sm2Error, Sm2Result}; +use crate::{sm2::util::kdf, sm3::hash::Sm3Hash}; pub struct EncryptCtx { klen: usize, diff --git a/src/sm2/exchange.rs b/src/sm2/exchange.rs index aadd4c2..1b8a2c6 100644 --- a/src/sm2/exchange.rs +++ b/src/sm2/exchange.rs @@ -1,10 +1,11 @@ use super::ecc::*; use super::util::kdf; +use crate::sm2::error::{Sm2Error, Sm2Result}; +use crate::sm3::hash::Sm3Hash; + use byteorder::{BigEndian, WriteBytesExt}; use num_bigint::BigUint; use num_traits::*; -use sm2::error::{Sm2Error, Sm2Result}; -use sm3::hash::Sm3Hash; fn compute_z(id: &str, pk: &Point) -> Sm2Result<[u8; 32]> { let curve = EccCtx::new(); diff --git a/src/sm2/field.rs b/src/sm2/field.rs index 78645df..e6cbbcb 100644 --- a/src/sm2/field.rs +++ b/src/sm2/field.rs @@ -14,10 +14,11 @@ // Implementation of the prime field(SCA-256) used by SM2 +use crate::sm2::error::{Sm2Error, Sm2Result}; + use byteorder::{BigEndian, ReadBytesExt, WriteBytesExt}; use num_bigint::BigUint; use num_traits::Num; -use sm2::error::{Sm2Error, Sm2Result}; use std::io::Cursor; pub struct FieldCtx { diff --git a/src/sm2/signature.rs b/src/sm2/signature.rs index 2fc89ce..14d19c4 100644 --- a/src/sm2/signature.rs +++ b/src/sm2/signature.rs @@ -12,17 +12,16 @@ // See the License for the specific language governing permissions and // limitations under the License. +use crate::sm2::error::{Sm2Error, Sm2Result}; +use crate::sm3::hash::Sm3Hash; + use super::ecc::*; use super::field::FieldElem; +use byteorder::{BigEndian, WriteBytesExt}; use num_bigint::BigUint; use num_traits::*; -use sm3::hash::Sm3Hash; - -use yasna; - -use byteorder::{BigEndian, WriteBytesExt}; -use sm2::error::{Sm2Error, Sm2Result}; use std::fmt; +use yasna; pub type Pubkey = Point; pub type Seckey = BigUint; diff --git a/src/sm3/hash.rs b/src/sm3/hash.rs index 49f8bd1..e388f36 100644 --- a/src/sm3/hash.rs +++ b/src/sm3/hash.rs @@ -17,7 +17,7 @@ // Input:"abc" // Output:66c7f0f4 62eeedd9 d1f2d46b dc10e4e2 4167c487 5cf2f7a2 297da02b 8f4ba8e0 -use sm3::error::{Sm3Error, Sm3Result}; +use crate::sm3::error::{Sm3Error, Sm3Result}; // Sample 2 // Input:"abcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcd" diff --git a/src/sm4/cipher.rs b/src/sm4/cipher.rs index 4c3c7cc..fc59d29 100644 --- a/src/sm4/cipher.rs +++ b/src/sm4/cipher.rs @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -use sm4::error::{Sm4Error, Sm4Result}; +use crate::sm4::error::{Sm4Error, Sm4Result}; static SBOX: [u8; 256] = [ 0xd6, 0x90, 0xe9, 0xfe, 0xcc, 0xe1, 0x3d, 0xb7, 0x16, 0xb6, 0x14, 0xc2, 0x28, 0xfb, 0x2c, 0x05, diff --git a/src/sm4/cipher_mode.rs b/src/sm4/cipher_mode.rs index 66105f6..c768d23 100644 --- a/src/sm4/cipher_mode.rs +++ b/src/sm4/cipher_mode.rs @@ -13,7 +13,7 @@ // limitations under the License. use super::cipher::Sm4Cipher; -use sm4::error::{Sm4Error, Sm4Result}; +use crate::sm4::error::{Sm4Error, Sm4Result}; pub enum CipherMode { Cfb,