chore: checkpoint before Python removal

This commit is contained in:
2026-03-26 22:33:59 +00:00
parent 683cec9307
commit e568ddf82a
29972 changed files with 11269302 additions and 2 deletions

1
vendor/blake2/.cargo-checksum.json vendored Normal file
View File

@@ -0,0 +1 @@
{"files":{".cargo_vcs_info.json":"4a6647eae78567b5ffee84c768035d1cc1291d305162b99d7add8c72d05a3441","CHANGELOG.md":"3ef44e9baac1fd907756799009f4452ace487c9e80b32518fe2bdb758929255f","Cargo.toml":"44e9d8775828733264ddd041abf6faab096ddc25b4d6138c0274a5c98b000bda","Cargo.toml.orig":"52e3b2e2163a7fa9c44f030daf65707bbcadb5f620657acaa47c7574909a6319","LICENSE-APACHE":"a9040321c3712d8fd0b09cf52b17445de04a23a10165049ae187cd39e5c86be5","LICENSE-MIT":"9c768944eb4a0422ca2efc25ea9fb2fb9e7fbd3fdb04e86b87366339cb7466db","README.md":"b0218e8484d85a340ca0e21c13752355e7a24e17497e62bdb674717f5eb88bec","benches/mod.rs":"f61c6cacfe1a3f70940806d0213572f7887dc1ecc9c1946a868baad3e8a6c341","src/as_bytes.rs":"01e8e60ef0a9b68fa6bae6c1577f3967aef442c245003967604eef7e9ccae5a9","src/consts.rs":"03edc1d4697a6074c9389202324444f27625ef11f17d34cc86b83d0dda920e79","src/lib.rs":"4014e33ab4dbe879ebf8168a4cbe88f71b837589e1cd238fd469e0579337f9ff","src/macros.rs":"4d92b71adb3f464758635fa00058d478b814bb5004e5677055815547acf3a698","src/simd.rs":"79d6d11d14664c908c2f6a2120c23e8de0e0422b610a8b838aa95ba469ef43fc","src/simd/simd_opt.rs":"b254d82005e288f1d07531ef71b2468be0bc70ae9bdba1b46001acac4db283fe","src/simd/simd_opt/u32x4.rs":"f87ab763a2f7a60e0192c9eb16df3fd172f7e1747cd26e081b5e7f074701b13c","src/simd/simd_opt/u64x4.rs":"6f9e371ec300bbb3af4f4f6d9b052257eb4da669b5595b16b17f4710559f5b85","src/simd/simdint.rs":"3b506bb05761752142f61ca8de138958af9a050ddcfe5bbf454dd9a003bf71c3","src/simd/simdop.rs":"6154f31c9675f33ba476eb6d5378deda657afc79ad43be1c9257f4f4306e43ce","src/simd/simdty.rs":"24e6e7eac6005eec0aceec7b96b3a8e04ca695479bfd22e704f51926515f6f13","tests/data/blake2b/fixed.blb":"b8e100fe195f7c201973fdcb6cfcd23cc752f5c8c9431a3076208ec81709d658","tests/data/blake2b/mac.blb":"79b14e080b63c0860823c7837b8b005d9b9fbeab6cd2eaa072621ff377eafd7a","tests/data/blake2b/variable.blb":"c91130bc29c9fad4c952b79c4126bebd752073d033bf41bfe54dd656b37698e9","tests/data/blake2s/mac.blb":"4bca0c66c84951babf34ff95b9d8b0d5f6332403000bbd40cebcc142ff22d832","tests/data/blake2s/variable.blb":"ef88d9f6407013337ac8ed587ec1552b502f1001e029291c6075b40e44e3d63a","tests/mac.rs":"1e5c414e1cd44cc023ea3b7dc8a154fe8a6b36dce496a3b7a5b933e412ed51c0","tests/mod.rs":"d2da3d57ecaddbfcf292fd0475ebfd988efd52f992bd08113ef4b990f961087d","tests/persona.rs":"5e7131d30c3b4a777cc8bd8c74c00cf418d80241da10a7b74e12282c8e3fd775"},"package":"46502ad458c9a52b69d4d4d32775c788b7a1b85e8bc9d482d92250fc0e3f8efe"}

6
vendor/blake2/.cargo_vcs_info.json vendored Normal file
View File

@@ -0,0 +1,6 @@
{
"git": {
"sha1": "1f727ce37ff40fa0cce84eb8543a45bdd3ca4a4e"
},
"path_in_vcs": "blake2"
}

128
vendor/blake2/CHANGELOG.md vendored Normal file
View File

@@ -0,0 +1,128 @@
# 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.6 (2022-12-16)
### Added
- `size_opt` Cargo feature ([#440])
### Changed
- Implement `KeyInit::new` in terms of `KeyInit::new_from_slice` ([#435])
[#435]: https://github.com/RustCrypto/hashes/pull/435
[#440]: https://github.com/RustCrypto/hashes/pull/440
## 0.10.5 (2022-11-11)
### Fixed
- Implementation of the `KeyInit::new` method for MAC types ([#432])
[#432]: https://github.com/RustCrypto/hashes/pull/432
## 0.10.4 (2022-02-17) [YANKED]
### Fixed
- Bug on big-endian targets ([#366])
[#366]: https://github.com/RustCrypto/hashes/pull/366
## 0.10.3 (2022-02-17) [YANKED]
### Fixed
- Minimal versions build ([#363])
[#363]: https://github.com/RustCrypto/hashes/pull/363
## 0.10.2 (2022-01-09) [YANKED]
## Fixed
- Rare compilation error by adding `'static` bound on `OutSize`. ([#347])
- Values of `KeySize` associated type. ([#349])
[#347]: https://github.com/RustCrypto/hashes/pull/347
[#349]: https://github.com/RustCrypto/hashes/pull/349
## 0.10.1 (2022-01-05) [YANKED]
## Fixed
- Compilation error with enabled `reset` feature. ([#342])
[#342]: https://github.com/RustCrypto/hashes/pull/342
## 0.10.0 (2021-12-07) [YANKED]
### Changed
- Update to `digest` v0.10 and remove dependency on `crypto-mac` ([#217])
- `Blake2b` and `Blake2s` renamed into `Blake2b512` and `Blake2s256` respectively.
New `Blake2b` and `Blake2s` are generic over output size. `VarBlake2b` and `VarBlake2s`
renamed into `Blake2bVar` and `Blake2sVar` respectively. ([#217])
- Hasher reset functionality moved behind a new non-default feature, `reset`.
This must be enabled to use the methods `reset`, `finalize_reset` and `finalize_into_reset`.
### Removed
- `Blake2b` and `Blake2s` no longer support MAC functionality. ([#217])
### Added
- Separate `Blake2bMac` and `Blake2sMac` types generic over output size and `Blake2bMac512`
and `Blake2sMac256` type aliases around them. ([#217])
[#217]: https://github.com/RustCrypto/hashes/pull/217
## 0.9.2 (2021-08-25)
### Fixed
- Building with `simd_opt` on recent nightlies ([#301])
[#301]: https://github.com/RustCrypto/hashes/pull/301
## 0.9.1 (2020-10-26)
### Changed
- Bump `opaque-debug` to v0.3 ([#168])
- Bump `block-buffer` to v0.9 ([#164])
[#168]: https://github.com/RustCrypto/hashes/pull/168
[#164]: https://github.com/RustCrypto/hashes/pull/164
## 0.9.0 (2020-06-10)
### Added
- Support for Persona and Salt ([#78])
### Changed
- Update to `digest` v0.9 release; MSRV 1.41+ ([#155])
- Use new `*Dirty` traits from the `digest` crate ([#153])
- Bump `crypto-mac` to v0.8 release ([#152])
- Bump `block-buffer` to v0.8 release ([#151])
- Rename `*result*` to `finalize` ([#148])
- Upgrade to Rust 2018 edition ([#119])
[#155]: https://github.com/RustCrypto/hashes/pull/155
[#153]: https://github.com/RustCrypto/hashes/pull/153
[#152]: https://github.com/RustCrypto/hashes/pull/152
[#151]: https://github.com/RustCrypto/hashes/pull/151
[#148]: https://github.com/RustCrypto/hashes/pull/148
[#119]: https://github.com/RustCrypto/hashes/pull/133
[#78]: https://github.com/RustCrypto/hashes/pull/78
## 0.8.1 (2019-08-25)
## 0.8.0 (2018-10-11)
## 0.7.1 (2018-04-30)
## 0.7.0 (2017-11-15)
## 0.6.1 (2017-07-24)
## 0.6.0 (2017-06-12)
## 0.5.2 (2017-05-17)
## 0.5.1 (2017-05-02)
## 0.5.0 (2017-04-06)
## 0.4.0 (2017-03-06)
## 0.3.0 (2016-11-17)
## 0.2.0 (2016-10-14)
## 0.1.1 (2016-10-11)
## 0.1.0 (2016-10-09)

51
vendor/blake2/Cargo.toml vendored Normal file
View File

@@ -0,0 +1,51 @@
# 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 = "blake2"
version = "0.10.6"
authors = ["RustCrypto Developers"]
description = "BLAKE2 hash functions"
documentation = "https://docs.rs/blake2"
readme = "README.md"
keywords = [
"crypto",
"blake2",
"hash",
"digest",
]
categories = [
"cryptography",
"no-std",
]
license = "MIT OR Apache-2.0"
repository = "https://github.com/RustCrypto/hashes"
[dependencies.digest]
version = "0.10.3"
features = ["mac"]
[dev-dependencies.digest]
version = "0.10.3"
features = ["dev"]
[dev-dependencies.hex-literal]
version = "0.2.2"
[features]
default = ["std"]
reset = []
simd = []
simd_asm = ["simd_opt"]
simd_opt = ["simd"]
size_opt = []
std = ["digest/std"]

201
vendor/blake2/LICENSE-APACHE vendored Normal file
View File

@@ -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.

26
vendor/blake2/LICENSE-MIT vendored Normal file
View File

@@ -0,0 +1,26 @@
Copyright (c) 2015-2016 The blake2-rfc Developers, Cesar Barros
Copyright (c) 2017 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.

56
vendor/blake2/README.md vendored Normal file
View File

@@ -0,0 +1,56 @@
# RustCrypto: BLAKE2
[![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 [BLAKE2 hash function][1] family.
[Documentation][docs-link]
## 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/blake2.svg
[crate-link]: https://crates.io/crates/blake2
[docs-image]: https://docs.rs/blake2/badge.svg
[docs-link]: https://docs.rs/blake2/
[license-image]: https://img.shields.io/badge/license-Apache2.0/MIT-blue.svg
[chat-image]: https://img.shields.io/badge/zulip-join_chat-blue.svg
[chat-link]: https://rustcrypto.zulipchat.com/#narrow/stream/260041-hashes
[rustc-image]: https://img.shields.io/badge/rustc-1.41+-blue.svg
[build-image]: https://github.com/RustCrypto/hashes/workflows/blake2/badge.svg?branch=master
[build-link]: https://github.com/RustCrypto/hashes/actions?query=workflow%3Ablake2
[//]: # (general links)
[1]: https://blake2.net/

22
vendor/blake2/benches/mod.rs vendored Normal file
View File

@@ -0,0 +1,22 @@
#![feature(test)]
extern crate test;
use blake2::{Blake2b512, Blake2s256};
use digest::bench_update;
use test::Bencher;
bench_update!(
Blake2b512::default();
blake2b512_10 10;
blake2b512_100 100;
blake2b512_1000 1000;
blake2b512_10000 10000;
);
bench_update!(
Blake2s256::default();
blake2s256_10 10;
blake2s256_100 100;
blake2s256_1000 1000;
blake2s256_10000 10000;
);

45
vendor/blake2/src/as_bytes.rs vendored Normal file
View File

@@ -0,0 +1,45 @@
// Copyright 2016 blake2-rfc Developers
//
// Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or
// http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or
// http://opensource.org/licenses/MIT>, at your option. This file may not be
// copied, modified, or distributed except according to those terms.
use core::mem;
use core::slice;
#[allow(clippy::missing_safety_doc)]
pub unsafe trait Safe {}
pub trait AsBytes {
fn as_bytes(&self) -> &[u8];
fn as_mut_bytes(&mut self) -> &mut [u8];
}
impl<T: Safe> AsBytes for [T] {
#[inline]
fn as_bytes(&self) -> &[u8] {
unsafe {
slice::from_raw_parts(self.as_ptr() as *const u8, self.len() * mem::size_of::<T>())
}
}
#[inline]
fn as_mut_bytes(&mut self) -> &mut [u8] {
unsafe {
slice::from_raw_parts_mut(
self.as_mut_ptr() as *mut u8,
self.len() * mem::size_of::<T>(),
)
}
}
}
unsafe impl Safe for u8 {}
unsafe impl Safe for u16 {}
unsafe impl Safe for u32 {}
unsafe impl Safe for u64 {}
unsafe impl Safe for i8 {}
unsafe impl Safe for i16 {}
unsafe impl Safe for i32 {}
unsafe impl Safe for i64 {}

47
vendor/blake2/src/consts.rs vendored Normal file
View File

@@ -0,0 +1,47 @@
#![allow(clippy::unreadable_literal)]
pub static SIGMA: [[usize; 16]; 12] = [
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],
[14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3],
[11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4],
[7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8],
[9, 0, 5, 7, 2, 4, 10, 15, 14, 1, 11, 12, 6, 8, 3, 13],
[2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5, 15, 14, 1, 9],
[12, 5, 1, 15, 14, 13, 4, 10, 0, 7, 6, 3, 9, 2, 8, 11],
[13, 11, 7, 14, 12, 1, 3, 9, 5, 0, 15, 4, 8, 6, 2, 10],
[6, 15, 14, 9, 11, 3, 0, 8, 12, 2, 13, 7, 1, 4, 10, 5],
[10, 2, 8, 4, 7, 6, 1, 5, 15, 11, 9, 14, 3, 12, 13, 0],
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],
[14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3],
];
pub static BLAKE2B_IV: [u64; 8] = [
0x6a09e667f3bcc908,
0xbb67ae8584caa73b,
0x3c6ef372fe94f82b,
0xa54ff53a5f1d36f1,
0x510e527fade682d1,
0x9b05688c2b3e6c1f,
0x1f83d9abfb41bd6b,
0x5be0cd19137e2179,
];
/*
pub const BLAKE2B_BLOCKBYTES : usize = 128;
pub const BLAKE2B_OUTBYTES : usize = 64;
pub const BLAKE2B_KEYBYTES : usize = 64;
pub const BLAKE2B_SALTBYTES : usize = 16;
pub const BLAKE2B_PERSONALBYTES : usize = 16;
*/
pub static BLAKE2S_IV: [u32; 8] = [
0x6A09E667, 0xBB67AE85, 0x3C6EF372, 0xA54FF53A, 0x510E527F, 0x9B05688C, 0x1F83D9AB, 0x5BE0CD19,
];
/*
pub const BLAKE2S_BLOCKBYTES : usize = 64;
pub const BLAKE2S_OUTBYTES : usize = 32;
pub const BLAKE2S_KEYBYTES : usize = 32;
pub const BLAKE2S_SALTBYTES : usize = 8;
pub const BLAKE2S_PERSONALBYTES : usize = 8;
*/

172
vendor/blake2/src/lib.rs vendored Normal file
View File

@@ -0,0 +1,172 @@
//! An implementation of the [BLAKE2][1] hash functions.
//!
//! # Usage
//!
//! [`Blake2b512`] and [`Blake2s256`] can be used in the following way:
//!
//! ```rust
//! use blake2::{Blake2b512, Blake2s256, Digest};
//! use hex_literal::hex;
//!
//! // create a Blake2b512 object
//! let mut hasher = Blake2b512::new();
//!
//! // write input message
//! hasher.update(b"hello world");
//!
//! // read hash digest and consume hasher
//! let res = hasher.finalize();
//! assert_eq!(res[..], hex!("
//! 021ced8799296ceca557832ab941a50b4a11f83478cf141f51f933f653ab9fbc
//! c05a037cddbed06e309bf334942c4e58cdf1a46e237911ccd7fcf9787cbc7fd0
//! ")[..]);
//!
//! // same example for Blake2s256:
//! let mut hasher = Blake2s256::new();
//! hasher.update(b"hello world");
//! let res = hasher.finalize();
//! assert_eq!(res[..], hex!("
//! 9aec6806794561107e594b1f6a8a6b0c92a0cba9acf5e5e93cca06f781813b0b
//! ")[..]);
//! ```
//!
//! Also see [RustCrypto/hashes](https://github.com/RustCrypto/hashes) readme.
//!
//! ## Variable output size
//!
//! This implementation supports run and compile time variable sizes.
//!
//! Run time variable output example:
//! ```rust
//! use blake2::Blake2bVar;
//! use blake2::digest::{Update, VariableOutput};
//! use hex_literal::hex;
//!
//! let mut hasher = Blake2bVar::new(10).unwrap();
//! hasher.update(b"my_input");
//! let mut buf = [0u8; 10];
//! hasher.finalize_variable(&mut buf).unwrap();
//! assert_eq!(buf, hex!("2cc55c84e416924e6400"));
//! ```
//!
//! Compile time variable output example:
//! ```rust
//! use blake2::{Blake2b, Digest, digest::consts::U10};
//! use hex_literal::hex;
//!
//! type Blake2b80 = Blake2b<U10>;
//!
//! let mut hasher = Blake2b80::new();
//! hasher.update(b"my_input");
//! let res = hasher.finalize();
//! assert_eq!(res[..], hex!("2cc55c84e416924e6400")[..]);
//! ```
//!
//! # Acknowledgment
//! Based on the [blake2-rfc][2] crate.
//!
//! [1]: https://en.wikipedia.org/wiki/BLAKE_(hash_function)#BLAKE2
//! [2]: https://github.com/cesarb/blake2-rfc
#![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_attr(feature = "simd", feature(platform_intrinsics, repr_simd))]
#![cfg_attr(feature = "simd", allow(incomplete_features))]
#[cfg(feature = "std")]
extern crate std;
pub use digest::{self, Digest};
use core::{convert::TryInto, fmt, marker::PhantomData, ops::Div};
use digest::{
block_buffer::{Lazy, LazyBuffer},
consts::{U128, U32, U4, U64},
core_api::{
AlgorithmName, Block, BlockSizeUser, Buffer, BufferKindUser, CoreWrapper,
CtVariableCoreWrapper, OutputSizeUser, RtVariableCoreWrapper, TruncSide, UpdateCore,
VariableOutputCore,
},
crypto_common::{InvalidLength, Key, KeyInit, KeySizeUser},
generic_array::{ArrayLength, GenericArray},
typenum::{IsLessOrEqual, LeEq, NonZero, Unsigned},
FixedOutput, HashMarker, InvalidOutputSize, MacMarker, Output, Update,
};
#[cfg(feature = "reset")]
use digest::{FixedOutputReset, Reset};
mod as_bytes;
mod consts;
mod simd;
#[macro_use]
mod macros;
use as_bytes::AsBytes;
use consts::{BLAKE2B_IV, BLAKE2S_IV};
use simd::{u32x4, u64x4, Vector4};
blake2_impl!(
Blake2bVarCore,
"Blake2b",
u64,
u64x4,
U64,
U128,
32,
24,
16,
63,
BLAKE2B_IV,
"Blake2b instance with a variable output.",
"Blake2b instance with a fixed output.",
);
/// BLAKE2b which allows to choose output size at runtime.
pub type Blake2bVar = RtVariableCoreWrapper<Blake2bVarCore>;
/// Core hasher state of BLAKE2b generic over output size.
pub type Blake2bCore<OutSize> = CtVariableCoreWrapper<Blake2bVarCore, OutSize>;
/// BLAKE2b generic over output size.
pub type Blake2b<OutSize> = CoreWrapper<Blake2bCore<OutSize>>;
/// BLAKE2b-512 hasher state.
pub type Blake2b512 = Blake2b<U64>;
blake2_mac_impl!(Blake2bMac, Blake2bVarCore, U64, "Blake2b MAC function");
/// BLAKE2b-512 MAC state.
pub type Blake2bMac512 = Blake2bMac<U64>;
blake2_impl!(
Blake2sVarCore,
"Blake2s",
u32,
u32x4,
U32,
U64,
16,
12,
8,
7,
BLAKE2S_IV,
"Blake2s instance with a variable output.",
"Blake2s instance with a fixed output.",
);
/// BLAKE2s which allows to choose output size at runtime.
pub type Blake2sVar = RtVariableCoreWrapper<Blake2sVarCore>;
/// Core hasher state of BLAKE2s generic over output size.
pub type Blake2sCore<OutSize> = CtVariableCoreWrapper<Blake2sVarCore, OutSize>;
/// BLAKE2s generic over output size.
pub type Blake2s<OutSize> = CoreWrapper<Blake2sCore<OutSize>>;
/// BLAKE2s-256 hasher state.
pub type Blake2s256 = Blake2s<U32>;
blake2_mac_impl!(Blake2sMac, Blake2sVarCore, U32, "Blake2s MAC function");
/// BLAKE2s-256 MAC state.
pub type Blake2sMac256 = Blake2sMac<U32>;

432
vendor/blake2/src/macros.rs vendored Normal file
View File

@@ -0,0 +1,432 @@
macro_rules! blake2_impl {
(
$name:ident, $alg_name:expr, $word:ident, $vec:ident, $bytes:ident,
$block_size:ident, $R1:expr, $R2:expr, $R3:expr, $R4:expr, $IV:expr,
$vardoc:expr, $doc:expr,
) => {
#[derive(Clone)]
#[doc=$vardoc]
pub struct $name {
h: [$vec; 2],
t: u64,
#[cfg(feature = "reset")]
h0: [$vec; 2],
}
impl $name {
#[inline(always)]
fn iv0() -> $vec {
$vec::new($IV[0], $IV[1], $IV[2], $IV[3])
}
#[inline(always)]
fn iv1() -> $vec {
$vec::new($IV[4], $IV[5], $IV[6], $IV[7])
}
/// Creates a new context with the full set of sequential-mode parameters.
pub fn new_with_params(
salt: &[u8],
persona: &[u8],
key_size: usize,
output_size: usize,
) -> Self {
assert!(key_size <= $bytes::to_usize());
assert!(output_size <= $bytes::to_usize());
// The number of bytes needed to express two words.
let length = $bytes::to_usize() / 4;
assert!(salt.len() <= length);
assert!(persona.len() <= length);
// Build a parameter block
let mut p = [0 as $word; 8];
p[0] = 0x0101_0000 ^ ((key_size as $word) << 8) ^ (output_size as $word);
// salt is two words long
if salt.len() < length {
let mut padded_salt =
GenericArray::<u8, <$bytes as Div<U4>>::Output>::default();
for i in 0..salt.len() {
padded_salt[i] = salt[i];
}
p[4] = $word::from_le_bytes(padded_salt[0..length / 2].try_into().unwrap());
p[5] = $word::from_le_bytes(
padded_salt[length / 2..padded_salt.len()]
.try_into()
.unwrap(),
);
} else {
p[4] = $word::from_le_bytes(salt[0..salt.len() / 2].try_into().unwrap());
p[5] =
$word::from_le_bytes(salt[salt.len() / 2..salt.len()].try_into().unwrap());
}
// persona is also two words long
if persona.len() < length {
let mut padded_persona =
GenericArray::<u8, <$bytes as Div<U4>>::Output>::default();
for i in 0..persona.len() {
padded_persona[i] = persona[i];
}
p[6] = $word::from_le_bytes(padded_persona[0..length / 2].try_into().unwrap());
p[7] = $word::from_le_bytes(
padded_persona[length / 2..padded_persona.len()]
.try_into()
.unwrap(),
);
} else {
p[6] = $word::from_le_bytes(persona[0..length / 2].try_into().unwrap());
p[7] = $word::from_le_bytes(
persona[length / 2..persona.len()].try_into().unwrap(),
);
}
let h = [
Self::iv0() ^ $vec::new(p[0], p[1], p[2], p[3]),
Self::iv1() ^ $vec::new(p[4], p[5], p[6], p[7]),
];
$name {
#[cfg(feature = "reset")]
h0: h.clone(),
h,
t: 0,
}
}
fn finalize_with_flag(
&mut self,
final_block: &GenericArray<u8, $block_size>,
flag: $word,
out: &mut Output<Self>,
) {
self.compress(final_block, !0, flag);
let buf = [self.h[0].to_le(), self.h[1].to_le()];
out.copy_from_slice(buf.as_bytes())
}
fn compress(&mut self, block: &Block<Self>, f0: $word, f1: $word) {
use $crate::consts::SIGMA;
#[cfg_attr(not(feature = "size_opt"), inline(always))]
fn quarter_round(v: &mut [$vec; 4], rd: u32, rb: u32, m: $vec) {
v[0] = v[0].wrapping_add(v[1]).wrapping_add(m.from_le());
v[3] = (v[3] ^ v[0]).rotate_right_const(rd);
v[2] = v[2].wrapping_add(v[3]);
v[1] = (v[1] ^ v[2]).rotate_right_const(rb);
}
#[cfg_attr(not(feature = "size_opt"), inline(always))]
fn shuffle(v: &mut [$vec; 4]) {
v[1] = v[1].shuffle_left_1();
v[2] = v[2].shuffle_left_2();
v[3] = v[3].shuffle_left_3();
}
#[cfg_attr(not(feature = "size_opt"), inline(always))]
fn unshuffle(v: &mut [$vec; 4]) {
v[1] = v[1].shuffle_right_1();
v[2] = v[2].shuffle_right_2();
v[3] = v[3].shuffle_right_3();
}
#[cfg_attr(not(feature = "size_opt"), inline(always))]
fn round(v: &mut [$vec; 4], m: &[$word; 16], s: &[usize; 16]) {
quarter_round(v, $R1, $R2, $vec::gather(m, s[0], s[2], s[4], s[6]));
quarter_round(v, $R3, $R4, $vec::gather(m, s[1], s[3], s[5], s[7]));
shuffle(v);
quarter_round(v, $R1, $R2, $vec::gather(m, s[8], s[10], s[12], s[14]));
quarter_round(v, $R3, $R4, $vec::gather(m, s[9], s[11], s[13], s[15]));
unshuffle(v);
}
let mut m: [$word; 16] = Default::default();
let n = core::mem::size_of::<$word>();
for (v, chunk) in m.iter_mut().zip(block.chunks_exact(n)) {
*v = $word::from_ne_bytes(chunk.try_into().unwrap());
}
let h = &mut self.h;
let t0 = self.t as $word;
let t1 = match $bytes::to_u8() {
64 => 0,
32 => (self.t >> 32) as $word,
_ => unreachable!(),
};
let mut v = [
h[0],
h[1],
Self::iv0(),
Self::iv1() ^ $vec::new(t0, t1, f0, f1),
];
round(&mut v, &m, &SIGMA[0]);
round(&mut v, &m, &SIGMA[1]);
round(&mut v, &m, &SIGMA[2]);
round(&mut v, &m, &SIGMA[3]);
round(&mut v, &m, &SIGMA[4]);
round(&mut v, &m, &SIGMA[5]);
round(&mut v, &m, &SIGMA[6]);
round(&mut v, &m, &SIGMA[7]);
round(&mut v, &m, &SIGMA[8]);
round(&mut v, &m, &SIGMA[9]);
if $bytes::to_u8() == 64 {
round(&mut v, &m, &SIGMA[0]);
round(&mut v, &m, &SIGMA[1]);
}
h[0] = h[0] ^ (v[0] ^ v[2]);
h[1] = h[1] ^ (v[1] ^ v[3]);
}
}
impl HashMarker for $name {}
impl BlockSizeUser for $name {
type BlockSize = $block_size;
}
impl BufferKindUser for $name {
type BufferKind = Lazy;
}
impl UpdateCore for $name {
#[inline]
fn update_blocks(&mut self, blocks: &[Block<Self>]) {
for block in blocks {
self.t += block.len() as u64;
self.compress(block, 0, 0);
}
}
}
impl OutputSizeUser for $name {
type OutputSize = $bytes;
}
impl VariableOutputCore for $name {
const TRUNC_SIDE: TruncSide = TruncSide::Left;
#[inline]
fn new(output_size: usize) -> Result<Self, InvalidOutputSize> {
if output_size > Self::OutputSize::USIZE {
return Err(InvalidOutputSize);
}
Ok(Self::new_with_params(&[], &[], 0, output_size))
}
#[inline]
fn finalize_variable_core(
&mut self,
buffer: &mut Buffer<Self>,
out: &mut Output<Self>,
) {
self.t += buffer.get_pos() as u64;
let block = buffer.pad_with_zeros();
self.finalize_with_flag(block, 0, out);
}
}
#[cfg(feature = "reset")]
impl Reset for $name {
fn reset(&mut self) {
self.h = self.h0;
self.t = 0;
}
}
impl AlgorithmName for $name {
#[inline]
fn write_alg_name(f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str($alg_name)
}
}
impl fmt::Debug for $name {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str(concat!(stringify!($name), " { ... }"))
}
}
};
}
macro_rules! blake2_mac_impl {
(
$name:ident, $hash:ty, $max_size:ty, $doc:expr
) => {
#[derive(Clone)]
#[doc=$doc]
pub struct $name<OutSize>
where
OutSize: ArrayLength<u8> + IsLessOrEqual<$max_size>,
LeEq<OutSize, $max_size>: NonZero,
{
core: $hash,
buffer: LazyBuffer<<$hash as BlockSizeUser>::BlockSize>,
#[cfg(feature = "reset")]
key_block: Key<Self>,
_out: PhantomData<OutSize>,
}
impl<OutSize> $name<OutSize>
where
OutSize: ArrayLength<u8> + IsLessOrEqual<$max_size>,
LeEq<OutSize, $max_size>: NonZero,
{
/// Create new instance using provided key, salt, and persona.
///
/// Key length should not be bigger than block size, salt and persona
/// length should not be bigger than quarter of block size. If any
/// of those conditions is false the method will return an error.
#[inline]
pub fn new_with_salt_and_personal(
key: &[u8],
salt: &[u8],
persona: &[u8],
) -> Result<Self, InvalidLength> {
let kl = key.len();
let bs = <$hash as BlockSizeUser>::BlockSize::USIZE;
let qbs = bs / 4;
if kl > bs || salt.len() > qbs || persona.len() > qbs {
return Err(InvalidLength);
}
let mut padded_key = Block::<$hash>::default();
padded_key[..kl].copy_from_slice(key);
Ok(Self {
core: <$hash>::new_with_params(salt, persona, key.len(), OutSize::USIZE),
buffer: LazyBuffer::new(&padded_key),
#[cfg(feature = "reset")]
key_block: {
let mut t = Key::<Self>::default();
t[..kl].copy_from_slice(key);
t
},
_out: PhantomData,
})
}
}
impl<OutSize> KeySizeUser for $name<OutSize>
where
OutSize: ArrayLength<u8> + IsLessOrEqual<$max_size>,
LeEq<OutSize, $max_size>: NonZero,
{
type KeySize = $max_size;
}
impl<OutSize> KeyInit for $name<OutSize>
where
OutSize: ArrayLength<u8> + IsLessOrEqual<$max_size>,
LeEq<OutSize, $max_size>: NonZero,
{
#[inline]
fn new(key: &Key<Self>) -> Self {
Self::new_from_slice(key).expect("Key has correct length")
}
#[inline]
fn new_from_slice(key: &[u8]) -> Result<Self, InvalidLength> {
let kl = key.len();
if kl > <Self as KeySizeUser>::KeySize::USIZE {
return Err(InvalidLength);
}
let mut padded_key = Block::<$hash>::default();
padded_key[..kl].copy_from_slice(key);
Ok(Self {
core: <$hash>::new_with_params(&[], &[], key.len(), OutSize::USIZE),
buffer: LazyBuffer::new(&padded_key),
#[cfg(feature = "reset")]
key_block: {
let mut t = Key::<Self>::default();
t[..kl].copy_from_slice(key);
t
},
_out: PhantomData,
})
}
}
impl<OutSize> Update for $name<OutSize>
where
OutSize: ArrayLength<u8> + IsLessOrEqual<$max_size>,
LeEq<OutSize, $max_size>: NonZero,
{
#[inline]
fn update(&mut self, input: &[u8]) {
let Self { core, buffer, .. } = self;
buffer.digest_blocks(input, |blocks| core.update_blocks(blocks));
}
}
impl<OutSize> OutputSizeUser for $name<OutSize>
where
OutSize: ArrayLength<u8> + IsLessOrEqual<$max_size> + 'static,
LeEq<OutSize, $max_size>: NonZero,
{
type OutputSize = OutSize;
}
impl<OutSize> FixedOutput for $name<OutSize>
where
OutSize: ArrayLength<u8> + IsLessOrEqual<$max_size> + 'static,
LeEq<OutSize, $max_size>: NonZero,
{
#[inline]
fn finalize_into(mut self, out: &mut Output<Self>) {
let Self { core, buffer, .. } = &mut self;
let mut full_res = Default::default();
core.finalize_variable_core(buffer, &mut full_res);
out.copy_from_slice(&full_res[..OutSize::USIZE]);
}
}
#[cfg(feature = "reset")]
impl<OutSize> Reset for $name<OutSize>
where
OutSize: ArrayLength<u8> + IsLessOrEqual<$max_size>,
LeEq<OutSize, $max_size>: NonZero,
{
fn reset(&mut self) {
self.core.reset();
let kl = self.key_block.len();
let mut padded_key = Block::<$hash>::default();
padded_key[..kl].copy_from_slice(&self.key_block);
self.buffer = LazyBuffer::new(&padded_key);
}
}
#[cfg(feature = "reset")]
impl<OutSize> FixedOutputReset for $name<OutSize>
where
OutSize: ArrayLength<u8> + IsLessOrEqual<$max_size>,
LeEq<OutSize, $max_size>: NonZero,
{
#[inline]
fn finalize_into_reset(&mut self, out: &mut Output<Self>) {
let Self { core, buffer, .. } = self;
let mut full_res = Default::default();
core.finalize_variable_core(buffer, &mut full_res);
out.copy_from_slice(&full_res[..OutSize::USIZE]);
self.reset();
}
}
impl<OutSize> MacMarker for $name<OutSize>
where
OutSize: ArrayLength<u8> + IsLessOrEqual<$max_size>,
LeEq<OutSize, $max_size>: NonZero,
{
}
impl<OutSize> fmt::Debug for $name<OutSize>
where
OutSize: ArrayLength<u8> + IsLessOrEqual<$max_size>,
LeEq<OutSize, $max_size>: NonZero,
{
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}{} {{ ... }}", stringify!($name), OutSize::USIZE)
}
}
};
}

142
vendor/blake2/src/simd.rs vendored Normal file
View File

@@ -0,0 +1,142 @@
// Copyright 2015 blake2-rfc Developers
//
// Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or
// http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or
// http://opensource.org/licenses/MIT>, at your option. This file may not be
// copied, modified, or distributed except according to those terms.
mod simd_opt;
mod simdint;
mod simdop;
mod simdty;
pub use self::simdty::{u32x4, u64x4};
pub trait Vector4<T>: Copy {
fn gather(src: &[T], i0: usize, i1: usize, i2: usize, i3: usize) -> Self;
#[allow(clippy::wrong_self_convention)]
fn from_le(self) -> Self;
fn to_le(self) -> Self;
fn wrapping_add(self, rhs: Self) -> Self;
fn rotate_right_const(self, n: u32) -> Self;
fn shuffle_left_1(self) -> Self;
fn shuffle_left_2(self) -> Self;
fn shuffle_left_3(self) -> Self;
#[inline(always)]
fn shuffle_right_1(self) -> Self {
self.shuffle_left_3()
}
#[inline(always)]
fn shuffle_right_2(self) -> Self {
self.shuffle_left_2()
}
#[inline(always)]
fn shuffle_right_3(self) -> Self {
self.shuffle_left_1()
}
}
macro_rules! impl_vector4 {
($vec:ident, $word:ident) => {
impl Vector4<$word> for $vec {
#[inline(always)]
fn gather(src: &[$word], i0: usize, i1: usize, i2: usize, i3: usize) -> Self {
$vec::new(src[i0], src[i1], src[i2], src[i3])
}
#[cfg(target_endian = "little")]
#[inline(always)]
fn from_le(self) -> Self {
self
}
#[cfg(not(target_endian = "little"))]
#[inline(always)]
fn from_le(self) -> Self {
$vec::new(
$word::from_le(self.0),
$word::from_le(self.1),
$word::from_le(self.2),
$word::from_le(self.3),
)
}
#[cfg(target_endian = "little")]
#[inline(always)]
fn to_le(self) -> Self {
self
}
#[cfg(not(target_endian = "little"))]
#[inline(always)]
fn to_le(self) -> Self {
$vec::new(
self.0.to_le(),
self.1.to_le(),
self.2.to_le(),
self.3.to_le(),
)
}
#[inline(always)]
fn wrapping_add(self, rhs: Self) -> Self {
self + rhs
}
#[inline(always)]
fn rotate_right_const(self, n: u32) -> Self {
simd_opt::$vec::rotate_right_const(self, n)
}
#[cfg(feature = "simd")]
#[inline(always)]
fn shuffle_left_1(self) -> Self {
use crate::simd::simdint::simd_shuffle4;
const IDX: [u32; 4] = [1, 2, 3, 0];
unsafe { simd_shuffle4(self, self, IDX) }
}
#[cfg(not(feature = "simd"))]
#[inline(always)]
fn shuffle_left_1(self) -> Self {
$vec::new(self.1, self.2, self.3, self.0)
}
#[cfg(feature = "simd")]
#[inline(always)]
fn shuffle_left_2(self) -> Self {
use crate::simd::simdint::simd_shuffle4;
const IDX: [u32; 4] = [2, 3, 0, 1];
unsafe { simd_shuffle4(self, self, IDX) }
}
#[cfg(not(feature = "simd"))]
#[inline(always)]
fn shuffle_left_2(self) -> Self {
$vec::new(self.2, self.3, self.0, self.1)
}
#[cfg(feature = "simd")]
#[inline(always)]
fn shuffle_left_3(self) -> Self {
use crate::simd::simdint::simd_shuffle4;
const IDX: [u32; 4] = [3, 0, 1, 2];
unsafe { simd_shuffle4(self, self, IDX) }
}
#[cfg(not(feature = "simd"))]
#[inline(always)]
fn shuffle_left_3(self) -> Self {
$vec::new(self.3, self.0, self.1, self.2)
}
}
};
}
impl_vector4!(u32x4, u32);
impl_vector4!(u64x4, u64);

52
vendor/blake2/src/simd/simd_opt.rs vendored Normal file
View File

@@ -0,0 +1,52 @@
// Copyright 2015 blake2-rfc Developers
//
// Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or
// http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or
// http://opensource.org/licenses/MIT>, at your option. This file may not be
// copied, modified, or distributed except according to those terms.
#[allow(unused_macros)]
#[cfg(feature = "simd")]
macro_rules! transmute_shuffle {
($tmp:ident, $shuffle:ident, $vec:expr, $idx_n:expr, $idx:expr) => {
unsafe {
use crate::simd::simdint::$shuffle;
use crate::simd::simdty::$tmp;
use core::mem::transmute;
const IDX: [u32; $idx_n] = $idx;
let tmp_i: $tmp = transmute($vec);
let tmp_o: $tmp = $shuffle(tmp_i, tmp_i, IDX);
transmute(tmp_o)
}
};
}
#[cfg(feature = "simd")]
pub mod u32x4;
#[cfg(feature = "simd")]
pub mod u64x4;
#[cfg(not(feature = "simd"))]
macro_rules! simd_opt {
($vec:ident) => {
pub mod $vec {
use crate::simd::simdty::$vec;
#[inline(always)]
pub fn rotate_right_const(vec: $vec, n: u32) -> $vec {
$vec::new(
vec.0.rotate_right(n),
vec.1.rotate_right(n),
vec.2.rotate_right(n),
vec.3.rotate_right(n),
)
}
}
};
}
#[cfg(not(feature = "simd"))]
simd_opt!(u32x4);
#[cfg(not(feature = "simd"))]
simd_opt!(u64x4);

View File

@@ -0,0 +1,69 @@
// Copyright 2015 blake2-rfc Developers
//
// Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or
// http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or
// http://opensource.org/licenses/MIT>, at your option. This file may not be
// copied, modified, or distributed except according to those terms.
use crate::simd::simdty::u32x4;
#[cfg(feature = "simd_opt")]
#[inline(always)]
pub fn rotate_right_const(vec: u32x4, n: u32) -> u32x4 {
match n {
16 => rotate_right_16(vec),
8 => rotate_right_8(vec),
_ => rotate_right_any(vec, n),
}
}
#[cfg(not(feature = "simd_opt"))]
#[inline(always)]
pub fn rotate_right_const(vec: u32x4, n: u32) -> u32x4 {
rotate_right_any(vec, n)
}
#[inline(always)]
fn rotate_right_any(vec: u32x4, n: u32) -> u32x4 {
let r = n as u32;
let l = 32 - r;
(vec >> u32x4::new(r, r, r, r)) ^ (vec << u32x4::new(l, l, l, l))
}
#[cfg(feature = "simd_opt")]
#[inline(always)]
fn rotate_right_16(vec: u32x4) -> u32x4 {
if cfg!(target_feature = "ssse3") {
// pshufb (SSSE3) / vpshufb (AVX2)
transmute_shuffle!(
u8x16,
simd_shuffle16,
vec,
16,
[2, 3, 0, 1, 6, 7, 4, 5, 10, 11, 8, 9, 14, 15, 12, 13]
)
} else if cfg!(any(target_feature = "sse2", target_feature = "neon")) {
// pshuflw+pshufhw (SSE2) / vrev (NEON)
transmute_shuffle!(u16x8, simd_shuffle8, vec, 8, [1, 0, 3, 2, 5, 4, 7, 6])
} else {
rotate_right_any(vec, 16)
}
}
#[cfg(feature = "simd_opt")]
#[inline(always)]
fn rotate_right_8(vec: u32x4) -> u32x4 {
if cfg!(target_feature = "ssse3") {
// pshufb (SSSE3) / vpshufb (AVX2)
transmute_shuffle!(
u8x16,
simd_shuffle16,
vec,
16,
[1, 2, 3, 0, 5, 6, 7, 4, 9, 10, 11, 8, 13, 14, 15, 12]
)
} else {
rotate_right_any(vec, 8)
}
}

143
vendor/blake2/src/simd/simd_opt/u64x4.rs vendored Normal file
View File

@@ -0,0 +1,143 @@
// Copyright 2015 blake2-rfc Developers
//
// Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or
// http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or
// http://opensource.org/licenses/MIT>, at your option. This file may not be
// copied, modified, or distributed except according to those terms.
use crate::simd::simdty::u64x4;
#[cfg(feature = "simd_opt")]
#[inline(always)]
pub fn rotate_right_const(vec: u64x4, n: u32) -> u64x4 {
match n {
32 => rotate_right_32(vec),
24 => rotate_right_24(vec),
16 => rotate_right_16(vec),
_ => rotate_right_any(vec, n),
}
}
#[cfg(not(feature = "simd_opt"))]
#[inline(always)]
pub fn rotate_right_const(vec: u64x4, n: u32) -> u64x4 {
rotate_right_any(vec, n)
}
#[inline(always)]
fn rotate_right_any(vec: u64x4, n: u32) -> u64x4 {
let r = n as u64;
let l = 64 - r;
(vec >> u64x4::new(r, r, r, r)) ^ (vec << u64x4::new(l, l, l, l))
}
#[cfg(feature = "simd_opt")]
#[inline(always)]
fn rotate_right_32(vec: u64x4) -> u64x4 {
if cfg!(any(target_feature = "sse2", target_feature = "neon")) {
// 2 x pshufd (SSE2) / vpshufd (AVX2) / 2 x vrev (NEON)
transmute_shuffle!(u32x8, simd_shuffle8, vec, 8, [1, 0, 3, 2, 5, 4, 7, 6])
} else {
rotate_right_any(vec, 32)
}
}
#[cfg(feature = "simd_opt")]
#[inline(always)]
fn rotate_right_24(vec: u64x4) -> u64x4 {
if cfg!(all(
feature = "simd_asm",
target_feature = "neon",
target_arch = "arm"
)) {
// 4 x vext (NEON)
rotate_right_vext(vec, 3)
} else if cfg!(target_feature = "ssse3") {
// 2 x pshufb (SSSE3) / vpshufb (AVX2)
transmute_shuffle!(
u8x32,
simd_shuffle32,
vec,
32,
[
3, 4, 5, 6, 7, 0, 1, 2, 11, 12, 13, 14, 15, 8, 9, 10, 19, 20, 21, 22, 23, 16, 17,
18, 27, 28, 29, 30, 31, 24, 25, 26
]
)
} else {
rotate_right_any(vec, 24)
}
}
#[cfg(feature = "simd_opt")]
#[inline(always)]
fn rotate_right_16(vec: u64x4) -> u64x4 {
if cfg!(all(
feature = "simd_asm",
target_feature = "neon",
target_arch = "arm"
)) {
// 4 x vext (NEON)
rotate_right_vext(vec, 2)
} else if cfg!(target_feature = "ssse3") {
// 2 x pshufb (SSSE3) / vpshufb (AVX2)
transmute_shuffle!(
u8x32,
simd_shuffle32,
vec,
32,
[
2, 3, 4, 5, 6, 7, 0, 1, 10, 11, 12, 13, 14, 15, 8, 9, 18, 19, 20, 21, 22, 23, 16,
17, 26, 27, 28, 29, 30, 31, 24, 25
]
)
} else if cfg!(target_feature = "sse2") {
// 2 x pshuflw+pshufhw (SSE2)
transmute_shuffle!(
u16x16,
simd_shuffle16,
vec,
16,
[1, 2, 3, 0, 5, 6, 7, 4, 9, 10, 11, 8, 13, 14, 15, 12]
)
} else {
rotate_right_any(vec, 16)
}
}
#[cfg(all(feature = "simd_asm", target_feature = "neon", target_arch = "arm"))]
mod simd_asm_neon_arm {
use crate::simd::simdty::{u64x2, u64x4};
#[inline(always)]
fn vext_u64(vec: u64x2, b: u8) -> u64x2 {
unsafe {
let result: u64x2;
asm!("vext.8 ${0:e}, ${1:e}, ${1:e}, $2\nvext.8 ${0:f}, ${1:f}, ${1:f}, $2"
: "=w" (result)
: "w" (vec), "n" (b));
result
}
}
#[inline(always)]
pub fn rotate_right_vext(vec: u64x4, b: u8) -> u64x4 {
use crate::simd::simdint::{simd_shuffle2, simd_shuffle4};
unsafe {
let tmp0 = vext_u64(simd_shuffle2(vec, vec, [0, 1]), b);
let tmp1 = vext_u64(simd_shuffle2(vec, vec, [2, 3]), b);
simd_shuffle4(tmp0, tmp1, [0, 1, 2, 3])
}
}
}
#[cfg(all(feature = "simd_asm", target_feature = "neon", target_arch = "arm"))]
use self::simd_asm_neon_arm::rotate_right_vext;
#[cfg(feature = "simd_opt")]
#[cfg(not(all(feature = "simd_asm", target_feature = "neon", target_arch = "arm")))]
fn rotate_right_vext(_vec: u64x4, _n: u8) -> u64x4 {
unreachable!()
}

22
vendor/blake2/src/simd/simdint.rs vendored Normal file
View File

@@ -0,0 +1,22 @@
// Copyright 2015 blake2-rfc Developers
//
// Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or
// http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or
// http://opensource.org/licenses/MIT>, at your option. This file may not be
// copied, modified, or distributed except according to those terms.
#![allow(dead_code)]
#[cfg(feature = "simd")]
extern "platform-intrinsic" {
pub fn simd_add<T>(x: T, y: T) -> T;
pub fn simd_shl<T>(x: T, y: T) -> T;
pub fn simd_shr<T>(x: T, y: T) -> T;
pub fn simd_xor<T>(x: T, y: T) -> T;
pub fn simd_shuffle2<T, U>(v: T, w: T, idx: [u32; 2]) -> U;
pub fn simd_shuffle4<T, U>(v: T, w: T, idx: [u32; 4]) -> U;
pub fn simd_shuffle8<T, U>(v: T, w: T, idx: [u32; 8]) -> U;
pub fn simd_shuffle16<T, U>(v: T, w: T, idx: [u32; 16]) -> U;
pub fn simd_shuffle32<T, U>(v: T, w: T, idx: [u32; 32]) -> U;
}

103
vendor/blake2/src/simd/simdop.rs vendored Normal file
View File

@@ -0,0 +1,103 @@
// Copyright 2015 blake2-rfc Developers
//
// Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or
// http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or
// http://opensource.org/licenses/MIT>, at your option. This file may not be
// copied, modified, or distributed except according to those terms.
#[cfg(feature = "simd")]
use crate::simd::simdint;
use crate::simd::simdty::{u32x4, u64x4};
use core::ops::{Add, BitXor, Shl, Shr};
macro_rules! impl_ops {
($vec:ident) => {
impl Add for $vec {
type Output = Self;
#[cfg(feature = "simd")]
#[inline(always)]
fn add(self, rhs: Self) -> Self::Output {
unsafe { simdint::simd_add(self, rhs) }
}
#[cfg(not(feature = "simd"))]
#[inline(always)]
fn add(self, rhs: Self) -> Self::Output {
$vec::new(
self.0.wrapping_add(rhs.0),
self.1.wrapping_add(rhs.1),
self.2.wrapping_add(rhs.2),
self.3.wrapping_add(rhs.3),
)
}
}
impl BitXor for $vec {
type Output = Self;
#[cfg(feature = "simd")]
#[inline(always)]
fn bitxor(self, rhs: Self) -> Self::Output {
unsafe { simdint::simd_xor(self, rhs) }
}
#[cfg(not(feature = "simd"))]
#[inline(always)]
fn bitxor(self, rhs: Self) -> Self::Output {
$vec::new(
self.0 ^ rhs.0,
self.1 ^ rhs.1,
self.2 ^ rhs.2,
self.3 ^ rhs.3,
)
}
}
impl Shl<$vec> for $vec {
type Output = Self;
#[cfg(feature = "simd")]
#[inline(always)]
fn shl(self, rhs: Self) -> Self::Output {
unsafe { simdint::simd_shl(self, rhs) }
}
#[cfg(not(feature = "simd"))]
#[inline(always)]
fn shl(self, rhs: Self) -> Self::Output {
$vec::new(
self.0 << rhs.0,
self.1 << rhs.1,
self.2 << rhs.2,
self.3 << rhs.3,
)
}
}
impl Shr<$vec> for $vec {
type Output = Self;
#[cfg(feature = "simd")]
#[inline(always)]
fn shr(self, rhs: Self) -> Self::Output {
unsafe { simdint::simd_shr(self, rhs) }
}
#[cfg(not(feature = "simd"))]
#[inline(always)]
fn shr(self, rhs: Self) -> Self::Output {
$vec::new(
self.0 >> rhs.0,
self.1 >> rhs.1,
self.2 >> rhs.2,
self.3 >> rhs.3,
)
}
}
};
}
impl_ops!(u32x4);
impl_ops!(u64x4);

77
vendor/blake2/src/simd/simdty.rs vendored Normal file
View File

@@ -0,0 +1,77 @@
// Copyright 2016 blake2-rfc Developers
//
// Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or
// http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or
// http://opensource.org/licenses/MIT>, at your option. This file may not be
// copied, modified, or distributed except according to those terms.
#![allow(dead_code, non_camel_case_types)]
use crate::as_bytes::Safe;
#[cfg(feature = "simd")]
macro_rules! decl_simd {
($($decl:item)*) => {
$(
#[derive(Clone, Copy, Debug)]
#[repr(simd)]
$decl
)*
}
}
#[cfg(not(feature = "simd"))]
macro_rules! decl_simd {
($($decl:item)*) => {
$(
#[derive(Clone, Copy, Debug)]
#[repr(C)]
$decl
)*
}
}
decl_simd! {
pub struct Simd2<T>(pub T, pub T);
pub struct Simd4<T>(pub T, pub T, pub T, pub T);
pub struct Simd8<T>(pub T, pub T, pub T, pub T,
pub T, pub T, pub T, pub T);
pub struct Simd16<T>(pub T, pub T, pub T, pub T,
pub T, pub T, pub T, pub T,
pub T, pub T, pub T, pub T,
pub T, pub T, pub T, pub T);
pub struct Simd32<T>(pub T, pub T, pub T, pub T,
pub T, pub T, pub T, pub T,
pub T, pub T, pub T, pub T,
pub T, pub T, pub T, pub T,
pub T, pub T, pub T, pub T,
pub T, pub T, pub T, pub T,
pub T, pub T, pub T, pub T,
pub T, pub T, pub T, pub T);
}
pub type u64x2 = Simd2<u64>;
pub type u32x4 = Simd4<u32>;
pub type u64x4 = Simd4<u64>;
pub type u16x8 = Simd8<u16>;
pub type u32x8 = Simd8<u32>;
pub type u8x16 = Simd16<u8>;
pub type u16x16 = Simd16<u16>;
pub type u8x32 = Simd32<u8>;
impl<T> Simd4<T> {
#[inline(always)]
pub fn new(e0: T, e1: T, e2: T, e3: T) -> Simd4<T> {
Simd4(e0, e1, e2, e3)
}
}
unsafe impl<T: Safe> Safe for Simd2<T> {}
unsafe impl<T: Safe> Safe for Simd4<T> {}
unsafe impl<T: Safe> Safe for Simd8<T> {}
unsafe impl<T: Safe> Safe for Simd16<T> {}
unsafe impl<T: Safe> Safe for Simd32<T> {}

Binary file not shown.

View File

Binary file not shown.

View File

@@ -0,0 +1 @@
{"name":"blake2","vers":"0.10.6","deps":[{"name":"digest","req":"^0.10.3","features":["mac"],"optional":false,"default_features":true,"target":null,"kind":"normal","registry":"https://github.com/rust-lang/crates.io-index","package":null,"public":null,"artifact":null,"bindep_target":null,"lib":false},{"name":"digest","req":"^0.10.3","features":["dev"],"optional":false,"default_features":true,"target":null,"kind":"dev","registry":"https://github.com/rust-lang/crates.io-index","package":null,"public":null,"artifact":null,"bindep_target":null,"lib":false},{"name":"hex-literal","req":"^0.2.2","features":[],"optional":false,"default_features":true,"target":null,"kind":"dev","registry":"https://github.com/rust-lang/crates.io-index","package":null,"public":null,"artifact":null,"bindep_target":null,"lib":false}],"features":{"default":["std"],"reset":[],"simd":[],"simd_asm":["simd_opt"],"simd_opt":["simd"],"size_opt":[],"std":["digest/std"]},"features2":null,"cksum":"0638f0694eec8e60c019403cf001df4d4f100e4f6a710ecc163fcc350b455ce0","yanked":null,"links":null,"rust_version":null,"v":2}

Binary file not shown.

BIN
vendor/blake2/tests/data/blake2b/mac.blb vendored Normal file

Binary file not shown.

Binary file not shown.

BIN
vendor/blake2/tests/data/blake2s/mac.blb vendored Normal file

Binary file not shown.

Binary file not shown.

29
vendor/blake2/tests/mac.rs vendored Normal file
View File

@@ -0,0 +1,29 @@
#[cfg(not(feature = "reset"))]
use digest::new_mac_test as new_test;
#[cfg(feature = "reset")]
use digest::new_resettable_mac_test as new_test;
new_test!(blake2b_mac, "blake2b/mac", blake2::Blake2bMac512);
new_test!(blake2s_mac, "blake2s/mac", blake2::Blake2sMac256);
#[test]
fn blake2b_new_test() {
use blake2::digest::{generic_array::GenericArray, KeyInit, Mac};
fn run<T: Mac + KeyInit>(key: &[u8]) {
const DATA: &[u8] = &[42; 300];
let res1 = <T as Mac>::new(GenericArray::from_slice(key))
.chain_update(DATA)
.finalize()
.into_bytes();
let res2 = <T as Mac>::new_from_slice(&key)
.unwrap()
.chain_update(DATA)
.finalize()
.into_bytes();
assert_eq!(res1, res2);
}
run::<blake2::Blake2sMac256>(&[0x42; 32]);
run::<blake2::Blake2bMac512>(&[0x42; 64]);
}

19
vendor/blake2/tests/mod.rs vendored Normal file
View File

@@ -0,0 +1,19 @@
#[cfg(feature = "reset")]
use digest::dev::{fixed_reset_test as fixed_fn, variable_reset_test as varaible_fn};
#[cfg(not(feature = "reset"))]
use digest::dev::{fixed_test as fixed_fn, variable_test as varaible_fn};
use digest::new_test;
new_test!(blake2b_fixed, "blake2b/fixed", blake2::Blake2b512, fixed_fn,);
new_test!(
blake2b_variable,
"blake2b/variable",
blake2::Blake2bVar,
varaible_fn,
);
new_test!(
blake2s_variable,
"blake2s/variable",
blake2::Blake2sVar,
varaible_fn,
);

40
vendor/blake2/tests/persona.rs vendored Normal file
View File

@@ -0,0 +1,40 @@
use blake2::{digest::FixedOutput, Blake2bMac512, Blake2sMac256};
use hex_literal::hex;
#[test]
#[rustfmt::skip]
fn blake2s_persona() {
let key= hex!("
000102030405060708090a0b0c0d0e0f
101112131415161718191a1b1c1d1e1f
");
let persona = b"personal";
let ctx = Blake2sMac256::new_with_salt_and_personal(&key, &[], persona).unwrap();
assert_eq!(
ctx.finalize_fixed()[..],
hex!("
25a4ee63b594aed3f88a971e1877ef70
99534f9097291f88fb86c79b5e70d022
")[..],
);
}
#[test]
#[rustfmt::skip]
fn blake2b_persona() {
let key = hex!("
000102030405060708090a0b0c0d0e0f
101112131415161718191a1b1c1d1e1f
");
let persona = b"personal";
let ctx = Blake2bMac512::new_with_salt_and_personal(&key, &[], persona).unwrap();
assert_eq!(
ctx.finalize_fixed()[..],
hex!("
03de3b295dcfc3b25b05abb09bc95fe3
e9ff3073638badc68101d1e42019d077
1dd07525a3aae8318e92c5e5d967ba92
e4810d0021d7bf3b49da0b4b4a8a4e1f
")[..],
);
}