Skip to content

Commit

Permalink
Merge pull request #50 from nyonson/msrv-fixup
Browse files Browse the repository at this point in the history
Add MSRV build to CI
  • Loading branch information
nyonson committed May 7, 2024
2 parents 30c35d0 + 314b7e3 commit a82a180
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 40 deletions.
9 changes: 5 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,8 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
# Minumum Supported Rust Version (MSRV) is 1.56.1 but
# having some weird issues with the memchr dependency.
toolchain: [stable, beta, nightly]
# Minumum Supported Rust Version (MSRV) is 1.56.1.
toolchain: [1.56.1, stable, beta, nightly]
steps:
- uses: actions/checkout@v3
- name: Update Toolchain
Expand Down Expand Up @@ -74,8 +73,10 @@ jobs:
cargo test --package bip324 --verbose --no-default-features
cargo test --package bip324 --verbose --no-default-features --features alloc
- name: Check No Standard Library Support
# The cross tool used to test in a no standard library environment doesn't play nice with our MSRV, so limiting to just stable toolchain.
if: matrix.toolchain == 'stable'
run: |
rustup target add --toolchain ${{ matrix.toolchain }} thumbv7m-none-eabi
cargo install cross
cargo install cross --locked
cross build --package bip324 --target thumbv7m-none-eabi --no-default-features --features alloc
28 changes: 13 additions & 15 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 14 additions & 20 deletions protocol/src/chacha20poly1305/chacha20.rs
Original file line number Diff line number Diff line change
Expand Up @@ -359,11 +359,10 @@ mod tests {
let count = 1;
let mut chacha = ChaCha20::new(key, nonce, count);
let mut binding = [8; 3];
let to = binding.as_mut_slice();
chacha.apply_keystream(to).unwrap();
chacha.apply_keystream(&mut binding[..]).unwrap();
let mut chacha = ChaCha20::new(key, nonce, count);
chacha.apply_keystream(to).unwrap();
assert_eq!([8; 3], to);
chacha.apply_keystream(&mut binding[..]).unwrap();
assert_eq!([8; 3], binding);
}

#[test]
Expand All @@ -376,11 +375,10 @@ mod tests {
let count = 1;
let mut chacha = ChaCha20::new(key, nonce, count);
let mut binding = [8; 64];
let to = binding.as_mut_slice();
chacha.apply_keystream(to).unwrap();
chacha.apply_keystream(&mut binding[..]).unwrap();
let mut chacha = ChaCha20::new(key, nonce, count);
chacha.apply_keystream(to).unwrap();
assert_eq!([8; 64], to);
chacha.apply_keystream(&mut binding[..]).unwrap();
assert_eq!([8; 64], binding);
}

#[test]
Expand All @@ -393,13 +391,11 @@ mod tests {
let count = 64;
let mut chacha = ChaCha20::new(key, nonce, count);
let mut binding = *b"Ladies and Gentlemen of the class of '99: If I could offer you only one tip for the future, sunscreen would be it.";
let to = binding.as_mut_slice();
chacha.apply_keystream(to).unwrap();
assert_eq!(to, Vec::from_hex("6e2e359a2568f98041ba0728dd0d6981e97e7aec1d4360c20a27afccfd9fae0bf91b65c5524733ab8f593dabcd62b3571639d624e65152ab8f530c359f0861d807ca0dbf500d6a6156a38e088a22b65e52bc514d16ccf806818ce91ab77937365af90bbf74a35be6b40b8eedf2785e42874d").unwrap());
chacha.apply_keystream(&mut binding[..]).unwrap();
assert_eq!(binding[..], Vec::from_hex("6e2e359a2568f98041ba0728dd0d6981e97e7aec1d4360c20a27afccfd9fae0bf91b65c5524733ab8f593dabcd62b3571639d624e65152ab8f530c359f0861d807ca0dbf500d6a6156a38e088a22b65e52bc514d16ccf806818ce91ab77937365af90bbf74a35be6b40b8eedf2785e42874d").unwrap());
let mut chacha = ChaCha20::new(key, nonce, count);
chacha.apply_keystream(to).unwrap();
let binding = *b"Ladies and Gentlemen of the class of '99: If I could offer you only one tip for the future, sunscreen would be it.";
assert_eq!(binding, to);
chacha.apply_keystream(&mut binding[..]).unwrap();
assert_eq!(binding, *b"Ladies and Gentlemen of the class of '99: If I could offer you only one tip for the future, sunscreen would be it.");
}

#[test]
Expand All @@ -412,13 +408,11 @@ mod tests {
let block: u32 = 1;
let mut chacha = ChaCha20::new_from_block(key, nonce, block);
let mut binding = *b"Ladies and Gentlemen of the class of '99: If I could offer you only one tip for the future, sunscreen would be it.";
let to = binding.as_mut_slice();
chacha.apply_keystream(to).unwrap();
assert_eq!(to, Vec::from_hex("6e2e359a2568f98041ba0728dd0d6981e97e7aec1d4360c20a27afccfd9fae0bf91b65c5524733ab8f593dabcd62b3571639d624e65152ab8f530c359f0861d807ca0dbf500d6a6156a38e088a22b65e52bc514d16ccf806818ce91ab77937365af90bbf74a35be6b40b8eedf2785e42874d").unwrap());
chacha.apply_keystream(&mut binding[..]).unwrap();
assert_eq!(binding[..], Vec::from_hex("6e2e359a2568f98041ba0728dd0d6981e97e7aec1d4360c20a27afccfd9fae0bf91b65c5524733ab8f593dabcd62b3571639d624e65152ab8f530c359f0861d807ca0dbf500d6a6156a38e088a22b65e52bc514d16ccf806818ce91ab77937365af90bbf74a35be6b40b8eedf2785e42874d").unwrap());
chacha.block(block);
chacha.apply_keystream(to).unwrap();
let binding = *b"Ladies and Gentlemen of the class of '99: If I could offer you only one tip for the future, sunscreen would be it.";
assert_eq!(binding, to);
chacha.apply_keystream(&mut binding[..]).unwrap();
assert_eq!(binding, *b"Ladies and Gentlemen of the class of '99: If I could offer you only one tip for the future, sunscreen would be it.");
}

#[cfg(feature = "std")]
Expand Down
2 changes: 1 addition & 1 deletion protocol/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ pub struct PacketReader {
}

impl PacketReader {
/// Decode the length, in bytes, of the of the rest imbound message.
/// Decode the length, in bytes, of the rest of the inbound message.
///
/// Intended for use with `TcpStream` and `read_exact`. Note that this does not decode to the
/// length of contents described in BIP324, and is meant to represent the entire imbound message
Expand Down

0 comments on commit a82a180

Please sign in to comment.