Module: Yubikey::CRC

Defined in:
ext/yubikey_ext/yubikey_ext.c

Class Method Summary collapse

Class Method Details

.valid?(token) ⇒ Boolean

Check the CRC of a decrypted Yubikey OTP

token

16-byte binary token

Returns:

  • (Boolean)


35
36
37
38
39
40
41
42
43
# File 'ext/yubikey_ext/yubikey_ext.c', line 35

static VALUE
crc_check(VALUE self, VALUE token) {
  char* token_ptr = StringValuePtr(token);
  
  if (RSTRING(token)->len != YUBIKEY_BLOCK_SIZE)
    rb_raise(rb_eArgError, "token must be 16 bytes");
  
  return yubikey_crc_ok_p((uint8_t*)token_ptr) ? Qtrue : Qfalse;
}