25 yubikey_token_st token;
31 REDEBUG(
"Yubikey-Key attribute not found in control list, can't decrypt OTP data");
35 if (key->vp_length != YUBIKEY_KEY_SIZE) {
36 REDEBUG(
"Yubikey-Key length incorrect, expected %u got %zu", YUBIKEY_KEY_SIZE, key->vp_length);
40 yubikey_parse((
uint8_t const *) passcode +
inst->id_len, key->vp_octets, &token);
45 if (!yubikey_crc_ok_p((
uint8_t *) &token)) {
46 REDEBUG(
"Decrypting OTP token data failed, rejecting");
50 RDEBUG2(
"Token data decrypted successfully");
52 counter = (yubikey_counter(token.ctr) << 8) | token.use;
53 timestamp = (token.tstph << 16) | token.tstpl;
56 RDEBUG2(
"Session counter : %u", counter);
58 RDEBUG2(
"Token timestamp : %u", timestamp);
60 RDEBUG2(
"Random data : %u", token.rnd);
61 RDEBUG2(
"CRC data : 0x%x", token.crc);
73 vp->vp_uint32 = timestamp;
79 vp->vp_uint32 = token.rnd;
86 vp->vp_uint32 = counter;
93 RWDEBUG(
"Yubikey-Counter not found in control list, skipping replay attack checks");
98 REDEBUG(
"Replay attack detected! Counter value %u, is lt or eq to last known counter value %u",
99 counter,
vp->vp_uint32);
unlang_action_t
Returned by unlang_op_t calls, determine the next action of the interpreter.
module_instance_t const * mi
Instance of the module being instantiated.
Temporary structure to hold arguments for module calls.
int fr_pair_value_memdup(fr_pair_t *vp, uint8_t const *src, size_t len, bool tainted)
Copy data into an "octets" data type.
fr_pair_t * fr_pair_find_by_da_nested(fr_pair_list_t const *list, fr_pair_t const *prev, fr_dict_attr_t const *da)
Find a pair with a matching fr_dict_attr_t, by walking the nested fr_dict_attr_t tree.
#define pair_update_request(_attr, _da)
#define RETURN_MODULE_REJECT
#define RETURN_MODULE_INVALID
rlm_rcode_t
Return codes indicating the result of the module call.
fr_dict_attr_t const * attr_yubikey_random
fr_dict_attr_t const * attr_yubikey_counter
fr_dict_attr_t const * attr_yubikey_key
fr_dict_attr_t const * attr_yubikey_timestamp
fr_dict_attr_t const * attr_yubikey_private_id
unlang_action_t rlm_yubikey_decrypt(rlm_rcode_t *p_result, module_ctx_t const *mctx, request_t *request, char const *passcode)
void * data
Module's instance data.
MEM(pair_append_request(&vp, attr_eap_aka_sim_identity) >=0)
eap_aka_sim_process_conf_t * inst
Stores an attribute, a value and various bits of other data.
#define fr_box_octets(_val, _len)