Pointers -> refs in ykpiv_auth_verifyresponse
This commit is contained in:
+2
-17
@@ -2228,21 +2228,12 @@ pub unsafe fn ykpiv_auth_getchallenge(state: &mut YubiKey) -> Result<[u8; 8], Er
|
|||||||
/// Verify an auth response
|
/// Verify an auth response
|
||||||
pub unsafe fn ykpiv_auth_verifyresponse(
|
pub unsafe fn ykpiv_auth_verifyresponse(
|
||||||
state: &mut YubiKey,
|
state: &mut YubiKey,
|
||||||
response: *mut u8,
|
response: &[u8; 8],
|
||||||
response_len: usize,
|
|
||||||
) -> Result<(), ErrorKind> {
|
) -> Result<(), ErrorKind> {
|
||||||
let mut data = [0u8; 261];
|
let mut data = [0u8; 261];
|
||||||
let mut recv_len = data.len() as u32;
|
let mut recv_len = data.len() as u32;
|
||||||
let mut sw: i32 = 0;
|
let mut sw: i32 = 0;
|
||||||
|
|
||||||
if response.is_null() {
|
|
||||||
return Err(ErrorKind::GenericError);
|
|
||||||
}
|
|
||||||
|
|
||||||
if response_len != 8 {
|
|
||||||
return Err(ErrorKind::SizeError);
|
|
||||||
}
|
|
||||||
|
|
||||||
_ykpiv_begin_transaction(state)?;
|
_ykpiv_begin_transaction(state)?;
|
||||||
|
|
||||||
// send the response to the card and a challenge of our own.
|
// send the response to the card and a challenge of our own.
|
||||||
@@ -2254,13 +2245,7 @@ pub unsafe fn ykpiv_auth_verifyresponse(
|
|||||||
apdu.data[1] = 0x0a; // 2 + 8
|
apdu.data[1] = 0x0a; // 2 + 8
|
||||||
apdu.data[2] = 0x82;
|
apdu.data[2] = 0x82;
|
||||||
apdu.data[3] = 8;
|
apdu.data[3] = 8;
|
||||||
|
apdu.data[4..12].copy_from_slice(response);
|
||||||
memcpy(
|
|
||||||
apdu.data.as_mut_ptr().add(4) as *mut c_void,
|
|
||||||
response as *const c_void,
|
|
||||||
response_len,
|
|
||||||
);
|
|
||||||
|
|
||||||
apdu.lc = 12;
|
apdu.lc = 12;
|
||||||
|
|
||||||
let mut res = _send_data(state, &mut apdu, data.as_mut_ptr(), &mut recv_len, &mut sw);
|
let mut res = _send_data(state, &mut apdu, data.as_mut_ptr(), &mut recv_len, &mut sw);
|
||||||
|
|||||||
Reference in New Issue
Block a user