diff --git a/src/util.rs b/src/util.rs index 94f2786..4d56fc2 100644 --- a/src/util.rs +++ b/src/util.rs @@ -110,7 +110,7 @@ pub unsafe fn ykpiv_util_get_cardid( } } - _ykpiv_end_transaction(state); + let _ = _ykpiv_end_transaction(state); res } @@ -158,7 +158,7 @@ pub unsafe fn ykpiv_util_set_cardid( ); } - _ykpiv_end_transaction(state); + let _ = _ykpiv_end_transaction(state); res } @@ -188,7 +188,7 @@ pub unsafe fn ykpiv_util_get_cccid(state: &mut YubiKey, ccc: *mut CCCID) -> Resu if res.is_ok() { if len != CCC_TMPL.len() { - _ykpiv_end_transaction(state); + let _ = _ykpiv_end_transaction(state); return Err(ErrorKind::GenericError); } @@ -245,7 +245,7 @@ pub unsafe fn ykpiv_util_set_cccid( res = _ykpiv_save_object(state, YKPIV_OBJ_CAPABILITY as i32, buf.as_mut_ptr(), len); } - _ykpiv_end_transaction(state); + let _ = _ykpiv_end_transaction(state); res } @@ -337,7 +337,7 @@ pub unsafe fn ykpiv_util_list_keys( p_data = calloc(CB_PAGE, 1) as (*mut u8); if p_data.is_null() { - _ykpiv_end_transaction(state); + let _ = _ykpiv_end_transaction(state); return Err(ErrorKind::MemoryError); } @@ -429,7 +429,7 @@ pub unsafe fn ykpiv_util_list_keys( free(p_data as (*mut c_void)); } - _ykpiv_end_transaction(state); + let _ = _ykpiv_end_transaction(state); res } @@ -476,7 +476,7 @@ pub unsafe fn ykpiv_util_read_cert( } } - _ykpiv_end_transaction(state); + let _ = _ykpiv_end_transaction(state); res } @@ -496,7 +496,7 @@ pub unsafe fn ykpiv_util_write_cert( res = _write_certificate(state, slot, data, data_len, certinfo); } - _ykpiv_end_transaction(state); + let _ = _ykpiv_end_transaction(state); res } @@ -615,7 +615,7 @@ pub unsafe fn ykpiv_util_block_puk(state: &mut YubiKey) -> Result<(), ErrorKind> } } } else { - _ykpiv_end_transaction(state); + let _ = _ykpiv_end_transaction(state); return res; } } @@ -682,14 +682,14 @@ pub unsafe fn ykpiv_util_read_mscmap( ); if res.is_err() { - _ykpiv_end_transaction(state); + let _ = _ykpiv_end_transaction(state); return res; } ptr = buf.as_mut_ptr(); if cb_buf < CB_OBJ_TAG_MIN { - _ykpiv_end_transaction(state); + let _ = _ykpiv_end_transaction(state); return Ok(()); } @@ -698,7 +698,7 @@ pub unsafe fn ykpiv_util_read_mscmap( ptr = ptr.add(_ykpiv_get_length(ptr, &mut len)); if len > cb_buf - (ptr as isize - buf.as_mut_ptr() as isize) as usize { - _ykpiv_end_transaction(state); + let _ = _ykpiv_end_transaction(state); return Ok(()); } @@ -746,14 +746,14 @@ pub unsafe fn ykpiv_util_write_mscmap( res = _ykpiv_save_object(state, YKPIV_OBJ_MSCMAP as i32, ptr::null_mut(), 0); } - _ykpiv_end_transaction(state); + let _ = _ykpiv_end_transaction(state); return res; } let req_len = 1 + _ykpiv_set_length(buf.as_mut_ptr(), data_len) + data_len; if req_len > _obj_size_max(state) { - _ykpiv_end_transaction(state); + let _ = _ykpiv_end_transaction(state); return Err(ErrorKind::SizeError); } @@ -769,7 +769,7 @@ pub unsafe fn ykpiv_util_write_mscmap( res = _ykpiv_save_object(state, YKPIV_OBJ_MSCMAP as i32, buf.as_mut_ptr(), offset); } - _ykpiv_end_transaction(state); + let _ = _ykpiv_end_transaction(state); res } @@ -897,7 +897,7 @@ pub unsafe fn ykpiv_util_read_msroots( free(p_data as (*mut c_void)); } - _ykpiv_end_transaction(state); + let _ = _ykpiv_end_transaction(state); res } @@ -925,14 +925,14 @@ pub unsafe fn ykpiv_util_write_msroots( res = _ykpiv_save_object(state, YKPIV_OBJ_MSROOTS1 as i32, ptr::null_mut(), 0); } - _ykpiv_end_transaction(state); + let _ = _ykpiv_end_transaction(state); return res; } n_objs = (data_len / (cb_obj_max - 4)) + 1; if n_objs > 5 { - _ykpiv_end_transaction(state); + let _ = _ykpiv_end_transaction(state); return Err(ErrorKind::SizeError); } @@ -977,7 +977,7 @@ pub unsafe fn ykpiv_util_write_msroots( } } - _ykpiv_end_transaction(state); + let _ = _ykpiv_end_transaction(state); res } @@ -1356,7 +1356,7 @@ pub unsafe fn ykpiv_util_generate_key( free(ptr_exp as (*mut c_void)); } - _ykpiv_end_transaction(state); + let _ = _ykpiv_end_transaction(state); res } @@ -1517,7 +1517,7 @@ pub unsafe fn ykpiv_util_get_config( } } - _ykpiv_end_transaction(state); + let _ = _ykpiv_end_transaction(state); res } @@ -1562,7 +1562,7 @@ pub unsafe fn ykpiv_util_set_pin_last_changed(state: &mut YubiKey) -> Result<(), } } } - _ykpiv_end_transaction(state); + let _ = _ykpiv_end_transaction(state); res } @@ -1645,7 +1645,7 @@ pub unsafe fn ykpiv_util_get_derived_mgm( } } - _ykpiv_end_transaction(state); + let _ = _ykpiv_end_transaction(state); res } @@ -1705,7 +1705,7 @@ pub unsafe fn ykpiv_util_get_protected_mgm( } data.zeroize(); - _ykpiv_end_transaction(state); + let _ = _ykpiv_end_transaction(state); res } @@ -1917,7 +1917,7 @@ pub unsafe fn ykpiv_util_set_protected_mgm( data.zeroize(); mgm_key.zeroize(); - _ykpiv_end_transaction(state); + let _ = _ykpiv_end_transaction(state); res } diff --git a/src/yubikey.rs b/src/yubikey.rs index 25a1ef2..7587121 100644 --- a/src/yubikey.rs +++ b/src/yubikey.rs @@ -491,7 +491,7 @@ pub unsafe fn ykpiv_connect(state: &mut YubiKey, wanted: *const c_char) -> Resul _ykpiv_begin_transaction(state)?; let res = _ykpiv_select_application(state); - _ykpiv_end_transaction(state); + let _ = _ykpiv_end_transaction(state); res } @@ -782,7 +782,7 @@ pub unsafe fn ykpiv_transfer_data( } let res = _ykpiv_transfer_data(state, templ, in_data, in_len, out_data, out_len, sw); - _ykpiv_end_transaction(state); + let _ = _ykpiv_end_transaction(state); res } @@ -878,7 +878,7 @@ pub unsafe fn ykpiv_authenticate(state: &mut YubiKey, mut key: *const u8) -> Res mgm_key.is_null(), "didn't expect mgm key to be set by failing op!" ); - _ykpiv_end_transaction(state); + let _ = _ykpiv_end_transaction(state); return Err(ErrorKind::AlgorithmError); } @@ -895,12 +895,12 @@ pub unsafe fn ykpiv_authenticate(state: &mut YubiKey, mut key: *const u8) -> Res res = _send_data(state, &mut apdu, data.as_mut_ptr(), &mut recv_len, &mut sw); if res.is_err() { - _ykpiv_end_transaction(state); + let _ = _ykpiv_end_transaction(state); return res; } if sw != SW_SUCCESS { - _ykpiv_end_transaction(state); + let _ = _ykpiv_end_transaction(state); return Err(ErrorKind::AuthenticationError); } @@ -923,7 +923,7 @@ pub unsafe fn ykpiv_authenticate(state: &mut YubiKey, mut key: *const u8) -> Res ); if drc != DesErrorKind::Ok { - _ykpiv_end_transaction(state); + let _ = _ykpiv_end_transaction(state); return Err(ErrorKind::AuthenticationError); } @@ -949,7 +949,7 @@ pub unsafe fn ykpiv_authenticate(state: &mut YubiKey, mut key: *const u8) -> Res eprintln!("Failed getting randomness for authentication."); } - _ykpiv_end_transaction(state); + let _ = _ykpiv_end_transaction(state); return Err(ErrorKind::RandomnessError); } @@ -963,12 +963,12 @@ pub unsafe fn ykpiv_authenticate(state: &mut YubiKey, mut key: *const u8) -> Res res = _send_data(state, &mut apdu, data.as_mut_ptr(), &mut recv_len, &mut sw); if res.is_err() { - _ykpiv_end_transaction(state); + let _ = _ykpiv_end_transaction(state); return res; } if sw != SW_SUCCESS { - _ykpiv_end_transaction(state); + let _ = _ykpiv_end_transaction(state); return Err(ErrorKind::AuthenticationError); } @@ -1001,7 +1001,7 @@ pub unsafe fn ykpiv_authenticate(state: &mut YubiKey, mut key: *const u8) -> Res des_destroy_key(mgm_key); } - _ykpiv_end_transaction(state); + let _ = _ykpiv_end_transaction(state); res } @@ -1040,7 +1040,7 @@ pub(crate) unsafe fn ykpiv_set_mgmkey2( 0 => 0xff, 1 => 0xfe, _ => { - _ykpiv_end_transaction(state); + let _ = _ykpiv_end_transaction(state); return Err(ErrorKind::GenericError); } }; @@ -1065,7 +1065,7 @@ pub(crate) unsafe fn ykpiv_set_mgmkey2( } apdu.zeroize(); - _ykpiv_end_transaction(state); + let _ = _ykpiv_end_transaction(state); res } @@ -1220,7 +1220,7 @@ pub unsafe fn ykpiv_sign_data( state, raw_in, in_len, sign_out, out_len, algorithm, key, false, ); - _ykpiv_end_transaction(state); + let _ = _ykpiv_end_transaction(state); res } @@ -1239,7 +1239,7 @@ pub unsafe fn ykpiv_decrypt_data( // don't attempt to reselect in crypt operations to avoid problems with PIN_ALWAYS let res = _general_authenticate(state, input, input_len, out, out_len, algorithm, key, true); - _ykpiv_end_transaction(state); + let _ = _ykpiv_end_transaction(state); res } @@ -1285,7 +1285,7 @@ pub unsafe fn ykpiv_get_version(state: &mut YubiKey) -> Result Result { res = _ykpiv_get_serial(state, false); } - _ykpiv_end_transaction(state); + let _ = _ykpiv_end_transaction(state); res } @@ -1563,7 +1563,7 @@ pub unsafe fn ykpiv_verify_select( res = _verify(state, pin, pin_len); } - _ykpiv_end_transaction(state); + let _ = _ykpiv_end_transaction(state); res } @@ -1630,7 +1630,7 @@ pub unsafe fn ykpiv_set_pin_retries( } } - _ykpiv_end_transaction(state); + let _ = _ykpiv_end_transaction(state); res } @@ -1744,7 +1744,7 @@ pub unsafe fn ykpiv_change_pin( } } - _ykpiv_end_transaction(state); + let _ = _ykpiv_end_transaction(state); res } @@ -1770,7 +1770,7 @@ pub unsafe fn ykpiv_change_puk( res = _ykpiv_change_pin(state, 2, current_puk, current_puk_len, new_puk, new_puk_len); } - _ykpiv_end_transaction(state); + let _ = _ykpiv_end_transaction(state); res } @@ -1791,7 +1791,7 @@ pub unsafe fn ykpiv_unblock_pin( res = _ykpiv_change_pin(state, 1, puk, puk_len, new_pin, new_pin_len); } - _ykpiv_end_transaction(state); + let _ = _ykpiv_end_transaction(state); res } @@ -1810,7 +1810,7 @@ pub unsafe fn ykpiv_fetch_object( res = _ykpiv_fetch_object(state, object_id, data, len); } - _ykpiv_end_transaction(state); + let _ = _ykpiv_end_transaction(state); res } @@ -1894,7 +1894,7 @@ pub unsafe fn ykpiv_save_object( res = _ykpiv_save_object(state, object_id, indata, len); } - _ykpiv_end_transaction(state); + let _ = _ykpiv_end_transaction(state); res } @@ -2135,7 +2135,7 @@ pub unsafe fn ykpiv_import_private_key( } key_data.zeroize(); - _ykpiv_end_transaction(state); + let _ = _ykpiv_end_transaction(state); res } @@ -2184,7 +2184,7 @@ pub unsafe fn ykpiv_attest( } } - _ykpiv_end_transaction(state); + let _ = _ykpiv_end_transaction(state); res } @@ -2219,7 +2219,7 @@ pub unsafe fn ykpiv_auth_getchallenge(state: &mut YubiKey) -> Result<[u8; 8], Er } } - _ykpiv_end_transaction(state); + let _ = _ykpiv_end_transaction(state); res } @@ -2253,7 +2253,7 @@ pub unsafe fn ykpiv_auth_verifyresponse( } apdu.zeroize(); - _ykpiv_end_transaction(state); + let _ = _ykpiv_end_transaction(state); res } @@ -2292,6 +2292,6 @@ pub unsafe fn ykpiv_auth_deauthenticate(state: &mut YubiKey) -> Result<(), Error res = Err(ErrorKind::GenericError); } - _ykpiv_end_transaction(state); + let _ = _ykpiv_end_transaction(state); res }