Skip to content

Commit

Permalink
Add comments, bump version
Browse files Browse the repository at this point in the history
  • Loading branch information
bitfl0wer committed Apr 15, 2024
1 parent 6bb5613 commit 6c64aec
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "polyproto"
version = "0.7.0"
version = "0.7.1"
edition = "2021"
license = "MPL-2.0"
description = "(Generic) Rust types and traits to quickly get a polyproto implementation up and running"
Expand Down
6 changes: 6 additions & 0 deletions src/certs/capabilities/key_usage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,16 @@ impl KeyUsages {
byte_array.remove(0);
let mut key_usages = Vec::new();
if byte_array.len() == 2 {
// If the length of the byte array is 2, this means that DecipherOnly is set.
key_usages.push(KeyUsage::DecipherOnly);
byte_array.remove(0);
}
let mut current_try = 128u8;
loop {
// If the first byte is bigger than or equal to the current_try, this means that the
// KeyUsage belonging to the current_try is set. We can then divide the current_try by 2
// and continue checking if the KeyUsage belonging to the current_try is set, until we
// reach current_try == 1.
if current_try <= byte_array[0] {
byte_array[0] -= current_try;
key_usages.push(match current_try {
Expand All @@ -143,6 +148,7 @@ impl KeyUsages {
4 => KeyUsage::KeyCertSign,
2 => KeyUsage::CrlSign,
1 => KeyUsage::EncipherOnly,
// This should never happen, as we are only dividing by 2 until we reach 1.
_ => panic!("This should never happen. Please report this error to https://github.com/polyphony-chat/polyproto"),
})
}
Expand Down

0 comments on commit 6c64aec

Please sign in to comment.