Skip to content

Commit

Permalink
cosmetic/clippy related revision
Browse files Browse the repository at this point in the history
  • Loading branch information
carblue committed Jun 30, 2024
1 parent 88b59a1 commit 4b5b530
Show file tree
Hide file tree
Showing 12 changed files with 269 additions and 290 deletions.
40 changes: 20 additions & 20 deletions acos5/src/cmd_card_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,25 +34,25 @@ use crate::wrappers::{wr_do_log};
/// @apiNote Exempt from this function, card.serialnr MUST be treated as immutable. It's not clear to me if for
/// `SC_CARD_TYPE_ACOS5_64_V3` the last 2 bytes are meaningful if not in FIPS mode
/// (at least they are the same for each call, thus this uncertainty doesn't matter).\
/// This function is also callable via libopensc.so/dll:sc_card_ctl via `SC_CARDCTL_GET_SERIALNR`:
/// This function is also callable via `libopensc.so/dll:sc_card_ctl` via `SC_CARDCTL_GET_SERIALNR`:
///
/// @return Result::Ok(serial number); 6 bytes for `SC_CARD_TYPE_ACOS5_64_V2`, otherwise 8 bytes, or an OpenSC error
/// @return `Result::Ok(serial` number); 6 bytes for `SC_CARD_TYPE_ACOS5_64_V2`, otherwise 8 bytes, or an `OpenSC` error
///
/// # Errors
///
/// Will return `Result::Err` if sc_transmit_apdu or sc_check_sw fails, or apdu.resplen is wrong (for the card type),
/// Will return `Result::Err` if `sc_transmit_apdu` or `sc_check_sw` fails, or apdu.resplen is wrong (for the card type),
/// though this never happened so far. Thus its save to unwrap/expect the Ok variant.
///
/// # Examples
///
/// no_run
/// `no_run`
/// // may be run only with a card connected (and thus variable `card` populated accordingly)
/// use opensc_sys::{types::sc_serial_number, opensc::sc_card_ctl, cardctl::SC_CARDCTL_GET_SERIALNR, errors::SC_SUCCESS};
/// use std::os::raw::c_void;
/// let mut serial_number = sc_serial_number::default();
/// let rv = unsafe { sc_card_ctl(card, SC_CARDCTL_GET_SERIALNR, &mut serial_number as *mut _ as *mut c_void) };
/// assert_eq!(SC_SUCCESS, rv);
/// println!("serial_number: {:X?}", serial_number);
/// use `opensc_sys::{types::sc_serial_number`, `opensc::sc_card_ctl`, `cardctl::SC_CARDCTL_GET_SERIALNR`, `errors::SC_SUCCESS`};
/// use `std::os::raw::c_void`;
/// let mut `serial_number` = `sc_serial_number::default()`;
/// let rv = unsafe { `sc_card_ctl(card`, `SC_CARDCTL_GET_SERIALNR`, &mut `serial_number` as *mut _ as *mut `c_void`) };
/// `assert_eq!(SC_SUCCESS`, rv);
/// `println!("serial_number`: {:X?}", `serial_number`);
///
pub fn get_serialnr(card: &mut sc_card) -> Result<sc_serial_number, i32>
{
Expand Down Expand Up @@ -85,16 +85,16 @@ pub fn get_serialnr(card: &mut sc_card) -> Result<sc_serial_number, i32>
//QS
/// Get count of files/dirs within currently selected DF.
///
/// @return Result::Ok(count_files_curr_df), or an OpenSC error
/// @return `Result::Ok(count_files_curr_df`), or an `OpenSC` error
///
/// # Panics
/// ATTENTION: There shouldn't be more than 255 files in a DF, but if there are more, then the function panics,
/// because the following command get_file_info works based on byte-size indexing only !\
/// This function is also callable via libopensc.so/dll:sc_card_ctl via `SC_CARDCTL_ACOS5_GET_COUNT_FILES_CURR_DF`:
/// because the following command `get_file_info` works based on byte-size indexing only !\
/// This function is also callable via `libopensc.so/dll:sc_card_ctl` via `SC_CARDCTL_ACOS5_GET_COUNT_FILES_CURR_DF`:
///
/// # Errors
///
/// Will return `Result::Err` if sc_transmit_apdu or sc_check_sw fails, though this never happened so far.
/// Will return `Result::Err` if `sc_transmit_apdu` or `sc_check_sw` fails, though this never happened so far.
/// Thus it is save to unwrap/expect the Ok variant.
///
/// # Examples
Expand Down Expand Up @@ -136,14 +136,14 @@ pub fn get_count_files_curr_df(card: &mut sc_card) -> Result<u16, i32>

//QS
/// Get compact file information (8 bytes) of file referenced within currently selected DF.\
/// For hardware versions SC_CARD_TYPE_ACOS5_64_V2 and SC_CARD_TYPE_ACOS5_64_V3 the 8 bytes are:
/// For hardware versions `SC_CARD_TYPE_ACOS5_64_V2` and `SC_CARD_TYPE_ACOS5_64_V3` the 8 bytes are:
/// FDB, DCB, FILE ID, FILE ID, SIZE or MRL, SIZE or NOR, SFI, LCSI
/// For hardware version SC_CARD_TYPE_ACOS5_64_V4 the 8 bytes are:
/// For hardware version `SC_CARD_TYPE_ACOS5_64_V4` the 8 bytes are:
/// FDB, DCB, FILE ID, FILE ID, SIZE or MRL, SIZE or MRL, NOR or SFI, NOR or LCSI
///
/// @apiNote `SC_CARDCTL_ACOS5_GET_FILE_INFO`; for clients: for both card types SC_CARD_TYPE_ACOS5_64_* indexing starts
/// @apiNote `SC_CARDCTL_ACOS5_GET_FILE_INFO`; for clients: for both card types `SC_CARD_TYPE_ACOS5_64`_* indexing starts
/// from 0, for EVO starts from 1.\
/// @return file information (8 bytes) or an OpenSC error
/// @return file information (8 bytes) or an `OpenSC` error
///
/// # Errors
pub fn get_file_info(card: &mut sc_card, reference: u8 /*starting from 0*/) -> Result<[u8; 8], i32>
Expand Down Expand Up @@ -171,8 +171,8 @@ pub fn get_file_info(card: &mut sc_card, reference: u8 /*starting from 0*/) -> R
//QS
/// Get free EEPROM space in bytes.
///
/// @apiNote SC_CARDCTL_ACOS5_GET_FREE_SPACE
/// @return free EEPROM space or an OpenSC error
/// @apiNote `SC_CARDCTL_ACOS5_GET_FREE_SPACE`
/// @return free EEPROM space or an `OpenSC` error
///
/// # Errors
pub fn get_free_space(card: &mut sc_card) -> Result<u32, i32>
Expand Down
8 changes: 3 additions & 5 deletions acos5/src/constants_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ impl Fci {
*/
/// # Panics
/// All Reference Manuals are congruent about:
/// Tag 0x82 (ISO7816_TAG_FCP_TYPE) is followed by either 1,2,5 or 6 bytes !
/// Tag 0x82 (`ISO7816_TAG_FCP_TYPE`) is followed by either 1,2,5 or 6 bytes !
/// Thus, the assert macro should never emit a panic !
/// Similar for the other asserts or unreachable etc. macros:
/// According to the Reference Manual, correct working of the card operating system
Expand Down Expand Up @@ -743,7 +743,6 @@ impl Default for CardCtlSymCrypt {

/////////////////////////////////////////////////////////////////////////////////
/* Stores 1 record of Security Environment File, intended to be placed in a Vec, stored with the DF */
//#[allow(clippy::upper_case_acronyms)]
#[repr(C)]
#[derive(Default, Debug, Copy, Clone, PartialEq)]
pub struct SACinfo /*SeInfo*/ {
Expand Down Expand Up @@ -779,7 +778,6 @@ pub struct SCDO { // for SCDO_TAGs Always_Deny ..AuthT every scdo content is in

/* Stores SAE information for an instruction from <AMDO><SCDO> simple-TLV, intended to be placed in a Vec, stored with the DF
TODO SCDO Tags 0xA0 and 0xAF are not yet covered */
//#[allow(clippy::upper_case_acronyms)]
#[allow(non_snake_case)]
#[repr(C)]
#[derive(Default, Debug, Copy, Clone, PartialEq)]
Expand Down Expand Up @@ -854,10 +852,10 @@ pub fn is_DFMF(fdb: u8) -> bool
(fdb & FDB_DF) == FDB_DF
}

/// Wraps sc_bytes2apdu
/// Wraps `sc_bytes2apdu`
///
/// Additionally, it
/// 1. Asserts SC_SUCCESS of call to sc_bytes2apdu
/// 1. Asserts `SC_SUCCESS` of call to `sc_bytes2apdu`
/// 2. Asserts, that the provided argument `cse` actually got assigned to apdu.cse
/// 3. If rbuf is not empty, then it assigns the provided argument `rbuf` to apdu.resp and apdu.resplen
///
Expand Down
Loading

0 comments on commit 4b5b530

Please sign in to comment.