Skip to content

Commit

Permalink
Merge pull request #44 from citahub/bump_0.5
Browse files Browse the repository at this point in the history
chore: update edtion to 2021
  • Loading branch information
Pencil-Yao authored May 26, 2022
2 parents 223017e + 76f36d4 commit 3ead619
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 20 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
[package]
name = "libsm"
version = "0.4.1"
version = "0.5.0"
authors = [
"Tang Zongxun <[email protected]>",
"Niu Junxiang <[email protected]>",
"yieazy <[email protected]>",
"Rivtower Technologies <[email protected]>"
]

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"
Expand Down
7 changes: 4 additions & 3 deletions src/sm2/ecc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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;

Expand Down
5 changes: 2 additions & 3 deletions src/sm2/encrypt.rs
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
5 changes: 3 additions & 2 deletions src/sm2/exchange.rs
Original file line number Diff line number Diff line change
@@ -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();
Expand Down
3 changes: 2 additions & 1 deletion src/sm2/field.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
11 changes: 5 additions & 6 deletions src/sm2/signature.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/sm3/hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion src/sm4/cipher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/sm4/cipher_mode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 3ead619

Please sign in to comment.