-
Notifications
You must be signed in to change notification settings - Fork 35
Workspace-level lint configuration #194
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| allow-unwrap-in-consts = true | ||
| allow-unwrap-in-tests = true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,8 +5,7 @@ | |
| html_favicon_url = "https://raw.githubusercontent.com/RustCrypto/media/6ee8e381/logo.svg" | ||
| )] | ||
| #![cfg_attr(docsrs, feature(doc_cfg))] | ||
| #![forbid(unsafe_code)] | ||
| #![warn(missing_docs)] | ||
| #![allow(clippy::unwrap_used, reason = "todo")] | ||
|
|
||
| use belt_hash::digest::FixedOutput; | ||
| use belt_hash::{BeltHash, Digest, block_api::belt_compress}; | ||
|
|
@@ -15,9 +14,13 @@ use belt_hash::{BeltHash, Digest, block_api::belt_compress}; | |
| /// | ||
| /// # Panics | ||
| /// If `N` is not equal to 16, 24, or 32. | ||
| // TODO: use compile-time checks for `N` | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Went ahead and implemented the compile-time checks here and below in |
||
| #[inline] | ||
| #[must_use] | ||
| pub fn belt_keyexpand<const N: usize>(k: &[u8; N]) -> [u32; 8] { | ||
| const { | ||
| assert!(matches!(N, 16 | 24 | 32), "N must be 16, 24, or 32"); | ||
| } | ||
|
|
||
| let mut t = [0u32; 8]; | ||
| // TODO: move this conversion into `belt_keyrep` when we will be able | ||
| // to use generic parameters as `[u32; N / 4]`. | ||
|
|
@@ -44,15 +47,30 @@ pub fn belt_keyexpand<const N: usize>(k: &[u8; N]) -> [u32; 8] { | |
| /// `belt-keyrep` key repetition algorithm described in STB 34.101.31-2020 8.1.3. | ||
| /// | ||
| /// # Panics | ||
| /// If `(N, M)` is not equal to `(16, 16)`, `(24, 16)`, `(24, 24)`, | ||
| /// `(32, 16)`, `(32, 24)`, or `(32, 32)`. | ||
| // TODO: use compile-time check for `N` and `M` | ||
| /// If `(N, M)` is not equal to one of: | ||
| /// - `(16, 16)` | ||
| /// - `(24, 16)` | ||
| /// - `(24, 24)` | ||
| /// - `(32, 16)` | ||
| /// - `(32, 24)` | ||
| /// - `(32, 32)` | ||
| #[inline] | ||
| #[must_use] | ||
| pub fn belt_keyrep<const N: usize, const M: usize>( | ||
| x: &[u8; N], | ||
| d: &[u8; 12], | ||
| i: &[u8; 16], | ||
| ) -> [u8; M] { | ||
| const { | ||
| assert!( | ||
| matches!( | ||
| (N, M), | ||
| (16, 16) | (24, 16) | (24, 24) | (32, 16) | (32, 24) | (32, 32) | ||
| ), | ||
| "invalid N/M values" | ||
| ); | ||
| } | ||
|
|
||
| let r: u32 = match (N, M) { | ||
| (16, 16) => 0xC8BA94B1, | ||
| (24, 16) => 0x12D6E35B, | ||
|
|
@@ -89,6 +107,7 @@ pub fn belt_keyrep<const N: usize, const M: usize>( | |
|
|
||
| /// `bake-kdf` key derivation algorithm described in STB 34.101.66-2014 8.1.4. | ||
| #[inline] | ||
| #[must_use] | ||
| pub fn bake_kdf(x: &[u8], s: &[u8], c: u128) -> [u8; 32] { | ||
| let mut hasher = BeltHash::default(); | ||
| hasher.update(x); | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,5 @@ | ||
| //! Test vectors | ||
|
|
||
| use bake_kdf::{bake_kdf, belt_keyexpand, belt_keyrep}; | ||
| use hex_literal::hex; | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,5 @@ | ||
| //! Wycheproof test vectors. | ||
|
|
||
| use hkdf::{GenericHkdf, HmacImpl}; | ||
| use hmac::{Hmac, SimpleHmac}; | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.