Libu2f-emu  0.0.0
Universal 2nd Factor (U2F) Emulation C Library
Functions
counter.c File Reference
#include <fcntl.h>
#include <stdlib.h>
#include <stdio.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include "counter.h"
#include "utils.h"
Include dependency graph for counter.c:

Functions

static void counter_increment (struct u2f_emu_vdev_counter *vdev_counter)
 Increment the counter of an U2F virtual device. More...
 
static uint32_t counter_read (struct u2f_emu_vdev_counter *vdev_counter)
 Read the counter value of an U2F virtual device. More...
 
bool counter_new_from_dir (const char *pathname, struct u2f_emu_vdev_counter **vdev_counter_ref)
 Create a new counter that sync with the counter file inside the setup directory. More...
 
bool counter_new_epthemeral (struct u2f_emu_vdev_counter **vdev_counter_ref)
 Create a new ephemeral counter. More...
 
void counter_free (struct u2f_emu_vdev_counter *vdev_counter)
 Release the ressources used by the counter. More...
 

Function Documentation

void counter_free ( struct u2f_emu_vdev_counter vdev_counter)

Release the ressources used by the counter.

Parameters
vdev_counterThe virtual device counter to release.
static void counter_increment ( struct u2f_emu_vdev_counter vdev_counter)
static

Increment the counter of an U2F virtual device.

Parameters
vdev_counterThe virtual device counter to increment.
bool counter_new_epthemeral ( struct u2f_emu_vdev_counter **  counter_ref)

Create a new ephemeral counter.

Parameters
counter_refThe reference to the counter to create.
Returns
Success: true. Failure: false.
bool counter_new_from_dir ( const char *  pathname,
struct u2f_emu_vdev_counter **  counter_ref 
)

Create a new counter that sync with the counter file inside the setup directory.

Parameters
pathnameThe pathname of the setup directory.
counter_refThe reference to the counter to create.
Returns
Success: true. Failure: false.
static uint32_t counter_read ( struct u2f_emu_vdev_counter vdev_counter)
static

Read the counter value of an U2F virtual device.

Parameters
vdev_counterThe virtual device counter to read.
Returns
The counter value.