Remove usages of YKPIV_OBJ_MAX_SIZE

...replacing them with `CB_BUF_MAX`.

Both constants are 3072, however `CB_BUF_MAX` is what the original code
was using.

See discussion here:

https://github.com/tarcieri/yubikey-piv.rs/pull/17#discussion_r350166104
This commit is contained in:
Tony Arcieri
2019-11-25 08:49:29 -08:00
parent 67ed32cbf9
commit 79b1142f21
3 changed files with 4 additions and 7 deletions
-2
View File
@@ -229,8 +229,6 @@ pub const YKPIV_OBJ_MSROOTS3: u32 = 0x005f_ff13;
pub const YKPIV_OBJ_MSROOTS4: u32 = 0x005f_ff14; pub const YKPIV_OBJ_MSROOTS4: u32 = 0x005f_ff14;
pub const YKPIV_OBJ_MSROOTS5: u32 = 0x005f_ff15; pub const YKPIV_OBJ_MSROOTS5: u32 = 0x005f_ff15;
pub const YKPIV_OBJ_MAX_SIZE: usize = 3072;
pub const YKPIV_PINPOLICY_TAG: u8 = 0xaa; pub const YKPIV_PINPOLICY_TAG: u8 = 0xaa;
pub const YKPIV_PINPOLICY_DEFAULT: u8 = 0; pub const YKPIV_PINPOLICY_DEFAULT: u8 = 0;
pub const YKPIV_PINPOLICY_NEVER: u8 = 1; pub const YKPIV_PINPOLICY_NEVER: u8 = 1;
+2 -2
View File
@@ -165,7 +165,7 @@ impl MgmKey {
/// Set protected management key (MGM) /// Set protected management key (MGM)
pub fn set_protected(&self, yubikey: &mut YubiKey) -> Result<(), Error> { pub fn set_protected(&self, yubikey: &mut YubiKey) -> Result<(), Error> {
let mut data = Zeroizing::new(vec![0u8; YKPIV_OBJ_MAX_SIZE]); let mut data = Zeroizing::new(vec![0u8; CB_BUF_MAX]);
let max_size = yubikey.obj_size_max(); let max_size = yubikey.obj_size_max();
let txn = yubikey.begin_transaction()?; let txn = yubikey.begin_transaction()?;
@@ -207,7 +207,7 @@ impl MgmKey {
} }
// set the protected mgm flag in admin data // set the protected mgm flag in admin data
cb_data = YKPIV_OBJ_MAX_SIZE; cb_data = data.len();
let mut flags_1 = [0u8; 1]; let mut flags_1 = [0u8; 1];
+2 -3
View File
@@ -455,7 +455,6 @@ impl<'tx> Transaction<'tx> {
sw = response.status_words().code(); sw = response.status_words().code();
if sw != StatusWords::Success.code() && (sw >> 8 != 0x61) { if sw != StatusWords::Success.code() && (sw >> 8 != 0x61) {
// TODO(tarcieri): is this really OK?
return Ok(Response::new(sw.into(), Zeroizing::new(vec![]))); return Ok(Response::new(sw.into(), Zeroizing::new(vec![])));
} }
@@ -484,7 +483,7 @@ impl<'tx> Transaction<'tx> {
let indata_remaining = set_object(object_id, &mut indata); let indata_remaining = set_object(object_id, &mut indata);
inlen -= indata_remaining.len(); inlen -= indata_remaining.len();
let response = self.transfer_data(&templ, &indata[..inlen], YKPIV_OBJ_MAX_SIZE)?; let response = self.transfer_data(&templ, &indata[..inlen], CB_BUF_MAX)?;
if !response.is_success() { if !response.is_success() {
return Err(Error::GenericError); return Err(Error::GenericError);
@@ -523,7 +522,7 @@ impl<'tx> Transaction<'tx> {
let templ = [0, YKPIV_INS_PUT_DATA, 0x3f, 0xff]; let templ = [0, YKPIV_INS_PUT_DATA, 0x3f, 0xff];
// TODO(tarcieri): replace with vector // TODO(tarcieri): replace with vector
let mut data = [0u8; YKPIV_OBJ_MAX_SIZE]; let mut data = [0u8; CB_BUF_MAX];
if indata.len() > CB_OBJ_MAX { if indata.len() > CB_OBJ_MAX {
return Err(Error::SizeError); return Err(Error::SizeError);