Skip to content
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

Minor bug- and clippy fixes #74

Merged
merged 5 commits into from
Nov 6, 2023
Merged

Minor bug- and clippy fixes #74

merged 5 commits into from
Nov 6, 2023

Conversation

kpcyrd
Copy link
Contributor

@kpcyrd kpcyrd commented Nov 6, 2023

A very brief list of what was changed:

  • In KeyType::from_ed25519_with_keyid_hash_algorithms it's using &key[..ED25519_PRIVATE_KEY_LENGTH] and then &key[ED25519_PUBLIC_KEY_LENGTH..], while the "correct" thing would be &key[ED25519_PRIVATE_KEY_LENGTH..] to refer to the bytes after the private key. This ultimately doesn't matter at all in the final binary though, since both constants are 32. This patch changes it to let (private_key_bytes, public_key_bytes) = key.split_at(ED25519_PRIVATE_KEY_LENGTH);
  • In the error message for unknown oid's, it's encoding each byte in a byte array to hex using {:x}, this works as expected for 0x10 to 0xff, but for values like 0x00 to 0x0f it would print 0 and f respectively. The byte sequence [0x0f, 0x77, 0x0f] would get hex encoded as f77f, suggesting [0xf7, 0x7f]. This is inside of an error branch though and doesn't have any real impact on the library.
  • A few match bool { true => {}, false => {} }; expressions have been rewritten to if bool { ... } else { ... } or .then_some(...).
  • Instead of impl AsRef<Vec<String>> for Command { do impl AsRef<[String]> for Command { because with an immutable reference, a Vec (pointer + length + capacity) doesn't have any benefits over a slice (pointer + length). This is technically a semver breaking change though.
  • Instead of x if x == ED25519_SPKI_OID => Ok(KeyType::Ed25519), Rust supports writing just ED25519_SPKI_OID => Ok(KeyType::Ed25519),

Copy link
Member

@alanssitis alanssitis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@adityasaky adityasaky merged commit f0532d9 into in-toto:master Nov 6, 2023
4 checks passed
@adityasaky
Copy link
Member

Thanks @kpcyrd!

@kpcyrd kpcyrd deleted the review branch November 6, 2023 21:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants