summaryrefslogtreecommitdiffstats
path: root/third_party/rust/md-5
diff options
context:
space:
mode:
Diffstat (limited to 'third_party/rust/md-5')
-rw-r--r--third_party/rust/md-5/.cargo-checksum.json1
-rw-r--r--third_party/rust/md-5/CHANGELOG.md84
-rw-r--r--third_party/rust/md-5/Cargo.toml54
-rw-r--r--third_party/rust/md-5/LICENSE-APACHE201
-rw-r--r--third_party/rust/md-5/LICENSE-MIT27
-rw-r--r--third_party/rust/md-5/README.md72
-rw-r--r--third_party/rust/md-5/benches/mod.rs14
-rw-r--r--third_party/rust/md-5/src/compress.rs165
-rw-r--r--third_party/rust/md-5/src/lib.rs146
-rw-r--r--third_party/rust/md-5/tests/data/md5.blbbin0 -> 3271 bytes
-rw-r--r--third_party/rust/md-5/tests/mod.rs15
11 files changed, 779 insertions, 0 deletions
diff --git a/third_party/rust/md-5/.cargo-checksum.json b/third_party/rust/md-5/.cargo-checksum.json
new file mode 100644
index 0000000000..abcc52a8ba
--- /dev/null
+++ b/third_party/rust/md-5/.cargo-checksum.json
@@ -0,0 +1 @@
+{"files":{"CHANGELOG.md":"75ed9e0b2e0941de92a0d5eeedb6d413da8f959acfa393a50a2a5866857bb14e","Cargo.toml":"68a313a16ee100979d0c77b4844dbf232f8cf55104799dd8e0bb086ebb2812c4","LICENSE-APACHE":"a9040321c3712d8fd0b09cf52b17445de04a23a10165049ae187cd39e5c86be5","LICENSE-MIT":"b4eb00df6e2a4d22518fcaa6a2b4646f249b3a3c9814509b22bd2091f1392ff1","README.md":"23c2e70875a8ccdd29c0c7e929f1769dd8ae1f3e5be5dcd0a368f1d9fab1917b","benches/mod.rs":"10a5c151bf7b145838ab754013d49463e3123297778cfe275c95ebec28c4f7c9","src/compress.rs":"0b6392b665e9ac4e6c380d06370c44380a75f0eb3532ca2e7d50a26c39b3b286","src/lib.rs":"8b71d4d7999456b0eb538819d470ff472cea28bd6201569689d4de7e1c8c3c78","tests/data/md5.blb":"d32b41b81a906139c80f2bdf20920a547a5b5a6aaba2797fc2629665c42aaa47","tests/mod.rs":"b729eff5e20d0fee8da37aa101e6bc36919be11197350fffe2dc2b976f178f96"},"package":"6365506850d44bff6e2fbcb5176cf63650e48bd45ef2fe2665ae1570e0f4b9ca"} \ No newline at end of file
diff --git a/third_party/rust/md-5/CHANGELOG.md b/third_party/rust/md-5/CHANGELOG.md
new file mode 100644
index 0000000000..87fec720d2
--- /dev/null
+++ b/third_party/rust/md-5/CHANGELOG.md
@@ -0,0 +1,84 @@
+# Changelog
+
+All notable changes to this project will be documented in this file.
+
+The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
+and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
+
+## 0.10.5 (2022-09-32)
+### Added
+- Feature-gated OID support ([#413])
+
+[#413]: https://github.com/RustCrypto/hashes/pull/413
+
+## 0.10.4 (2022-09-02)
+### Fixed
+- MSRV issue which was not resolved by v0.10.3 ([#401])
+
+[#401]: https://github.com/RustCrypto/hashes/pull/401
+
+## 0.10.3 (2022-09-02)
+### Fixed
+- MSRV issue caused by publishing v0.10.2 using a buggy Nightly toolchain ([#399])
+
+[#399]: https://github.com/RustCrypto/hashes/pull/399
+
+## 0.10.2 (2022-08-30)
+### Changed
+- Ignore `asm` feature on unsupported targets ([#388])
+
+[#388]: https://github.com/RustCrypto/hashes/pull/388
+
+## 0.10.1 (2022-02-17)
+### Fixed
+- Minimal versions build ([#363])
+
+[#363]: https://github.com/RustCrypto/hashes/pull/363
+
+## 0.10.0 (2021-12-07)
+### Changed
+- Update to `digest` v0.10 ([#217])
+
+[#217]: https://github.com/RustCrypto/hashes/pull/217
+
+## 0.9.1 (2020-06-28)
+### Changed
+- Update to `block-buffer` v0.9 ([#164])
+- Update to `opaque-debug` v0.3 ([#168])
+
+[#164]: https://github.com/RustCrypto/hashes/pull/164
+[#168]: https://github.com/RustCrypto/hashes/pull/168
+
+## 0.9.0 (2020-06-09)
+### Changed
+- Update to `digest` v0.9 release; MSRV 1.41+ ([#155])
+- Use new `*Dirty` traits from the `digest` crate ([#153])
+- Bump `block-buffer` to v0.8 release ([#151])
+- Rename `*result*` to `finalize` ([#148])
+- Update to Rust 2018 edition ([#128])
+
+[#155]: https://github.com/RustCrypto/hashes/pull/155
+[#153]: https://github.com/RustCrypto/hashes/pull/153
+[#151]: https://github.com/RustCrypto/hashes/pull/151
+[#148]: https://github.com/RustCrypto/hashes/pull/148
+[#128]: https://github.com/RustCrypto/hashes/pull/128
+
+## 0.8.0 (2018-10-02)
+
+## 0.7.0 (2017-11-15)
+
+## 0.5.2 (2017-06-13)
+
+## 0.5.1 (2017-06-13)
+
+## 0.5.0 (2017-06-12)
+
+## 0.4.4 (2017-06-02)
+
+## 0.4.3 (2017-05-09)
+
+## 0.4.2 (2017-05-02)
+
+## 0.4.1 (2017-04-18)
+
+## 0.4.0 (2017-04-06)
diff --git a/third_party/rust/md-5/Cargo.toml b/third_party/rust/md-5/Cargo.toml
new file mode 100644
index 0000000000..fddb804ce7
--- /dev/null
+++ b/third_party/rust/md-5/Cargo.toml
@@ -0,0 +1,54 @@
+# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO
+#
+# When uploading crates to the registry Cargo will automatically
+# "normalize" Cargo.toml files for maximal compatibility
+# with all versions of Cargo and also rewrite `path` dependencies
+# to registry (e.g., crates.io) dependencies.
+#
+# If you are reading this file be aware that the original Cargo.toml
+# will likely look very different (and much more reasonable).
+# See Cargo.toml.orig for the original contents.
+
+[package]
+edition = "2018"
+name = "md-5"
+version = "0.10.5"
+authors = ["RustCrypto Developers"]
+description = "MD5 hash function"
+documentation = "https://docs.rs/md-5"
+readme = "README.md"
+keywords = [
+ "crypto",
+ "md5",
+ "hash",
+ "digest",
+]
+categories = [
+ "cryptography",
+ "no-std",
+]
+license = "MIT OR Apache-2.0"
+repository = "https://github.com/RustCrypto/hashes"
+
+[lib]
+name = "md5"
+
+[dependencies.digest]
+version = "0.10.4"
+
+[dev-dependencies.digest]
+version = "0.10.4"
+features = ["dev"]
+
+[dev-dependencies.hex-literal]
+version = "0.2.2"
+
+[features]
+asm = ["md5-asm"]
+default = ["std"]
+oid = ["digest/oid"]
+std = ["digest/std"]
+
+[target."cfg(any(target_arch = \"x86\", target_arch = \"x86_64\"))".dependencies.md5-asm]
+version = "0.5"
+optional = true
diff --git a/third_party/rust/md-5/LICENSE-APACHE b/third_party/rust/md-5/LICENSE-APACHE
new file mode 100644
index 0000000000..78173fa2e7
--- /dev/null
+++ b/third_party/rust/md-5/LICENSE-APACHE
@@ -0,0 +1,201 @@
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+END OF TERMS AND CONDITIONS
+
+APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+Copyright [yyyy] [name of copyright owner]
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
diff --git a/third_party/rust/md-5/LICENSE-MIT b/third_party/rust/md-5/LICENSE-MIT
new file mode 100644
index 0000000000..66cf75563b
--- /dev/null
+++ b/third_party/rust/md-5/LICENSE-MIT
@@ -0,0 +1,27 @@
+Copyright (c) 2006-2009 Graydon Hoare
+Copyright (c) 2009-2013 Mozilla Foundation
+Copyright (c) 2016 Artyom Pavlov
+
+Permission is hereby granted, free of charge, to any
+person obtaining a copy of this software and associated
+documentation files (the "Software"), to deal in the
+Software without restriction, including without
+limitation the rights to use, copy, modify, merge,
+publish, distribute, sublicense, and/or sell copies of
+the Software, and to permit persons to whom the Software
+is furnished to do so, subject to the following
+conditions:
+
+The above copyright notice and this permission notice
+shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
+ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
+TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
+PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
+SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.
diff --git a/third_party/rust/md-5/README.md b/third_party/rust/md-5/README.md
new file mode 100644
index 0000000000..56af1749bf
--- /dev/null
+++ b/third_party/rust/md-5/README.md
@@ -0,0 +1,72 @@
+# RustCrypto: MD5
+
+[![crate][crate-image]][crate-link]
+[![Docs][docs-image]][docs-link]
+![Apache2/MIT licensed][license-image]
+![Rust Version][rustc-image]
+[![Project Chat][chat-image]][chat-link]
+[![Build Status][build-image]][build-link]
+
+Pure Rust implementation of the [MD5 hash function][1].
+
+[Documentation][docs-link]
+
+## ⚠️ Security Warning
+
+This crate is provided for the purposes of legacy interoperability with
+protocols and systems which mandate the use of MD5.
+
+However, MD5 is [cryptographically broken and unsuitable for further use][2].
+
+Collision attacks against MD5 are both practical and trivial, and
+[theoretical attacks against MD5's preimage resistance have been found][3].
+
+[RFC6151][4] advises no new IETF protocols can be designed MD5-based constructions,
+including HMAC-MD5.
+
+## Minimum Supported Rust Version
+
+Rust **1.41** or higher.
+
+Minimum supported Rust version can be changed in the future, but it will be
+done with a minor version bump.
+
+## SemVer Policy
+
+- All on-by-default features of this library are covered by SemVer
+- MSRV is considered exempt from SemVer as noted above
+
+## License
+
+Licensed under either of:
+
+ * [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0)
+ * [MIT license](http://opensource.org/licenses/MIT)
+
+at your option.
+
+### Contribution
+
+Unless you explicitly state otherwise, any contribution intentionally submitted
+for inclusion in the work by you, as defined in the Apache-2.0 license, shall be
+dual licensed as above, without any additional terms or conditions.
+
+[//]: # (badges)
+
+[crate-image]: https://img.shields.io/crates/v/md-5.svg
+[crate-link]: https://crates.io/crates/md-5
+[docs-image]: https://docs.rs/md-5/badge.svg
+[docs-link]: https://docs.rs/md-5/
+[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
+[chat-image]: https://img.shields.io/badge/zulip-join_chat-blue.svg
+[chat-link]: https://rustcrypto.zulipchat.com/#narrow/stream/260041-hashes
+[build-image]: https://github.com/RustCrypto/hashes/workflows/md5/badge.svg?branch=master
+[build-link]: https://github.com/RustCrypto/hashes/actions?query=workflow%3Amd5
+
+[//]: # (general links)
+
+[1]: https://en.wikipedia.org/wiki/MD5
+[2]: https://www.kb.cert.org/vuls/id/836068
+[3]: https://dl.acm.org/citation.cfm?id=1724151
+[4]: https://tools.ietf.org/html/rfc6151
diff --git a/third_party/rust/md-5/benches/mod.rs b/third_party/rust/md-5/benches/mod.rs
new file mode 100644
index 0000000000..7729eb708c
--- /dev/null
+++ b/third_party/rust/md-5/benches/mod.rs
@@ -0,0 +1,14 @@
+#![feature(test)]
+extern crate test;
+
+use digest::bench_update;
+use md5::Md5;
+use test::Bencher;
+
+bench_update!(
+ Md5::default();
+ md5_10 10;
+ md5_100 100;
+ md5_1000 1000;
+ md5_10000 10000;
+);
diff --git a/third_party/rust/md-5/src/compress.rs b/third_party/rust/md-5/src/compress.rs
new file mode 100644
index 0000000000..46857038e3
--- /dev/null
+++ b/third_party/rust/md-5/src/compress.rs
@@ -0,0 +1,165 @@
+#![allow(clippy::many_single_char_names, clippy::unreadable_literal)]
+use core::convert::TryInto;
+
+const RC: [u32; 64] = [
+ // round 1
+ 0xd76aa478, 0xe8c7b756, 0x242070db, 0xc1bdceee, 0xf57c0faf, 0x4787c62a, 0xa8304613, 0xfd469501,
+ 0x698098d8, 0x8b44f7af, 0xffff5bb1, 0x895cd7be, 0x6b901122, 0xfd987193, 0xa679438e, 0x49b40821,
+ // round 2
+ 0xf61e2562, 0xc040b340, 0x265e5a51, 0xe9b6c7aa, 0xd62f105d, 0x02441453, 0xd8a1e681, 0xe7d3fbc8,
+ 0x21e1cde6, 0xc33707d6, 0xf4d50d87, 0x455a14ed, 0xa9e3e905, 0xfcefa3f8, 0x676f02d9, 0x8d2a4c8a,
+ // round 3
+ 0xfffa3942, 0x8771f681, 0x6d9d6122, 0xfde5380c, 0xa4beea44, 0x4bdecfa9, 0xf6bb4b60, 0xbebfbc70,
+ 0x289b7ec6, 0xeaa127fa, 0xd4ef3085, 0x04881d05, 0xd9d4d039, 0xe6db99e5, 0x1fa27cf8, 0xc4ac5665,
+ // round 4
+ 0xf4292244, 0x432aff97, 0xab9423a7, 0xfc93a039, 0x655b59c3, 0x8f0ccc92, 0xffeff47d, 0x85845dd1,
+ 0x6fa87e4f, 0xfe2ce6e0, 0xa3014314, 0x4e0811a1, 0xf7537e82, 0xbd3af235, 0x2ad7d2bb, 0xeb86d391,
+];
+
+#[inline(always)]
+fn op_f(w: u32, x: u32, y: u32, z: u32, m: u32, c: u32, s: u32) -> u32 {
+ ((x & y) | (!x & z))
+ .wrapping_add(w)
+ .wrapping_add(m)
+ .wrapping_add(c)
+ .rotate_left(s)
+ .wrapping_add(x)
+}
+#[inline(always)]
+fn op_g(w: u32, x: u32, y: u32, z: u32, m: u32, c: u32, s: u32) -> u32 {
+ ((x & z) | (y & !z))
+ .wrapping_add(w)
+ .wrapping_add(m)
+ .wrapping_add(c)
+ .rotate_left(s)
+ .wrapping_add(x)
+}
+
+#[inline(always)]
+fn op_h(w: u32, x: u32, y: u32, z: u32, m: u32, c: u32, s: u32) -> u32 {
+ (x ^ y ^ z)
+ .wrapping_add(w)
+ .wrapping_add(m)
+ .wrapping_add(c)
+ .rotate_left(s)
+ .wrapping_add(x)
+}
+
+#[inline(always)]
+fn op_i(w: u32, x: u32, y: u32, z: u32, m: u32, c: u32, s: u32) -> u32 {
+ (y ^ (x | !z))
+ .wrapping_add(w)
+ .wrapping_add(m)
+ .wrapping_add(c)
+ .rotate_left(s)
+ .wrapping_add(x)
+}
+
+#[inline]
+pub fn compress_block(state: &mut [u32; 4], input: &[u8; 64]) {
+ let mut a = state[0];
+ let mut b = state[1];
+ let mut c = state[2];
+ let mut d = state[3];
+
+ let mut data = [0u32; 16];
+ for (o, chunk) in data.iter_mut().zip(input.chunks_exact(4)) {
+ *o = u32::from_le_bytes(chunk.try_into().unwrap());
+ }
+
+ // round 1
+ a = op_f(a, b, c, d, data[0], RC[0], 7);
+ d = op_f(d, a, b, c, data[1], RC[1], 12);
+ c = op_f(c, d, a, b, data[2], RC[2], 17);
+ b = op_f(b, c, d, a, data[3], RC[3], 22);
+
+ a = op_f(a, b, c, d, data[4], RC[4], 7);
+ d = op_f(d, a, b, c, data[5], RC[5], 12);
+ c = op_f(c, d, a, b, data[6], RC[6], 17);
+ b = op_f(b, c, d, a, data[7], RC[7], 22);
+
+ a = op_f(a, b, c, d, data[8], RC[8], 7);
+ d = op_f(d, a, b, c, data[9], RC[9], 12);
+ c = op_f(c, d, a, b, data[10], RC[10], 17);
+ b = op_f(b, c, d, a, data[11], RC[11], 22);
+
+ a = op_f(a, b, c, d, data[12], RC[12], 7);
+ d = op_f(d, a, b, c, data[13], RC[13], 12);
+ c = op_f(c, d, a, b, data[14], RC[14], 17);
+ b = op_f(b, c, d, a, data[15], RC[15], 22);
+
+ // round 2
+ a = op_g(a, b, c, d, data[1], RC[16], 5);
+ d = op_g(d, a, b, c, data[6], RC[17], 9);
+ c = op_g(c, d, a, b, data[11], RC[18], 14);
+ b = op_g(b, c, d, a, data[0], RC[19], 20);
+
+ a = op_g(a, b, c, d, data[5], RC[20], 5);
+ d = op_g(d, a, b, c, data[10], RC[21], 9);
+ c = op_g(c, d, a, b, data[15], RC[22], 14);
+ b = op_g(b, c, d, a, data[4], RC[23], 20);
+
+ a = op_g(a, b, c, d, data[9], RC[24], 5);
+ d = op_g(d, a, b, c, data[14], RC[25], 9);
+ c = op_g(c, d, a, b, data[3], RC[26], 14);
+ b = op_g(b, c, d, a, data[8], RC[27], 20);
+
+ a = op_g(a, b, c, d, data[13], RC[28], 5);
+ d = op_g(d, a, b, c, data[2], RC[29], 9);
+ c = op_g(c, d, a, b, data[7], RC[30], 14);
+ b = op_g(b, c, d, a, data[12], RC[31], 20);
+
+ // round 3
+ a = op_h(a, b, c, d, data[5], RC[32], 4);
+ d = op_h(d, a, b, c, data[8], RC[33], 11);
+ c = op_h(c, d, a, b, data[11], RC[34], 16);
+ b = op_h(b, c, d, a, data[14], RC[35], 23);
+
+ a = op_h(a, b, c, d, data[1], RC[36], 4);
+ d = op_h(d, a, b, c, data[4], RC[37], 11);
+ c = op_h(c, d, a, b, data[7], RC[38], 16);
+ b = op_h(b, c, d, a, data[10], RC[39], 23);
+
+ a = op_h(a, b, c, d, data[13], RC[40], 4);
+ d = op_h(d, a, b, c, data[0], RC[41], 11);
+ c = op_h(c, d, a, b, data[3], RC[42], 16);
+ b = op_h(b, c, d, a, data[6], RC[43], 23);
+
+ a = op_h(a, b, c, d, data[9], RC[44], 4);
+ d = op_h(d, a, b, c, data[12], RC[45], 11);
+ c = op_h(c, d, a, b, data[15], RC[46], 16);
+ b = op_h(b, c, d, a, data[2], RC[47], 23);
+
+ // round 4
+ a = op_i(a, b, c, d, data[0], RC[48], 6);
+ d = op_i(d, a, b, c, data[7], RC[49], 10);
+ c = op_i(c, d, a, b, data[14], RC[50], 15);
+ b = op_i(b, c, d, a, data[5], RC[51], 21);
+
+ a = op_i(a, b, c, d, data[12], RC[52], 6);
+ d = op_i(d, a, b, c, data[3], RC[53], 10);
+ c = op_i(c, d, a, b, data[10], RC[54], 15);
+ b = op_i(b, c, d, a, data[1], RC[55], 21);
+
+ a = op_i(a, b, c, d, data[8], RC[56], 6);
+ d = op_i(d, a, b, c, data[15], RC[57], 10);
+ c = op_i(c, d, a, b, data[6], RC[58], 15);
+ b = op_i(b, c, d, a, data[13], RC[59], 21);
+
+ a = op_i(a, b, c, d, data[4], RC[60], 6);
+ d = op_i(d, a, b, c, data[11], RC[61], 10);
+ c = op_i(c, d, a, b, data[2], RC[62], 15);
+ b = op_i(b, c, d, a, data[9], RC[63], 21);
+
+ state[0] = state[0].wrapping_add(a);
+ state[1] = state[1].wrapping_add(b);
+ state[2] = state[2].wrapping_add(c);
+ state[3] = state[3].wrapping_add(d);
+}
+
+#[inline]
+pub fn compress(state: &mut [u32; 4], blocks: &[[u8; 64]]) {
+ for block in blocks {
+ compress_block(state, block)
+ }
+}
diff --git a/third_party/rust/md-5/src/lib.rs b/third_party/rust/md-5/src/lib.rs
new file mode 100644
index 0000000000..87fe9134fb
--- /dev/null
+++ b/third_party/rust/md-5/src/lib.rs
@@ -0,0 +1,146 @@
+//! An implementation of the [MD5][1] cryptographic hash algorithm.
+//!
+//! # Usage
+//!
+//! ```rust
+//! use md5::{Md5, Digest};
+//! use hex_literal::hex;
+//!
+//! // create a Md5 hasher instance
+//! let mut hasher = Md5::new();
+//!
+//! // process input message
+//! hasher.update(b"hello world");
+//!
+//! // acquire hash digest in the form of GenericArray,
+//! // which in this case is equivalent to [u8; 16]
+//! let result = hasher.finalize();
+//! assert_eq!(result[..], hex!("5eb63bbbe01eeed093cb22bb8f5acdc3"));
+//! ```
+//!
+//! Also see [RustCrypto/hashes][2] readme.
+//!
+//! [1]: https://en.wikipedia.org/wiki/MD5
+//! [2]: https://github.com/RustCrypto/hashes
+
+#![no_std]
+#![doc(
+ html_logo_url = "https://raw.githubusercontent.com/RustCrypto/media/6ee8e381/logo.svg",
+ html_favicon_url = "https://raw.githubusercontent.com/RustCrypto/media/6ee8e381/logo.svg"
+)]
+#![warn(missing_docs, rust_2018_idioms)]
+
+#[cfg(all(feature = "asm", any(target_arch = "x86", target_arch = "x86_64")))]
+extern crate md5_asm as compress;
+
+#[cfg(not(all(feature = "asm", any(target_arch = "x86", target_arch = "x86_64"))))]
+mod compress;
+
+pub use digest::{self, Digest};
+
+use compress::compress;
+
+use core::{fmt, slice::from_ref};
+#[cfg(feature = "oid")]
+use digest::const_oid::{AssociatedOid, ObjectIdentifier};
+use digest::{
+ block_buffer::Eager,
+ core_api::{
+ AlgorithmName, Block, BlockSizeUser, Buffer, BufferKindUser, CoreWrapper, FixedOutputCore,
+ OutputSizeUser, Reset, UpdateCore,
+ },
+ typenum::{Unsigned, U16, U64},
+ HashMarker, Output,
+};
+/// Core MD5 hasher state.
+#[derive(Clone)]
+pub struct Md5Core {
+ block_len: u64,
+ state: [u32; 4],
+}
+
+impl HashMarker for Md5Core {}
+
+impl BlockSizeUser for Md5Core {
+ type BlockSize = U64;
+}
+
+impl BufferKindUser for Md5Core {
+ type BufferKind = Eager;
+}
+
+impl OutputSizeUser for Md5Core {
+ type OutputSize = U16;
+}
+
+impl UpdateCore for Md5Core {
+ #[inline]
+ fn update_blocks(&mut self, blocks: &[Block<Self>]) {
+ self.block_len = self.block_len.wrapping_add(blocks.len() as u64);
+ compress(&mut self.state, convert(blocks))
+ }
+}
+
+impl FixedOutputCore for Md5Core {
+ #[inline]
+ fn finalize_fixed_core(&mut self, buffer: &mut Buffer<Self>, out: &mut Output<Self>) {
+ let bit_len = self
+ .block_len
+ .wrapping_mul(Self::BlockSize::U64)
+ .wrapping_add(buffer.get_pos() as u64)
+ .wrapping_mul(8);
+ let mut s = self.state;
+ buffer.len64_padding_le(bit_len, |b| compress(&mut s, convert(from_ref(b))));
+ for (chunk, v) in out.chunks_exact_mut(4).zip(s.iter()) {
+ chunk.copy_from_slice(&v.to_le_bytes());
+ }
+ }
+}
+
+impl Default for Md5Core {
+ #[inline]
+ fn default() -> Self {
+ Self {
+ block_len: 0,
+ state: [0x6745_2301, 0xEFCD_AB89, 0x98BA_DCFE, 0x1032_5476],
+ }
+ }
+}
+
+impl Reset for Md5Core {
+ #[inline]
+ fn reset(&mut self) {
+ *self = Default::default();
+ }
+}
+
+impl AlgorithmName for Md5Core {
+ fn write_alg_name(f: &mut fmt::Formatter<'_>) -> fmt::Result {
+ f.write_str("Md5")
+ }
+}
+
+impl fmt::Debug for Md5Core {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+ f.write_str("Md5Core { ... }")
+ }
+}
+
+#[cfg(feature = "oid")]
+#[cfg_attr(docsrs, doc(cfg(feature = "oid")))]
+impl AssociatedOid for Md5Core {
+ const OID: ObjectIdentifier = ObjectIdentifier::new_unwrap("1.2.840.113549.2.5");
+}
+
+/// MD5 hasher state.
+pub type Md5 = CoreWrapper<Md5Core>;
+
+const BLOCK_SIZE: usize = <Md5Core as BlockSizeUser>::BlockSize::USIZE;
+
+#[inline(always)]
+fn convert(blocks: &[Block<Md5Core>]) -> &[[u8; BLOCK_SIZE]] {
+ // SAFETY: GenericArray<u8, U64> and [u8; 64] have
+ // exactly the same memory layout
+ let p = blocks.as_ptr() as *const [u8; BLOCK_SIZE];
+ unsafe { core::slice::from_raw_parts(p, blocks.len()) }
+}
diff --git a/third_party/rust/md-5/tests/data/md5.blb b/third_party/rust/md-5/tests/data/md5.blb
new file mode 100644
index 0000000000..3f6d643839
--- /dev/null
+++ b/third_party/rust/md-5/tests/data/md5.blb
Binary files differ
diff --git a/third_party/rust/md-5/tests/mod.rs b/third_party/rust/md-5/tests/mod.rs
new file mode 100644
index 0000000000..316cb8fbe9
--- /dev/null
+++ b/third_party/rust/md-5/tests/mod.rs
@@ -0,0 +1,15 @@
+use digest::dev::{feed_rand_16mib, fixed_reset_test};
+use hex_literal::hex;
+use md5::{Digest, Md5};
+
+digest::new_test!(md5_main, "md5", md5::Md5, fixed_reset_test);
+
+#[test]
+fn md5_rand() {
+ let mut h = Md5::new();
+ feed_rand_16mib(&mut h);
+ assert_eq!(
+ h.finalize()[..],
+ hex!("61aec26f1b909578ef638ae02dac0977")[..]
+ );
+}