pub unsafe fn ykpiv_attest(
    state: *mut YubiKey,
    key: u8,
    data: *mut u8,
    data_len: *mut usize,
) -> ErrorKind {
    let mut res = ErrorKind::GenericError;
    let templ = [0, YKPIV_INS_ATTEST, key, 0];
    let mut sw: i32 = 0;
    let mut ul_data_len: usize;

    if state.is_null() || data.is_null() || data_len.is_null() {
        return ErrorKind::ArgumentError;
    }

    ul_data_len = *data_len;

    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,
            &mut ul_data_len,
            &mut sw,
        );

        if res == ErrorKind::Ok {
            if sw != SW_SUCCESS {
                res = ErrorKind::GenericError;
                if sw == SW_ERR_NOT_SUPPORTED {
                    res = ErrorKind::NotSupported;
                }
            } else if *data as i32 != 0x30 {
                res = ErrorKind::GenericError;
            } else {
                *data_len = ul_data_len;
            }
        }
    }

    _ykpiv_end_transaction(state);
    res
}
/// Generate an attestation certificate for a stored key
Generate an attestation certificate for a stored key
Generate an attestation certificate for a stored key
pub unsafe fn ykpiv_attest(
    state: *mut YubiKey,
    key: u8,
    data: *mut u8,
    data_len: *mut usize,
) -> ErrorKind {
    let mut res = ErrorKind::GenericError;
    let templ = [0, YKPIV_INS_ATTEST, key, 0];
    let mut sw: i32 = 0;
    let mut ul_data_len: usize;
    if state.is_null() || data.is_null() || data_len.is_null() {
        return ErrorKind::ArgumentError;
    }
    ul_data_len = *data_len;
    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,
            &mut ul_data_len,
            &mut sw,
        );
        if res == ErrorKind::Ok {
            if sw != SW_SUCCESS {
                res = ErrorKind::GenericError;
                if sw == SW_ERR_NOT_SUPPORTED {
                    res = ErrorKind::NotSupported;
                }
            } else if *data as i32 != 0x30 {
                res = ErrorKind::GenericError;
            } else {
                *data_len = ul_data_len;
            }
        }
    }
    _ykpiv_end_transaction(state);
    res
}
pub unsafe fn ykpiv_attest ( state : * mut YubiKey , key : u8 , data : * mut u8 , data_len : * mut usize , ) -> ErrorKind { let mut res = ErrorKind :: GenericError ; let templ = [ 0 , YKPIV_INS_ATTEST , key , 0 ] ; let mut sw : i32 = 0 ; let mut ul_data_len : usize ; if state . is_null ( ) || data . is_null ( ) || data_len . is_null ( ) { return ErrorKind :: ArgumentError ; } ul_data_len = * data_len ; 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 , & mut ul_data_len , & mut sw , ) ; if res == ErrorKind :: Ok { if sw != SW_SUCCESS { res = ErrorKind :: GenericError ; if sw == SW_ERR_NOT_SUPPORTED { res = ErrorKind :: NotSupported ; } } else if * data as i32 != 0x30 { res = ErrorKind :: GenericError ; } else { * data_len = ul_data_len ; } } } _ykpiv_end_transaction ( state ) ; res }
Generate an attestation certificate for a stored key
Generate an attestation certificate for a stored key
state
*mut YubiKey
key
u8
data
*mut u8
data_len
*mut usize