diff --git a/.github/workflows/hmac.yml b/.github/workflows/hmac.yml index 257237f..ce00522 100644 --- a/.github/workflows/hmac.yml +++ b/.github/workflows/hmac.yml @@ -23,7 +23,7 @@ jobs: strategy: matrix: rust: - - 1.41.0 # MSRV + - 1.57.0 # MSRV - stable target: - thumbv7em-none-eabi @@ -49,7 +49,7 @@ jobs: strategy: matrix: rust: - - 1.41.0 # MSRV + - 1.57.0 # MSRV - stable steps: - uses: actions/checkout@v3.1.0 diff --git a/Cargo.lock b/Cargo.lock index 9e9b7e5..f376fd6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -21,16 +21,16 @@ checksum = "847495c209977a90e8aad588b959d0ca9f5dc228096d29a6bd3defd53f35eaec" [[package]] name = "block-buffer" -version = "0.10.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69cce20737498f97b993470a6e536b8523f0af7892a4f928cceb1ac5e52ebe7e" +version = "0.11.0-pre" +source = "git+https://github.com/RustCrypto/utils?branch=hex_literal_0.11#b7630ebd7df40ed4f3baa5bcab976543469bf378" dependencies = [ + "crypto-common 0.2.0-pre", "generic-array", ] [[package]] name = "cbc-mac" -version = "0.1.1" +version = "0.2.0" dependencies = [ "aes", "cipher", @@ -51,14 +51,14 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d1873270f8f7942c191139cb8a40fd228da6c3fd2fc376d7e92d47aa14aeb59e" dependencies = [ - "crypto-common", + "crypto-common 0.1.6", "inout", "zeroize", ] [[package]] name = "cmac" -version = "0.7.1" +version = "0.8.0" dependencies = [ "aes", "cipher", @@ -89,6 +89,15 @@ dependencies = [ "typenum", ] +[[package]] +name = "crypto-common" +version = "0.2.0-pre" +source = "git+https://github.com/RustCrypto/traits?branch=crypto_common_v0.2#48d751024011dd39abb3926dacb66b6ca7d7ef37" +dependencies = [ + "generic-array", + "typenum", +] + [[package]] name = "dbl" version = "0.3.2" @@ -109,13 +118,12 @@ dependencies = [ [[package]] name = "digest" -version = "0.10.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8168378f4e5023e7218c89c891c0fd8ecdb5e5e4f18cb78f38cf245dd021e76f" +version = "0.11.0" +source = "git+https://github.com/RustCrypto/traits?branch=digest_v0.11#c4e2e77a21300c3f46ddaf5cb6739b09b865dd98" dependencies = [ "blobby", "block-buffer", - "crypto-common", + "crypto-common 0.2.0-pre", "subtle", ] @@ -135,6 +143,18 @@ version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7ebdb29d2ea9ed0083cd8cece49bbd968021bd99b0849edb4a9a7ee0fdf6a4e0" +[[package]] +name = "hmac" +version = "0.13.0" +dependencies = [ + "digest", + "hex-literal", + "md-5", + "sha1", + "sha2", + "streebog", +] + [[package]] name = "inout" version = "0.1.3" @@ -168,9 +188,17 @@ dependencies = [ "cipher", ] +[[package]] +name = "md-5" +version = "0.11.0" +source = "git+https://github.com/RustCrypto/hashes?branch=digest_v0.11#e87e3c53d9f129bc3780757b5d37d9de89bbf2bc" +dependencies = [ + "digest", +] + [[package]] name = "pmac" -version = "0.7.1" +version = "0.8.0" dependencies = [ "aes", "cipher", @@ -178,6 +206,34 @@ dependencies = [ "digest", ] +[[package]] +name = "sha1" +version = "0.11.0" +source = "git+https://github.com/RustCrypto/hashes?branch=digest_v0.11#e87e3c53d9f129bc3780757b5d37d9de89bbf2bc" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest", +] + +[[package]] +name = "sha2" +version = "0.11.0" +source = "git+https://github.com/RustCrypto/hashes?branch=digest_v0.11#e87e3c53d9f129bc3780757b5d37d9de89bbf2bc" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest", +] + +[[package]] +name = "streebog" +version = "0.11.0" +source = "git+https://github.com/RustCrypto/hashes?branch=digest_v0.11#e87e3c53d9f129bc3780757b5d37d9de89bbf2bc" +dependencies = [ + "digest", +] + [[package]] name = "subtle" version = "2.4.1" diff --git a/Cargo.toml b/Cargo.toml index ee782d4..8cd4923 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,11 +2,16 @@ members = [ "cbc-mac", "cmac", - "pmac", -] -exclude = [ "hmac", + "pmac", ] [profile.dev] opt-level = 2 + +[patch.crates-io] +digest = { git="https://github.com/RustCrypto/traits", branch = "digest_v0.11" } +md-5 = { git="https://github.com/RustCrypto/hashes", branch="digest_v0.11"} +sha1 = { git="https://github.com/RustCrypto/hashes", branch="digest_v0.11"} +sha2 = { git="https://github.com/RustCrypto/hashes", branch="digest_v0.11"} +streebog = { git="https://github.com/RustCrypto/hashes", branch="digest_v0.11"} \ No newline at end of file diff --git a/README.md b/README.md index b5a4d0f..2a1e884 100644 --- a/README.md +++ b/README.md @@ -10,10 +10,10 @@ Collection of [Message Authentication Code][1] (MAC) algorithms written in pure | Algorithm | Crate | Crates.io | Documentation | MSRV | |-----------|----------|:-------------:|:-------------:|:----:| -| [CBC-MAC] | [`cbc-mac`] | [![crates.io](https://img.shields.io/crates/v/cbc-mac.svg)](https://crates.io/crates/cbc-mac) | [![Documentation](https://docs.rs/cbc-mac/badge.svg)](https://docs.rs/cbc-mac) | ![MSRV 1.56][msrv-1.56] | -| [CMAC] | [`cmac`] | [![crates.io](https://img.shields.io/crates/v/cmac.svg)](https://crates.io/crates/cmac) | [![Documentation](https://docs.rs/cmac/badge.svg)](https://docs.rs/cmac) | ![MSRV 1.56][msrv-1.56] | -| [HMAC] | [`hmac`] | [![crates.io](https://img.shields.io/crates/v/hmac.svg)](https://crates.io/crates/hmac) | [![Documentation](https://docs.rs/hmac/badge.svg)](https://docs.rs/hmac) | ![MSRV 1.41][msrv-1.41] | -| [PMAC] | [`pmac`] | [![crates.io](https://img.shields.io/crates/v/pmac.svg)](https://crates.io/crates/pmac) | [![Documentation](https://docs.rs/pmac/badge.svg)](https://docs.rs/pmac) | ![MSRV 1.56][msrv-1.56] | +| [CBC-MAC] | [`cbc-mac`] | [![crates.io](https://img.shields.io/crates/v/cbc-mac.svg)](https://crates.io/crates/cbc-mac) | [![Documentation](https://docs.rs/cbc-mac/badge.svg)](https://docs.rs/cbc-mac) | ![MSRV 1.57][msrv-1.57] | +| [CMAC] | [`cmac`] | [![crates.io](https://img.shields.io/crates/v/cmac.svg)](https://crates.io/crates/cmac) | [![Documentation](https://docs.rs/cmac/badge.svg)](https://docs.rs/cmac) | ![MSRV 1.57][msrv-1.57] | +| [HMAC] | [`hmac`] | [![crates.io](https://img.shields.io/crates/v/hmac.svg)](https://crates.io/crates/hmac) | [![Documentation](https://docs.rs/hmac/badge.svg)](https://docs.rs/hmac) | ![MSRV 1.57][msrv-1.57] | +| [PMAC] | [`pmac`] | [![crates.io](https://img.shields.io/crates/v/pmac.svg)](https://crates.io/crates/pmac) | [![Documentation](https://docs.rs/pmac/badge.svg)](https://docs.rs/pmac) | ![MSRV 1.57][msrv-1.57] | ### Minimum Supported Rust Version (MSRV) Policy @@ -39,8 +39,7 @@ Unless you explicitly state otherwise, any contribution intentionally submitted [license-image]: https://img.shields.io/badge/license-Apache2.0/MIT-blue.svg [deps-image]: https://deps.rs/repo/github/RustCrypto/MACs/status.svg [deps-link]: https://deps.rs/repo/github/RustCrypto/MACs -[msrv-1.41]: https://img.shields.io/badge/rustc-1.41.0+-blue.svg -[msrv-1.56]: https://img.shields.io/badge/rustc-1.56.0+-blue.svg +[msrv-1.57]: https://img.shields.io/badge/rustc-1.57.0+-blue.svg [//]: # (crates) diff --git a/cbc-mac/Cargo.toml b/cbc-mac/Cargo.toml index 0afdb7e..c5b6ae9 100644 --- a/cbc-mac/Cargo.toml +++ b/cbc-mac/Cargo.toml @@ -1,24 +1,24 @@ [package] name = "cbc-mac" -version = "0.1.1" # Also update html_root_url in lib.rs when bumping this +version = "0.2.0" description = "Implementation of Cipher Block Chaining Message Authentication Code (CBC-MAC)" authors = ["RustCrypto Developers"] license = "MIT OR Apache-2.0" edition = "2021" -rust-version = "1.56" +rust-version = "1.57" readme = "README.md" documentation = "https://docs.rs/cbc-mac" repository = "https://github.com/RustCrypto/MACs" keywords = ["crypto", "mac", "daa"] [dependencies] -digest = { version = "0.10.3", features = ["mac"] } +digest = { version = "0.11", features = ["mac"] } cipher = "0.4.2" [dev-dependencies] aes = "0.8" des = "0.8" -digest = { version = "0.10.3", features = ["dev"] } +digest = { version = "0.11", features = ["dev"] } hex-literal = "0.3" [features] diff --git a/cbc-mac/README.md b/cbc-mac/README.md index e958abb..8074bc0 100644 --- a/cbc-mac/README.md +++ b/cbc-mac/README.md @@ -13,7 +13,7 @@ Pure Rust implementation of the [Cipher Block Chaining Message Authentication Co ## Minimum Supported Rust Version -Rust **1.56** or higher. +Rust **1.57** or higher. Minimum supported Rust version can be changed in the future, but it will be done with a minor version bump. @@ -45,7 +45,7 @@ dual licensed as above, without any additional terms or conditions. [docs-image]: https://docs.rs/cbc-mac/badge.svg [docs-link]: https://docs.rs/cbc-mac/ [license-image]: https://img.shields.io/badge/license-Apache2.0/MIT-blue.svg -[rustc-image]: https://img.shields.io/badge/rustc-1.56+-blue.svg +[rustc-image]: https://img.shields.io/badge/rustc-1.57+-blue.svg [chat-image]: https://img.shields.io/badge/zulip-join_chat-blue.svg [chat-link]: https://rustcrypto.zulipchat.com/#narrow/stream/260044-MACs [build-image]: https://github.com/RustCrypto/MACs/workflows/cbc-mac/badge.svg?branch=master&event=push diff --git a/cbc-mac/src/lib.rs b/cbc-mac/src/lib.rs index 8c11027..4fed55d 100644 --- a/cbc-mac/src/lib.rs +++ b/cbc-mac/src/lib.rs @@ -27,8 +27,7 @@ #![no_std] #![doc( html_logo_url = "https://raw.githubusercontent.com/RustCrypto/media/26acc39f/logo.svg", - html_favicon_url = "https://raw.githubusercontent.com/RustCrypto/media/26acc39f/logo.svg", - html_root_url = "https://docs.rs/cbc-mac/0.1.1" + html_favicon_url = "https://raw.githubusercontent.com/RustCrypto/media/26acc39f/logo.svg" )] #![deny(unsafe_code)] #![cfg_attr(docsrs, feature(doc_cfg))] diff --git a/cmac/Cargo.toml b/cmac/Cargo.toml index 56b6804..5df5656 100644 --- a/cmac/Cargo.toml +++ b/cmac/Cargo.toml @@ -1,11 +1,11 @@ [package] name = "cmac" -version = "0.7.1" # Also update html_root_url in lib.rs when bumping this +version = "0.8.0" description = "Generic implementation of Cipher-based Message Authentication Code" authors = ["RustCrypto Developers"] license = "MIT OR Apache-2.0" edition = "2021" -rust-version = "1.56" +rust-version = "1.57" readme = "README.md" documentation = "https://docs.rs/cmac" repository = "https://github.com/RustCrypto/MACs" @@ -13,12 +13,12 @@ keywords = ["crypto", "mac", "cmac", "omac"] categories = ["cryptography", "no-std"] [dependencies] -digest = { version = "0.10.3", features = ["mac"] } +digest = { version = "0.11", features = ["mac"] } cipher = "0.4.2" dbl = "0.3" [dev-dependencies] -digest = { version = "0.10.3", features = ["dev"] } +digest = { version = "0.11", features = ["dev"] } hex-literal = "0.3" aes = "0.8" des = "0.8" diff --git a/cmac/README.md b/cmac/README.md index 2e2b21c..3e86ae0 100644 --- a/cmac/README.md +++ b/cmac/README.md @@ -13,7 +13,7 @@ Pure Rust implementation of the [Cipher-based Message Authentication Code (CMAC) ## Minimum Supported Rust Version -Rust **1.56** or higher. +Rust **1.57** or higher. Minimum supported Rust version can be changed in the future, but it will be done with a minor version bump. @@ -45,7 +45,7 @@ dual licensed as above, without any additional terms or conditions. [docs-image]: https://docs.rs/cmac/badge.svg [docs-link]: https://docs.rs/cmac/ [license-image]: https://img.shields.io/badge/license-Apache2.0/MIT-blue.svg -[rustc-image]: https://img.shields.io/badge/rustc-1.56+-blue.svg +[rustc-image]: https://img.shields.io/badge/rustc-1.57+-blue.svg [chat-image]: https://img.shields.io/badge/zulip-join_chat-blue.svg [chat-link]: https://rustcrypto.zulipchat.com/#narrow/stream/260044-MACs [build-image]: https://github.com/RustCrypto/MACs/workflows/cmac/badge.svg?branch=master&event=push diff --git a/cmac/src/lib.rs b/cmac/src/lib.rs index 52f1778..1ff1845 100644 --- a/cmac/src/lib.rs +++ b/cmac/src/lib.rs @@ -42,8 +42,7 @@ #![no_std] #![doc( html_logo_url = "https://raw.githubusercontent.com/RustCrypto/media/26acc39f/logo.svg", - html_favicon_url = "https://raw.githubusercontent.com/RustCrypto/media/26acc39f/logo.svg", - html_root_url = "https://docs.rs/cmac/0.7.1" + html_favicon_url = "https://raw.githubusercontent.com/RustCrypto/media/26acc39f/logo.svg" )] #![forbid(unsafe_code)] #![cfg_attr(docsrs, feature(doc_cfg))] diff --git a/hmac/Cargo.lock b/hmac/Cargo.lock deleted file mode 100644 index 52f4ebf..0000000 --- a/hmac/Cargo.lock +++ /dev/null @@ -1,166 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -version = 3 - -[[package]] -name = "blobby" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "847495c209977a90e8aad588b959d0ca9f5dc228096d29a6bd3defd53f35eaec" - -[[package]] -name = "block-buffer" -version = "0.10.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69cce20737498f97b993470a6e536b8523f0af7892a4f928cceb1ac5e52ebe7e" -dependencies = [ - "generic-array", -] - -[[package]] -name = "cfg-if" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" - -[[package]] -name = "cpufeatures" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28d997bd5e24a5928dd43e46dc529867e207907fe0b239c3477d924f7f2ca320" -dependencies = [ - "libc", -] - -[[package]] -name = "crypto-common" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" -dependencies = [ - "generic-array", - "typenum", -] - -[[package]] -name = "digest" -version = "0.10.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "adfbc57365a37acbd2ebf2b64d7e69bb766e2fea813521ed536f5d0520dcf86c" -dependencies = [ - "blobby", - "block-buffer", - "crypto-common", - "subtle", -] - -[[package]] -name = "generic-array" -version = "0.14.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bff49e947297f3312447abdca79f45f4738097cc82b06e72054d2223f601f1b9" -dependencies = [ - "typenum", - "version_check", -] - -[[package]] -name = "hex-literal" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d70693199b3cf4552f3fa720b54163927a3ebed2aef240efaf556033ab336a11" -dependencies = [ - "hex-literal-impl", - "proc-macro-hack", -] - -[[package]] -name = "hex-literal-impl" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59448fc2f82a5fb6907f78c3d69d843e82ff5b051923313cc4438cb0c7b745a8" -dependencies = [ - "proc-macro-hack", -] - -[[package]] -name = "hmac" -version = "0.12.1" -dependencies = [ - "digest", - "hex-literal", - "md-5", - "sha1", - "sha2", - "streebog", -] - -[[package]] -name = "libc" -version = "0.2.132" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8371e4e5341c3a96db127eb2465ac681ced4c433e01dd0e938adbef26ba93ba5" - -[[package]] -name = "md-5" -version = "0.10.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "66b48670c893079d3c2ed79114e3644b7004df1c361a4e0ad52e2e6940d07c3d" -dependencies = [ - "digest", -] - -[[package]] -name = "proc-macro-hack" -version = "0.5.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5" - -[[package]] -name = "sha1" -version = "0.10.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f04293dc80c3993519f2d7f6f511707ee7094fe0c6d3406feb330cdb3540eba3" -dependencies = [ - "cfg-if", - "cpufeatures", - "digest", -] - -[[package]] -name = "sha2" -version = "0.10.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "82e6b795fe2e3b1e845bafcb27aa35405c4d47cdfc92af5fc8d3002f76cebdc0" -dependencies = [ - "cfg-if", - "cpufeatures", - "digest", -] - -[[package]] -name = "streebog" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e7fe6ed8a42cec360e070309427bb7959e102849b0dbaa7de19d5b9860bd536" -dependencies = [ - "digest", -] - -[[package]] -name = "subtle" -version = "2.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" - -[[package]] -name = "typenum" -version = "1.15.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcf81ac59edc17cc8697ff311e8f5ef2d99fcbd9817b34cec66f90b6c3dfd987" - -[[package]] -name = "version_check" -version = "0.9.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" diff --git a/hmac/Cargo.toml b/hmac/Cargo.toml index bf45b73..aa37a1d 100644 --- a/hmac/Cargo.toml +++ b/hmac/Cargo.toml @@ -1,10 +1,11 @@ [package] name = "hmac" -version = "0.12.1" # Also update html_root_url in lib.rs when bumping this +version = "0.13.0" description = "Generic implementation of Hash-based Message Authentication Code (HMAC)" authors = ["RustCrypto Developers"] license = "MIT OR Apache-2.0" -edition = "2018" +edition = "2021" +rust-version = "1.57" readme = "README.md" documentation = "https://docs.rs/hmac" repository = "https://github.com/RustCrypto/MACs" @@ -12,15 +13,15 @@ keywords = ["crypto", "mac", "hmac", "digest"] categories = ["cryptography", "no-std"] [dependencies] -digest = { version = "0.10.3", features = ["mac"] } +digest = { version = "0.11", features = ["mac"] } [dev-dependencies] -digest = { version = "0.10", features = ["dev"] } -md-5 = { version = "0.10", default-features = false } -sha1 = { version = "0.10", default-features = false } -sha2 = { version = "0.10", default-features = false } -streebog = { version = "0.10", default-features = false } -hex-literal = "0.2.2" +digest = { version = "0.11", features = ["dev"] } +md-5 = { version = "0.11", default-features = false } +sha1 = { version = "0.11", default-features = false } +sha2 = { version = "0.11", default-features = false } +streebog = { version = "0.11", default-features = false } +hex-literal = "0.3.3" [features] std = ["digest/std"] diff --git a/hmac/README.md b/hmac/README.md index 52d4ef9..b99d9f7 100644 --- a/hmac/README.md +++ b/hmac/README.md @@ -12,7 +12,7 @@ Pure Rust implementation of the [Hash-based Message Authentication Code (HMAC)][ ## Minimum Supported Rust Version -Rust **1.41** or higher. +Rust **1.57** or higher. Minimum supported Rust version can be changed in the future, but it will be done with a minor version bump. @@ -44,7 +44,7 @@ dual licensed as above, without any additional terms or conditions. [docs-image]: https://docs.rs/hmac/badge.svg [docs-link]: https://docs.rs/hmac/ [license-image]: https://img.shields.io/badge/license-Apache2.0/MIT-blue.svg -[rustc-image]: https://img.shields.io/badge/rustc-1.41+-blue.svg +[rustc-image]: https://img.shields.io/badge/rustc-1.57+-blue.svg [chat-image]: https://img.shields.io/badge/zulip-join_chat-blue.svg [chat-link]: https://rustcrypto.zulipchat.com/#narrow/stream/260044-MACs diff --git a/hmac/src/lib.rs b/hmac/src/lib.rs index b93fb31..ee63878 100644 --- a/hmac/src/lib.rs +++ b/hmac/src/lib.rs @@ -38,10 +38,10 @@ //! // incorrect use of the code value may permit timing attacks which defeats //! // the security provided by the `CtOutput` //! let code_bytes = result.into_bytes(); -//! let expected = hex!(" -//! 97d2a569059bbcd8ead4444ff99071f4 -//! c01d005bcefe0d3567e1be628e5fdcd9 -//! "); +//! let expected = hex!( +//! "97d2a569059bbcd8ead4444ff99071f4" +//! "c01d005bcefe0d3567e1be628e5fdcd9" +//! ); //! assert_eq!(code_bytes[..], expected[..]); //! ``` //! @@ -57,10 +57,10 @@ //! //! mac.update(b"input message"); //! -//! let code_bytes = hex!(" -//! 97d2a569059bbcd8ead4444ff99071f4 -//! c01d005bcefe0d3567e1be628e5fdcd9 -//! "); +//! let code_bytes = hex!( +//! "97d2a569059bbcd8ead4444ff99071f4" +//! "c01d005bcefe0d3567e1be628e5fdcd9" +//! ); //! // `verify_slice` will return `Ok(())` if code is correct, `Err(MacError)` otherwise //! mac.verify_slice(&code_bytes[..]).unwrap(); //! ``` @@ -76,7 +76,7 @@ //! the [`Error`][std::error::Error] trait for error types) //! - `reset`: enables implementation of the [`Reset`][digest::Reset] trait //! (note that it makes HMAC states bigger) -//! +//! //! [`digest`]: https://docs.rs/digest //! [`sha2`]: https://docs.rs/sha2 //! [`RustCrypto/hashes`]: https://github.com/RustCrypto/hashes @@ -84,8 +84,7 @@ #![no_std] #![doc( html_logo_url = "https://raw.githubusercontent.com/RustCrypto/media/26acc39f/logo.svg", - html_favicon_url = "https://raw.githubusercontent.com/RustCrypto/media/26acc39f/logo.svg", - html_root_url = "https://docs.rs/hmac/0.12.1" + html_favicon_url = "https://raw.githubusercontent.com/RustCrypto/media/26acc39f/logo.svg" )] #![forbid(unsafe_code)] #![cfg_attr(docsrs, feature(doc_cfg))] @@ -105,7 +104,7 @@ use digest::{ mod optim; mod simple; -pub use optim::{Hmac, HmacCore}; +pub use optim::{EagerHash, Hmac, HmacCore}; pub use simple::SimpleHmac; const IPAD: u8 = 0x36; diff --git a/hmac/src/optim.rs b/hmac/src/optim.rs index 32d6277..655f1f1 100644 --- a/hmac/src/optim.rs +++ b/hmac/src/optim.rs @@ -1,52 +1,50 @@ use super::{get_der_key, IPAD, OPAD}; use core::{fmt, slice}; -#[cfg(feature = "reset")] -use digest::Reset; use digest::{ block_buffer::Eager, core_api::{ - AlgorithmName, Block, BlockSizeUser, Buffer, BufferKindUser, CoreProxy, CoreWrapper, - FixedOutputCore, OutputSizeUser, UpdateCore, + AlgorithmName, Block, BlockSizeUser, Buffer, BufferKindUser, CoreWrapper, FixedOutputCore, + OutputSizeUser, UpdateCore, }, crypto_common::{Key, KeySizeUser}, - generic_array::typenum::{IsLess, Le, NonZero, U256}, HashMarker, InvalidLength, KeyInit, MacMarker, Output, }; /// Generic HMAC instance. pub type Hmac = CoreWrapper>; -/// Generic core HMAC instance, which operates over blocks. -pub struct HmacCore -where - D: CoreProxy, - D::Core: HashMarker +/// Trait implemented by eager hashes which expose their block-level core. +pub trait EagerHash { + /// Block-level core type of the hash. + type Core: HashMarker + UpdateCore + FixedOutputCore + BufferKindUser + Default - + Clone, - ::BlockSize: IsLess, - Le<::BlockSize, U256>: NonZero, -{ - digest: D::Core, - opad_digest: D::Core, - #[cfg(feature = "reset")] - ipad_digest: D::Core, + + Clone; } -impl Clone for HmacCore +impl EagerHash for CoreWrapper where - D: CoreProxy, - D::Core: HashMarker + C: HashMarker + UpdateCore + FixedOutputCore + BufferKindUser + Default + Clone, - ::BlockSize: IsLess, - Le<::BlockSize, U256>: NonZero, { + type Core = C; +} + +/// Generic core HMAC instance, which operates over blocks. +pub struct HmacCore { + digest: D::Core, + opad_digest: D::Core, + #[cfg(feature = "reset")] + ipad_digest: D::Core, +} + +impl Clone for HmacCore { fn clone(&self) -> Self { Self { digest: self.digest.clone(), @@ -57,92 +55,25 @@ where } } -impl MacMarker for HmacCore -where - D: CoreProxy, - D::Core: HashMarker - + UpdateCore - + FixedOutputCore - + BufferKindUser - + Default - + Clone, - ::BlockSize: IsLess, - Le<::BlockSize, U256>: NonZero, -{ -} +impl MacMarker for HmacCore {} -impl BufferKindUser for HmacCore -where - D: CoreProxy, - D::Core: HashMarker - + UpdateCore - + FixedOutputCore - + BufferKindUser - + Default - + Clone, - ::BlockSize: IsLess, - Le<::BlockSize, U256>: NonZero, -{ +impl BufferKindUser for HmacCore { type BufferKind = Eager; } -impl KeySizeUser for HmacCore -where - D: CoreProxy, - D::Core: HashMarker - + UpdateCore - + FixedOutputCore - + BufferKindUser - + Default - + Clone, - ::BlockSize: IsLess, - Le<::BlockSize, U256>: NonZero, -{ - type KeySize = <::Core as BlockSizeUser>::BlockSize; +impl KeySizeUser for HmacCore { + type KeySize = <::Core as BlockSizeUser>::BlockSize; } -impl BlockSizeUser for HmacCore -where - D: CoreProxy, - D::Core: HashMarker - + UpdateCore - + FixedOutputCore - + BufferKindUser - + Default - + Clone, - ::BlockSize: IsLess, - Le<::BlockSize, U256>: NonZero, -{ - type BlockSize = <::Core as BlockSizeUser>::BlockSize; +impl BlockSizeUser for HmacCore { + type BlockSize = <::Core as BlockSizeUser>::BlockSize; } -impl OutputSizeUser for HmacCore -where - D: CoreProxy, - D::Core: HashMarker - + UpdateCore - + FixedOutputCore - + BufferKindUser - + Default - + Clone, - ::BlockSize: IsLess, - Le<::BlockSize, U256>: NonZero, -{ - type OutputSize = <::Core as OutputSizeUser>::OutputSize; +impl OutputSizeUser for HmacCore { + type OutputSize = <::Core as OutputSizeUser>::OutputSize; } -impl KeyInit for HmacCore -where - D: CoreProxy, - D::Core: HashMarker - + UpdateCore - + FixedOutputCore - + BufferKindUser - + Default - + Clone, - ::BlockSize: IsLess, - Le<::BlockSize, U256>: NonZero, -{ +impl KeyInit for HmacCore { #[inline(always)] fn new(key: &Key) -> Self { Self::new_from_slice(key.as_slice()).unwrap() @@ -173,36 +104,14 @@ where } } -impl UpdateCore for HmacCore -where - D: CoreProxy, - D::Core: HashMarker - + UpdateCore - + FixedOutputCore - + BufferKindUser - + Default - + Clone, - ::BlockSize: IsLess, - Le<::BlockSize, U256>: NonZero, -{ +impl UpdateCore for HmacCore { #[inline(always)] fn update_blocks(&mut self, blocks: &[Block]) { self.digest.update_blocks(blocks); } } -impl FixedOutputCore for HmacCore -where - D: CoreProxy, - D::Core: HashMarker - + UpdateCore - + FixedOutputCore - + BufferKindUser - + Default - + Clone, - ::BlockSize: IsLess, - Le<::BlockSize, U256>: NonZero, -{ +impl FixedOutputCore for HmacCore { #[inline(always)] fn finalize_fixed_core(&mut self, buffer: &mut Buffer, out: &mut Output) { let mut hash = Output::::default(); @@ -221,36 +130,16 @@ where #[cfg(feature = "reset")] #[cfg_attr(docsrs, doc(cfg(feature = "reset")))] -impl Reset for HmacCore -where - D: CoreProxy, - D::Core: HashMarker - + UpdateCore - + FixedOutputCore - + BufferKindUser - + Default - + Clone, - ::BlockSize: IsLess, - Le<::BlockSize, U256>: NonZero, -{ +impl digest::Reset for HmacCore { #[inline(always)] fn reset(&mut self) { self.digest = self.ipad_digest.clone(); } } -impl AlgorithmName for HmacCore +impl AlgorithmName for HmacCore where - D: CoreProxy, - D::Core: HashMarker - + AlgorithmName - + UpdateCore - + FixedOutputCore - + BufferKindUser - + Default - + Clone, - ::BlockSize: IsLess, - Le<::BlockSize, U256>: NonZero, + D::Core: AlgorithmName, { fn write_alg_name(f: &mut fmt::Formatter<'_>) -> fmt::Result { f.write_str("Hmac<")?; @@ -259,18 +148,9 @@ where } } -impl fmt::Debug for HmacCore +impl fmt::Debug for HmacCore where - D: CoreProxy, - D::Core: HashMarker - + AlgorithmName - + UpdateCore - + FixedOutputCore - + BufferKindUser - + Default - + Clone, - ::BlockSize: IsLess, - Le<::BlockSize, U256>: NonZero, + D::Core: AlgorithmName, { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.write_str("HmacCore<")?; diff --git a/pmac/Cargo.toml b/pmac/Cargo.toml index a512e5d..4787a1a 100644 --- a/pmac/Cargo.toml +++ b/pmac/Cargo.toml @@ -1,11 +1,11 @@ [package] name = "pmac" -version = "0.7.1" # Also update html_root_url in lib.rs when bumping this +version = "0.8.0" description = "Generic implementation of Parallelizable Message Authentication Code" authors = ["RustCrypto Developers"] license = "MIT OR Apache-2.0" edition = "2021" -rust-version = "1.56" +rust-version = "1.57" readme = "README.md" documentation = "https://docs.rs/pmac" repository = "https://github.com/RustCrypto/MACs" @@ -13,13 +13,13 @@ keywords = ["crypto", "mac", "pmac"] categories = ["cryptography", "no-std"] [dependencies] -digest = { version = "0.10.3", features = ["mac"] } +digest = { version = "0.11", features = ["mac"] } cipher = "0.4.2" dbl = "0.3" [dev-dependencies] aes = "0.8" -digest = { version = "0.10.3", features = ["dev"] } +digest = { version = "0.11", features = ["dev"] } [features] std = ["digest/std"] diff --git a/pmac/README.md b/pmac/README.md index 93dfbba..43deaba 100644 --- a/pmac/README.md +++ b/pmac/README.md @@ -13,7 +13,7 @@ Pure Rust implementation of the [Parallel Message Authentication Code (PMAC)][1] ## Minimum Supported Rust Version -Rust **1.56** or higher. +Rust **1.57** or higher. Minimum supported Rust version can be changed in the future, but it will be done with a minor version bump. @@ -45,7 +45,7 @@ dual licensed as above, without any additional terms or conditions. [docs-image]: https://docs.rs/pmac/badge.svg [docs-link]: https://docs.rs/pmac/ [license-image]: https://img.shields.io/badge/license-Apache2.0/MIT-blue.svg -[rustc-image]: https://img.shields.io/badge/rustc-1.56+-blue.svg +[rustc-image]: https://img.shields.io/badge/rustc-1.57+-blue.svg [chat-image]: https://img.shields.io/badge/zulip-join_chat-blue.svg [chat-link]: https://rustcrypto.zulipchat.com/#narrow/stream/260044-MACs [build-image]: https://github.com/RustCrypto/MACs/workflows/pmac/badge.svg?branch=master&event=push diff --git a/pmac/src/lib.rs b/pmac/src/lib.rs index 41ee11d..cd86243 100644 --- a/pmac/src/lib.rs +++ b/pmac/src/lib.rs @@ -42,8 +42,7 @@ #![no_std] #![doc( html_logo_url = "https://raw.githubusercontent.com/RustCrypto/media/26acc39f/logo.svg", - html_favicon_url = "https://raw.githubusercontent.com/RustCrypto/media/26acc39f/logo.svg", - html_root_url = "https://docs.rs/pmac/0.7.1" + html_favicon_url = "https://raw.githubusercontent.com/RustCrypto/media/26acc39f/logo.svg" )] #![forbid(unsafe_code)] #![cfg_attr(docsrs, feature(doc_cfg))]