pub unsafe fn ykpiv_set_pin_retries(
    state: *mut YubiKey,
    pin_tries: i32,
    puk_tries: i32,
) -> ErrorKind {
    let mut res = ErrorKind::Ok;
    let mut templ = [0, YKPIV_INS_SET_PIN_RETRIES, 0, 0];
    let mut data = [0u8; 255];
    let mut recv_len: usize = data.len();
    let mut sw: i32 = 0i32;

    // Special case: if either retry count is 0, it's a successful no-op
    if pin_tries == 0 || puk_tries == 0 {
        return ErrorKind::Ok;
    }

    if pin_tries > 0xff || puk_tries > 0xff || pin_tries < 1 || puk_tries < 1 {
        return ErrorKind::RangeError;
    }

    templ[2] = pin_tries as (u8);
    templ[3] = puk_tries as (u8);

    if _ykpiv_begin_transaction(state) != ErrorKind::Ok {
        return ErrorKind::PcscError;
    }

    if _ykpiv_ensure_application_selected(state) == ErrorKind::Ok {
        res = ykpiv_transfer_data(
            state,
            templ.as_ptr(),
            ptr::null(),
            0,
            data.as_mut_ptr(),
            &mut recv_len,
            &mut sw,
        );

        if res == ErrorKind::Ok {
            res = match sw {
                SW_SUCCESS => ErrorKind::Ok,
                SW_ERR_AUTH_BLOCKED => ErrorKind::AuthenticationError,
                SW_ERR_SECURITY_STATUS => ErrorKind::AuthenticationError,
                _ => ErrorKind::GenericError,
            };
        }
    }

    _ykpiv_end_transaction(state);
    res
}
/// Set the number of PIN retries
Set the number of PIN retries
Set the number of PIN retries
pub unsafe fn ykpiv_set_pin_retries(
    state: *mut YubiKey,
    pin_tries: i32,
    puk_tries: i32,
) -> ErrorKind {
    let mut res = ErrorKind::Ok;
    let mut templ = [0, YKPIV_INS_SET_PIN_RETRIES, 0, 0];
    let mut data = [0u8; 255];
    let mut recv_len: usize = data.len();
    let mut sw: i32 = 0i32;
    // Special case: if either retry count is 0, it's a successful no-op
    if pin_tries == 0 || puk_tries == 0 {
        return ErrorKind::Ok;
    }
    if pin_tries > 0xff || puk_tries > 0xff || pin_tries < 1 || puk_tries < 1 {
        return ErrorKind::RangeError;
    }
    templ[2] = pin_tries as (u8);
    templ[3] = puk_tries as (u8);
    if _ykpiv_begin_transaction(state) != ErrorKind::Ok {
        return ErrorKind::PcscError;
    }
    if _ykpiv_ensure_application_selected(state) == ErrorKind::Ok {
        res = ykpiv_transfer_data(
            state,
            templ.as_ptr(),
            ptr::null(),
            0,
            data.as_mut_ptr(),
            &mut recv_len,
            &mut sw,
        );
        if res == ErrorKind::Ok {
            res = match sw {
                SW_SUCCESS => ErrorKind::Ok,
                SW_ERR_AUTH_BLOCKED => ErrorKind::AuthenticationError,
                SW_ERR_SECURITY_STATUS => ErrorKind::AuthenticationError,
                _ => ErrorKind::GenericError,
            };
        }
    }
    _ykpiv_end_transaction(state);
    res
}
pub unsafe fn ykpiv_set_pin_retries ( state : * mut YubiKey , pin_tries : i32 , puk_tries : i32 , ) -> ErrorKind { let mut res = ErrorKind :: Ok ; let mut templ = [ 0 , YKPIV_INS_SET_PIN_RETRIES , 0 , 0 ] ; let mut data = [ 0u8 ; 255 ] ; let mut recv_len : usize = data . len ( ) ; let mut sw : i32 = 0i32 ; // Special case: if either retry count is 0, it's a successful no-op if pin_tries == 0 || puk_tries == 0 { return ErrorKind :: Ok ; } if pin_tries > 0xff || puk_tries > 0xff || pin_tries < 1 || puk_tries < 1 { return ErrorKind :: RangeError ; } templ [ 2 ] = pin_tries as ( u8 ) ; templ [ 3 ] = puk_tries as ( u8 ) ; if _ykpiv_begin_transaction ( state ) != ErrorKind :: Ok { return ErrorKind :: PcscError ; } if _ykpiv_ensure_application_selected ( state ) == ErrorKind :: Ok { res = ykpiv_transfer_data ( state , templ . as_ptr ( ) , ptr :: null ( ) , 0 , data . as_mut_ptr ( ) , & mut recv_len , & mut sw , ) ; if res == ErrorKind :: Ok { res = match sw { SW_SUCCESS => ErrorKind :: Ok , SW_ERR_AUTH_BLOCKED => ErrorKind :: AuthenticationError , SW_ERR_SECURITY_STATUS => ErrorKind :: AuthenticationError , _ => ErrorKind :: GenericError , } ; } } _ykpiv_end_transaction ( state ) ; res }
Set the number of PIN retries
Set the number of PIN retries
state
*mut YubiKey
pin_tries
i32
puk_tries
i32