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

The YubiKey::save_object doesn't require mutable reference #560

Open
G1gg1L3s opened this issue Feb 28, 2024 · 0 comments
Open

The YubiKey::save_object doesn't require mutable reference #560

G1gg1L3s opened this issue Feb 28, 2024 · 0 comments

Comments

@G1gg1L3s
Copy link

In the current version, the Yubikey::save_object method requires a mutable reference to the data being saved:

yubikey.rs/src/yubikey.rs

Lines 629 to 634 in b07612e

/// Save an object.
#[cfg(feature = "untested")]
pub fn save_object(&mut self, object_id: ObjectId, indata: &mut [u8]) -> Result<()> {
let txn = self.begin_transaction()?;
txn.save_object(object_id, indata)
}

However, it appears that the mutability requirement is unnecessary, given that the Transaction::save_object method accepts an immutable slice:

/// Save an object.
pub fn save_object(&self, object_id: ObjectId, indata: &[u8]) -> Result<()> {
let templ = [0, Ins::PutData.code(), 0x3f, 0xff];

I understand that this modification is currently marked under the untested feature. Nevertheless, moving to the use of an immutable slice would definitely enhance the API.

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

No branches or pull requests

1 participant