yubikey 0.2.0

A library to interact with YubiKeys, developed at Coturnix.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
pub const CRC_RESIDUAL_OK: u16 = 0xf0b8;

pub fn crc16(data: &[u8]) -> u16 {
    let mut m_crc = 0xffff;
    for &b in data {
        m_crc ^= b as u16;
        for _ in 0..8 {
            let j = m_crc & 1;
            m_crc >>= 1;
            if j != 0 {
                m_crc ^= 0x8408
            }
        }
    }
    m_crc
}